Skip to content

🎨 Complete NFT Marketplace - Full Stack Web3 dApp A decentralized NFT marketplace built with modern architecture, featuring React frontend, Go backend, and Solidity smart contracts. Includes wallet integration, real blockchain transactions, and comprehensive documentation. πŸ› οΈ Tech: React β€’ Go β€’ Solidity β€’ Wagmi β€’ RainbowKit β€’ Hardhat

Notifications You must be signed in to change notification settings

abrahao-dev/nft-marketplace

Repository files navigation

🎨 NFT Marketplace Full Stack - Complete Guide

A complete decentralized NFT marketplace built with modern architecture, Web3 integration, and software engineering best practices. The application allows users to connect their wallets, view NFTs from a collection, and perform secure buy and sell operations on the Ethereum testnet.

🎯 Project Objectives

Demonstrate in practice the construction of a complete decentralized application (dApp) with:

  • Web3 Development and blockchain integration
  • Wallet Integration (WalletConnect, Wagmi, RainbowKit)
  • RESTful APIs with Go for high performance
  • Tokenization and transfer of digital assets (NFTs)
  • Modular and scalable architecture

πŸš€ Implemented Features

βœ… Core Features

  • πŸ”— Connect wallet via Metamask or WalletConnect
  • πŸ“‹ List NFTs available in the marketplace
  • πŸ” Display details and metadata of each NFT
  • πŸ’° Buy NFTs with blockchain transactions
  • πŸ“ List NFTs for sale (listing via contract)
  • πŸ“Š Simplified transaction history
  • πŸ—„οΈ Go API to serve NFT metadata (ERC721 standard)

πŸš€ Future Features

  • 🎯 NFT Staking
  • 🎨 Dynamic minting via frontend
  • 🌐 IPFS integration for images
  • ⭐ Reputation system for sellers
  • πŸ“ˆ Analytics dashboard on-chain

πŸ—οΈ System Architecture

Frontend (React + Wagmi) <--> Backend (Go REST API) <--> Blockchain (Ethereum testnet)

πŸ”„ Data Flow

  1. Frontend: React with RainbowKit, Wagmi and Viem for wallet connection, listing and NFT purchases
  2. Backend: Go with Fiber serving RESTful endpoints for NFT metadata and transaction recording
  3. Smart Contract: Solidity (ERC721) for NFT issuance, listing and sale, compiled and deployed via Hardhat
  4. Blockchain: Goerli or Sepolia Testnet, accessed via Alchemy or Infura RPC
  5. Storage: JSONs served via local API (can be extended to IPFS)

πŸ“¦ Technology Stack

Layer Stack / Tools Version
Frontend React, Vite, Wagmi, RainbowKit, Tailwind CSS React 18+
Backend Go, Fiber, REST API Go 1.20+
Smart Contracts Solidity, Hardhat, OpenZeppelin Solidity ^0.8.0
Blockchain Ethereum (Goerli / Sepolia) -
Infrastructure Railway / Render (API), Vercel (Web) -
Wallet Support Metamask, WalletConnect -

πŸ“ Project Structure

