Summary
The SDK supports network switching for EVM supported and custom networks. Configuring additional networks is done by providing theevmNetworks
parameter inside the DynamicContextProvider
settings
Setup
evmNetworks
Once you have determined the list of networks you want to support, you will need to pass an array ofEvmNetwork
to the DynamicContextProvider
settings. The reference for an EvmNetwork can be found here. The following example sets the Ethereum mainnet and Polygon as supported networks for the application. A comprehensive list of networks can be found at chainlist.org
Custom EVM Network
See the EvmNetwork reference for all props available to define a custom network. You are now ready to switch networks!Usage
Using the WalletConnector instance provided by useDynamicContext, you have two useful methods for network switchingMethod | Description |
---|---|
supportsNetworkSwitching(): boolean | whether the connector supports network switching. |
switchNetwork({ networkChainId, networkName }: { networkChainId?: number; networkName?: string; }): Promise<void> | switch to another network by provider either the network name or chain id specified in the list of EvmNetwork |
switchNetwork
with a connector supporting network switching, the SDK will either request the user to confirm the network switch or add the network if it was not previously set.
