Available accounts

You can also get the list of Ethereum accounts provided by the Ethereum client or web3 provider connected to truffle while running the migration. accounts is an array object, and you can access accounts using the index. You can also get the same list of accounts using the web3.eth.getAccounts() (this call is present with web3j.js version 0.2x.x) function call:

var TestContract = artifacts.require("TestContract");

module.exports = function(deployer, network, accounts) {
deployer.deploy(TestContract, accounts[0]);
}

As shown in the preceding example, it deploys a contract named TestContract and passes accounts[0] (the first Ethereum account) as an argument to the constructor of TestContract.

By default, the Ganache GUI and Ganache CLI versions create and initialize only 10 accounts. Hence, using the accounts object, you can only get 10 accounts. You can increase the number of accounts using advanced settings in Ganache.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.163.91