nft-marketplace/
β”œβ”€β”€ backend/                 # Go API
β”‚   β”œβ”€β”€ main.go             # Application entry point
β”‚   β”œβ”€β”€ routes/             # Route definitions
β”‚   β”‚   β”œβ”€β”€ nft.go         # NFT routes
β”‚   β”‚   └── transaction.go # Transaction routes
β”‚   β”œβ”€β”€ handlers/           # Business logic
β”‚   β”‚   └── nft_handler.go
β”‚   β”œβ”€β”€ models/             # Data models
β”‚   β”‚   β”œβ”€β”€ nft.go
β”‚   β”‚   └── transaction.go
β”‚   β”œβ”€β”€ middleware/         # Middlewares (CORS, etc.)
β”‚   β”œβ”€β”€ config/             # Configurations
β”‚   β”œβ”€β”€ go.mod              # Go dependencies
β”‚   β”œβ”€β”€ Dockerfile          # Containerization
β”‚   └── railway.json        # Railway deployment
β”œβ”€β”€ frontend/               # React App
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/     # React components
β”‚   β”‚   β”‚   β”œβ”€β”€ Header.tsx
β”‚   β”‚   β”‚   └── NFTCard.tsx
β”‚   β”‚   β”œβ”€β”€ pages/          # Application pages
β”‚   β”‚   β”‚   β”œβ”€β”€ Home.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Marketplace.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ NFTDetail.tsx
β”‚   β”‚   β”‚   └── MyNFTs.tsx
β”‚   β”‚   β”œβ”€β”€ hooks/          # Custom hooks
β”‚   β”‚   β”œβ”€β”€ utils/          # Utilities
β”‚   β”‚   β”œβ”€β”€ App.tsx         # Main component
β”‚   β”‚   └── main.tsx        # Entry point
β”‚   β”œβ”€β”€ package.json        # Node.js dependencies
β”‚   β”œβ”€β”€ vite.config.ts      # Vite configuration
β”‚   β”œβ”€β”€ tailwind.config.js  # Tailwind configuration
β”‚   └── tsconfig.json       # TypeScript configuration
β”œβ”€β”€ contracts/              # Smart Contracts
β”‚   β”œβ”€β”€ NFTToken.sol        # ERC721 contract
β”‚   β”œβ”€β”€ NFTMarketplace.sol  # Main contract
β”‚   β”œβ”€β”€ hardhat.config.js   # Hardhat configuration
β”‚   β”œβ”€β”€ scripts/            # Deployment scripts
β”‚   β”‚   └── deploy.js
β”‚   β”œβ”€β”€ test/               # Contract tests
β”‚   └── package.json        # Hardhat dependencies
β”œβ”€β”€ docs/                   # Documentation
β”‚   β”œβ”€β”€ API.md             # API documentation
β”‚   └── DEPLOYMENT.md      # Deployment guide
β”œβ”€β”€ docker-compose.yml      # Container orchestration
β”œβ”€β”€ Makefile               # Automation commands
β”œβ”€β”€ setup.sh               # Setup script
└── README.md              # This file

πŸ› οΈ Prerequisites

πŸ“‹ System Requirements

  • Node.js 18+ and Yarn/NPM installed
  • Go 1.20+ with modules enabled
  • Git for version control
  • Metamask with testnet (Goerli/Sepolia) configured

πŸ”‘ Required Accounts

  • Alchemy or Infura (RPC endpoint)
  • Vercel (frontend deployment)
  • Railway or Render (backend deployment)
  • GitHub (repository and CI/CD)

πŸ’° Test Resources

  • Testnet faucet (free ETH for testing)
  • Hardhat for contract deployment
  • Etherscan for contract verification

πŸš€ Quick Setup

1. Clone and Initial Setup

git clone <repository-url>
cd nft-marketplace

# Automatic setup (Linux/Mac)
./setup.sh

# Or manual setup
make setup

2. Configure Environment Variables

Backend (.env)

cd backend
cp env.example .env
PORT=8080
ENVIRONMENT=development
CORS_ORIGIN=http://localhost:3000

Frontend (.env)

cd frontend
cp env.example .env
VITE_API_URL=http://localhost:8080
VITE_CONTRACT_ADDRESS=your_deployed_contract_address
VITE_CHAIN_ID=11155111  # Sepolia

Smart Contracts (.env)

cd contracts
cp env.example .env
PRIVATE_KEY=your_private_key
ALCHEMY_API_KEY=your_alchemy_key
ETHERSCAN_API_KEY=your_etherscan_key

3. Deploy Smart Contracts

cd contracts
npm install
npx hardhat compile
npx hardhat run scripts/deploy.js --network sepolia

4. Start Backend

cd backend
go mod tidy
go run main.go

5. Start Frontend

cd frontend
npm install
npm run dev

🌐 Access URLs


πŸ“š API Endpoints

NFTs

  • GET /api/v1/nfts - List all NFTs
  • GET /api/v1/nfts/:id - Get specific NFT
  • GET /api/v1/nfts/:id/metadata - Get ERC721 metadata
  • POST /api/v1/nfts - Create new NFT
  • PUT /api/v1/nfts/:id - Update NFT
  • DELETE /api/v1/nfts/:id - Delete NFT

