Simple deployment command of a contract with two constructor arguments using forge
is as follows
forge create src/Contract.sol:MyToken --constructor-args "My Token" "MT"
But in my case, I should pass some objects as constructor arguments to deploy a contract similar to below one
struct DiamondArgs {
address owner;
address init;
bytes initCalldata;
}
contract MyContract {
constructor(DiamondArgs memory _args) {}
}
So, the deployment command would look like this
forge create src/MyContract.sol:MyContract --constructor-args '{owner: "ownerAddress", init: "initAddress", initCalldata: "initCalldata"}'
When trying to pass that object, the result looks like this :
forge create --constructor-args [object Object] ...
What's the workaround for this?
Best Answer
Ok, took me too long to figure it out but you can pass objects by using --constructor-args-path and creating a file named 'args' with your arguments in it.
In your case:
Hope this helps, let me know if you have questions!