Management API Reference

Handling networks

The following guide will show you how to handle networks with Openfort's smart wallets using the EIP-1193 provider.

You can also use Viem's switchChain method with the chain ID you wish to switch to.

Get the current network#

To get the current network, you can use the eth_chainId request (with no params)


_10
await wallet.provider.request({
_10
"method": "eth_chainId",
_10
"params": [],
_10
});

Switch networks#

To switch the smart wallet to a different network, send a wallet_switchEthereumChain JSON-RPC request to the wallet's EIP-1193 provider. In the request's params, specify your target chainId as a hexadecimal string.


_10
await wallet.provider.request({
_10
method: 'wallet_switchEthereumChain',
_10
// Replace '0x5' with the chainId of your target network
_10
params: [{chainId: '0x5'}],
_10
});