Skip to content

The MerkleTree library is a Plutarch implementation of a Merkle Tree data structure, which provides a method for creating, manipulating Merkle Trees Off Chain, and verifying Merkle Trees On Chain

License

Notifications You must be signed in to change notification settings

solidsnakedev/plutarch-merkle-tree

Repository files navigation

MerkleTree

How to use

import Plutarch.MerkleTree (pmember)
import Plutus.MerkleTree (fromList, mkProof, rootHash, member)
import Data.Maybe (fromJust)
import PlutusTx qualified
import Plutarch.Prelude
import Utils

-- Create your MerkleTree
myMerkleTree = fromList ["a","b","c","d","e","f","g","h","1","2","3","4"]

-- Create your Proof for "e" member
myProof = fromJust $ mkProof "e" myMerkleTree

-- Extract the Root Hash from MerkleTree
root = rootHash myMerkleTree

Plutarch On Chain

pmyProof = pmap # plam (\x -> pdata x) #$ pconstant myProof

evalT $ pmember # (pconstant "e") # (pconstant root) # pmyProof

Haskell On Chain

member (PlutusTx.Prelude.encodeUtf8 "e") root myProof

This library takes the PlutusTx code from the Hydra project, developed and maintained by Input Output Hong Kong (IOHK).

The repository can be found at https://github.com/input-output-hk/hydra/tree/master/plutus-merkle-tree

About

The MerkleTree library is a Plutarch implementation of a Merkle Tree data structure, which provides a method for creating, manipulating Merkle Trees Off Chain, and verifying Merkle Trees On Chain

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published