This project is a full-stack decentralized application (dApp) for minting and viewing NFTs on the Nexus blockchain testnet. It consists of two main parts:
- Location:
contracts/,scripts/,hardhat.config.ts - Description:
- The core NFT logic is implemented in the Solidity smart contract
SimpleNFT.sol. - This contract is an ERC-721 NFT with owner enumeration and metadata management.
- Deployment and management scripts are provided using Hardhat.
- The contract is responsible for minting, tracking ownership, and managing NFT metadata.
- The core NFT logic is implemented in the Solidity smart contract
- Location:
frontend/ - Description:
- The frontend is a React app built with Next.js.
- It allows users to mint NFTs and view NFTs owned by any address.
- Uses ethers.js to interact with the deployed smart contract on the blockchain.
- Requires the contract's ABI and address to communicate with the NFT logic.
ABI stands for Application Binary Interface. It is a JSON file generated when you compile your smart contract. The ABI defines how the frontend (or any client) can interact with the contract: what functions are available, what parameters they take, and what data they return.
- In this project, the ABI for
SimpleNFT.solis generated by Hardhat and copied tofrontend/abi/SimpleNFT.json. - The frontend imports this ABI to know how to call contract functions (like minting or querying NFTs).
- Keeping the ABI in sync with the deployed contract is essential for the frontend to work correctly.
Important: Whenever you make edits to the Solidity contract (
.solfiles), you must:
- Recompile the contract with
npx hardhat compile.- Copy the updated ABI to the frontend with
node copy-abi.js.- (If you redeploy) Update the contract address in
frontend/.env.local.
- Mint NFTs: Anyone can mint an NFT to their own or another address.
- View NFTs: Enter any wallet address to see all NFTs owned by that address.
- No images/metadata: This demo does not serve images or metadata for NFTs.
git clone https://github.com/nexus-xyz/example-nft-minter
pnpm install # or npm install, make sure you install in root as well as frontend directoriesCreate a .env file in the root with:
PRIVATE_KEY=your_private_key_for_deployment
NEXT_PUBLIC_URL=http://localhost:3000 # or your deployed frontend URL
In frontend/, create a .env.local file:
NEXT_PUBLIC_NFT_CONTRACT_ADDRESS=your_deployed_contract_address
npx hardhat compile
node scripts/deploy.js- The deployment script will print the contract address. Copy this address for the frontend config.
After deploying, run:
node copy-abi.jsThis copies the contract ABI to frontend/abi/SimpleNFT.json for the frontend to use.
In frontend/.env.local, set:
NEXT_PUBLIC_NFT_CONTRACT_ADDRESS=your_deployed_contract_address
cd frontend
pnpm install # or npm install
pnpm dev # or npm run devOpen http://localhost:3000 to use the app.
contracts/— Solidity smart contractsscripts/— Deployment scriptsfrontend/— Next.js frontend appfrontend/abi/— Contract ABI for frontend
- Compile contracts:
npx hardhat compile - Deploy contract:
node scripts/deploy.js - Copy ABI:
node copy-abi.js - Run frontend:
cd frontend && pnpm dev
- Node.js 18+
- pnpm or npm
- Wallet with testnet funds for deployment
MIT