@tableland/sdk

A D1Database client and helpers for the Tableland network
Table of Contents
Background
The @tableland/sdk
library provides a minimal client and SDK that implements the D1Database interface on top of the Tableland network. It can be used as a drop-in replacement to work with many community-created D1 tools and libraries. It also comes with a set of helper utilities for working with Tableland.
Usage
See the API documentation for details.
import { Database } from "@tableland/sdk";
import { providers } from "ethers";
const provider = new providers.Web3Provider(window.ethereum);
await provider.send("eth_requestAccounts", []);
const signer = provider.getSigner();
const db = new Database({ signer });
const stmt = db.prepare("SELECT name, age FROM users_80001_1 LIMIT ?").bind(3);
const { results } = await stmt.all();
console.log(results);
Full library documentation available on GitHub, and
general docs, examples, and more available on our docs site.
Install
You can install via npm/yarn:
npm i @tableland/sdk
Or directly via GitHub:
npm i tablelandnetwork/js-tableland
Development
Get started by cloning, installing, building, and testing the project:
git clone git@github.com:tablelandnetwork/js-tableland.git
cd js-tableland
npm install
npm run build
npm test
To run tests in a few of the common browser environments we are using Playwright. Once your code changes are finished you can run the brower tests by doing:
cd test/browser/server
npm install
cd ../../
npm run test:browser
Contributing
PRs accepted.
Small note: If editing the README, please conform to the
standard-readme specification.
License
MIT AND Apache-2.0, © 2021-2022 Tableland Network Contributors