Skip to content

Instantly share code, notes, and snippets.

@jessgusclark
Created April 22, 2021 10:43
Show Gist options
  • Save jessgusclark/1f8eb6960306afd91079cb9a26d551c9 to your computer and use it in GitHub Desktop.
Save jessgusclark/1f8eb6960306afd91079cb9a26d551c9 to your computer and use it in GitHub Desktop.
Adding an ERC20 token to Metamask with wallet_watchAsset
const params = addToken({
type: 'ERC20',
options: {
address: '0x2acc95758f8b5f583470ba265eb685a8f45fc9d5',
symbol: 'RIF',
decimals: 18,
image: 'https://s2.coinmarketcap.com/static/img/coins/64x64/3701.png'
}
})
window.ethereum.request({ method: 'wallet_watchAsset', params })
.then(() => setLog([...log, 'Success, Token added!']))
.catch((error: Error) => setLog([...log, `Error: ${error.message}`]))
@etherpan
Copy link

etherpan commented Jun 8, 2022

I think good article.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment