Blog
5 min readOctoPeeps team

How to pin NFT metadata and images to IPFS, step by step

Pin your NFT media folder, write ERC-721 metadata with ipfs:// image links, pin the metadata folder and set baseURI. Plus the mistakes that break collections.

Every NFT has two parts that live off-chain: the media (an image, video or 3D file) and a small JSON metadata file that describes it. Your contract only stores a pointer to the metadata. This guide shows how to pin both to IPFS so the pointer keeps working for as long as the content is pinned, no matter which marketplace or wallet reads it.

What you need

Step 1: pin the media folder

Upload the whole media folder in one go instead of file by file. A folder upload gives you a single directory CID, and every file is reachable under it:

ipfs://<MEDIA_CID>/1.png
ipfs://<MEDIA_CID>/2.png

In Octopin, open the upload page, choose folder, and select the directory. When it finishes you get the directory CID. Open one file through a public gateway such as https://ipfs.io/ipfs/<MEDIA_CID>/1.png to confirm it resolves outside our own gateway too.

Step 2: write the metadata JSON

Each token gets one JSON file following the ERC-721 metadata standard (ERC-1155 uses the same shape). The image field must point at the media using the ipfs:// scheme:

{
  "name": "Octo #1",
  "description": "One of 4,848 OctoPeeps.",
  "image": "ipfs://<MEDIA_CID>/1.png",
  "attributes": [
    { "trait_type": "Background", "value": "Teal" },
    { "trait_type": "Eyes", "value": "Sleepy" }
  ]
}

Name the files by token ID. Many projects drop the .json extension (1, 2, ...) so the contract can build the URI as baseURI + tokenId. If you keep the extension, make sure your contract appends it.

Step 3: pin the metadata folder

Upload the metadata directory the same way. You get a second CID, and each token's metadata is at ipfs://<METADATA_CID>/1. Spot-check a few files through a public gateway and confirm the image links open.

Step 4: set the base URI in your contract

Set baseURI (or return it from tokenURI) as:

ipfs://<METADATA_CID>/

Use ipfs://, not an https gateway URL. A gateway hostname ties your collection to one company's server forever. The ipfs:// form lets every marketplace and wallet pick its own gateway, and lets you switch pinning providers without touching the contract. Full explanation here.

Step 5: check it on a marketplace

After minting a test token, open it on OpenSea or Magic Eden and use "refresh metadata". Marketplaces cache aggressively, so the first fetch can take a few minutes. How marketplaces resolve ipfs:// URIs.

Common mistakes

How much space does a collection need?

Metadata is tiny, usually under 1 KB per token. Media is what counts: a 10,000-piece PFP collection at around 100 KB per image needs about 1 GB. That fits the Octopin free plan's storage, though its 2,000 file limit means a collection that size needs the $5/mo Hobby plan.

Try Octopin for free

1 GB free. Unlimited bandwidth. No credit card.