【问题标题】:How to get a specific account from web3 with version 1.2.x?如何使用 1.2.x 版本从 web3 获取特定帐户?
【发布时间】:2020-12-23 15:54:57
【问题描述】:

在旧版本的 web3 中,web3.eth.accounts[0] 返回一个特定的帐户。我将它用作投票函数的参数,如下所示:

app.vote(1, { from: web3.eth.accounts[0]})

1.2.x 版本开始,web3 使用 web3.eth.getAccounts() 返回节点控制的帐户列表。

如何像以前使用此 web3 版本一样获得特定帐户?

【问题讨论】:

    标签: npm ethereum web3 truffle ganache


    【解决方案1】:

    web3.eth.defaultAccount;

    未定义

    //设置默认账号 web3.eth.defaultAccount = '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe';

    【讨论】:

      猜你喜欢
      • 2018-08-26
      • 1970-01-01
      • 2021-08-23
      • 2023-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多