-
-
Save Sekhmet/a8f3bb693f51fb7fdf713ce5e6253ff7 to your computer and use it in GitHub Desktop.
infura
This file contains 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
const fetch = require('node-fetch'); | |
async function run() { | |
let current = 3963556; | |
while (true) { | |
const currentFrom = current; | |
const currentTo = current + 5; | |
console.time('fetch'); | |
const req = await fetch('https://sepolia.infura.io/v3/UPDATE_ME', { | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json' | |
}, | |
body: JSON.stringify({ | |
jsonrpc: '2.0', | |
id: 1, | |
method: 'eth_getLogs', | |
params: [ | |
{ | |
fromBlock: `0x${currentFrom.toString(16)}`, | |
toBlock: `0x${currentTo.toString(16)}` | |
} | |
] | |
}) | |
}); | |
await req.json(); | |
console.timeEnd('fetch'); | |
current = currentTo + 1; | |
} | |
} | |
run(); |
This file contains 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
API_KEY=$1 | |
START_BLOCK=3962845 | |
STEP=5 | |
to_hex() { | |
printf "0x%x\n" $1 | |
} | |
current=$START_BLOCK | |
while true | |
do | |
from=$(to_hex $current) | |
to=$(to_hex $(($current + $STEP))) | |
echo "from: $current, to: $((current + $STEP))" | |
curl https://sepolia.infura.io/v3/$API_KEY \ | |
-H "Content-Type: application/json" \ | |
-d "{ \"id\": 61, \"jsonrpc\": \"2.0\", \"method\": \"eth_getLogs\", \"params\": [{ \"fromBlock\": \"$from\", \"toBlock\": \"$to\" }]}" \ | |
--output /dev/null \ | |
-s -w 'Total: %{time_total}s\n' | |
current=$(($current + $STEP + 1)) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment