Tableland
Learn how to use Tableland SQL to track Object Name, Type, and IPFS CID of objects stored in an IPFS Filebase Bucket.
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.
- 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 a Filebase bucket created on the IPFS network. For instructions on how to create a bucket on the IPFS network, see here.
export TBL_PRIVATE_KEY=[PRIVATE_KEY_STRING]
Replace
PRIVATE_KEY_STRING
with your private key string.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.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:
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 |
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.
If you have any questions, please join our Discord server, or send us an email at [email protected]
Last modified 1yr ago