Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    merkle-patricia-treepublic

    SYNOPSIS

    NPM Package Build Status Coverage Status Gitter or #ethereumjs on freenode

    js-standard-style

    This is an implementation of the modified merkle patricia tree as specified in the Ethereum's yellow paper.

    The modified Merkle Patricia tree (trie) provides a persistent data structure to map between arbitrary-length binary data (byte arrays). It is defined in terms of a mutable data structure to map between 256-bit binary fragments and arbitrary-length binary data. The core of the trie, and its sole requirement in terms of the protocol specification is to provide a single 32-byte value that identifies a given set of key-value pairs.
    - Ethereum's yellow paper

    The only backing store supported is LevelDB through the levelup module.

    INSTALL

    npm install merkle-patricia-tree

    USAGE

    Initialization and Basic Usage

    var Trie = require('merkle-patricia-tree'),
    levelup = require('levelup'),
    db = levelup('./testdb'),
    trie = new Trie(db); 
     
    trie.put('test', 'one', function () {
      trie.get('test', function (err, value) {
        if(value) console.log(value.toString())
      });
    });

    Merkle Proofs

    Trie.prove(trie, 'test', function (err, prove) {
      if (err) return cb(err)
      Trie.verifyProof(trie.root, 'test', prove, function (err, value) {
        if (err) return cb(err)
        console.log(value.toString())
        cb()
      })
    })

    API

    ./docs/

    TESTING

    npm test

    REFERENCES

    LICENSE

    MPL-2.0

    install

    npm i merkle-patricia-tree

    Downloadsweekly downloads

    13,061

    version

    2.3.1

    license

    MPL-2.0

    repository

    githubgithub

    last publish

    collaborators

    • avatar
    • avatar
    • avatar