I'm trying to build a smart contract with Truffle. I can compile it just fine, but when I try to deploy it on the network, I don't get an option to pass in the initialiser parameters and thus the contract fails.

How do I pass the parameters to a Truffle-compiled contract during deployment?


1 Answer 1


In your 2_deploy_contracts.js file you can add parameters when deploying the contract:

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

module.exports = function(deployer) {
  deployer.deploy(Contract,constructor_param_1, constructor_param_2, ,constructor_param_3, ,constructor_param_etc);

  • 1
    What if the contract argument is another contract? How is is provided in this deploy contracts file? For example I am trying to deploy this: github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/… How do I provide MintableToken _token
    – codesalsa
    Commented Feb 23, 2018 at 21:21
  • How can you pass an argument to the utility which executes 2_deploy_contracts.js (i.e., how can you pass an argument to truffle migrate or truffle deploy)? Commented Oct 3, 2018 at 14:04
  • Ha, found it. Just add it at the end of the truffle migrate command-line, and then in 2_deploy_contracts.js, access it via process.argv. Commented Oct 3, 2018 at 14:15

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