thirdweb-dev / js

Best in class web3 SDKs for Browser, Node and Mobile apps
https://thirdweb.com
Apache License 2.0
416 stars 309 forks source link

useSwitchChain does not switch activeChain #1180

Closed TaeyoonKwon closed 1 year ago

TaeyoonKwon commented 1 year ago

When I change the chain using this hook, it does not change the activeChain

const switchChain = useSwitchChain();

Which results rpc error.

For instance, if default active chain was Polygon, then if I switchChain to Binance,

useContractWrite hook still uses Polygon rpc network.

MananTank commented 1 year ago

@TaeyoonKwon useSwitchChain does not change the activeChain - It only changes the network in connected wallet.

If you want the useContractWrite to use a different network - you need to pass the desired activeChain to <ThirdwebProvider/>