Replies: 2 comments 2 replies
-
This sort of question should be posted in Q&A under discussions. I just transferred! |
Beta Was this translation helpful? Give feedback.
-
ChatGPT says: To pass objects as constructor arguments to a contract using forge, you can encode the object as JSON and pass the JSON string as an argument to the --constructor-args flag. For example, in the case of the DiamondArgs struct from your example, the deployment command would look something like this:
Alternatively, you can also use the --json flag to pass the object as a JSON file. The command would look something like this:
where diamond-args.json is the name of a file that contains the JSON-encoded DiamondArgs object. In either case, the DiamondArgs object will be passed to the MyContract contract's constructor as a single argument when the contract is deployed. |
Beta Was this translation helpful? Give feedback.
-
Simple deployment command of a contract with two constructor arguments using
forge
is as followsforge create src/Contract.sol:MyToken --constructor-args "My Token" "MT"
But need to pass some objects as constructor arguments to deploy a contract similar to below one
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?
Beta Was this translation helpful? Give feedback.
All reactions