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:

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.

export TBL_PRIVATE_KEY=[PRIVATE_KEY_STRING]

Replace PRIVATE_KEY_STRING with your private key string.

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

tableland create "CREATE TABLE AssetTracker (id INT PRIMARY KEY, name TEXT, type TEXT, cid TEXT, provider TEXT, url TEXT);" --description="Filebase Asset Tracker"

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:

{
  "name": "assettracker_192
}

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.

tableland query "INSERT INTO assettracker_192 VALUES (0, 'filebase_robot.png', 'PNG', 'bafybeict7kegxaugjue5rcys65islddi2rnzmj2hh2wfq3wynf7t772hy4', 'filebase.com', '<https://bafybeict7kegxaugjue5rcys65islddi2rnzmj2hh2wfq3wynf7t772hy4.ipfs.dweb.link>');"

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:

idnametypecidproviderurl

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:

tableland query "SELECT * FROM assettracker_192;"

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.

Last updated