DEV Community

Cover image for Bridging on-chain and off-chain data in NFTs with Fauna
Fauna for Fauna, Inc.

Posted on • Originally published at fauna.com

Bridging on-chain and off-chain data in NFTs with Fauna

In Building scalable dApps with Ethereum, Polygon, and Fauna, we explored the challenges in building dApps with completely on-chain architectures. These challenges are rooted in the scaling limitations of Layer-1 blockchains like Ethereum, which are optimized for security and provenance over speed and scalability. Outside the context of scale, since blockchains often operate as de facto public ledgers, hosting private or sensitive data on chain can also be problematic for applications that are straddling decentralized and centralized information systems — think login or bank account information, healthcare data, etc. In a similar vein, with the increased adoption of NFTs, it’s critical for dApps built around NFTs to find an off-chain data storage solution that can store metadata securely and scale efficiently.

Apps built on blockchain technology are subject to what Ethereum co-founder Vitalik Buterin has called the blockchain trilemma — an ongoing compromise for developers and participants in the blockchain ecosystem between scalability, security, and decentralization. Because blockchains operate as immutable ledgers, and thus have enormous utility for data that needs to be hosted in a decentralized/immutable manner, this also results in slower transaction times.

With the growth in usage through a use case like NFTs, which are still ultimately tethered to centralized systems for the majority of users interfacing with the NFT ecosystem, they must naturally also have off-chain data elements to ensure privacy. Generally, unstructured data, personal data, and images will reside off chain in a typical NFT dApp due to transaction processing times and costs, privacy concerns, or some combination thereof with purely on-chain architectures.

Image description

NFT architecture

Storing, accessing, and distributing data in NFT dApps fall on a spectrum between being completely on chain and partly off chain. Because NFTs are minted on a blockchain, NFT marketplaces and creators must make decisions that are inevitably mediated by the blockchain trilemma of scalability, security, and decentralization. As such, NFT marketplaces like OpenSea, Rarible, and NBA TopShot, while all leveraging a Layer-1 platform like Ethereum for consensus and hosting the smart contract, must also host other forms of data that aren’t always suitable for a blockchain. NFT marketplaces and creators are exploring a range of solutions to how to best navigate this balance between on-chain and off-chain data, with some combination of metadata and media being stored on-chain or off-chain.

Fauna’s approach to off-chain NFT data storage

Let’s review a common NFT marketplace use case, with metadata containing user login and image information residing in an off-chain database.

This fictional NFT marketplace called Faunibles hosts the smart contract that dictates the terms of the NFT on Ethereum, the metadata in Fauna, and the image/media in IPFS or another distributed file hosting solution. With a combination of edge compute solutions like CloudFlare or Fastly as the compute layer and Fauna as the database, Faunibles gets started quickly with no server administration, and benefits from low latency with global distribution for the compute and database layers.

While Fauna isn’t a decentralized database, it has some of the same advantages of blockchain due to its global distribution and consistency. Other key benefits include:

  • Temporality
  • GraphQL Interface
  • ABAC

Off-chain storage concerns for NFT marketplaces and how Fauna addresses them

Posterity, long-term permanence and data redundancy

One of the biggest advantages of storing data on chain is the promise of permanence; off-chain data storage methods could lead to NFT owners with a smart contract that has a link to unavailable content. Fauna is a distributed, ACID compliant database — ensuring that any data written to the database is distributed across multiple nodes to guarantee consistency.

Ease of use

Fauna natively supports GraphQL and doesn’t require any database administration. Having GraphQL support makes it simpler for developers to use Fauna alongside blockchain tools like The Graph (which also supports GraphQL), enabling dApps to interoperate between off-chain and on-chain data using GraphQL — all while leaving provisioning, sharding, scaling, and other time-sensitive server administration to Fauna.

Fine-grained data security

NFTs must achieve high security and reliability across their data storage systems and avoid exposing private data in all chains and databases. Attribute-based access control (ABAC) enables dApp teams to have confidence that they can store sensitive user information like wallet addresses in their off-chain databases securely alongside the rest of their application data.

Advanced indexing

Fauna provides powerful indexing capabilities that improve the performance of searching, sorting, and combining results from multiple tables or collections. This ensures that users of dApps aren’t hit with high latency from their off-chain databases when querying between on-chain and off-chain data. This is particularly important when building latency-sensitive applications like an NFT marketplace.

How Fauna solves your off-chain database needs and requirements

Fauna provides a seamless, interoperable environment for your NFT off-chain data needs. Fauna is a document-relational database delivered as an API — you don’t have to worry about any infrastructure operations, and it’s automatically globally distributed as your user base grows. It empowers developers with the essential capabilities needed to build reliable and scalable off-chain storage for NFTs and ship apps faster.

How to get started with Fauna

Fauna is easy to use and quick to get started. Sign up for our forever free pricing plan to explore all the capabilities and start building! If you want to discuss your NFT use case with us or need more assistance, please reach out to us. We’re excited to see what problems you solve for your customers and partner with you in your journey!

Check out this video to explore how a current Fauna customer DigitalAX is leveraging Fauna’s native GraphQL capabilities to index data both on and off-chain in building its digital fashion NFT marketplace.

Top comments (0)