0.1.0-alpha.3 • Published 3 years ago

provendb-sdk-node v0.1.0-alpha.3

Weekly downloads
-
License
AGPL-3.0-only
Repository
github
Last release
3 years ago

provendb-sdk-node

The ProvenDB SDK for Node.

NOTE: The SDK is is in beta. For any bugs, please raise an issue.

The use of our services requires an API key. Visit provendb.com to sign in/register and create one.

Installation

npm install provendb-sdk-node

Libraries

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

Examples

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.

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.
tree.addProof(proof);

// Export it to file
tree.exportSync("./merkle.json");

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

Documentation

Full API documentation not yet available.