关于区块链:Metamask一键添加代币

不废话间接上代码

const address='xxx' //代币地址
const symbol = 'xxx' //代币名称(个别都是英文大写)
const decimals = 18 //写死18
const image = 'xxx' //代币图标
ethereum.request({
    method: 'wallet_watchAsset',
    params: {
        type: 'ERC20',
        options: {
            address,
            symbol,
            decimals,
            image 
        }
    }
})

以上就是一键增加代币代码,心愿对大家有帮忙

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理