imToken For Developers
English
English
  • Introduction
  • products
    • WebView
      • Development Guide for imToken DApp
      • RPC Methods
      • Compatibility
      • Preload URL Options
      • SDK APIs
      • Release changes
    • Universal Links
    • Deep Linking
  • References
    • imToken Brand Guide
    • dapp-sdk
    • tokenlon-onboarding
    • tokenlon-mmsk
    • tokenlon-mmproxy
    • tokenlon-jssdk
    • tokenlon-open-api
Powered by GitBook
On this page
  • Introduction
  • Implemented RPCs
  • DEPRECATED
  • Unimplemented
  • Feedback and help

Was this helpful?

  1. products
  2. WebView

RPC Methods

Ethereum RPCs implemented in the imToken application.

PreviousDevelopment Guide for imToken DAppNextCompatibility

Last updated 3 years ago

Was this helpful?

Introduction

Here is the list of all Ethereum RPCs currently supported by the imToken App, for more information you can also refer to .

imToken's DApp browser , we only inject the Provider.(you can get it using window.ethereum) For more information on how to start connecting to your wallet using Provider, please refer to:

  • Our

  • MetaMask documentation:

  • Or refer to the following simplified code:

// Modern application
window.web3 = new Web3(ethereum)

// Or with ethers
await window.ethereum.enable()
const provider = new ethers.providers.Web3Provider(window.ethereum)

Implemented RPCs

eth_requestAccounts

This method is specified by .

Requests that the user provides an Ethereum address to be identified by.

Returns

string[] - An array of a single, hexadecimal Ethereum address string.

eth_accounts

eth_sendTransaction

personal_sign

alias: personal_sign , eth_signTypedData , eth_signTypedData_v3 eth_signTypedData_v4

net_version

eth_chainId

wallet_addEthereumChain

An API for adding Ethereum chains to wallet applications.

API wallet_addEthereumChain only works on versions higher than 2.8.4.

Returns

null - The method returns null if the request was successful, and an error otherwise.

Params

type EthereumChain = {
  chainId: string
  chainName: string
  nativeCurrency: {
    name: string
    symbol: string // 2-6 characters long
    decimals: number // 18
  };
  rpcUrls: string[]
  blockExplorerUrls?: string[]
}

Example

const chain = {
  chainId: "0x64",
  chainName: "xDAI Chain",
  rpcUrls: ["https://dai.poa.network"],
  iconUrls: [
    "https://xdaichain.com/fake/example/url/xdai.svg",
    "https://xdaichain.com/fake/example/url/xdai.png",
  ],
  nativeCurrency: {
    name: "xDAI",
    symbol: "xDAI",
    decimals: 18,
  },
}

window.ethereum.request({
  method: "wallet_addEthereumChain",
  params: [chain],
})

wallet_switchEthereumChain

An RPC method for switching the wallet’s active Ethereum chain.

API wallet_switchEthereumChain only works on versions higher than 2.10.0.

Returns

null - The method returns null if the request was successful, and an error otherwise.

Params

type EthereumChain = {
  chainId: string
}

Example

const chain = {
  chainId: "0x64",
}

window.ethereum.request({
  method: "wallet_switchEthereumChain",
  params: [chain],

DEPRECATED

enable (DEPRECATED)

Use ethereum.request({ method: 'eth_requestAccounts' }) instead.

sendAsync (DEPRECATED)

Use ethereum.request() instead.

send (DEPRECATED)

Use ethereum.request() instead.

eth_sign

Use personal_sign instead.

Unimplemented

eth_subscribe

This RPC interface is not currently implemented in imToken.

Feedback and help

This method is specified by .

This method is specified by .

Please refer to the for the differences between the signature methods.

This method (personal_sign) is similar to eth_sign, but has better security, see for details.

This method is specified by .

This method is specified by .

This method is specified by

This method is specified by .

This method is specified by .

If you need to leave feedback or request help from the developers, please create a topic in the .

the Ethereum RPCs#eth_accounts
the Ethereum RPCs#eth_sendtransaction
metamask docs (a-brief-history)
Technical Reference
the Ethereum RPCs#eth_sign
the Ethereum RPCs#net_version
EIP-695
EIP-3085
EIP-3326
GitHub Discussion
the Ethereum RPCs
Guide documentation
Ethereum Provider
EIP-1193: Ethereum Provider JavaScript API
EIP-1102
no longer injects web3 into the DApp