MerkleProofWrapper Smart Contract Module in Bunzz

We are excited to announce our new MerkleProofWrapper Module available in Bunzz and created by LightFury.

This contract allows you to verify whether single or multiple leaves exist on the MerkleTree or not. It’s a wrapper contract based on OpenZeppelin’s MerkleProof library.

This contract does not have any variables in itself.

You can access this Module and the code here: https://bit.ly/3YMuCHK

This contract’s functions deal with verification of Merkle Tree proofs.

  • The proofs can be generated using the JavaScript library
    https://github.com/miguelmota/merkletreejs.
  • Note: The hashing algorithm should be keccak256 and pair sorting should be enabled.
  • Note: This contract is not a standalone contract. This will work like a library contract.

How to Use

  1. Deploy the smart contract via Bunzz
  2. Write front-end or back-end projects which use MerkleTree to store data, like whitelists or sensitive information.
  3. Generate the MerkleTree and store the Proofs and Leaves on the backend
  4. Share the leaf for a specific user, the proofs for that leaf and the root of the MerkleTree to the user upon user’s request.
  5. Users can use the deployed MerkleProofWrapper smart contract to verify whether those are correct.
  6. DeFi builders can use the deployed MerkleProofWrapper smart contract to verify the user’s request.
    For this:
  • Users can get leaves and proofs from the backend.
  • Root of the MerkleTree must be stored in the DeFi’s main smart contract.
  • Inside the main smart contract, call the deployed MerkleProofWrapper contract to verify the user’s request. This will reduce the size of the main smart contract for DeFi builders.

  • Here is the usage of the library.

https://forum.openzeppelin.com/t/how-to-use-merkleproof-library/2818/2

And here’s another usage of it.

https://medium.com/codex/using-merkle-trees-for-smart-contracts-24ccf6f75a0a

With this MerkleProofWrapper, you can do like this:

MerkleProofWrapper(address _merkleProofWrapperAddress).verify(_merkleProof, root, leaf)

By doing this, you can reduce the size of the contract deployed.

Functions

#READ

  • verifyCalldata
  • verify
  • processProofCalldata
  • processProof
  • processMultiProofCalldata
  • processMultiProof
  • multiProofVerifyCalldata
  • multiProofVerify

You can access this Module and the code here: https://bit.ly/3YMuCHK

If you still haven’t signed up to Bunzz, what are you waiting for?

Sign up here https://app.bunzz.dev/signup and get your smart contracts deployed in 5 minutes through our great GUI.

Share this article:

Leave a Comment

Your email address will not be published. Required fields are marked *