Skip to content

nexus-xyz/example-nft-minter

Repository files navigation

Nexus NFT Collection DApp

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:


Project Structure & Components

1. NFT Logic (Smart Contract)

  • 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.

2. Frontend (Next.js App)

  • 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.

What is the ABI?

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.sol is generated by Hardhat and copied to frontend/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 (.sol files), you must:

  1. Recompile the contract with npx hardhat compile.
  2. Copy the updated ABI to the frontend with node copy-abi.js.
  3. (If you redeploy) Update the contract address in frontend/.env.local.

Features

  • 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.

Getting Started

1. Clone & Install Dependencies

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 directories

2. Environment Variables

Create 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

3. Compile & Deploy the Smart Contract

npx hardhat compile
node scripts/deploy.js
  • The deployment script will print the contract address. Copy this address for the frontend config.

4. Copy the ABI for Frontend Use

After deploying, run:

node copy-abi.js

This copies the contract ABI to frontend/abi/SimpleNFT.json for the frontend to use.


5. Configure the Frontend

In frontend/.env.local, set:

NEXT_PUBLIC_NFT_CONTRACT_ADDRESS=your_deployed_contract_address

6. Run the Frontend

cd frontend
pnpm install # or npm install
pnpm dev # or npm run dev

Open http://localhost:3000 to use the app.


Project Structure

  • contracts/ — Solidity smart contracts
  • scripts/ — Deployment scripts
  • frontend/ — Next.js frontend app
  • frontend/abi/ — Contract ABI for frontend

Useful Commands

  • Compile contracts: npx hardhat compile
  • Deploy contract: node scripts/deploy.js
  • Copy ABI: node copy-abi.js
  • Run frontend: cd frontend && pnpm dev

Requirements

  • Node.js 18+
  • pnpm or npm
  • Wallet with testnet funds for deployment

License

MIT