0

Block Builders! I am trying to migrate my two smart contracts using truffle and Genache. I would like to specify the deploying accounts existing locally. However, when I try to migrate the contracts I get error prompt that the provided address being invalid.

Here is my 2_deployed_contracts.js

var Bank = artifacts.require("Bank");
var Client = artifacts.require("Client");

module.exports = function(deployer, accounts) {
  deployer.deploy(Bank, {from: accounts[0], value: 
  web3.utils.toWei("30", "ether")}).then((bank)=>{
    return deployer.deploy(Client, bank.address, {from:accounts[1]});
  });
};

and the reported error prompt:

Error:  *** Deployment Failed ***

"Bank" -- Provided address "d" is invalid, the capitalization checksum test 
failed, or its an indrect IBAN address which can't be converted..

at /usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle- 
deployer/src/deployment.js:364:1
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)

Only when I hard code the account address at from field, the migration success. The accounts variable seems not working like most of the other posts suggested. I could not figure it out why, because I thought truffle would inject accounts variable.

2
  • Would you adding console.log(accounts[0], accounts[1]) and post the output here? Commented Jan 1, 2019 at 11:50
  • And also console.log(bank.address). Commented Jan 1, 2019 at 11:52

1 Answer 1

3

You've got the accounts argument at the wrong position (2nd instead of 3rd).

Change this:

module.exports = function(deployer, accounts)

To this:

module.exports = function(deployer, network, accounts)

P.S.: In the Provided address "d" is invalid error, the d is probably the first letter in your network name - development - as configured in your Truffle configuration file (truffle-config.js).

1
  • @Alex: You're welcome. You can find the relevant section in Truffle documentation here. Commented Jan 1, 2019 at 12:04

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.