【问题标题】:How do I get the addresses from the Ganache?如何从 Ganache 获取地址?
【发布时间】:2022-09-22 14:37:01
【问题描述】:

我正在尝试在 Remix IDE 中实现虚拟智能投票。

我想从 Ganache 获取剩余的 99 个地址来创建一个迭代并让他们在投票站注册然后投票。

我如何获得这些地址?

photo from Ganache

  • 您还在使用哪些其他工具?松露?乙醚?安全帽?如果有的话,你也可以分享你已经尝试过的东西吗?
  • 我正在为 Ganache 使用 Truffle Suite [trufflesuite.com]。我没有做出任何有价值的事情。
  • this 可能会有所帮助。您只需调用web3.getAccounts(),其中web3 将是使用您的Ganache url 初始化的Web3 对象

标签: solidity smartcontracts remix ganache


【解决方案1】:

只需添加到 Martijn,您还可以使用 ganache-cli 包并指定您想要的帐户数量!!!

const ganache = require('ganache-cli');
const Web3 =  require('web3');

const options = { a: 100 }; // NO OF ACCOUNTS
const provider = ganache.provider(options);
const web3 = new Web3(provider);
const accounts = web3.getAccounts();

您可以使用以下文档安装 ganache-cli -> https://www.npmjs.com/package//ganache-cli

【讨论】:

    猜你喜欢
    • 2010-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-10
    • 2013-08-02
    相关资源
    最近更新 更多