tip: 3326
title: Wallet Switch TRON Chain Method
author: Aaron <aaronluotron@gmail.com>
discussions to: https://github.com/tronprotocol/tips/issues/464
category: Interface
status: Final
created: 2022-09-05
An method for the wallets to switch between TRON chains.
This protocol allows DApps to call the wallets to switch to TRON chains. The calling DApp must provide the unique identifier of the chains to tell the wallets which particular TRON chain to switch to.
Any DApp needs a chain to run, and some DApps only interact with a chain on TRON. This protocol will allow DApps to notify the wallets to switch to the corresponding chain, which improves user experience. Ethereum already has a similar protocol EIP-3326.
wallet_switchEthereumChain
try {
await tron.request({
method: 'wallet_switchEthereumChain',
params: [{chainId: '0x2b6653dc'}]
});
} catch (e) {}
wallet_switchEthereumChain
accepts an object, type is as follows:
interface SwitchEthereumChainParameter {
chainId: string;
}
If the DApp does not provide a chainId, the wallet must reject the request.
About chainId
:
- The chainId must be obtained through the RPC method of TRON's
eth_chainId
. - wallet must know chainId
- wallet must be able to switch chains based on chainId
If successful, returns null. If failed, an error code and an error message will be returned. See the Error Code section for details.
Error Code | Name | Description |
---|---|---|
-32002 | Other requests are being processed | current DApp is processed, it cannot execute the request |
-32602 | Invalid params | invalid parameters, or added additional parameters |
4902 | Invalid chainId | only some chainIds are supported, see the Parameters section for details |
4001 | User rejected request | the user has rejected this request |
4200 | Unsupported method | unsupported method |
This protocol has no impact on existing wallets and DApps, but it is recommended that all wallets and DApps implement this protocol.