A comprehensive blockchain-based ticketing platform that transforms event tickets into verifiable NFTs on the Polygon network. This system provides secure, transparent, and decentralized ticket management with built-in resale marketplace, royalty collection, and access control features.
- Overview
- Architecture
- Technology Stack
- Project Structure
- Getting Started
- Configuration
- Deployment
- Development
The Decentralized Ticketing System is a full-stack Web3 application that enables event organizers to create, manage, and sell tickets as non-fungible tokens (NFTs) on the blockchain. Each ticket is a unique ERC-721 token with metadata stored on IPFS, ensuring immutability and verifiability.
- NFT-Based Tickets: Each ticket is a unique ERC-721 token with on-chain ownership
- Voucher System: Secure EIP-712 signed vouchers for ticket redemption
- Resale Marketplace: Built-in secondary market with automatic royalty collection
- Access Control: Role-based permissions for organizers, gatekeepers, and marketplaces
- IPFS Integration: Decentralized metadata storage via Pinata
- The Graph Integration: Indexed blockchain data for efficient querying
- Refund System: Automated refund processing before event dates
- Check-In System: Gatekeeper role for marking tickets as used
The system consists of four main components:
- Blockchain Layer: Smart contracts deployed on Polygon Amoy testnet
- Backend API: Express.js server handling ticket creation, voucher generation, and IPFS operations
- Frontend Application: React-based web interface for users and organizers
- Subgraph: The Graph protocol subgraph for indexing and querying blockchain events
- Organizer creates event and tickets through the backend API
- Ticket metadata is uploaded to IPFS via Pinata
- Backend generates EIP-712 signed vouchers for each ticket
- Users redeem vouchers on-chain, minting NFT tickets
- Subgraph indexes all blockchain events for efficient querying
- Frontend displays tickets and enables marketplace interactions
- Solidity: ^0.8.20
- OpenZeppelin Contracts: Security-audited contract libraries
- Network: Polygon Amoy Testnet (Chain ID: 80002)
- Node.js: Runtime environment
- Pinata: IPFS pinning service
- Axios: HTTP client for API requests
- React: ^19.1.1 - UI library
- TypeScript: Type-safe JavaScript
- Ethers.js: ^6.15.0 - Blockchain interaction
- Web3Modal: Wallet connection management
- Tailwind CSS: Utility-first CSS framework
- Framer Motion: Animation library
- The Graph Protocol: Decentralized indexing protocol
- AssemblyScript: Subgraph handler language
- Graph CLI: Development and deployment tools
Decentralized-Event /
├── blockchain/ # Smart contracts
│ ├── contracts/ # Solidity sources
│ ├── migrations/ # Truffle migrations
│ ├── scripts/ # Admin & helper scripts
│ ├── test/ # Contract tests
│ ├── build/ # Compiled artifacts
│ └── truffle-config.js
│
├── backend/ # Express API + IPFS + voucher service
│ ├── api/ # Serverless entry (Vercel)
│ ├── services/ # Voucher, IPFS, caching logic
│ ├── scripts/ # Ticket creation utilities
│ ├── data/ # Local cache
│ ├── server.js # Dev server
│ └── package.json
│
├── frontend/ # React + Vite dApp
│ ├── src/
│ │ ├── components/ # Reusable UI
│ │ ├── pages/ # App screens
│ │ ├── context/ # Web3 + Wallet contexts
│ │ ├── hooks/ # Reusable hooks
│ │ ├── utils/ # ABI, IPFS, subgraph helpers
│ │ ├── App.tsx
│ │ └── main.tsx
│ ├── public/
│ ├── vite.config.ts
│ ├── tailwind.config.js
│ └── package.json
│
├── subgraph/ # The Graph subgraph
│ └── ticket-nft-subgraph/
│ ├── schema.graphql
│ ├── subgraph.yaml
│ ├── src/ # Mapping functions
│ └── abis/
│
└── README.md
- Node.js (v18 or higher)
- npm or yarn package manager
- MetaMask or compatible Web3 wallet
- Polygon Amoy testnet MATIC tokens (for gas fees)
- Pinata account (for IPFS storage)
- The Graph Studio account (for subgraph deployment)
- Clone the repository
git clone https://github.com/Priyank-Adhav/Decentralized-Event-Ticketing
cd Decentralized_ticketing_system-1- Install blockchain dependencies
cd blockchain
npm install- Install backend dependencies
cd ../backend
npm install- Install frontend dependencies
cd ../frontend
npm install- Install subgraph dependencies
cd ../subgraph/ticket-nft-subgraph npm install # or yarn install
Create a .env file in the blockchain/ directory:
PRIVATE_KEY=your_private_key_here AMOY_RPC_URL=https://rpc-amoy.polygon.technology/ SIGNER=0x... # Address that will sign vouchers EVENT_TIMESTAMP=1735689600 # Unix timestamp PAYEES=0x...,0x... # Comma-separated addresses SHARES=70,30 # Comma-separated share percentages
Create a .env file in the backend/ directory:
PORT=3001 CONTRACT_ADDRESS=0x... # Deployed TicketNFT contract address CHAIN_ID=80002 AMOY_RPC_URL=https://rpc-amoy.polygon.technology/ PRIVATE_KEY=your_private_key_here # For voucher signing # MongoDB Configuration (MongoDB Atlas) MONGO_URI=mongodb+srv://username:[email protected]/ticketing?retryWrites=true&w=majority # IPFS Configuration (Pinata) PINATA_JWT=your_pinata_jwt_token # OR use API key/secret: PINATA_API_KEY=your_api_key PINATA_SECRET_KEY=your_secret_key PINATA_GATEWAY_URL=https://gateway.pinata.cloud/ipfs FRONTEND_URL=http://localhost:5173
Create a .env file in the frontend/ directory:
VITE_BACKEND_URL=http://localhost:3001 VITE_CONTRACT_ADDRESS=0x... # Deployed TicketNFT contract address VITE_CHAIN_ID=80002 VITE_RPC_URL=https://rpc-amoy.polygon.technology/ VITE_WALLET_CONNECT_PROJECT_ID=your_walletconnect_project_id
Update subgraph/ticket-nft-subgraph/subgraph.yaml with your contract address and start block:
source: address: "0xYourContractAddress" startBlock: 27855492
cd blockchain # Compile contracts npm run compile # Deploy to Polygon Amoy npm run migrate:amoy
Save the deployed contract address for use in other components.
Update the backend .env with the deployed contract address and ensure the PRIVATE_KEY matches the signer address configured in the contract.
cd subgraph/ticket-nft-subgraph # Generate code npm run codegen # Build subgraph npm run build # Deploy to The Graph Studio npm run deploy
cd backend
npm startcd frontend # Development server npm run dev
