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.
npm install provendb-sdk-node
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"; |
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!
Full API documentation not yet available.