provendb-sdk-node
TypeScript icon, indicating that this package has built-in type declarations

0.1.0-alpha.3 • Public • Published

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

Name Description Import
anchor The ProvenDB Anchor client. import { anchor } from "provendb-sdk-node";
merkle A 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.

Readme

Keywords

none

Package Sidebar

Install

npm i provendb-sdk-node

Weekly Downloads

2

Version

0.1.0-alpha.3

License

AGPL-3.0-only

Unpacked Size

3.1 MB

Total Files

103

Last publish

Collaborators

  • southbanksoftwareadmin