Kwil v2
Search
⌃K

Getting Started

The Kwil-JS SDK supports creating and interacting with Kwil databases in Node.js and browser.
Kwil-JS is a JavaScript/Typescript SDK for building web and Node.js applications to interact with the Kwil network.
A sample repository for using the Kwil-JS SDK in Node and Browser can be found here.

Installation

npm i kwil

NodeJS Initialization

import ethers.js and kwil.js, and initialize the Kwil client.
const kwiljs = require('kwil');
const { ethers } = require('ethers');
// instead of a provider, nodeJS requires a wallet
const wallet = new ethers.Wallet("my_ethereum_private_key")
// create a new Kwil web client
const kwil = new kwiljs.NodeKwil({
kwilProvider: "kwil_provider_endpoint",
});
The public kwil_provider_endpoint is found here.

Web Initialization

In browser, all imports must be destructured. There is no default value to import from the Kwil SDK.
Import ethers.js and kwil.js.
import { WebKwil } from 'kwil';
import { BrowserProvider } from 'ethers';
const provider = new BrowserProvider(window.ethereum)
const kwil = new WebKwil({
kwilProvider: "kwil_provider_endpoint"
});

The Kwil Object

The initialized "kwil" object, returned from either the NodeKwil or WebKwil provider, is used in the next examples that show how to query metadata, execute actions, fund your database, and execute CRUD operations.
To check that you have a valid kwil provider, call kwil.ping().