You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 11, 2025. It is now read-only.
This on-chain program provides an interface for composing smart contracts to create and use SPL ConcurrentMerkleTrees.
20
+
The primary application of using SPL ConcurrentMerkleTrees is to synchronize off-chain databases with on-chain updates.
19
21
20
-
* Solana Program Library [tests](https://github.com/solana-labs/solana-program-library/tree/master/account-compression/sdk/tests)
22
+
SPL ConcurrentMerkleTrees are Merkle Trees that have their roots on-chain with support for fast-forwarding proofs. Fast forwarding allows multiple updates to the tree in a single block and reduces the latency burden on indexers.
21
23
22
-
* Metaplex Program Library Compressed NFT [tests](https://github.com/metaplex-foundation/metaplex-program-library/tree/master/bubblegum/js/tests)
23
24
24
-
## Information
25
-
26
-
This on-chain program provides an interface for composing smart-contracts to create and use SPL ConcurrentMerkleTrees. The primary application of using SPL ConcurrentMerkleTrees is to make edits to off-chain data with on-chain verification.
25
+
In order to execute transactions that modify an SPL ConcurrentMerkleTree, an indexer will need to
26
+
parse through transactions that touch the tree in order to provide up-to-date merkle proofs.
27
+
For more information regarding merkle proofs, see this great [explainer](https://ethereum.org/en/developers/tutorials/merkle-proofs-for-offline-data-integrity/).
27
28
28
29
This program is targeted towards supporting [Metaplex Compressed NFTs](https://github.com/metaplex-foundation/metaplex-program-library/tree/master/bubblegum) and may be subject to change.
29
30
30
-
Note: Using this program requires an indexer to parse transaction information and write relevant information to an off-chain database.
31
+
A **rough draft** of the whitepaper for SPL ConcurrentMerkleTrees can be found [here](https://drive.google.com/file/d/1BOpa5OFmara50fTvL0VIVYjtg-qzHCVc/view).
32
+
33
+
## High Level Overview
34
+
35
+
### Instructions
36
+
Code to interact with the on-chain instructions is auto-generated by `@metaplex-foundation/solita`.
37
+
Exported functions to create instructions have pattern `create<instructionName>Instruction`.
38
+
* For example, account compression's `append_leaf` instruction has a `Solita`-generated factory function called
39
+
`createAppendLeafInstruction`.
40
+
41
+
`Solita` provides very low-level functions to create instructions. Thus, helper functions are provided for each instruction, denoted with the suffix `ix`.
42
+
* For example: `createReplaceLeafInstruction` has a helper function `createReplaceLeafIx`
43
+
44
+
### Modules
45
+
46
+
A merkle tree reference implementation is provided to index the on-chain trees. The `MerkleTree` class and its helpers are provided
47
+
under `src/merkle-tree`.
48
+
49
+
The `MerkleTree` class is meant to follow a similar interface as `MerkleTree` from [`merkletreejs`](https://www.npmjs.com/package/merkletreejs).
A **rough draft** of the whitepaper for SPL ConcurrentMerkleTree's can be found [here](https://drive.google.com/file/d/1BOpa5OFmara50fTvL0VIVYjtg-qzHCVc/view).
4. Replace a leaf in the tree, using a 3rd party indexer
138
+
139
+
This example assumes that some 3rd party service is indexing the the tree at `cmtKeypair.publicKey` for you, and providing MerkleProofs via some REST endpoint.
140
+
The `getProofFromAnIndexer` function is a **placeholder** to exemplify this relationship.
141
+
142
+
```typescript
143
+
// Get a new leaf
144
+
const newLeaf:Buffer=crypto.randomBytes(32);
145
+
146
+
// Query off-chain indexer for a MerkleProof
147
+
// possibly by executing GET request against a REST api
0 commit comments