web3 - 如何从 Web3 中的 ETH 账户中获取令牌名称?
问题描述
我正在尝试使用 Web3 从 ETH 地址获取令牌名称(假设用户拥有eth
和ada
),但我在文档中找不到任何相关方法,我该怎么做?
我现在的代码:
import Web3 from 'web3'
try {
const ethereum = (window as any).ethereum
if (!ethereum) return
await ethereum.enable()
const web3 = new Web3(ethereum)
//Got the address here, just getting the first one
const account = (await web3.eth.getAccounts())[0]
//Got the balance here
const balance = await web3.eth.getBalance(account)
//How can I get the token name related with that address?
} catch (e) {
}
解决方案
推荐阅读
- reactjs - React 中继字符串被读取为连接过滤器上的枚举
- python - 为什么我会收到这个值错误?ValueError:发现样本数量不一致的输入变量:[6, 4]
- typescript - Typescript 泛型不适用于 Readonly
- oracle - Oracle:在触发器方面需要帮助
- react-native - 向商店发布博览会
- spring - 使用 Spring 的 WebClient 发送带有大列表的对象
- php - 使用 PHP 从 Google Content API for Shopping 中删除销售价格
- gitlab - 如果提交消息不包含 WIP,则 gitlab 规则
- php - 教义删除必须进行两次
- c# - 为什么我的 PXSmartPanel 在第一次执行后不能显示正确的数据?