Build a complete ERC-721 NFT collection contract with merkle tree allowlists, reveal mechanics, royalty enforcement, and gas-optimized minting.
## ROLE You are an NFT smart contract developer who has launched 50+ collections across Ethereum and L2s. You understand the evolution from basic ERC-721 to ERC-721A and the tradeoffs of different minting architectures. ## OBJECTIVE Create a production-ready NFT collection contract for [COLLECTION NAME] with [MAX SUPPLY] NFTs on [CHAIN] featuring allowlist minting, public minting, and delayed reveal. ## TASK ### Contract Foundation - Base contract: ERC721A for gas-efficient batch minting vs standard ERC721 with justification - Metadata: on-chain vs off-chain (IPFS/Arweave) with URI management - Royalty standard: ERC-2981 royalty info with operator filter registry for marketplace enforcement - Ownership: Ownable2Step for secure ownership transfer - Supply management: maximum supply, reserved tokens for team/airdrops ### Minting Phases - Phase 1 — Allowlist mint: Merkle tree verification, per-wallet limits, reduced price - Phase 2 — Public mint: open minting with per-transaction and per-wallet limits - Phase 3 — Dutch auction (optional): price decreasing over time blocks - Free claim: separate merkle root for free mint allocations - Phase transitions: owner-controlled with automatic time-based fallback ### Reveal Mechanism - Pre-reveal: all tokens point to a single placeholder metadata URI - Reveal trigger: owner function that sets base URI and randomization seed - Randomization: Chainlink VRF for provably fair token-to-art mapping - Provenance hash: pre-commitment hash of final metadata ordering - Batch reveal: optional partial reveals for collections with staggered drops ### Gas Optimization - ERC721A batch minting: mint 5+ tokens for nearly the cost of minting 1 - Merkle proof verification: O(log n) verification vs O(n) array checking - Bitmap for claimed status: pack 256 claim flags into a single storage slot - Lazy minting: defer token data writes until first transfer - Minimized storage: avoid storing redundant data derivable from token ID ### Security Considerations - Bot prevention: max per-transaction limits, max per-wallet limits, no contract minting - Signature-based minting: EIP-712 signed messages as alternative to merkle trees - Withdrawal pattern: pull-based ETH withdrawal to avoid reentrancy - Fund splitting: automated royalty splits to multiple recipients - Emergency controls: pause minting, update merkle root, adjust pricing ### Marketplace Integration - Operator filter: DefaultOperatorFilterer for royalty-enforcing marketplaces - Metadata standards: OpenSea, LooksRare, Blur metadata compatibility - Collection-level metadata: contractURI() for collection name, description, image - Token-level metadata: proper JSON schema with attributes, image, animation_url ## OUTPUT FORMAT Complete Solidity contract with minting logic, reveal system, deployment checklist, and Hardhat/Foundry test outline. ## CONSTRAINTS - Must work with both EOA and smart contract wallets (EIP-4337) - Gas cost for single mint must be under 100K gas - Contract must be verified on block explorer immediately after deployment - Include fallback for Chainlink VRF failure (owner backup reveal) - Metadata must conform to OpenSea metadata standards
Or press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
[COLLECTION NAME][MAX SUPPLY][CHAIN]