RPC Methods

imToken 应用内的 Ethereum RPCs 实现说明。

介绍

这是 imToken 应用当前支持的所有 Ethereum RPC 列表,你也可以在 Ethereum RPC 官方文档arrow-up-right 内查看更多信息。

imToken 应用的 WebView (DApp 浏览器) 不会注入 web3.js ,我们只提供基础的 Provider 以供连接。关于如何使用 Provider 将应用连接到 imToken,请参考如下:

// 现代应用推荐方式
window.web3 = new Web3(ethereum)

// 或是使用 ethers
await window.ethereum.enable()
const provider = new ethers.providers.Web3Provider(window.ethereum)

已实现的 RPC

eth_requestAccounts

此方法来源于 EIP-1102arrow-up-right

请求用户提供一个以太坊地址。

Returns

string[] - 一个单一的、十六进制的以太坊地址字符串的数组。

eth_accounts

此方法来源于 the Ethereum RPCs#eth_accountsarrow-up-right

eth_sendTransaction

此方法来源于 the Ethereum RPCs#eth_sendtransactionarrow-up-right

personal_sign

别名: personal_sign , eth_signTypedData , eth_signTypedData_v3 eth_signTypedData_v4

对于多种不同的鉴权方式之间的区别和历史原因,请参考 metamask docs (a-brief-history)arrow-up-right 文档的解释说明。

此方法 (personal_sign) 近似于 eth_sign,但更安全,可以在 技术参考arrow-up-right 中查看详细信息。

此方法来源于 the Ethereum RPCs#eth_signarrow-up-right

net_version

此方法来源于 the Ethereum RPCs#net_versionarrow-up-right

eth_chainId

此方法来源 EIP-695arrow-up-right

wallet_addEthereumChain

此方法来源于 EIP-3085arrow-up-right

用于将以太坊链添加到钱包应用程序的 API。

circle-exclamation

Returns

null - 如果请求成功,该方法返回 null,否则返回错误。

Params

Example

wallet_switchEthereumChain

此方法来源于 EIP-3326arrow-up-right

用于切换当前以太坊网络的 API。

circle-exclamation

Returns

null - 如果请求成功,该方法返回 null,否则返回错误。

Params

Example

已废弃

enable (废弃的)

circle-exclamation

sendAsync (废弃的)

circle-exclamation

send (废弃的)

circle-exclamation

eth_sign (废弃的)

circle-exclamation

未实现

eth_subscribe

此 RPC 接口当前未在 imToken 应用内实现。

反馈与帮助

如果你需要请求开发者帮助或反馈问题,请在 GitHub Discussionarrow-up-right 中创建一个主题。

Last updated