A full-stack Web3 ticketing platform where event tickets are minted as ERC-721 NFTs on Ethereum Sepolia testnet. Secure, transparent, and scalable β powered by smart contracts, a Node.js backend, and a React frontend with MetaMask integration.
- π« NFT Tickets β Each ticket is a unique ERC-721 token minted on-chain
- π³ MetaMask Integration β Connect wallet, buy tickets, and sign transactions
- π· QR Code Validation β Real camera scanning for entry gate validation
- π Owner Controls β Create events, deactivate sales, withdraw revenue
- π‘ Live Blockchain Sync β WebSocket listener keeps MongoDB in sync with on-chain events
- π REST API β Full backend API for events, tickets, and validation
- π¨ Sleek Dark UI β Space Grotesk font, gold accents, glassmorphism design
| Layer | Technology |
|---|---|
| Smart Contract | Solidity, ERC-721, OpenZeppelin |
| Development | Hardhat, Ethers.js v6 |
| Blockchain | Ethereum Sepolia Testnet |
| Backend | Node.js, Express.js, MongoDB, Mongoose |
| Blockchain Listener | Ethers.js WebSocket Provider |
| Frontend | React 18, React Router v6 |
| Wallet | Ethers.js v6, MetaMask |
| QR Codes | html5-qrcode, QR Server API |
| Styling | CSS-in-JS, Space Grotesk, Material Icons |
detickets/
β
βββ hardhat.config.js
βββ .env β Hardhat env vars
β
βββ contracts/
β βββ Deticket.sol β ERC-721 smart contract
β
βββ scripts/
β βββ deploy.js β Hardhat deployment script
β
βββ artifacts/ β Auto-generated by Hardhat compile
β
βββ backend/
β βββ index.js β Express server entry point
β βββ .env β Backend environment variables
β βββ abi/
β β βββ EventTicketPlatform.json β Contract ABI (copy from artifacts)
β βββ db/
β β βββ connect.js β MongoDB connection
β βββ models/
β β βββ Event.js
β β βββ Ticket.js
β βββ routes/
β β βββ events.js
β β βββ tickets.js
β β βββ validate.js
β βββ services/
β β βββ listener.js β Real-time blockchain event listener
β βββ scripts/
β βββ syncEvents.js β Manually sync missed events
β βββ syncTickets.js β Manually sync missed tickets
β
βββ frontend/
βββ package.json
βββ src/
βββ App.js
βββ index.js
βββ index.css
βββ abi/
β βββ EventTicketPlatform.json β Contract ABI (copy from artifacts)
βββ context/
β βββ WalletContext.js β Global MetaMask + contract state
βββ components/
β βββ Sidebar.js β Navigation sidebar
βββ pages/
βββ EventList.js β Homepage
βββ BuyTicket.js β Purchase + mint ticket
βββ MyTickets.js β View owned NFT tickets
βββ AdminPanel.js β Owner dashboard
βββ QRScanner.js β Camera QR entry validation
- Node.js v18+
- MongoDB running locally
- MetaMask browser extension
- Alchemy account (free tier works)
- Sepolia testnet ETH β sepoliafaucet.com
git clone https://github.com/yourusername/detickets.git
cd detickets# Root β Hardhat
npm install
# Backend
cd backend && npm install
# Frontend
cd ../frontend && npm installRoot .env
PRIVATE_KEY=your_deployer_wallet_private_key
RPC_URL=https://eth-sepolia.g.alchemy.com/v2/YOUR_ALCHEMY_KEY
API_KEY=your_etherscan_api_keybackend/.env
MONGO_URI=mongodb://localhost:27017/detickets
RPC_URL=https://eth-sepolia.g.alchemy.com/v2/YOUR_ALCHEMY_KEY
WS_RPC_URL=wss://eth-sepolia.g.alchemy.com/v2/YOUR_ALCHEMY_KEY
CONTRACT_ADDRESS=0xYOUR_DEPLOYED_CONTRACT_ADDRESS
OWNER_PRIVATE_KEY=your_deployer_wallet_private_key
PORT=3001npx hardhat compile
npx hardhat run scripts/deploy.js --network sepoliaCopy the printed contract address and update CONTRACT_ADDRESS in backend/.env and frontend/src/context/WalletContext.js.
# Windows
cp artifacts\contracts\Deticket.sol\EventTicketPlatform.json backend\abi\EventTicketPlatform.json
cp artifacts\contracts\Deticket.sol\EventTicketPlatform.json frontend\src\abi\EventTicketPlatform.jsoncd backend
npm run dev
# β
MongoDB connected
# π Blockchain listener started
# π Server running on http://localhost:3001cd frontend
npm start
# Opens at http://localhost:3000| Method | Endpoint | Description |
|---|---|---|
| GET | /api/events |
Get all events |
| GET | /api/events/active |
Get active events only |
| GET | /api/events/:eventId |
Get single event with tickets |
| GET | /api/tickets/:tokenId |
Get single ticket |
| GET | /api/tickets/owner/:address |
Get tickets by wallet address |
| GET | /api/validate/:tokenId |
Check ticket validity status |
| POST | /api/validate |
Validate ticket + mark used on-chain |
| Page | URL | Access | Description |
|---|---|---|---|
| Events | / |
Everyone | Browse all upcoming events |
| Buy Ticket | /events/:id |
MetaMask required | Mint an NFT ticket |
| My Tickets | /my-tickets |
Connected wallet | View tickets + QR codes |
| Admin Panel | /admin |
Owner wallet only | Create events, withdraw revenue |
| QR Scanner | /scanner |
Owner wallet only | Validate tickets at entry gate |
Owner creates event β Admin Panel
β
Event saved on-chain + synced to MongoDB via listener
β
User connects MetaMask β buys ticket β pays ETH
β
ERC-721 NFT minted to user's wallet on Sepolia
β
Listener saves ticket to MongoDB automatically
β
User opens My Tickets β reveals QR code image
β
Owner opens QR Scanner β scans QR with camera
β
Ticket validated on-chain β permanently marked as used
β
Owner withdraws accumulated ETH from Admin Panel
Deployed on Sepolia: 0x69a25A22F86b375ae79D756B37b721EfEf4FC574
| Function | Description | Access |
|---|---|---|
createEvent(name, date, venue, price, supply, maxResalePct) |
Create a new ticketed event | Owner only |
mintTicket(eventId, seat, metadataURI, buyer) |
Mint an NFT ticket | Public (payable) |
deactivateEvent(eventId) |
Stop ticket sales | Owner only |
markTicketAsUsed(tokenId, qrHash) |
Validate and consume a ticket | Owner only |
withdrawRevenue() |
Withdraw accumulated platform fees | Owner only |
getEventDetails(eventId) |
Read event info | Public |
Run these if the listener missed events while the backend was offline:
cd backend
node scripts/syncEvents.js # sync all on-chain events to MongoDB
node scripts/syncTickets.js # sync all on-chain tickets to MongoDB1. Open MetaMask β click network dropdown
2. Add Network β search "Sepolia Testnet" β Add
3. Get free test ETH from https://sepoliafaucet.com
4. Connect wallet on the DeTickets site
- Fork the repository
- Create a feature branch
git checkout -b feature/my-feature - Commit your changes
git commit -m "Add my feature" - Push to the branch
git push origin feature/my-feature - Open a Pull Request
This project is licensed under the MIT License. See LICENSE for details.
- OpenZeppelin β ERC-721 contract standards
- Hardhat β Ethereum development environment
- Alchemy β Blockchain node provider
- Ethers.js β Ethereum JavaScript library
- Google Stitch β UI design
Built with β€οΈ on Ethereum