Tableland Documentation
website·Indexed 33 days ago
https://docs.tableland.xyz/Documentation for Tableland, a web3 database platform. Includes guides on using the JavaScript/TypeScript SDK, the Validator Gateway API, and a unique subset of SQLite for database operations. Covers smart contract integration with Tableland controllers for access control, row-level permissions, and tutorials for building dynamic NFTs and key-value stores.
What's inside Tableland
- The Tableland CLI is a command-line wrapper around the Tableland SDK. It extends the SDK's functionality by allowing users to interact with tables across the network and perform bulk operations, such as writing to the database directly from SQL files or CSV data.
Overview of Tableland web3 SQL database
Tableland is a web3 SQL database compatible with EVM chains, including Ethereum, Optimism, Arbitrum One, Arbitrum Nova, Base, Polygon, and Filecoin. It allows developers to scale, mutate, and access chain-driven data (such as onchain rules and identity) by offloading accessibility to a decentralized network of validator nodes that monitor the host chain for updates.Overview of Tableland and Lit Protocol integration
Tableland data is open by default. To implement private data storage, Lit Protocol can be used as a decentralized key management network. Instead of a single entity holding a private key, Lit distributes key shares across a network. Decryption requires a pre-defined threshold of nodes to combine shares. This allows developers to encrypt data before writing it to Tableland and decrypt it upon reading, using Lit's built-in access control system.Overview of the Signer interface
TheSignerinterface represents an account on the Ethereum Blockchain. While typically backed by a private key (via mnemonic or hardware wallet), the API is abstract to support advanced signing entities like Smart Contract Wallets or Virtual Wallets. It extendsAddressable,ContractRunner, andNameResolver.Overview of the Tableland SDK
The
@tableland/sdkprovides a client that implements the Cloudflare D1 Database interface on top of the Tableland network, allowing it to be used as a drop-in replacement for community-created D1 tools and libraries. It supports both ESM and CommonJS. The SDK consists of three main APIs:- Database API: The primary API for SQL operations, compatible with the Cloudflare D1 client API.
- Validator API: A secondary API for interacting directly with Tableland Validator nodes.
- Registry API: A secondary API for calling Tableland's smart contracts (e.g., onchain access control).
Overview of Tableland Studio
Tableland Studio is a web application designed to help users create projects to organize tables and collaborate with others. It abstracts blockchain-specific complexities, making it an ideal entry point for getting started with Tableland.Overview of Tableland Access Control methods
Tableland provides two complementary methods for configuring access control on a per-table basis:
- Smart Contract Rules & Controllers: A flexible, dynamic system where a controller contract asserts user permissions (e.g., based on token balances, roles, or ownership) before allowing
INSERT,UPDATE, orDELETEoperations. These can include specificWHEREandWITH CHECKclauses. - SQL GRANT/REVOKE Statements: A simpler, more rigid system familiar to SQL developers. These grant static
INSERT,UPDATE, orDELETEpermissions to specific addresses and cannot be based on on-chain dynamic definitions.
- Smart Contract Rules & Controllers: A flexible, dynamic system where a controller contract asserts user permissions (e.g., based on token balances, roles, or ownership) before allowing
Overview of Tableland Symmetric Encryption Plugin
The experimental encryption plugin allows developers to encrypt table data before writing it to Tableland and decrypt it after querying. It uses AES symmetric encryption. Because Tableland is an open database, data is publicly readable unless encrypted.
Warning: This plugin is a simple symmetric implementation and is NOT suitable for production use cases. It is intended as a reference point for building more secure, custom encryption schemes using the
createProcessormethod.Overview of Tableland SQL Specification
Tableland uses a unique subset of the SQLite SQL language. While it omits many standard SQL features, it adds specific constraints and features tailored for Tableland operations. The core API is summarized by eight primary statement types:CREATE TABLE,ALTER TABLE,INSERT,UPDATE,DELETE,SELECT,GRANT, andREVOKE.Overview of JETI for Tableland SDK
The JETI (JavaScript Extension for Tableland Integrations) package is a library used with the@tableland/sdkto transform data on the client-side. It allows developers to transform data before submitting it to Tableland and 'untransform' data retrieved from queries. It provides built-in extensions for IPFS pinning, string truncation, and encryption, as well as acreateProcessorfunction for building custom plugins.Overview of the Tableland Registry contract
The Tableland registry smart contract controls the creation and mutation of tables as well as access controls. Interactions with the registry involve passing raw SQL statements which are emitted and later materialized at the Tableland validator node. It is highly recommended to use theTablelandDeployments.solandSQLHelpers.sollibraries to construct these SQL statements.Overview of Tableland's relational database architecture
Tableland is a permissionless relational database network designed to scale structured web3 data. It functions as a collection of SQL databases that communicate and agree on table states based on on-chain instructions. Unlike standard blockchains, which are global state machines for computation, Tableland provides a native relational data layer for efficient storage and retrieval of structured data using SQL.