How do we pass in constructor parameters to a contract that we want to test? I understand that the initial contract deployment occurs in the migrations
file, but if, for testing/debugging purposes, we want to deploy and instantiate the contract in the Truffle Console, how do we do so? How about in our testing files?
Per instance, say our ExampleContract.sol
file is:
contract ExampleContract { function ExampleContract(uint256 my_param){} })
And our 2_deploy_contracts.js
file has this line at the top, but doesn't deploy the contract :
var ExampleContract = artifacts.require("./ExampleContract.sol");
We open a Truffle Ganache console & then migrate our stuff in:
truffle console --network ganache
migrate --compile-all
Now, we have the contract's information (including its address) stored in ExampleContract
, but how can we then instantiate it with parameters we wish to pass into its constructor? What is the equivalent of the deployer.deploy
object in migrations
that we may pass parameters into?