DEV Community

Dennis Dawson for RippleX Developers

Posted on

NFT Payload Storage Options

NFT Payload Storage Options

NFTs are records stored on the XRP Ledger that can represent digital assets. The actual data represented by the NFT can be stored inline, on a server you administer, or on a third-party server. These are a few of the possible solutions you can use for third-party storage.

Permanent Storage

There are several service providers that offer persistent storage solutions for your NFT data.

IPFS is a modular suite of protocols for organizing and transferring data, designed from the ground up with the principles of content addressing and peer-to-peer networking.

Arweave is a permanent and decentralized web inside an open ledger.

Filecoin is a data storage network backed by an application token.

Storj is based on blockchain technology and peer-to-peer protocols to provide secure, private, and encrypted cloud storage.

Chia Network develops a blockchain and smart transaction platform based on storage-based mining.

Cached Storage

Third-party NFT storage providers are increasingly focusing on storing these decentralized files and retrieving them fast for users. Many NFT marketplaces on XRPL today are storing cached versions of the IPFS originals to provide fast, reliable, and responsive websites.

Cloudflare Stream helps creators publish their videos online without having to think about video quality, device compatibility, storage buckets or digging through FFmpeg documentation.

Infura’s NFT API makes the NFT metadata you need accessible and searchable.

Pinata is a web3 media management platform that offers tools to handle file storage, content distribution and premium content experiences.

Example - Pinata

Pinata is a solution that allows you to store cached NFT information for rapid retrieval.

What is Pinata?

Pinata is a web3 media management platform that offers developers the easiest way to use IPFS (InterPlanetary File System). Pinata offers tools that handle the complexities of file storage, content distribution (via Dedicated Gateways), and creating premium content experiences (with Submarine).

How to Upload to IPFS with Pinata

There are two main ways you can upload files to IPFS with Pinata: the Pinata web app, and the Pinata API.

Pinata Web App

To get started, visit the Pinata website and sign up for a free account. A free starter account gives you up to 1GB storage and 100 files.

To upload a file to Pinata:

  1. Press Upload.
  2. Select File.
  3. Enter the file name.
  4. Click Upload.

When the file upload is complete, it is listed in your file manager with the name and CID for that file.

Pinata API

Use the Pinata API if you are building a platform or application and prefer to upload through an API.

For example, the following is a node.js code snippet showing how to perform a file upload to Pinata:

var axios = require('axios');
var FormData = require('form-data');
var fs = require('fs');
var data = new FormData();
data.append('file', fs.createReadStream('/Users/Desktop/images/cat.JPG'));
data.append('pinataOptions', '{"cidVersion": 1}');
data.append('pinataMetadata', '{"name": "MyFile", "keyvalues": {"company": "Pinata"}}');
var config = {
  method: 'post',
  url: 'https://api.pinata.cloud/pinning/pinFileToIPFS',
  headers: {
    'Authorization': 'Bearer PINATA JWT',
    ...data.getHeaders()
  },
data : data };
const res = await axios(config);
console.log(res.data);
 ipfs://QmRAuxeMnsjPsbwW8LkKtk6Nh6MoqTvyKwP3zwuwJnB2yP
Enter fullscreen mode Exit fullscreen mode

See:

How to view and retrieve content from IPFS with Pinata

There are several different ways you can view and reference your content, including a Protocol URI, Public Gateway, and Dedicated Gateway.

Protocol URI

A standard IPFS URL looks like this:

ipfs://QmRAuxeMnsjPsbwW8LkKtk6Nh6MoqTvyKwP3zwuwJnB2yP
Enter fullscreen mode Exit fullscreen mode

If you copy and paste that into your browser, you might not get anything back. That's because in order to use this one, you need to have a local IPFS node running to participate in the network. Even when you do, it will likely be slow, since IPFS is still a growing network.

You might want to use a Protocol URI for a couple of reasons. If you're building on a blockchain that frequently uses IPFS, such as Ethereum or another L2 chain, many marketplaces and apps are compatible with this format. When they see it, they use tools to convert the URL into a gateway URL so it can display the content on a website. This can be a good thing or a bad thing. If the platform has a dedicated/private gateway, the speed is fast (much like other dedicated gateways). However, if the platform uses a public gateway, the speed can be slow. In the end, the platform has control over how well your content is received.

Additionally, using the standard IPFS URL might help future proof your assets, as public gateways might be stopped in the future (however the CID is still in the URL in those cases, so if the platform knows what to do, they can still get the content, if pinned).

Public Gateway

A public gateway URL looks something like this:

https://gateway.pinata.cloud/ipfs/QmRAuxeMnsjPsbwW8LkKtk6Nh6MoqTvyKwP3zwuwJnB2yP
Enter fullscreen mode Exit fullscreen mode

This delivers the content in the browser without the need of a local IPFS node. However, since this gateway is a public gateway, your speed might vary due to the heavy traffic and congestion. Some platforms will see this kind of the URL and switch it out with their own faster gateway choice, but not always. Generally you want to assume that if you take this path, the assets will be slow.

Dedicated Gateway

A dedicated gateway URL looks something like this:

https://pinnieblog.mypinata.cloud/ipfs/QmRAuxeMnsjPsbwW8LkKtk6Nh6MoqTvyKwP3zwuwJnB2yP
Enter fullscreen mode Exit fullscreen mode

Dedicated Gateways are much much faster than any other method, and should ideally be used when trying to display content on your own platform. However, using them in an NFT project should be done with caution. If you use a Dedicated Gateway in your NFT project metadata and image links, your speed will be great, however any time another marketplace or rarity bot asks the blockchain for the IPFS data, your gateway will be hit. Since most Dedicated Gateways are paid services, this could greatly drive up your costs and usage. You’ll get the best performance, control, and flexibility with this method; however, you might have to pay more than the other methods.

Learn more about Pinata at Pinata.cloud.

Top comments (0)