EVM Provider
After setting up your wallet, you can access the EVM provider:
import { useTomo, getWalletState } from '@tomo-inc/tomo-web-sdk';
// react
const { providers } = useTomo()
const { ethereumProvider } = providers;
// pure js
const ethereumProvider = window.tomo_ethereumSwitch Chain ID
You can switch chains between different EVM networks (see Supported Chains for the enabled network list). By default, you use the Ethereum mainnet.
//interface
switchChain(chainId: string): Promise<void>
getChainId(): number | string
const chainId = '1'
// react
const current = await ethereumProvider.getChainId();
const res = await ethereumProvider.switchChain(chainId);
// pure js
const current = await window.tomo_ethereum.getChainId();
const res = await window.tomo_ethereum.switchChain(chainId);Get the EVM address
The EVM address from the wallet state or provider.
Provider Functions
providers.ethereumProvider exposes three functions for sending requests to the user's wallet:
Signing a Message
It uses the Ethereum provider to sign a plaintext offchain message, which returns the message's signature with the message header. We also provide a shortcut for sign type data where the msg is a json string of the data.
Send Transaction
You can also send the transaction directly through this sendTransaction method. The return value is the transaction signature if signed and sent correctly.
Requests
We also support the standard wallet JSON RPC API for wallet actions
Last updated