Skip to content

Commit

Permalink
generate-merkle-tree
Browse files Browse the repository at this point in the history
  • Loading branch information
sanbir committed Oct 2, 2024
1 parent d466d69 commit 45c25d5
Show file tree
Hide file tree
Showing 4 changed files with 534 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,4 @@ dist
.yarn/install-state.gz
.pnp.*


tree.json
27 changes: 27 additions & 0 deletions 01-generate-merkle-tree.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// https://github.com/OpenZeppelin/merkle-tree?tab=readme-ov-file#building-a-tree

import { StandardMerkleTree } from "@openzeppelin/merkle-tree";
import fs from "fs";

async function main() {
try {
const values = [
["0x1111111111111111111111111111111111111111", "5000000000000000000"],
["0x2222222222222222222222222222222222222222", "2500000000000000000"]
];

const tree = StandardMerkleTree.of(values, ["address", "uint256"]);

console.log('Merkle Root:', tree.root);
fs.writeFileSync("tree.json", JSON.stringify(tree.dump()));

console.log('Done.')
} catch (err) {
console.log(err)
}
}

main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "eth-merkle-drop",
"author": "P2P Validator <[email protected]>",
"license": "MIT",
"scripts": {
"01-generate-merkle-tree": "ts-node 01-generate-merkle-tree.ts",
"deploy": "forge script script/Deploy.s.sol:Deploy --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast --chain holesky --json --verify --etherscan-api-key $ETHERSCAN_API_KEY -vvvvv"
},
"dependencies": {
"@openzeppelin/merkle-tree": "1.0.7",
"@types/node": "22.5.4",
"cross-env": "7.0.3",
"dotenv": "16.4.5",
"ts-node": "10.9.2",
"typescript": "5.6.2"
},
"packageManager": "[email protected]+sha512.4abf725084d7bcbafbd728bfc7bee61f2f791f977fd87542b3579dcb23504d170d46337945e4c66485cd12d588a0c0e570ed9c477e7ccdd8507cf05f3f92eaca"
}
Loading

0 comments on commit 45c25d5

Please sign in to comment.