Created
April 29, 2024 12:09
-
-
Save 0xngmi/be06b780b4c10e64b428774a556f4116 to your computer and use it in GitHub Desktop.
Detect chains that dont support PUSH0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function detectPush0Support(rpcs) { | |
return (await Promise.all(rpcs.map(async rpc => { | |
try { | |
const res = await fetch(rpc, { | |
method: "POST", | |
headers: { | |
"Content-Type": "application/json" | |
}, | |
body: JSON.stringify({ | |
"method": "eth_call", | |
"params": [ | |
{ | |
"from": null, | |
"data": "0x604260005260205FF3" | |
}, | |
"latest" | |
], | |
"id": 1, | |
"jsonrpc": "2.0" | |
}) | |
}).then(r => r.json()) | |
if (res.result !== "0x0000000000000000000000000000000000000000000000000000000000000042") { | |
return rpc | |
} | |
} catch (e) { | |
console.log("error", rpc, String(e)) | |
} | |
}))).filter(Boolean) | |
} | |
detectPush0Support([ | |
"https://arb1.arbitrum.io/rpc", | |
"https://rpc.ankr.com/optimism", | |
"https://rpc.ankr.com/polygon", | |
"https://rpc.ankr.com/avalanche", | |
"https://rpc.ankr.com/fantom", | |
]).then(failedRpcs => console.log("Chains with no PUSH0 support: ", failedRpcs)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment