Merkle.s.sol is implemented using forge-std for quick and simple interaction with the core contracts. The script reads from script/target/input.json, generates merkle proof using Merkle.sol and then outputs at script/target/output.json.
The hashes of the leafs are generated using keccak256(bytes.concat(keccak256(abi.encode(...)))), which is the same as OpenZeppelin/merkle-tree.
forge test for verifying the proof output and leaf hashing
README
forge-std version
Remarks
I created this PR mainly for fun to play around with the repo and file I/O + JSON parsing using forge-std! :)
The code is sort of messy because of the limitation of forge-std/StdJson.sol (e.g. string starting with "0x" could not be normally decoded, weird behaviour when decoding array of arrays, etc.). The type casting and bytes decoding parts are also a bit chunky, feel free to let me know if any part should be improved!
Script
Merkle.s.sol
is implemented usingforge-std
for quick and simple interaction with the core contracts. The script reads fromscript/target/input.json
, generates merkle proof usingMerkle.sol
and then outputs atscript/target/output.json
.The hashes of the leafs are generated using
keccak256(bytes.concat(keccak256(abi.encode(...))))
, which is the same asOpenZeppelin/merkle-tree
.Updated
script/
containingMerkle.s.sol
& helper functionsRemarks
I created this PR mainly for fun to play around with the repo and file I/O + JSON parsing using forge-std! :)
The code is sort of messy because of the limitation of
forge-std/StdJson.sol
(e.g. string starting with "0x" could not be normally decoded, weird behaviour when decoding array of arrays, etc.). The type casting and bytes decoding parts are also a bit chunky, feel free to let me know if any part should be improved!