Quick Start

Quick Start

The bare minimum steps to take in order to use Tableland.

The bulk of what developers will need is described in detail throughout the resources in the Walkthroughs section. But, for those looking to install and skip straight to building, here are the steps you should take.

⚠️
Tableland is still a testnet and will be launching a Tableland mainnet in 2023. But, smart contracts and apps deployed on testnet and mainnet chains can and should use the Tableland testnet. Developers should still proceed with caution due to the nature of testnets and ensure contracts that use Tableland are upgradable.

JavaScript SDK

  1. Install the JavaScript SDK using npm:
  2. npm install --save @tableland/sdk

    Or yarn:

    yarn add @tableland/sdk
  3. Import it and use it in your client-side web app:
  4. import { connect } from '@tableland/sdk'
    
    // Establish a connection
    const tableland = await connect({ network: "testnet", chain: "polygon-mumbai" });
    
    // Create a table
    const { name } = await tableland.create(`id int primary key, name text`, `quickstart`)
    // Wait for the table to be created, then query
    const writeRes = await tableland.write(`INSERT INTO ${name} VALUES (0, 'Bobby Tables');`
    const readRes = await tableland.read(`SELECT * FROM ${name}`)

    Note: Node.js support also exists; see the SDK docs for more detailed setup information, including the ethers library.

CLI

  1. Install the Tableland CLI using npm:
  2. npm install -g @tableland/cli

    or yarn:

    yarn add global @tableland/cli
  3. And using the CLI, create a table, insert (write) a value (after signing a Sign In With Ethereum token), and read from the newly updated table:
  4. # Create a table & save its returned `name` locally
    tableland create "id int primary key, name text" "quickstart" --chain=polygon-mumbai --privateKey "your_private_key_"
    
    # Write to the table by INSERTing a value
    # Note: every table `name` is unique, so replace `quickstart_5_74` with your
    tableland write "INSERT INTO quickstart_5_74 VALUES (0, 'Bobby Tables')" --chain=polygon-mumbai --privateKey "your_private_key_" --token "siwe_token"
    
    # Read from the table
    # Note: replace the table name with yours
    # Although, anyone can *read* from *any* table, so this statement is valid for anyone
    tableland read "SELECT * FROM quickstart_5_74;" --chain=polygon-mumbai 

Smart Contracts

  1. Clone the repo at evm-tableland, which has smart contracts in a hardhat project:
  2. git clone https://github.com/tablelandnetwork/evm-tableland
  3. Build the client
  4. npm install
    npx hardhat compile
    npm run build
  5. Start a local hardhat node & deploy the contracts:
  6. # in one terminal, run the following
    npx hardhat node
    
    # and in a separate terminal, deploy the contracts
    npx hardhat run scripts/deploy.ts --network localhost

If those setup steps didn’t provide enough context, head over to the more detailed documentation!