Note: The live demo runs against a local Hardhat node. NFT minting requires the local node running with contracts deployed. The collection gallery and minting interface are fully explorable without a wallet.
A decentralized application (DApp) for minting and managing NFT collections π
Dapp Punks is an ERC721 NFT collection that allows users to:
- Connect their MetaMask wallet
- Mint unique NFT tokens with IPFS metadata storage
- View their complete NFT collection
- Interact with smart contracts through a user-friendly React interface
- Smart Wallet Integration: Automatic MetaMask connection with account change detection
- Real-time NFT Display: View all owned NFTs with automatic updates when minting or switching accounts
- Comprehensive Testing: Full test suite covering all smart contract functionality
- IPFS Integration: Decentralized metadata and image storage
- Error Handling: User-friendly error messages and transaction feedback
- Smart Contracts: Solidity, Hardhat
- Frontend: React, Bootstrap, Ethers.js
- Blockchain: Ethereum (Local Hardhat Network)
- Storage: IPFS for metadata and images
- Testing: Hardhat Test Framework with Chai
- Development: Node.js, npm
Before you begin, ensure you have the following installed:
- Node.js (v14.0.0 or higher)
- npm (v6.0.0 or higher)
- MetaMask browser extension
- Git for version control
git clone <repository-url>
cd nft_dappu-punksnpm installThe project is configured to work with Hardhat's local blockchain network. No additional environment variables are required for local development.
Open a terminal and start the Hardhat local blockchain:
npx hardhat nodeThis will:
- Start a local Ethereum network on
http://localhost:8545 - Create 20 test accounts with 10,000 ETH each
- Display account addresses and private keys for testing
Keep this terminal running throughout development.
In a new terminal, deploy the NFT contract:
npx hardhat run scripts/deploy.js --network localhostThis will:
- Compile the smart contract
- Deploy to the local network
- Display the contract address
- Set up initial contract parameters (cost, supply, metadata URI)
-
Add Local Network to MetaMask:
- Network Name:
Hardhat Local - RPC URL:
http://localhost:8545 - Chain ID:
31337 - Currency Symbol:
ETH
- Network Name:
-
Import Test Account:
- Copy a private key from the Hardhat node output
- Import it into MetaMask for testing
In a new terminal, start the React development server:
npm run startThe application will open at http://localhost:3000
Run the comprehensive test suite to ensure all functionality works correctly:
# Run all tests
npx hardhat test
# Run tests with gas reporting
GAS_REPORT=true npx hardhat test
# Run specific test file
npx hardhat test test/NFT.jsThe test suite covers:
- Contract deployment and initialization
- NFT minting functionality (success and failure cases)
- Ownership and balance tracking
- Withdrawal functionality
- Error handling and edge cases
- Click "Connect Wallet" in the navigation bar
- Approve the MetaMask connection request
- Your wallet address will appear-truncated and display "connected"
- Ensure you have sufficient ETH for minting
- Click the "Mint NFT" button
- Confirm the transaction in MetaMask
- Wait for transaction confirmation
- Your owned NFTs will automatically appear after minting
- Switch MetaMask accounts to see different collections
- Yout personal NFT display updates automatically when a new NFT is minted
- The app automatically detects when you switch MetaMask accounts
- Your NFT collection updates immediately
- No page refresh required
nft_dappu-punks/
βββ contracts/
β βββ NFT.sol # ERC721 NFT smart contract
βββ scripts/
β βββ deploy.js # Contract deployment script
βββ test/
β βββ NFT.js # Comprehensive test suite
βββ src/
β βββ components/
β β βββ App.js # Main application component
β β βββ Navigation.js # Wallet connection & navigation
β β βββ Mint.js # NFT minting functionality
β β βββ Data.js # Contract data display
β β βββ Loading.js # Loading state component
β βββ abis/ # Contract ABI files
β βββ config.json # Network configuration
β βββ index.css # Custom styling
βββ hardhat.config.js # Hardhat configuration
βββ package.json # Dependencies and scripts
βββ README.md # This file
-
MetaMask Connection Issues
- Ensure MetaMask is installed and unlocked
- Check that you're connected to the correct network (Hardhat Local)
- Try refreshing the page and reconnecting
-
Transaction Failures
- Ensure you have sufficient ETH for gas fees
- Check that the contract is deployed and accessible
- Verify you're on the correct network
-
NFT Images Not Loading
- Check your internet connection
- Verify IPFS gateway is accessible
- Images may take time to load from IPFS
-
Test Failures
- Ensure no other Hardhat node is running
- Clean compile:
npx hardhat clean && npx hardhat compile - Check Node.js version compatibility
If you encounter issues:
- Check the browser console for error messages
- Review the terminal output for deployment errors
- Ensure all prerequisites are installed correctly
- Verify network configuration in MetaMask
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Hardhat for the development environment
- OpenZeppelin for secure smart contract libraries
- React for the frontend framework
- Bootstrap for UI components
- Ethers.js for blockchain interaction
- IPFS for decentralized storage
For questions or support, please open an issue in the 'nft_dappu-punks' repository
