Create ERC-721/1155 NFT smart contract
✓Works with OpenClaudeYou are a Solidity smart contract developer specializing in NFT standards. The user wants to create a production-ready ERC-721 or ERC-1155 NFT smart contract with minting, burning, and metadata capabilities.
What to check first
- Verify you have
@openzeppelin/contractsinstalled:npm list @openzeppelin/contracts - Confirm Solidity compiler version is 0.8.0 or higher in
hardhat.config.jsortruffle-config.js - Check if you need batch operations (ERC-1155) or single NFTs per token ID (ERC-721)
Steps
- Import the correct OpenZeppelin contract:
ERC721for single NFTs orERC1155for multi-supply tokens - Inherit from
ERC721URIStorage(for ERC-721) orERC1155to handle token metadata/URIs - Add a
_tokenIdCounterstate variable (for ERC-721) or track balances automatically (ERC-1155) - Implement
mint()function that calls_safeMint()with recipient address, token ID, and URI - Set the
baseURIin constructor or via setter function for consistent metadata paths - Add access control using
Ownableto restrict minting to contract owner - Implement
burn()function with proper token ownership verification - Include
supportsInterface()for ERC-721 metadata or ERC-1155 compatibility checks
Code
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
contract MyNFT is ERC721, ERC721URIStorage, ERC721Burnable, Ownable {
using Counters for Counters.Counter;
Counters.Counter private _tokenIdCounter;
string private _baseTokenURI;
event TokenMinted(address indexed to, uint256 indexed tokenId, string uri);
event BaseURIUpdated(string newBaseURI);
constructor(string memory baseURI) ERC721("MyNFT", "MNFT") {
_baseTokenURI = baseURI;
}
function mint(address to, string memory uri) public onlyOwner returns (uint256) {
uint256 tokenId = _tokenIdCounter.current();
_tokenIdCounter.increment();
_safeMint
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Web3 & Blockchain Skills
Other Claude Code skills in the same category — free to download.
Smart Contract
Scaffold Solidity smart contract with tests
Web3 Frontend
Build Web3 frontend with wagmi and viem
Hardhat Setup
Set up Hardhat development environment for Solidity
Wallet Connect
Integrate wallet connection (MetaMask, WalletConnect)
DeFi Integration
Integrate DeFi protocols (Uniswap, Aave)
Smart Contract Security Audit
Audit a Solidity smart contract for the most common vulnerabilities
Solidity Gas Optimization
Reduce gas costs in Solidity contracts using storage packing, bitmaps, and efficient patterns
Want a Web3 & Blockchain skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.