ETH

Ethereum & EVM integration with OneKey’s injected EIP‑1193 provider

Use the injected EIP‑1193 provider to build EVM dApps with OneKey. Start by detecting the provider and requesting accounts, then use the methods below for transactions and signing.

Minimal pattern

const provider = window?.$onekey?.ethereum
  || window?.ethereum?.providers?.find(p => p?.isOneKey || p?.onekey)
  || window?.ethereum
if (!provider) throw new Error('OneKey not detected')
const [account] = await provider.request({ method: 'eth_requestAccounts' })

Events & network

  • Listen to accountsChanged and chainChanged

  • For switching/adding chains: wallet_switchEthereumChain, wallet_addEthereumChain

Common errors

  • 4001: user rejected

  • 4902: unknown chain (add the chain first)

  • Invalid params: use 0x‑prefixed hex strings; avoid raw BigInt in RPC params

  • Use OneKey deeplinks that carry a WalletConnect URI

See also JavaScript (EIP‑1193) for an extended introduction.

Last updated

Was this helpful?