How to Create and Deploy an ERC-721 (NFT) Token

·

Digital collectibles compatible with the ERC-721 standard have surged in popularity, especially since the rise of projects like Cryptokitties. This guide will walk you through creating and deploying your own NFT using the OpenZeppelin standard, covering everything from metadata creation to smart contract deployment.

What You Will Learn

Key Requirements


Understanding NFTs and ERC-721

What Are Non-Fungible Tokens?

NFTs are unique digital assets that cannot be replicated or exchanged 1:1 like cryptocurrencies. Each NFT has distinct attributes, making it ideal for representing:

👉 Learn more about NFT use cases

ERC-721 Standard Explained

ERC-721 is the technical standard for NFTs on Ethereum. It defines:


Step-by-Step Guide

1. Hosting NFT Assets on IPFS

Option A: Standard IPFS CLI Method

  1. Install IPFS CLI.
  2. Add files via:

    ipfs add art.png
    ipfs add nft.json
  3. Use the returned hashes (e.g., Qm...) to access files via https://ipfs.io/ipfs/Qm....

Option B: QuickNode IPFS (Simplified)

  1. Upload files via QuickNode’s dashboard.
  2. Copy the auto-generated IPFS URL (e.g., https://qn-shared.quicknode-ipfs.com/ipfs/Qm...).

2. Writing the ERC-721 Smart Contract

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

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

contract MyToken is ERC721, ERC721URIStorage {
    constructor() ERC721("MyToken", "MTK") {}

    function mintNFT(address to, uint256 tokenId, string memory uri) public {
        _safeMint(to, tokenId);
        _setTokenURI(tokenId, uri);
    }
}

3. Deploying the Contract

  1. Compile and deploy via Remix IDE (Ethereum Sepolia testnet).
  2. Call mintNFT with:

    • Recipient address
    • Token ID (e.g., 1)
    • IPFS JSON URL

👉 Explore advanced NFT contracts


FAQs

1. How much does it cost to mint an NFT?

Deployment costs depend on gas fees. Testnets like Sepolia allow free minting with test ETH.

2. Can I update NFT metadata after minting?

No. ERC-721 metadata is immutable once deployed. Plan metadata carefully.

3. What’s the difference between ERC-721 and ERC-1155?

ERC-1155 supports both fungible and non-fungible tokens in a single contract.


Conclusion

By following this guide, you’ve:

For further reading, check out OpenZeppelin’s ERC-721 Wizard.

Need help? Join our Discord community for developer support!


### Key Features:  
- **SEO Optimization**: Keywords like "ERC-721," "NFT minting," and "IPFS" are naturally integrated.  
- **Structured Format**: Clear headings, bullet points, and FAQs enhance readability.  
- **Engagement**: Anchor texts and a friendly tone encourage interaction.