Created
June 5, 2023 18:40
-
-
Save eshaben/76ab5786bfdb0bb34686959b0044a2ae 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
import { ethers } from 'ethers'; | |
const providerRPC = { | |
moonriver: { | |
name: 'moonriver', | |
// Switch to see opposite results: https://moonriver.unitedbloc.com | |
rpc: 'https://moonriver.api.onfinality.io/public', // Insert your RPC URL here | |
chainId: 1285, // 0x505 in hex, | |
}, | |
}; | |
const provider = new ethers.JsonRpcProvider(providerRPC.moonriver.rpc, { | |
chainId: providerRPC.moonriver.chainId, | |
name: providerRPC.moonriver.name, | |
}); | |
// Iterate over 10 blocks (includes 2077599) | |
console.log('==================================================') | |
console.log('COMPARING BLOCK.TRANSACTIONS TO TXRECEIPT.BLOCKNUMBER') | |
for (let i = 2077595; i < 2077604; i++) { | |
const block = await provider.getBlock(i, true); | |
const txs = block.transactions; | |
txs.forEach(async (transaction) => { | |
const txReceipt = await provider.getTransactionReceipt(transaction); | |
if (txReceipt.blockNumber !== block.number) { | |
console.log( | |
`requested txs for block ${block.number}, but tx receipt says tx belongs to block ${txReceipt.blockNumber}` | |
); | |
} | |
}); | |
} | |
// Iterate over 10 blocks (includes 2077599) | |
console.log(); | |
console.log('==================================================') | |
console.log('COMPARING LOGS OF A BLOCK TO TXRECEIPT.BLOCKNUMBER') | |
for (let i = 2077595; i < 2077604; i++) { | |
const logs = await provider.getLogs({ fromBlock: i, toBlock: i }); | |
logs.forEach(async (log) => { | |
const txReceipt = await provider.getTransactionReceipt(log.transactionHash); | |
if (txReceipt.blockNumber !== i) { | |
console.log(`requested logs for block ${i}, but tx receipt says tx belongs to block ${txReceipt.blockNumber}`); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment