diff --git a/packages/incremental-merkle-tree.sol/README.md b/packages/incremental-merkle-tree.sol/README.md index fa69328..98903f9 100644 --- a/packages/incremental-merkle-tree.sol/README.md +++ b/packages/incremental-merkle-tree.sol/README.md @@ -2,7 +2,7 @@
Incremental Merkle tree smart contracts.
+Incremental Merkle tree Solidity libraries.
@@ -34,6 +34,13 @@
+## Libraries:
+
+✔️ [IncrementalBinaryTree](https://github.com/appliedzkp/zk-kit/blob/main/packages/incremental-merkle-tree.sol/contracts/IncrementalBinaryTree.sol)\
+✔️ [IncrementalQuinTree](https://github.com/appliedzkp/zk-kit/blob/main/packages/incremental-merkle-tree.sol/contracts/IncrementalQuinTree.sol)
+
+> The methods of each library are always the same (i.e `insert`, `remove`, `verify`).
+
---
## 🛠 Install
@@ -54,13 +61,15 @@ yarn add @zk-kit/incremental-merkle-tree.sol
## 📜 Usage
+### Importing and using the library
+
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@zk-kit/incremental-merkle-tree.sol/contracts/IncrementalBinaryTree.sol";
-contract Test {
+contract Example {
using IncrementalBinaryTree for IncrementalTreeData;
event TreeCreated(bytes32 id, uint8 depth);
@@ -70,7 +79,7 @@ contract Test {
mapping(bytes32 => IncrementalTreeData) public trees;
function createTree(bytes32 _id, uint8 _depth) external {
- require(trees[_id].depth == 0, "Test: tree already exists");
+ require(trees[_id].depth == 0, "Example: tree already exists");
trees[_id].init(_depth, 0);
@@ -78,7 +87,7 @@ contract Test {
}
function insertLeaf(bytes32 _treeId, uint256 _leaf) external {
- require(trees[_treeId].depth != 0, "Test: tree does not exist");
+ require(trees[_treeId].depth != 0, "Example: tree does not exist");
trees[_treeId].insert(_leaf);
@@ -91,7 +100,7 @@ contract Test {
uint256[] memory _proofSiblings,
uint8[] memory _proofPathIndices
) external {
- require(trees[_treeId].depth != 0, "Test: tree does not exist");
+ require(trees[_treeId].depth != 0, "Example: tree does not exist");
trees[_treeId].remove(_leaf, _proofSiblings, _proofPathIndices);
@@ -101,6 +110,55 @@ contract Test {
```
+### Creating an Hardhat task to deploy the contract
+
+```ts
+import { poseidon_gencontract as poseidonContract } from "circomlibjs"
+import { Contract } from "ethers"
+import { task, types } from "hardhat/config"
+
+task("deploy:example", "Deploy an Example contract")
+ .addOptionalParam