metamask-mobile
metamask-mobile copied to clipboard
[Bug]: Adding new ERC20 token from JS is not working
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
- Call
wallet_watchAssetfrom JS - 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
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?