Skip to main content

Getting Started

Welcome to zkDatabase, a cutting-edge NoSQL database designed by Orochi Network to provide provable data integrity utilizing Zero-Knowledge Proofs (ZKP). This guide will help you get started with setting up and using zkDatabase.

Requirements

Before you begin, ensure you have the following installed:

  • Node.js v24 or later
  • npm v11 or later (or Yarn)

A basic understanding of:

  • NoSQL databases concepts
  • TypeScript/JavaScript async/await patterns
  • A basic understanding of Zero-Knowledge Proofs

Installation

zkDatabase SDK is provided as a npm package, you need to install the zkDatabase SDK in your project:

npm install zkdb 

or

yarn add zkdb 

This command initializes your project with the necessary dependencies to interact with zkDatabase as a Service.

Platform Support

The zkDatabase SDK is designed to work seamlessly in both Node.js and browser environments:

  • Node.js: Perfect for server-side applications, backend services, and CLI tools
  • Browser: Works with modern browsers for client-side applications using bundlers like Webpack, Vite, or Rollup

No additional configuration is required - the SDK automatically adapts to your environment.

Start using zkDatabase

Obtain an API Key

To use zkDatabase, you need to obtain an API key from the zkDatabase Management tool. This API key will be used to authenticate your requests to the zkDatabase service. Get API Key

Connect to zkDatabase endpoint

To start interacting with zkDatabase you must create an instance with your API key and the service URL:

import { ZkDatabase } from 'zkdb';

const zkdb = new ZkDatabase({
apiKey: 'zkdb_536aac02a1b7.c001b6b8f...da3aa4185d8d2ad07f0ae94aT',
// This URL is for test environment
url: "https://serverless.zkdatabase.org/graphql",
});

From now on, assumed that we have an instance of zkDatabase and it called zkdb.

Working with Result Types

The zkDatabase SDK uses a Result pattern for error handling. All async operations return a Result type that can be either Ok or Err:

// Using unwrap() - throws if error
const info = (await zkdb.db('my_db').info()).unwrap();

// Using isOk() and isErr() for checking
const result = await zkdb.db('my_db').exist();
if (result.isOk()) {
console.log('Database exists:', result.unwrap());
} else {
console.log('Error:', result.unwrapErr().message);
}

// Using unwrapOr() for default values
const exists = (await zkdb.db('my_db').exist()).unwrapOr(false);