Introduction
NFTs (Non-Fungible Tokens) have surged in popularity, from CryptoKitties clogging the Ethereum network to Twitter's founder selling his first tweet as an NFT for nearly $3 million.
This guide walks you through creating your own NFT collection using:
- The Ethereum blockchain
- The ERC-721 standard
- IPFS for decentralized image storage
- OpenSea for marketplace listing
What Is an NFT?
An NFT is a unique digital asset verified via blockchain, ideal for:
- Collectibles (e.g., NBA TopShot)
- Art (e.g., CryptoPunks)
- Game items (e.g., Gods Unchained)
- Virtual worlds (e.g., Decentraland)
- Real-world assets (e.g., real estate)
The ERC-721 Standard
Proposed in 2018, ERC-721 is a Non-Fungible Token Standard enabling:
- Token transfers between accounts
- Balance checks
- Ownership verification
- Optional metadata integration
Tools & Development Assets
Prerequisites
- Node.js & npm: Download here
- Truffle: Install via npm
- Pinata Account: Sign up
- IDE (e.g., VS Code)
- MetaMask: Chrome extension
Key Tools Explained
- OpenZeppelin: Reusable Solidity contracts for secure ERC-721 deployment.
- Truffle: Ethereum development framework for testing/deployment.
- Infura: Provides access to Ethereum nodes.
- IPFS: Decentralized storage for NFT metadata/assets.
- Pinata: Pins files to IPFS for permanence.
- OpenSea: Marketplace for buying/selling NFTs.
Metadata Setup
Off-Chain vs. On-Chain Storage
- Off-Chain (Recommended): Lower cost, stored on IPFS.
- On-Chain: Higher gas fees but fully decentralized.
ERC-721 JSON Schema Example
{
"description": "Galaxy photo collection",
"image": "ipfs://QmZ6iJbUpEfKxUodwx4DgaF9zquvRjJEMXAkH8EJtWPLKm",
"name": "Starry Night #1",
"attributes": [
{"trait_type": "Author", "value": "Jane Doe"},
{"trait_type": "Resolution", "value": "6016x3385px"}
]
}👉 Learn more about OpenSea metadata standards
Upload Metadata to IPFS via Pinata
- Upload Images: Add files to Pinata’s dashboard.
- Copy IPFS URL: Use this in your metadata files.
- Upload Metadata Folder: Pin the entire folder to IPFS.
Example IPFS folder URL: https://gateway.pinata.cloud/ipfs/QmcdnHCTuPoazQG8ft3tsRQ6RZTob6EDgAR5Mo3LV2Weif/
Environment Setup
Initialize Project:
mkdir my-nft && cd my-nft npm init -y npm install @openzeppelin/contracts truffle npx truffle initConfigure Truffle:
Edittruffle-config.jsfor Rinkeby:const HDWalletProvider = require('@truffle/hdwallet-provider'); const secrets = require('./secrets.json'); module.exports = { networks: { rinkeby: { provider: () => new HDWalletProvider( secrets.mnemonic, `https://rinkeby.infura.io/v3/${secrets.projectId}` ), network_id: 4 } } };- Fund Testnet Account: Use Rinkeby Faucet.
Smart Contract Deployment
Deploy Script:
Createmigrations/2_deploy_token.js:const ERC721PresetMinterPauserAutoId = artifacts.require('ERC721PresetMinterPauserAutoId'); module.exports = function(deployer) { deployer.deploy( ERC721PresetMinterPauserAutoId, "My NFT Collection", "MNC", "ipfs://QmcdnHCTuPoazQG8ft3tsRQ6RZTob6EDgAR5Mo3LV2Weif/" ); };Deploy to Rinkeby:
npx truffle migrate --network rinkebyMint an NFT:
await mynft.mint("0xYourMetaMaskAddress");
Listing on OpenSea
Find Contract Address:
truffle(rinkeby)> mynft.addressImport to OpenSea:
- Go to OpenSea.
- Click "My Collections" → "Import Contract".
- Paste your contract address.
Example listing URL: https://testnets.opensea.io/assets/0xYourContractAddress/0
👉 Explore advanced NFT use cases
FAQs
How much does it cost to mint an NFT?
Costs vary based on Ethereum gas fees. Testnet deployments are free, but mainnet minting can range from $50–$200+.
Can I update NFT metadata after minting?
No, metadata is immutable once deployed to IPFS. Plan carefully!
How do I make my NFT dynamic?
Use oracles (e.g., Chainlink) to fetch real-time data or upgradeable contracts.
Why isn’t my NFT showing on OpenSea?
It may take 12–24 hours for OpenSea to index new contracts. Verify transactions on Etherscan.
Next Steps
- Mainnet Deployment: Estimate costs using ETH Gas Station.
- Dynamic NFTs: Integrate oracles for real-time updates.
- On-Chain Metadata: Explore storing metadata directly in contracts.
Conclusion
You’ve now:
- Created an ERC-721 NFT with OpenZeppelin.
- Stored metadata on IPFS via Pinata.
- Listed your NFT on OpenSea.
For further learning, check out Your Immutable Future podcast.
🚀 Ready to launch your NFT project? Start here!