Update docs

This commit is contained in:
Miguel Mota 2022-10-26 18:12:58 -07:00
parent 6a01e3bef7
commit db1e45f5c7
No known key found for this signature in database
GPG Key ID: 67EC1161588A00F9
3 changed files with 32 additions and 5 deletions

View File

@ -165,6 +165,10 @@ More info [here](https://bitcointalk.org/?topic=102395).
- [Eth 2.0 specs - Merkle Multiproofs](https://github.com/ethereum/eth2.0-specs/blob/dev/ssz/merkle-proofs.md#merkle-multiproofs) - [Eth 2.0 specs - Merkle Multiproofs](https://github.com/ethereum/eth2.0-specs/blob/dev/ssz/merkle-proofs.md#merkle-multiproofs)
- [What is complete binary tree?](https://xlinux.nist.gov/dads/HTML/completeBinaryTree.html)
- [What is perfect binary tree?](https://xlinux.nist.gov/dads/HTML/perfectBinaryTree.html)
## Contributing ## Contributing
Pull requests are welcome! Pull requests are welcome!

View File

@ -33,6 +33,7 @@
- [Notes](#notes) - [Notes](#notes)
- [Resources](#resources) - [Resources](#resources)
- [Contributing](#contributing) - [Contributing](#contributing)
- [Tip Jar](#tip-jar)
- [License](#license) - [License](#license)
## Install ## Install
@ -73,8 +74,8 @@ console.log(tree.verify(proof, leaf, root)) // true
const badLeaves = ['a', 'x', 'c'].map(x => SHA256(x)) const badLeaves = ['a', 'x', 'c'].map(x => SHA256(x))
const badTree = new MerkleTree(badLeaves, SHA256) const badTree = new MerkleTree(badLeaves, SHA256)
const badLeaf = SHA256('x') const badLeaf = SHA256('x')
const badProof = tree.getProof(badLeaf) const badProof = badTree.getProof(badLeaf)
console.log(tree.verify(badProof, leaf, root)) // false console.log(badTree.verify(badProof, badLeaf, root)) // false
``` ```
Print tree to console: Print tree to console:
@ -130,7 +131,10 @@ npm test
- Q: How do you verify merkle [multiproofs](https://github.com/ethereum/eth2.0-specs/blob/dev/ssz/merkle-proofs.md#merkle-multiproofs) in Solidity? - Q: How do you verify merkle [multiproofs](https://github.com/ethereum/eth2.0-specs/blob/dev/ssz/merkle-proofs.md#merkle-multiproofs) in Solidity?
- A: Check out the example repo [merkletreejs-multiproof-solidity](https://github.com/miguelmota/merkletreejs-multiproof-solidity) on how to generate merkle multiproofs with this library and verify them in Solidity. - A: Check out the example repo [merkletreejs-multiproof-solidity](https://github.com/miguelmota/merkletreejs-multiproof-solidity) on how to generate merkle multiproofs with this library and verify them in Solidity.
- Q: Is there a CLI version? - Q: Is there an NFT whitelist example in Solidity?
- A: Check out the example repo [merkletreejs-nft-whitelist](https://github.com/miguelmota/merkletreejs-nft-whitelist) on how to generate merkle root of whitelisted accounts and merkle proofs with this library and verify them in Solidity.
- Q: Is there a CLI version of this library?
- Yes, see [merkletreejs-cli](https://github.com/miguelmota/merkletreejs-cli). - Yes, see [merkletreejs-cli](https://github.com/miguelmota/merkletreejs-cli).
@ -172,6 +176,16 @@ For contributions please create a new branch and submit a pull request for revie
_Many thanks to all the [contributors](https://github.com/miguelmota/merkletreejs/graphs/contributors) that made this library better._ _Many thanks to all the [contributors](https://github.com/miguelmota/merkletreejs/graphs/contributors) that made this library better._
## Tip Jar
[![BTC Tip Jar](https://img.shields.io/badge/BTC-tip-yellow.svg?logo=bitcoin&style=flat)](https://www.blockchain.com/btc/address/3KdMW53vUMLPEC33xhHAUx4EFtvmXQF8Kf) `3KdMW53vUMLPEC33xhHAUx4EFtvmXQF8Kf`
[![ETH Tip Jar](https://img.shields.io/badge/ETH-tip-blue.svg?logo=ethereum&style=flat)](https://etherscan.io/address/0x9ed3D6793a6b74d8c9A998f5C4b50a25947D53aF) `0x9ed3D6793a6b74d8c9A998f5C4b50a25947D53aF`
Thank you for tips! 🙏
## License ## License
[MIT](LICENSE) Released under the [MIT](./LICENSE) license.
© [Miguel Mota](https://github.com/miguelmota)

View File

@ -10,6 +10,7 @@
### Properties ### Properties
* [complete](_src_merkletree_.options.md#optional-complete)
* [duplicateOdd](_src_merkletree_.options.md#optional-duplicateodd) * [duplicateOdd](_src_merkletree_.options.md#optional-duplicateodd)
* [fillDefaultHash](_src_merkletree_.options.md#optional-filldefaulthash) * [fillDefaultHash](_src_merkletree_.options.md#optional-filldefaulthash)
* [hashLeaves](_src_merkletree_.options.md#optional-hashleaves) * [hashLeaves](_src_merkletree_.options.md#optional-hashleaves)
@ -20,6 +21,14 @@
## Properties ## Properties
### `Optional` complete
**complete**? : *boolean*
If set to `true`, the resulting tree will be a complete tree. Recommended for use of multiProofs.
___
### `Optional` duplicateOdd ### `Optional` duplicateOdd
**duplicateOdd**? : *boolean* **duplicateOdd**? : *boolean*
@ -64,7 +73,7 @@ ___
**sortLeaves**? : *boolean* **sortLeaves**? : *boolean*
If set to `true`, the leaves will be sorted. If set to `true`, the leaves will be sorted. Recommended for use of multiProofs.
___ ___