Skip to content

How to reduce eth_chainId calls? #2689

Answered by ricmoo
s1na asked this question in Q&A
Feb 14, 2022 · 3 comments · 3 replies
Discussion options

You must be logged in to vote

If you are connecting to a JSON-RPC node that cannot change its chain ID, you probably want to use the StaticJsonRpcProvider, which doesn't perform this check.

It is in general necessary because many JSON-RPC connections, such as MetaMask, allow the user to change the chain ID on a whim, by clicking a drop-down in the UI.

This will cause complete chaos if the check for chain ID is not made. For example, if you call getTransactionNonce on Ropsten and then send a transaction on mainnet, the nonce will likely not match, resulting in ether a NONCE_EXPIRED error or a transaction that will never get mined. Likewise, if you are querying for events, and the block number drastically changes, you a…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@s1na
Comment options

Answer selected by s1na
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@ricmoo
Comment options

@micwallace
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants