# Could not switchChain with web3auth ver 9.7.0?

**URL:** <https://builder.metamask.io/t/could-not-switchchain-with-web3auth-ver-9-7-0/2652>\
**Category:** Embedded Wallets (Web3Auth)\
**Created:** [November 14, 2025, 2:31am UTC](https://builder.metamask.io/t/could-not-switchchain-with-web3auth-ver-9-7-0/2652 "2025-11-14T02:31:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter\_Pham](https://yyz1.discourse-cdn.com/flex011/user_avatar/builder.metamask.io/peter_pham/32/1628_2.png) [@Peter\_Pham](https://builder.metamask.io/u/Peter_Pham)\
**Post date:** [November 14, 2025, 2:31am UTC](https://builder.metamask.io/t/could-not-switchchain-with-web3auth-ver-9-7-0/2652/1 "2025-11-14T02:31:27Z")

</div>

Hi Guys, Do we have any example or tutorial for switchChain with web3auth version 9.7.0 ? I cannot find the docs or tutorial of ver 9.7.0

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/metamaskbuilderhub/original/2X/4/46cc4ed0505de840afd83d26f8c3095c9e9043a3.svg) [@system](https://builder.metamask.io/u/system)\
**Post date:** [November 14, 2025, 2:33am UTC](https://builder.metamask.io/t/could-not-switchchain-with-web3auth-ver-9-7-0/2652/2 "2025-11-14T02:33:04Z")

</div>

Thanks — Peter! I hear you: you’re trying to switch chains with Web3Auth v9.7.0 and can’t find an example. I grouped what you’ve given and a quick, practical example you can try, plus what I’d need if it still fails.

Captured details

- SDK: Web3Auth
- SDK version: 9.7.0 (from your message)
- Platform: not specified (I’ll assume web unless you tell me otherwise)

Quick explanation

- Chain switching uses the Ethereum provider RPC methods (wallet\_switchEthereumChain and wallet\_addEthereumChain). With Web3Auth you get a provider with request(…) so you can call these RPC methods the same way as with other providers — as long as the provider implements them.

Minimal example (web, after web3auth.connect())  
try {  
// provider is the object returned by await web3auth.connect()  
await provider.request({  
method: ‘wallet\_switchEthereumChain’,  
params: [{ chainId: ‘0x89’ }], // example: Polygon mainnet (hex)  
});  
} catch (switchError) {  
// 4902 means the chain is not added in the wallet — add it  
if (switchError && switchError.code === 4902) {  
await provider.request({  
method: ‘wallet\_addEthereumChain’,  
params: [{  
chainId: ‘0x89’,  
chainName: ‘Polygon Mainnet’,  
nativeCurrency: { name: ‘MATIC’, symbol: ‘MATIC’, decimals: 18 },  
rpcUrls: [‘[https://polygon-rpc.com/](https://polygon-rpc.com/)’],  
blockExplorerUrls: [‘[https://polygonscan.com/](https://polygonscan.com/)’],  
}],  
});  
} else {  
// handle other errors  
console.error(switchError);  
throw switchError;  
}  
}

Notes and tips

- Make sure you’re calling provider from await web3auth.connect() (not a stale provider).
- Ensure chainId is in hex (0x…); decimal will usually fail.
- Some providers may not implement these RPCs; if provider.request is missing or the method returns “method not found”, the provider likely doesn’t support chain switching.

Useful docs

- MetaMask RPC methods (wallet\_switchEthereumChain / wallet\_addEthereumChain): [Wallet API introduction | MetaMask developer documentation](https://docs.metamask.io/guide/rpc-api.html#methods)
- Web3Auth docs / SDK: [Introduction | Documentation | Web3Auth](https://web3auth.io/docs) (for provider initialization & connect flow)

If this still fails, please share only what’s needed:

- Your web3auth init + connect snippet (the minimal code you use to get provider)
- The exact error message from the browser console (or a screenshot)

I won’t ask for more than that — with those two items I can pinpoint whether it’s a provider capability issue, a param format issue, or something else. Want to paste your init/connect code now?

> Note: This response was generated by an AI bot and may require further verification. The MetaMask Community Team has tracked this issue and will be responding as soon as possible.

> Additionally, we would recommend you to join our biweekly Office Hours to get this resolved even faster. [MetaMask Developer Office Hours](https://builder.metamask.io/t/metamask-developer-office-hours/2544/1)

---

<div class="post-metadata">

**Author:** ![yashovardhan](https://yyz1.discourse-cdn.com/flex011/user_avatar/builder.metamask.io/yashovardhan/32/1526_2.png) [@yashovardhan](https://builder.metamask.io/u/yashovardhan)\
**Post date:** [January 8, 2026, 12:29pm UTC](https://builder.metamask.io/t/could-not-switchchain-with-web3auth-ver-9-7-0/2652/3 "2026-01-08T12:29:18Z")

</div>

Hey @Peter_Pham

Do you specifically want to use Web3Auth v9.7 only? I’d recommend to shift to v10 SDKs ideally since v9 will be deprecated in a few months.

---

<div class="post-metadata">

**Author:** ![f13r](https://yyz1.discourse-cdn.com/flex011/user_avatar/builder.metamask.io/f13r/32/2897_2.png) [@f13r](https://builder.metamask.io/u/f13r)\
**Post date:** [March 25, 2026, 10:26am UTC](https://builder.metamask.io/t/could-not-switchchain-with-web3auth-ver-9-7-0/2652/4 "2026-03-25T10:26:25Z")

</div>

How can you expect your users to use V10 if essential npm packages are still only available for v9?!

When will this be upgraded?

[https://www.npmjs.com/package/@web3auth/ethereum-provider](https://www.npmjs.com/package/@web3auth/ethereum-provider)

---

<div class="post-metadata">

**Author:** ![holyyy](https://yyz1.discourse-cdn.com/flex011/user_avatar/builder.metamask.io/holyyy/32/1556_2.png) [@holyyy](https://builder.metamask.io/u/holyyy)\
**Post date:** [March 26, 2026, 3:31am UTC](https://builder.metamask.io/t/could-not-switchchain-with-web3auth-ver-9-7-0/2652/5 "2026-03-26T03:31:24Z")

</div>

Hi @f13r ! I can see you opened a new post about this issue. Let’s continue the discussion there. Thank you!

> [@V10 migration blocked by missing npm package](https://builder.metamask.io/t/v10-migration-blocked-by-missing-npm-package/3014):
>
> We wanted to upgrade to V10, but a crucial NPM package is not being upgraded since a year - why? [https://www.npmjs.com/package/@web3auth/ethereum-provider](https://www.npmjs.com/package/@web3auth/ethereum-provider)

---

<div class="post-metadata">

**Author:** ![yashovardhan](https://yyz1.discourse-cdn.com/flex011/user_avatar/builder.metamask.io/yashovardhan/32/1526_2.png) [@yashovardhan](https://builder.metamask.io/u/yashovardhan)\
**Post date:** [March 29, 2026, 1:09pm UTC](https://builder.metamask.io/t/could-not-switchchain-with-web3auth-ver-9-7-0/2652/6 "2026-03-29T13:09:13Z")

</div>

This package is irrelevant for v10 SDKs since the code is directly migrated to the `@web3auth/modal` package
