0

Always, when I try to send parameters for the constructor function I use a migration file and where I´m trying to deploy the contract, add the parameters...Something like that:

var OVXET = artifacts.require("./OVXET.sol");


module.exports = function(deployer) {
    deployer.deploy(OVXET, 1000000000, "OVXET", "OVX", accounts[1], accounts[2]);
}

But in this case...how I have to send the accounts? I want the same accounts that I am using the test files. Have I to incorporate a var initialized with web3.accounts?

Solution:

var accounts = web3.eth.accounts;

Is there another way to implement this task?

1
  • After try different things, the answer is create a var before module.exports using web3 features: var accounts = web3.eth.accounts;
    – Jorge
    Commented Dec 22, 2017 at 22:48

1 Answer 1

1

In Truffle's documentation they have an example how to access accounts from your ethereum client.

In your case it should be like this:

var OVXET = artifacts.require("./OVXET.sol");

module.exports = function(deployer, network, accounts) {
    deployer.deploy(OVXET, 1000000000, "OVXET", "OVX", accounts[1], accounts[2]);
}

The exported function has two additional parameters 'network' and 'accounts'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.