Marketplace

  • GET /api/v1/nfts/marketplace/listings - Listed NFTs
  • POST /api/v1/nfts/:id/list - List NFT
  • POST /api/v1/nfts/:id/buy - Buy NFT
  • DELETE /api/v1/nfts/:id/cancel-listing - Cancel listing

Transactions

  • GET /api/v1/transactions - List transactions
  • GET /api/v1/transactions/:id - Get specific transaction
  • GET /api/v1/transactions/user/:address - User transactions
  • GET /api/v1/transactions/nft/:tokenId - NFT transactions

πŸ”§ Useful Commands

Development

# Start all services
make dev

# Frontend only
make frontend

# Backend only
make backend

# Tests
make test

# Build
make build

Deployment

# Deploy smart contracts
make deploy-contracts

# Deploy backend
make deploy-backend

# Deploy frontend
make deploy-frontend

πŸ” Security

Smart Contracts

  • Reentrancy protection in contracts
  • Input validation and security checks
  • Pausability for emergencies
  • Ownership controls for administrative functions

Backend

  • Input sanitization in all APIs
  • Rate limiting to prevent spam
  • CORS properly configured
  • Wallet validation before sensitive operations

Frontend

  • Connected wallet validation before interactions
  • Error boundaries for error handling
  • Loading states for better UX
  • HTTPS required in production

πŸ§ͺ Testing

Smart Contracts

cd contracts
npx hardhat test
npx hardhat coverage

Backend

cd backend
go test ./...
go test -v -cover ./...

Frontend

cd frontend
npm test
npm run test:coverage

πŸš€ Deployment

Frontend (Vercel)

cd frontend
npm run build
# Deploy to Vercel via GitHub integration

Backend (Railway/Render)

cd backend
# Configure environment variables
# Deploy via Railway or Render dashboard

Smart Contracts

cd contracts
npx hardhat run scripts/deploy.js --network mainnet
npx hardhat verify --network mainnet CONTRACT_ADDRESS

πŸ† Technical Differentiators

Strengths

  • Modular project with clear separation between layers
  • Go backend code ideal for high performance
  • Ethereum standards usage (ERC721) and compatible metadata
  • Real integration with testnet via popular wallets
  • Extensible architecture for production

Performance

  • Redis cache for NFT metadata
  • Lazy loading of images in frontend
  • Query optimization in backend
  • CDN for static assets

🀝 Contributing

  1. Fork the project
  2. Create a branch for your feature (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Code Standards

  • Go: Use gofmt and golint
  • React: Use ESLint and Prettier
  • Solidity: Use Solhint
  • Commits: Use conventional commits

πŸ“„ License

This project is under the MIT license. See the LICENSE file for more details.


πŸ†˜ Support

If you encounter any problems or have questions:

  1. Check the documentation in docs/
  2. Open an issue on GitHub
  3. Consult the guide QUICK-START.md
  4. Use the Makefile for common commands

πŸ™ Acknowledgments


πŸ“ˆ Roadmap

Phase 1 - MVP βœ…

  • Basic smart contracts
  • Simple Go API
  • Basic React frontend
  • Web3 integration

Phase 2 - Improvements 🚧

  • Royalty system
  • IPFS integration
  • Analytics dashboard
  • E2E tests

Phase 3 - Scalability 🎯

  • Layer 2 support
  • Multi-chain
  • Mobile app
  • DAO governance

🎯 Ready to start? Follow the setup instructions above and start exploring the world of NFTs! For specific implementation questions, consult the development guide.

About

🎨 Complete NFT Marketplace - Full Stack Web3 dApp A decentralized NFT marketplace built with modern architecture, featuring React frontend, Go backend, and Solidity smart contracts. Includes wallet integration, real blockchain transactions, and comprehensive documentation. πŸ› οΈ Tech: React β€’ Go β€’ Solidity β€’ Wagmi β€’ RainbowKit β€’ Hardhat

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published