Building the World’s First SQL console NFT

Building the World’s First SQL console NFT

We're rolling out a new update to the Table NFT that makes every NFT a data application that allows a viewer to explore the dataset

Introducing the World’s First SQL console NFT

We're rolling out a new update to the Table NFT that makes every NFT a data application that allows a viewer to explore the dataset

Every table is an NFT containing data, an app, and the ability to update itself

Today, we're rolling out a new update to the Table NFT that makes every NFT a data application that allows a viewer to explore the dataset without leaving the marketplace, wallet, or any place the NFT shows up. We're excited about NFTs that do more than show you something—adding this little feature to our own data NFTs gets our minds racing over where they go next. 🚀



The Table NFTs are unique NFTs produced each time a user of the Tableland protocol creates a new table. They are valid ERC-721 tokens and help showcase our belief that NFTs are more than art and collectibles. You can explore thousands of tables created by users (and smart contracts) on any NFT marketplace. For example, here are tables created on Mumbai. The next step in our Table NFT roadmap was to make it so that every dataset's NFT could also serve as the gateway to explore the underlying data.


Executing the Table NFT

The new Table NFT includes the ability for any viewer to open up a single NFT and drop right into an interface to view and query the data. If you aren't familiar with SQL, don't worry, you can still see the raw data. If you are familiar with SQL, you'll find that the interface lets you do more than look at this single table's data. The Table NFT is a fully featured SQL explorer where you can join, manipulate, and even update data!


New possibilities

Wait a second, did you say "update"?! That's right! The Table NFTs are interactive and self-modifying.

But what do I mean by "self-modifying"? Many NFTs are modifiable. For example:

  1. Head over to the Moonbirds NFT contract on etherscan, submit the right request (and own a Moonbird) and your Moonbird is now nested.
  2. Head over to the Tableland Rigs Garage and take your Rigs out for training, and now your Rig is in flight.

But what if we could take this a step further? Can we allow the NFT itself to provide the mechanism by which the NFT is altered? This feature allows NFTs to become interactive and interpersonal: user actions can change not only what they're seeing but they can also change what others are seeing.

Of course, you can't change data you don't have permission to change. For permissions, the Tableland protocol has customizable access control rules anchored to smart contracts on the blockchain.

How does the Table NFT work?

Here are the main concepts for building a decentralized NFT-based app (i.e., an executable NFT or xNFT):

  1. With Tableland, you can create relational tables using SQL. Each Table you create is it’s own NFT. The NFT confers certain rights over the table of data.
  2. The NFT application is written primarily in React. The application is written so that it requires no external dependencies. See the repo.
  3. The final build is pushed to IPFS and Filecoin. You can see the app running over IPFS here.
  4. The IPFS link can now be included in every Table NFT's animation_url field. This field is used by OpenSea and others when someone views a single NFT. In our case, this will load the web app.

View this one, this one, or this one for examples.

The challenges of making an NFT app that runs everywhere

Opensea (and most marketplaces) display the animation URL in an iframe which is sandboxed. In Opensea’s case, the iframe is sandboxed to ”allow-scripts” only. This blocks some of the interactions we'd like to see in the NFT, primarily around wallet connections.

Wagmi and Rainbowkit are both wonderful tools, but they were not built to be used in this context. So users can open a Table NFT in OpenSea and read the data, but if they attempt to send any write requests, they'll need to flip over to the Tableland Console (where wallet connections are possible).

For hackers that try to build their own applications inside NFTs, here are a few more gotchas.

  • LocalStorage isn’t available. LocalStorage in the browser is super useful. There’s just one problem; it doesn’t work in sandboxed iframes with only the “allow-scripts” property. When one attempts to use it, it throws an error. To make Rainbowkit work, we needed to alter the JavaScript to remove the calls to localStorage. Not ideal, but it worked.
  • WebSockets are blocked in the iframe sandbox. Rainbow kit allows you to use the underlying wallet's QR connectors to connect to a mobile wallet. Nice. However, these QR connectors all seem to use websockets to connect to a server that connects to your phone. Guess what doesn’t work inside these sandboxed iframes? That’s right; websockets. Why this is, I haven’t the foggiest idea. You can use any sort of post or get request. Websockets are just a more efficient way of doing the same operations.
  • Links can’t escape the iframe. Opensea doesn’t add the “allow-popups” property to the iframe, so attempting to open links will only work if they target the iframe. New tabs or navigation away from the current page are no-ops. So I couldn’t even easily send a user to another page on which they could perform their transactions with the network.

Do I believe it is a wise idea for Opensea to sandbox their iframes? Absolutely. But it certainly complicates making an interactive NFT.

What’s next?

Building NFTs that contain executable programs is not new to NFT enthusiasts. There are many projects on OpenSea that have experimented with the concept. Take this example from a year ago,, where the creators let you play a game built in Unity right on OpenSea. More recently, Coral raised $20m to build out the "xNFT" or executable NFT ecosystem on Solana. While it's pretty clear that most NFTs won't be built this way, there are some obvious cases where doing so can increase interoperability, collectability, preservability, or utility.

Even before Web3, open data communities have wrestled with ideas of transparency, utility, and interoperability for a long time. In our case, where NFTs represent unique datasets, the interoperable application that can be embedded anywhere the data is used or lives opens up for how people can explore and understand the data. It's also just fun to see our application run on all the marketplaces :D.

We hope this inspires other developers to come experiment with us. If that’s you, consider applying for the next Pilot Program cohort (starting in January 2023, apps open now) or watch out for the next EthGlobal hackathon and come hack with us.