Skip to content

Instantly share code, notes, and snippets.

@lucasfernandes
Last active November 28, 2024 14:21
Show Gist options
  • Select an option

  • Save lucasfernandes/f3a05632d394ade58b766b71083333aa to your computer and use it in GitHub Desktop.

Select an option

Save lucasfernandes/f3a05632d394ade58b766b71083333aa to your computer and use it in GitHub Desktop.
// MyContract constructor
constructor(address,uint256,MyInterface.MyStruct[] memory,bool,bool)
// Script used in deploy
function run() external returns (MyContract myContract) {
address someAddress = 0x...;
uint256 totalMax = 100_000 ether;
MyInterface.MyStruct[] memory strs = new MyInterface.MyStruct[](6);
MyInterface.MyStruct memory str1 = MyInterface.MyStruct("A", 100 ether, 5_000 ether);
MyInterface.MyStruct memory str2 = MyInterface.MyStruct("B", 50 ether, 50 ether);
MyInterface.MyStruct memory str3 = MyInterface.MyStruct("C", 100 ether, 100 ether);
MyInterface.MyStruct memory str4 = MyInterface.MyStruct("D", 100 ether, 150 ether);
MyInterface.MyStruct memory str5 = MyInterface.MyStruct("E", 100 ether, 200 ether);
MyInterface.MyStruct memory str6 = MyInterface.MyStruct("F", 100 ether, 300 ether);
strs[0] = str1;
strs[1] = str2;
strs[2] = str3;
strs[3] = str4;
strs[4] = str5;
strs[5] = str6;
vm.startBroadcast();
myContract = new MyContract(someAddress, totalMax, strs, false, false);
vm.stopBroadcast();
return myContract;
}
// Script to Verify
source .env && forge verify-contract \
--chain-id 8543 \
--watch \
--via-ir \
--rpc-url base \
--constructor-args $(cast abi-encode "constructor(address,uint256,(string,uint256,uint256)[],bool,bool)" "0x..." 100000000000000000000000 "[('A',100000000000000000000,5000000000000000000000),('B',50000000000000000000,50000000000000000000),('C',100000000000000000000,100000000000000000000),('D',100000000000000000000,150000000000000000000),('E',100000000000000000000,200000000000000000000),('F',100000000000000000000,300000000000000000000)]" false false) \
--etherscan-api-key base \
--force \
0x... \
src/MyContract.sol:MyContract
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment