A decentralized ticketing platform built on blockchain technology that allows users to mint, purchase, transfer, and verify event tickets as NFTs (Non-Fungible Tokens). This project combines Web3 technology with a modern full-stack application to prevent ticket fraud and enable secure peer-to-peer ticket transfers.
- π Blockchain-Based Tickets: Each ticket is a unique ERC-721 NFT on the blockchain
- π¦ MetaMask Integration: Connect your crypto wallet to interact with the platform
- ποΈ Event Management: Browse and purchase tickets for various events
- π± QR Code Verification: Generate and verify tickets using QR codes
- πΈ Secure Transfers: Transfer tickets directly between wallets
- π Ticket Validation: Verify ticket authenticity on the blockchain
- π Transaction History: Track all ticket purchases and transfers
- π¨ Modern UI: Built with React, TypeScript, and Tailwind CSS
The project consists of three main components:
- Modern React application with TypeScript
- MetaMask wallet integration
- Responsive UI with Tailwind CSS
- React Router for navigation
- QR code generation and scanning
- RESTful API for event and transaction management
- MongoDB database for storing event details
- Integration with blockchain for ticket verification
- CORS-enabled API endpoints
- ERC-721 NFT standard implementation
- Custom ticket minting and management logic
- Event-based ticket tracking
- OpenZeppelin contracts for security
- React 18 - UI library
- TypeScript - Type-safe JavaScript
- Vite - Build tool and dev server
- Ethers.js - Ethereum library for Web3 interaction
- Tailwind CSS - Utility-first CSS framework
- React Router - Client-side routing
- Lucide React - Icon library
- QRCode.js - QR code generation
- Node.js - JavaScript runtime
- Express - Web framework
- MongoDB - NoSQL database
- Mongoose - MongoDB ODM
- Ethers.js - Blockchain interaction
- CORS - Cross-origin resource sharing
- dotenv - Environment variable management
- Solidity ^0.8.20 - Smart contract language
- Hardhat - Ethereum development environment
- OpenZeppelin - Secure smart contract library
- ERC-721 - NFT token standard
Before running this project, make sure you have:
- Node.js (v16 or higher)
- npm or yarn
- MongoDB (local or cloud instance)
- MetaMask browser extension
- Git
git clone https://github.com/Jiyasingh06/Digital_Payment_Project.git
cd Digital_Payment_Project-mainnpm installcd backend
npm install
cd ..cd smart-contract
npm install
cd ..Create a .env file in the root directory:
# MongoDB Configuration
MONGODB_URI=mongodb://localhost:27017/ticketnft
# Backend Port
PORT=5000
# Blockchain Configuration
RPC_URL=http://127.0.0.1:8545
PRIVATE_KEY=your_private_key_here
# Contract Address (will be set after deployment)
CONTRACT_ADDRESS=your_deployed_contract_addressMake sure MongoDB is running on your system:
# For local MongoDB
mongodOr use a cloud MongoDB service like MongoDB Atlas.
cd smart-contract
npm run nodecd smart-contract
npm run deploy:localCopy the deployed contract address and update it in:
.envfilesrc/web3/deployment.json
cd backend
node seedDatabase.jscd backend
npm start
# or for development with auto-reload
npm run devnpm run devThe application will be available at:
- Frontend: http://localhost:5173
- Backend API: http://localhost:5000
- Blockchain: http://localhost:8545
Digital_Payment_Project-main/
βββ src/ # Frontend source code
β βββ components/ # React components
β β βββ Header.tsx
β β βββ MetaMaskPrompt.tsx
β βββ context/ # React context providers
β β βββ WalletContext.tsx
β βββ pages/ # Page components
β β βββ EventsPage.tsx
β β βββ MyTicketsPage.tsx
β β βββ TransferPage.tsx
β β βββ VerifyPage.tsx
β βββ utils/ # Utility functions
β β βββ api.js
β β βββ qrcode.js
β βββ web3/ # Web3 integration
β β βββ connectWallet.js
β β βββ contract.js
β β βββ contractABI.json
β β βββ deployment.json
β βββ App.tsx # Main app component
β βββ main.tsx # Entry point
β
βββ backend/ # Backend API
β βββ models/ # MongoDB models
β β βββ Event.js
β β βββ Transaction.js
β βββ routes/ # API routes
β β βββ eventRoutes.js
β β βββ transactionRoutes.js
β βββ server.js # Express server
β βββ seedDatabase.js # Database seeding
β βββ package.json
β
βββ smart-contract/ # Smart contracts
β βββ contracts/ # Solidity contracts
β β βββ TicketNFT.sol
β βββ deploy.js # Deployment script
β βββ hardhat.config.js # Hardhat configuration
β βββ mint-bulk.js # Bulk minting script
β βββ mint-test-tickets.js # Test ticket minting
β βββ package.json
β
βββ index.html # HTML template
βββ vite.config.ts # Vite configuration
βββ tailwind.config.js # Tailwind CSS config
βββ tsconfig.json # TypeScript config
βββ package.json # Root package.json
- Connect Wallet: Click "Connect MetaMask" to link your wallet
- Browse Events: View available events on the Events page
- Purchase Tickets: Buy tickets using your connected wallet
- View Tickets: Check your tickets in "My Tickets" section
- Transfer Tickets: Transfer tickets to another wallet address
- Verify Tickets: Use QR codes for ticket verification at events
- Mint Tickets: Use the smart contract to create tickets for events
- Verify at Entry: Scan QR codes to validate tickets
- Track Sales: Monitor ticket sales through the blockchain
GET /api/events- Get all eventsGET /api/events/:id- Get event by IDPOST /api/events- Create new eventPUT /api/events/:id- Update eventDELETE /api/events/:id- Delete event
GET /api/transactions- Get all transactionsGET /api/transactions/:walletAddress- Get transactions by walletPOST /api/transactions- Create new transaction
cd smart-contract
npm test# Test blockchain verification
node test-blockchain-verify.js
# Check ticket status
node check-tickets.js
# Test live state
node test-live-state.jsmintTicket()- Mint a new ticket NFTtransferTicket()- Transfer ticket to another addressgetTicketDetails()- Get ticket informationinvalidateTicket()- Mark ticket as usedisTicketValid()- Check if ticket is validgetEventTickets()- Get all tickets for an event
- Blockchain Immutability: Ticket data stored on blockchain
- Ownership Verification: Each ticket has a verified owner
- Transfer Protection: Only owner can transfer tickets
- Double-spending Prevention: Tickets can only be used once
- Smart Contract Security: Built with OpenZeppelin standards
- Get test MATIC from Mumbai Faucet
- Update
hardhat.config.jswith your credentials - Deploy contract:
npm run deploy:mumbainpm run buildDeploy the dist folder to:
- Vercel
- Netlify
- GitHub Pages
- Any static hosting service
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Jiya Singh - @Jiyasingh06
- OpenZeppelin for secure smart contract templates
- Hardhat for Ethereum development environment
- React and Vite for modern frontend tooling
- Tailwind CSS for styling
For issues and questions:
- Open an issue on GitHub
- Check existing documentation
- Review the code examples
- Add support for multiple blockchain networks
- Implement ticket resale marketplace
- Add price limits and royalties
- Mobile app development
- Enhanced analytics dashboard
- Multi-language support
- Integration with event platforms
This is an educational project. Always conduct thorough security audits before deploying smart contracts to production or handling real financial transactions.
Built with β€οΈ using React, Solidity, and Web3 technologies