Tableland
Learn how to use Tableland SQL to track Object Name, Type, and IPFS CID of objects stored in an IPFS Filebase Bucket.

What is Tableland?

Tableland is an SQL database and network protocol built for use on the Ethereum network. Tableland can be used to store anything from tokenURI metadata to NFT extensions or DAO tools. Tables created and stored with Tableland utilize a user’s Ethereum wallet address for authentication, so no usernames, passwords, or access keys required.
Tableland can be used to record and track metadata for objects stored in a Filebase IPFS bucket. Objects stored on the IPFS network have an associated IPFS CID which is unique to each file, but isn’t easily identifiable like typical file IDs or storage paths are. To solve this, you can create a database with Tableland that tracks your objects and their associated file name, type, and IPFS CID so you can query it whenever you need to quickly reference an object.
Read below to learn how to use Tableland SQL to track object name, type, and IPFS CID of objects stored in an IPFS Filebase bucket.

Prerequisites:

  • Sign up for Tableland early access using their Quick Start instructions. This process involves having your Ethereum public wallet address whitelisted for use with the Tableland API.
  • Download and install the Tableland CLI tool: npm i -g @textile/tableland-cli
  • Have Your Filebase Access and Secret Keys. Learn how to view your access keys here.
  • Have a Filebase bucket created on the IPFS network. For instructions on how to create a bucket on the IPFS network, see here.

1. Once your ETH wallet address has been whitelisted for use with Tableland, you will need to grab your private key string to interact with Ethereum to create a new table.

You can follow these instructions to grab your private key string from Metamask.

2. Export your private key string as an environment variable so you don’t have to keep pasting it.

1
export TBL_PRIVATE_KEY=[PRIVATE_KEY_STRING]
Copied!
Replace PRIVATE_KEY_STRING with your private key string.

3. Use the following CLI command to create a table on Tableland called AssetTracker.

1
tableland create "CREATE TABLE AssetTracker (id INT PRIMARY KEY, name TEXT, type TEXT, cid TEXT, provider TEXT, url TEXT);" --description="Filebase Asset Tracker"
Copied!
The response from that query is your new table name! You’ll need to reference that later to update and query the table. It should look something like the following:
1
{
2
"name": "assettracker_192
3
}
Copied!
If you have your own API keys for Infura, Alchemy, etc you can avoid the warning message that was printed with the above command. See tableland create —help for details.

4. Insert some data to query using the query CLI command.

1
tableland query "INSERT INTO assettracker_192 VALUES (0, 'filebase_robot.png', 'PNG', 'bafybeict7kegxaugjue5rcys65islddi2rnzmj2hh2wfq3wynf7t772hy4', 'filebase.com', '<https://bafybeict7kegxaugjue5rcys65islddi2rnzmj2hh2wfq3wynf7t772hy4.ipfs.dweb.link>');"
Copied!
Replace assettracker_192 with the value you received in the previous step. The following table has some additional objects you might want to include.
Example Database Table:
id
name
type
cid
provider
url
1
filebase_robot.png
PNG
bafybeict7kegxaugjue5rcys65islddi2rnzmj2hh2wfq3wynf7t772hy4
https://ipfs.filebase.io/ipfs/bafybeict7kegxaugjue5rcys65islddi2rnzmj2hh2wfq3wynf7t772hy4
2
filebase_logo.png
PNG
bafkreighyv7jppuyen6kvdw3lhnleydibj44wej3ejq2j7ndwd3hsa7oam
https://ipfs.filebase.io/ipfs/bafkreighyv7jppuyen6kvdw3lhnleydibj44wej3ejq2j7ndwd3hsa7oam

5. To query the database, use the following CLI command:

1
tableland query "SELECT * FROM assettracker_192;"
Copied!
This example queries all entries in the database. You can modify this to reflect your desired query for a single object or a certain criteria of objects.
For more information on Tableland, check out their documentation here.
If you have any questions, please join our Discord server, or send us an email at [email protected]