Anchoring trees to blockchains



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

Creating The Client

let client = anchor.connect(anchor.withCredentials("YOUR_API_KEY"));

Submitting a Proof

To submit a quick proof with defaults:

let proof = await client.submitProof("da63e4bd82fc6e5fd7337e6bd9147d8cada6652d9049020edc6deb69b18cf69c");

To submit a proof and wait for the proof to be CONFIRMED before resolving the promise, add the submitProofWithAwaitConfirmed option:

let proof = await client.submitProof("da63e4bd82fc6e5d7337e6bd9147d8cada6652d9049020edc6deb69b18cf69c", 

To submit a proof with different anchor types, add the submitProofWithAnchorType option:

let hederaProof = await client.submitProof("da63e4bd82fc6e5fd7337e6bd9147d8cada6652d9049020edc6deb69b18cf69c", 

let ethereumProof = await client.submitProof("da63e4bd82fc6e5fd7337e6bd9147d8cada6652d9049020edc6deb69b18cf69c", 

let bitcoinProof = await client.submitProof("da63e4bd82fc6e5fd7337e6bd9147d8cada6652d9049020edc6deb69b18cf69c", 

Subscribing to Proof Changes

When a proof is submitted, it is yet to be confirmed (unless your specify submitProofWithAwaitConfirmed option). Depending on the chosen anchor type, it may take a while for a proof to be CONFIRMED status. By subscribing to a proof, you will receive an updated proof when its status changes.

let proof = await client.submitProof("da63e4bd82fc6e5fd7337e6bd9147d8cada6652d9049020edc6deb69b18cf69c")

client.subscribeProof(, proof.anchorType, callback(err, proof) => {
    if (err) {
        // handle error
    } else {
        // do something with proof

Alternatively, you can retrieve a proof without subscribing by periodically calling getProof.

// Submit the proof
let submitted = await client.submitProof("da63e4bd82fc6e5fd7337e6bd9147d8cada6652d9049020edc6deb69b18cf69c")

// Wait 
// Update the proof with getProof
let updated = await getProof(, proof.anchorType)