When using WalletConnectModal with the Sign API, how can I get the currently active chainId of the wallet? #3318
-
Although the modal can add event listeners, it is passive in nature, meaning it only works while the modal is active. If the user switches the chainId on their wallet after the modal is closed, the modal won't be aware of this event. Even if the modal receives an event about the chainId change after the page is reopened, it may take some time and could be unstable. Therefore, I would like to know if there is a way to actively send a request to query the currently active chainId of the connected wallet, similar to an RPC request like "{ method: "eth_chainId" }". This way, I can proactively query the connected wallet to retrieve its current active chainId. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, Sign API works with an agnostic chain protocol (CAIP-25) so you establish a session with multiple chains at once, you only need to specify the chain when sending a transaction for example https://docs.walletconnect.com/2.0/web/sign/dapp-usage#making-requests If you still need to track the chains (because some wallets will behave differently) you can use event listeners like If you'd like a more high level library I'd recommend ethereum-provider or universal-provider |
Beta Was this translation helpful? Give feedback.
Hi, Sign API works with an agnostic chain protocol (CAIP-25) so you establish a session with multiple chains at once, you only need to specify the chain when sending a transaction for example https://docs.walletconnect.com/2.0/web/sign/dapp-usage#making-requests
If you still need to track the chains (because some wallets will behave differently) you can use event listeners like
session_update
https://docs.walletconnect.com/2.0/web/sign/dapp-usage#create-a-sessionIf you'd like a more high level library I'd recommend ethereum-provider or universal-provider