Skip to main content

Create an NFT

You can use Irys to create an NFT on Linea in three steps:

  1. Deploy your smart contract on Linea
  2. Permanently store your NFT assets on Irys
  3. Mint your NFTs using metadata stored on Irys

When you upload NFTs to Irys, you make a one-time payment for and your data is guaranteed to be retrievable forever. Creators and collectors benefit from the assurance that their NFTs are preserved indefinitely. NFT metadata and images stored are Irys are permanent and immutable.

You can also use Irys to create dynamic NFTs

that evolve based on onchain or offchain actions. :::

Deploy your smart contract​

If you're new to NFTs and smart contract development, consider deploying one of the audited ThirdWeb contracts to learn more.

You can also deploy this minimal contract using Remix.

// SPDX-License-Identifier: MIT
// Compatible with OpenZeppelin Contracts ^5.0.0
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract IrysLineaNFT is ERC721, ERC721URIStorage, Ownable {
uint256 private _nextTokenId;

constructor(address initialOwner)
ERC721("IrysLineaNFT", "ILNFT")
Ownable(initialOwner)
{}

function safeMint(address to, string memory uri) public onlyOwner {
uint256 tokenId = _nextTokenId++;
_safeMint(to, tokenId);
_setTokenURI(tokenId, uri);
}

// The following functions are overrides required by Solidity.
function tokenURI(uint256 tokenId)
public
view
override(ERC721, ERC721URIStorage)
returns (string memory)
{
return super.tokenURI(tokenId);
}

function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721, ERC721URIStorage)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
}

Store your assets on Irys​

Uploads to Irys are fully unconstrained; you can upload files of any size and use Irys to make images, videos, music, or interactive NFTs.

This guide covers using the Irys CLI to upload your assets to Irys. You can also do the same using the Irys SDK.

Store your visual assets​

Install the Irys CLI​

Install the CLI globally using the -g flag. Depending on your setup, you may or may not need to use sudo.

npm i -g @irys/cli

Depending on your setup, you may need to use the sudo command.

sudo npm i -g @irys/cli

Upload single assets​

To upload a single file, use the command irys upload.

irys upload myNFT.png \
-t linea-eth \
-w bf20......c9885307

The CLI will output the link to download the file from the Irys gateway.

Example:

Uploaded to https://gateway.irys.xyz/A7CXNp4WqwkY73TRxKR2o3gfSCw3ghhZZXiP8CM6Yv1x

Upload multiple assets​

To upload a folder of files, use the command irys upload-dir.

irys upload-dir myNFTs \
-t linea-eth \
-w bf20......c9885307

The CLI outputs a link to the manifest for the upload:

https://gateway.irys.xyz/A7CXNp4WqwkY73TRxKR2o3gfSCw3ghhZZXiG8CM6Yv1f

The CLI also produces a .json file containing the transaction IDs of each upload:

{
"manifest": "irys/paths",
"version": "0.1.0",
"paths": {
"nft1.png": { "id": "B7CXNp4WqwkY73TRxKR2o3gfSCw3ghhZZXiP8CM6Yv1x" },
"nft2.png": { "id": "C7CXNp4WqwkY73TRxKR2o3gfSCw3ghhZZXiP8CM6Yv1x" },
"nft3.png": { "id": "D7CXNp4WqwkY73TRxKR2o3gfSCw3ghhZZXiP8CM6Yv1x" },
"nft4.png": { "id": "E7CXNp4WqwkY73TRxKR2o3gfSCw3ghhZZXiP8CM6Yv1x" },
"nft5.png": { "id": "F7CXNp4WqwkY73TRxKR2o3gfSCw3ghhZZXiP8CM6Yv1x" }
}
}

You can download files by using the transaction ID directly, or by creating a URL using the manifest ID combined with the original file name. For example, nft1.png can be downloaded with either of these URLs:

  • https://gateway.irys.xyz/gF7CXNp4WqwkY73TRxKR2o3gfSCw3ghhZZXiP8CM6Yv1x
  • https://gateway.irys.xyz/F7CXNp4WqwkY73TRxKR2o3gfSCw3ghhZZXiP8CM6Yv1x/nft1.png

Store your metadata​

Create metadata​

Create unique metadata files, one for each NFT.

{
"name": "Irys & Linea Forever",
"description": "Irys & Linea NFTs #42",
"image": "https://gateway.irys.xyz/F7CXNp4WqwkY73TRxKR2o3gfSCw3ghhZZXiP8CM6Yv1x",
"background_color": "FEF4EE"
}

Upload metadata​

Upload the metadata to Irys

irys upload metadata.json \
-t linea-eth \
-w bf20......c9885307

Mint the NFTs​

Now use your metadata URLs (in the format https://gateway.irys.xyz/:txId) to mint the NFTs using the contract you deployed on Linea.