metamask-mobile icon indicating copy to clipboard operation
metamask-mobile copied to clipboard

[Bug]: Adding new ERC20 token from JS is not working

Open TheBojda opened this issue 7 months ago • 1 comments

Describe the bug

I tried to add a new ERC20 token using JavaScript. The process was completed successfully, and the popup displayed the text "Token added successfully. " However, I don't see the token in the wallet.

My JS code:

 const provider = await detectEthereumProvider()();
        if (provider && (provider as any).request) {
            try {
                await (provider as any).request({
                    method: 'wallet_watchAsset',
                    params: {
                        type: 'ERC20',
                        options: {
                            address: CONTRACT_ADDRESS,
                            symbol: 'CQM',
                            decimals: 18,
                            image: '' // Optionally add a token image URL
                        }
                    }
                });
            } catch (e: unknown) {
                const message = e instanceof Error ? e.message : String(e);
                alert('Failed to add CQM token: ' + message);
            }
        } else {
            alert('MetaMask is not detected.');
        }

Expected behavior

The token should be shown in the asset list.

Screenshots/Recordings

No response

Steps to reproduce

  1. Call wallet_watchAsset from JS
  2. Check your assets

Error messages or log output


Detection stage

In production (default)

Version

7.46.2 (1891)

Build type

None

Device

Xiaomi A2

Operating system

Android

Additional context

No response

Severity

No response

TheBojda avatar Jun 08 '25 07:06 TheBojda

Hi @TheBojda,

Sorry for the lack of updates on your request. Can you please let us know if the issue reproduces in the latest version as well?

epop-cs avatar Dec 11 '25 05:12 epop-cs