Skip to content

wallet_watchAsset

Defined in EIP-747

Allows suggesting a token to be added to a user's wallet. This method is used to request that the user tracks a specific token in their wallet. The wallet may prompt the user to approve the addition of the token and may reject the request if the token is already being tracked or if the parameters are invalid.

Parameters

interface WatchAssetParams {
  /**
   * The type of asset to watch
   * Currently only 'ERC20' is supported
   */
  type: string
  /**
   * The options for the asset being watched
   */
  options: {
    /**
     * The token contract address
     */
    address: string
    /**
     * A ticker symbol or shorthand, up to 11 characters
     */
    symbol: string
    /**
     * The number of token decimals
     */
    decimals: number
    /**
     * A string URL of the token logo
     */
    image?: string
  }
}
 
type WatchAssetParamsType = [WatchAssetParams]

Returns

boolean

Returns true if the token was added successfully (the user approved the request and the token was successfully added to their wallet), false otherwise (the request was rejected or failed).

Example

Request:

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "wallet_watchAsset",
  "params": {
    "type": "ERC20",
    "options": {
      "address": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
      "symbol": "USDT",
      "decimals": 6,
      "image": "https://static.alchemyapi.io/images/assets/825.png"
    }
  }
}

Response:

{
  "id": 1,
  "jsonrpc": "2.0",
  "result": true
}

Usage Example

// Request to watch a token
const wasAdded = await ethereum.request({
  method: 'wallet_watchAsset',
  params: {
    type: 'ERC20',
    options: {
      address: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
      symbol: 'USDT',
      decimals: 6,
      image: 'https://static.alchemyapi.io/images/assets/825.png'
    }
  }
});
 
if (wasAdded) {
  console.log('Token was added successfully');
} else {
  console.log('Token was not added');
}

Errors

CodeMessageDescription
4001User rejected the requestThe user rejected the request to add the token
4200Unsupported asset typeThe specified asset type is not supported (only ERC20 currently)
4100Missing or invalid parametersThe parameters provided are missing required fields or invalid