Skip to main content

Storing data and files with IPFS

Because storage space on blockchains is expensive, developers don't put large files or large pieces of static data on Tezos. Instead, they configure off-chain storage for the files or data and put a link to that data on Tezos itself. There are different ways to store data in this way, but many blockchain developers use the InterPlanetary File System (IPFS) protocol because it is decentralized.

Some examples of files or data that developers often store on IPFS are:

  • Smart contract metadata
  • Token metadata
  • Token media, such as thumbnails and preview images

One way to upload (or pin) data to IPFS is to use Pinata's IPFS provider. Follow these steps to set up a Pinata account and use it to pin data to IPFS:

  1. Create a free Pinata account at https://app.pinata.cloud/developers/api-keys.

  2. Go to the API Keys tab and click New Key.

  3. On the Create New API Key page, expand API Endpoint Access > Pinning and enable the pinFileToIPFS and pinJSONToIPFS permissions, as in this picture:

    Selecting the permissions for the Pinata key

  4. In the Key Name field, give the key a name, such as "My Key."

  5. Click Create Key.

    The API Key Info window shows the API key and secret, which you must copy immediately, because they are not shown again.

  6. Copy the API Key and API Secret fields and save the values.

    You can see the new API key on the API Keys tab:

    The new Pinata API key in the Pinata web app

Now you can upload data to IPFS via Pinata in many different ways, including:

warning

Keep your Pinata API Secret private; do not expose it in a frontend web application. If you want to pin data to IPFS in a web application, you may need to work with Pinata in a backend application to keep your Pinata information secret.