# Error using MerkleProof with a lot of leaves

**URL:** <https://forum.openzeppelin.com/t/error-using-merkleproof-with-a-lot-of-leaves/24663>\
**Category:** Contracts\
**Tags:** erc721\
**Created:** [February 14, 2022, 4:04pm UTC](https://forum.openzeppelin.com/t/error-using-merkleproof-with-a-lot-of-leaves/24663 "2022-02-14T16:04:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adrian\_Lawson](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/adrian_lawson/32/13211_2.png) [@Adrian\_Lawson](https://forum.openzeppelin.com/u/Adrian_Lawson)\
**Post date:** [February 14, 2022, 4:04pm UTC](https://forum.openzeppelin.com/t/error-using-merkleproof-with-a-lot-of-leaves/24663/1 "2022-02-14T16:04:14Z")

</div>

I have merkle proof integrated into our smart contract to implement a whitelist. It works nicely, but when I use a list of a lot of addresses (around 200), I run into issues. The proof for any address in this tree is an array of 8 hashes, and when putting that into the smart contract I keep getting 'false' as the result, even though I'm getting 'true' in my local environment. Am I not supposed to put in all 8 hashes for the proof or is there something else I'm missing? Thanks!

---

<div class="post-metadata">

**Author:** ![frangio](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/frangio/32/15251_2.png) [@frangio](https://forum.openzeppelin.com/u/frangio)\
**Post date:** [February 18, 2022, 11:19pm UTC](https://forum.openzeppelin.com/t/error-using-merkleproof-with-a-lot-of-leaves/24663/2 "2022-02-18T23:19:37Z")

</div>

Hi @Adrian_Lawson  
Can you share some of the code you're using and a way we could try to reproduce your issue?

---

<div class="post-metadata">

**Author:** ![Adrian\_Lawson](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/adrian_lawson/32/13211_2.png) [@Adrian\_Lawson](https://forum.openzeppelin.com/u/Adrian_Lawson)\
**Post date:** [March 3, 2022, 6:22pm UTC](https://forum.openzeppelin.com/t/error-using-merkleproof-with-a-lot-of-leaves/24663/3 "2022-03-03T18:22:02Z")

</div>

I figured it out, I wasn't sorting the proofs that the tree was returning. I made this change in my javascript to fix it:

```auto
//before
  const tree = new MerkleTree(leaves, keccak256)

//after
  const tree = new MerkleTree(leaves, keccak256, {sortPairs: true})

```
