walletWatchAssets method

Future<bool> walletWatchAssets({
  1. required String address,
  2. required String symbol,
  3. required int decimals,
  4. String? image,
  5. String type = 'ERC20',
})

Requests that the user tracks the token with address, symbol, and decimals in MetaMask, decimals is optional.

Returns true if token is successfully added.

Ethereum protocal only support type that is ERC20 for now.

Most Ethereum wallets support some set of tokens, usually from a centrally curated registry of tokens. wallet_watchAsset enables web3 application developers to ask their users to track tokens in their wallets, at runtime. Once added, the token is indistinguishable from those added via legacy methods, such as a centralized registry.


// Watch BUSD Token
await ethereum!.walletWatchAssets(
  address: '0xed24fc36d5ee211ea25a80239fb8c4cfd80f12ee',
  symbol: 'BUSD',
  decimals: 18,
);

Implementation

Future<bool> walletWatchAssets({
  required String address,
  required String symbol,
  required int decimals,
  String? image,
  String type = 'ERC20',
}) =>
    request<bool>(
      'wallet_watchAsset',
      _WatchAssetParamsImpl(
        type: type,
        options: _WatchAssetOptionsImpl(
          decimals: decimals,
          symbol: symbol,
          address: address,
          image: image,
        ),
      ),
    );