CLI quickstart
Learn how to create a table, add some sample data, and query the data using the CLI.
Using the Tableland CLI, developers can interact with their tables from the command line. There are some optional setup steps, including a config file and ensuring you have the proper testnet currency to execute table creates and writes.
1. Installation
Open your terminal and globally install the Tableland CLI.
- npm
- Yarn
- pnpm
npm install -g @tableland/cli
yarn global add @tableland/cli
pnpm add -g @tableland/cli
Local development
It's easiest to also use Local Tableland when you're first getting started. Install the @tableland/local
package globally (see here for details) and then start the local nodes. This will spin up a local Tableland validator node as well as a Hardhat node, allowing you to connect to chain ID 31337
and RPC URL http://127.0.0.1
for testing purposes.
- npm
- Yarn
- pnpm
npm install -g @tableland/local
yarn global add @tableland/local
pnpm add -g @tableland/local
And then spin the nodes up so that you can use Tableland without needing to connect to any testnets or mainnets:
npx local-tableland
The rest of these examples will make use of the local nodes, but you can also connect to any supported EVM chain by specifying the --chain
and --providerUrl
flags.
2. Create a configuration file
Specify your development environment's privateKey
, chain
, and providerUrl
(e.g., Alchemy, Infura, etc.). This creates a configuration file at /Users/$USER/.tablelandrc.json
that is automatically read by the tableland
commands.
tableland init
Ideally, you should choose to ues the aliases
feature. This is an option during the config step, and it allows you to write SQL statement with a locally saved alias to table name map. Thus, you can write statements with something like my_table
instead of my_table_31337_2
.
Note that values for the chain
can be found here (e.g., Polygon Amoy is called polygon-amoy
).