A note on getting the chain ID for transaction insights #2601
Montoya
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
If you are building transaction insights Snaps and relying on the chain ID to generate insights, please make sure you are using the
chainId
parameter passed in the transaction handler like so:If you are requesting the chain ID from the ethereum provider instead, this is not guaranteed to match the chain ID of the transaction. This is because in future updates of MetaMask, each site can have its own selected network independently of other sites and of the globally selected network in MetaMask. Thus, the following code will give unreliable outcomes:
Other requests using the ethereum provider will also give unreliable behavior. In general, you should check the current
chainId
before making any requests such as for reading token balances or contract data.Beta Was this translation helpful? Give feedback.
All reactions