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
pmyProof = pmap # plam (\x -> pdata x) #$ pconstant myProof
evalT $ pmember # (pconstant "e") # (pconstant root) # pmyProof
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