【问题标题】:How to read the ETH value and other token values from an account?如何从账户中读取 ETH 值和其他代币值?
【发布时间】:2018-04-21 08:41:14
【问题描述】:

假设我使用此代码创建了一个以太坊帐户:

web3.eth.accounts.create();
> {
    address: "0xb8CE9ab6943e0eCED004cDe8e3bBed6568B2Fa01",
    privateKey: "0x348ce564d427a3311b6536bbcff9390d69395b06ed6c486954e971d960fe8709",
    signTransaction: function(tx){...},
    sign: function(data){...},
    encrypt: function(password){...}
}

我以后如何连接(解锁)该帐户并查看其中包含的所有 ETH 和其他代币?

【问题讨论】:

  • 对于ERC20代币,您需要调用合约的balanceOf函数。

标签: javascript node.js ethereum web3js ether


【解决方案1】:

我以后如何连接(解锁)该帐户并查看其中包含的所有 ETH 和其他代币?

eth.accounts 显示所有已知帐户。解锁并查看第一个余额:

> personal.lockAccount(eth.accounts[0])
> eth.getBalance(eth.accounts[0])

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-08-08
    • 2022-06-25
    • 2021-12-25
    • 2022-12-23
    • 1970-01-01
    • 1970-01-01
    • 2018-06-22
    • 1970-01-01
    相关资源
    最近更新 更多