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.
npm i kwil
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",
});
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 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()
.Last modified 20d ago