Build a full-stack NFT platform on Nexus with Next.js, Firebase, and OpenSea compatibility
hardhat.config.js
which will define the network configuration, RPC endpoint for Hardhat to connect to, and chainID for signature verification:
.env
in your project root directoryhardhat.config.js
if not already present:contracts/SimpleNFT.sol
. The project uses an advanced ERC-721 implementation with enhanced metadata management, tailored for NFT collections requiring scalable minting, secure update mechanisms, and compatibility with modern NFT marketplaces.
SimpleNFT
, extends the ERC-721 standard to support modern NFT use cases including batch minting, dynamic metadata with optional freezing, and ERC-4906 metadata update events. It is built atop OpenZeppelin libraries for security and standard compliance.
ERC721
and ERC721URIStorage
, enabling both standard NFT transfer and ownership logic and per-token URI storage.
Batch Minting
Allows efficient minting of multiple NFTs in a single transaction. Useful for creators distributing large collections or performing airdrops.
Metadata Control and Freezing
The base URI can be updated by the owner until freezeMetadata()
is called. Once frozen, metadata becomes immutable, which is critical for collectors and marketplaces relying on permanent content.
ERC-4906 Support
Implements the ERC-4906 interface, which allows external platforms to detect when metadata has changed. The setBaseURI
method emits a BatchMetadataUpdate
event covering all tokens.
Ownership and Access Control
Relies on OpenZeppelin’s Ownable
pattern to restrict administrative functions (setBaseURI
, freezeMetadata
) to the contract owner.
Gas Efficiency
Uses a simple incrementing counter (_nextTokenId
) to assign token IDs, reducing storage complexity and minimizing gas costs. Batch minting via loops avoids external calls, maintaining compact logic.
Function | Description |
---|---|
constructor(...) | Initializes contract with name, symbol, and base URI; sets ownership |
_baseURI() | Internal getter for the stored baseURI |
setBaseURI(...) | Allows the owner to update metadata base URI; emits ERC-4906 update signal |
freezeMetadata() | Permanently disables URI updates and emits a MetadataFrozen event |
safeMint(...) | Mints a single token to the specified address |
batchMint(...) | Mints multiple tokens to a single address and returns all token IDs |
tokenURI(...) | Resolves the final token URI using base URI or stored value |
supportsInterface(...) | Advertises interface support for ERC-721, metadata extension, and ERC-4906 |
scripts/deploy.js
:
A deployment script is a programmatic way to deploy your smart contracts to a blockchain using Hardhat. Instead of manually interacting with the network through a UI or console, deployment scripts allow you to:
.env.local
file in the frontend directory:
frontend
npm run build
.next
frontend/src/app/page.tsx
file.