1

Here is my deploy hello js file

const hello = artifacts.require('./HelloWorld');

module.exports = function(deployer){
  deployer.deploy(hello);
};

And here is the contract code

pragma solidity^0.5.16;

contract HelloWorld {

    string private name;
    mapping (address => uint256) public balance;

    constructor(string memory _name) public {
      name = _name;
      balance[msg.sender] = 1000;
    }

    function getName() public view returns (string memory) {
      return name;
    }

    function setName(string memory _name) public {
      name = _name;
    }
}

1 Answer 1

3

You have to pass one string when deploying HelloWorld since its constructor receives one parameter.

constructor(string memory _name) public {

For example it should look like this

const hello = artifacts.require('./HelloWorld');

module.exports = function(deployer){
  deployer.deploy(hello, "zzzz");
};

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.