wallet_watchAsset
Requests that the user track the specified token in MetaMask. Returns a boolean indicating if the token was successfully added. Once added, the token is indistinguishable from those added using legacy methods, such as a centralized registry. Introduced by EIP-747.
Parameters
type(string)requiredThe token type (ERC20, ERC721, or ERC1155). Support for ERC-721 and ERC-1155 tokens is experimental and currently only available on the extension (not on mobile). See MIP-1 and the MIP proposal lifecycle for more information.
options(object)An object containing information about the token.
Returns
true if the token was added, false otherwise.
Errors
| Code | Description |
|---|---|
-32602 | Must specify address, symbol, and decimals. |
-32602 | Invalid symbol: not a string. |
-32602 | Invalid symbol '${symbol}': longer than 11 characters. |
-32602 | Invalid decimals '${decimals}': must be 0 <= 36. |
-32602 | Invalid address '${address}'. |
-32602 | Asset type is required. |
-32602 | Both address and tokenId are required. |
-32602 | Invalid address. |
-32000 | Suggested NFT is not owned by the selected account. |
-32000 | Suggested NFT of type ${standard} does not match received type ${type}. |
-32002 | Unable to verify ownership. Possibly because the standard is not supported or the user's currently selected network does not match the chain of the asset in question. |
await provider.request({
method: "wallet_watchAsset",
params: [
"ERC20",
{
"address": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
"symbol": "FOO",
"decimals": 18,
"image": "https://foo.io/token-image.svg"
}
]
});
{
"id": 1,
"jsonrpc": "2.0",
"result": true
}