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?
--constructor-args
, the deployment command would look something like this.forge create src/MyContract.sol:MyContract --constructor-args '(0xMyAddress1,0xMyAddress2,0x03)'
When using--constructor-args-path
,forge create src/MyContract.sol:MyContract --constructor-args-path args
And in the arg file(with no extension), the content is as follows(0xMyAddress1,0xMyAddress2,0x03)
Please be careful not to add whitespace between arguments