Skip to content

Instantly share code, notes, and snippets.

@antonyip
Created March 28, 2022 08:08
Show Gist options
  • Save antonyip/63519614ddb8e1d44907ea50eaeee453 to your computer and use it in GitHub Desktop.
Save antonyip/63519614ddb8e1d44907ea50eaeee453 to your computer and use it in GitHub Desktop.
curl https://api-dfk.avax.network/rpc -X POST -H "Content-Type: application/json" --data '{
"jsonrpc": "2.0",
"method": "eth_blockNumber",
"id": 1,
"params": {}
}'
curl https://api-dfk.avax.network/rpc -X POST -H "Content-Type: application/json" --data '{
"jsonrpc": "2.0",
"method": "eth_getBlockByNumber",
"id": 1,
"params": [
"0x2",
true
]
}'
curl https://api-dfk.avax.network/rpc -X POST -H "Content-Type: application/json" --data '{
"jsonrpc": "2.0",
"method": "eth_getTransactionReceipt",
"id": 2,
"params": ["0xbabc529fb22f016d61fe5ef264f69720739df31989de3b2d6cbe40fb44373fcd"]
}'
@antonyip
Copy link
Author

const axios = require('axios')
const axiosRetry = require('axios-retry');
process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0

axiosRetry(axios, { retries: 5 });

/*
curl https://api-dfk.avax.network/rpc -X POST -H "Content-Type: application/json" --data '
{
"jsonrpc":"2.0",
"method":"eth_getLogs",
"params":[{
"fromBlock":"",
"toBlock":"0xa6"
}],
"id":74
}'
*/

const getBlockByID = async (blockNumN) => {
const blockNumH = "0x" + parseInt(blockNumN,10).toString(16);
const rv = await axios.post("https://api-dfk.avax.network/rpc", {
"jsonrpc":"2.0",
"method":"eth_getBlockByNumber",
"params": [
blockNumH,
true
],
"id":blockNumN
},
{
timeout:30000,
});
return rv;
}

const getLogs = async (blockNumN) => {
const blockNumH = "0x" + parseInt(blockNumN,10).toString(16);
const rv = await axios.post("https://api-dfk.avax.network/rpc", {
"jsonrpc":"2.0",
"method":"eth_getLogs",
"params":[{
"fromBlock":blockNumH,
"toBlock":blockNumH
}],
"id":blockNumN
});
return rv;
}

async function main()
{
let current = 100;
const end = 110;
for (let i = current; i < end; i++) {
getLogs(i).then((res) => {
console.log(new Date().toISOString(),"|",JSON.stringify(res.data));
});
}
}
main();

@antonyip
Copy link
Author

@antonyip
Copy link
Author

antonyip commented Apr 1, 2022

bridge: 0x4F4f66964335D7bef23C16a62Fcd3d1E89f02959

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment