Search code examples
constructorsmartcontractsweb3jstruffleganache

how can i pass constructor values when deploying through truffle?


How can I deploy a smart contract with constructor predefined parameters values, I am using truffle, ganache!!

constructor (uint256 _targetAmount, uint256 _setDeadline) public {
        totalAmount = _targetAmount;
        deadline = block.timestamp + _setDeadline;
        minDepositAmount = 1 ether;
        manager = payable(msg.sender);
    } 

Solution

  • You can pass the constructor params after the first argument of deployer.deploy().

    deployer.deploy(MyContract, targetAmount, setDeadline);