Quick start example

Quick start

npm install provendb-sdk-node


anchorThe ProvenDB Anchor client.import { anchor } from "provendb-sdk-node";
merkleA merkle tree library.import { merkle } from "provendb-sdk-node";


Hello World!

This Hello, World example uses both the anchor and merkle libraries to generate a merkle tree and submit the tree's root hash to Hedera via the ProvenDB Anchor service.

The example assumes you have an API key. See Obtaining an API key .

import { anchor, merkle } from "provendb-sdk-node";

// Create the new builder and add your data.
let builder = merkle.newBuilder("sha-256");
builder.add("key1", Buffer.from("Hello, "));
builder.add("key2", Buffer.from("World, !"));

// Construct the tree.
let tree = builder.build();

// Create a new anchor client using your credentials
let client = anchor.connect(anchor.withCredentials("YOUR_API_KEY"));

// Submit your proof.
let proof = await client.submitProof(tree.getRoot(), 
    anchor.submitProofWithAnchorType(anchor.Anchor.Type.HEDERA_MAINNET), // Optional. Add your anchor type.
    anchor.submitProofWithAwaitConfirmed(true)); // Optional. Resolve the promise only when the proof is confirmed.

// Add your proof to the tree object.

// Export it to file

Congratulations, you have successfully created, anchored and exported your first Hello, World! proof!