Created
March 28, 2022 08:08
-
-
Save antonyip/63519614ddb8e1d44907ea50eaeee453 to your computer and use it in GitHub Desktop.
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
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"] | |
}' |
bridge: 0x4F4f66964335D7bef23C16a62Fcd3d1E89f02959
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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();