Skip to content

Overview

Preview feature: available in the latest preview. APIs may change before the stable release.

A verified data structure stores key-value data off chain and reduces all of it to one hash, the root. Anyone who holds the root can check a proof that a key has a given value, or has no value, without having the data.

The usual Cardano pattern is to keep the data in your application, store the root in a datum, and let a validator check proofs on chain.

MpfTrieJellyfish Merkle Tree
Choose it forProofs checked on chain by an Aiken validatorVersioned off-chain state, with proofs checked off chain
On-chain verifierAiken’s merkle-patricia-forestry libraryNone
Deleting a keySupportedNot implemented
Reading old versionsRecord versions with a storage backendBuilt in
WritesOne key at a time, or grouped in a sessionBatches, each with a version number

If your validator needs to check a proof, use MPF.

RocksDB is the recommended storage. PostgreSQL, H2 and SQLite are alternatives, through the -rdbms modules. The storage modules bring in their core module.

def cclVersion = '<version>' // the latest preview
dependencies {
// MPF
implementation "com.bloxbean.cardano:cardano-client-merkle-patricia-forestry-rocksdb:$cclVersion"
// JMT
implementation "com.bloxbean.cardano:cardano-client-jellyfish-merkle-rocksdb:$cclVersion"
}

SQL storage never creates its tables by itself. Call RdbmsMpfSchema.createIfNotExists(dbConfig) for MPF or RdbmsJmtSchemaInstaller.createIfNotExists(dbConfig) for JMT once, or apply the bundled DDL from /ddl/{mpf,jmt}/{postgres,h2,sqlite}/schema.sql with your migration tool. See the MPF and JMT module READMEs.