Skip to main content

Get Started

Why Polybase?

Polybase is the database for all of humanity’s data. Fast, decentralized and designed from the ground up to scale beyond 1M transactions per second.

Polybase is better than using a centralized database like Firebase or Postgres because you can encrypt data using wallets for "self sovereign data" and verifiably query Polybase from smart collections (coming soon).

Polybase is better than storing data on-chain because it's 1000 to a million times cheaper than on-chain storage. For example, storing 1MB on Ethereum costs around $64,000.

Blockchains are not built for scalable structured data storage so we built Polybase to combine the best attributes of web2 databases and blockchains.

Install Polybase

npm install @polybase/client
yarn add @polybase/client

Initialize the library

import { Polybase } from '@polybase/client'

const db = new Polybase({
defaultNamespace: "your-namespace"

Namespace must be used for collections.


If you specify a defaultNamespace, it will be automatically added for you when you create a collection instance.

Create a collection

You can create a collection using the library.

A Polybase collection describes the rules for a collection of data, not just a single record (as is the case with other smart collection languages).


Creating a collection via the Polybase Explorer is coming soon.

const createResponse = await db.applySchema(`
collection City {
id: string;
name: string;
country?: string;


constructor (id: string, name: string) { = id; = name;

setCountry (country: string) { = country;
`, 'your-namespace') // your-namespace is optional if you have defined a default namespace

For more details on creating collections, see the collection overview.

Create a collection record

When you create a new record, the constructor fn in your collection is called with the parameters you provide.

const db = new Polybase({ defaultNamespace: "your-namespace" })
await db.collection('City').create(['new-york', 'New York'])

Now go view the collection in the Explorer.

Update a collection record

You can update records by calling methods defined on your collection.

const db = new Polybase({ defaultNamespace: "your-namespace" })
await db.collection('City').call('setCountry', ['USA'])

Read a record

const db = new Polybase({ defaultNamespace: "your-namespace" })
const data = await db.collection('City').record('new-york').get()

Next steps