Secure, Transparent, and Fair Ticketing on the Blockchain.
TicketChain is a blockchain-based event ticketing system that mints tickets as NFTs, ensuring authenticity, preventing fraud, and enabling a fair secondary marketplace with price controls and royalties for organizers.
- Features
- Tech Stack
- Setup and Installation
- Usage
- NFT Smart Contract Implementation
- Smart Contract Details
- Challenges Faced
- NFT-Based Tickets: Each ticket is minted as a unique NFT, ensuring authenticity and preventing fraud.
- Fair Resale Market: Enforced price controls and automatic royalty distribution to organizers.
- Transparent Transactions: All ticket transactions are recorded on the blockchain for full transparency.
- User-Friendly Interface: Easy-to-use platform for both crypto-savvy and non-crypto users.
- Secure Ownership: Verifiable ticket ownership using blockchain technology.
- Blockchain: Aptos (Move language for smart contracts).
- Frontend: React.js with TypeScript.
- Backend: Node.js (optional for off-chain data).
- SDK: Aptos TypeScript SDK for blockchain interactions.
- Database: MongoDB (for off-chain data storage).
- React.js, Node.js and npm installed.
- Aptos CLI installed.
- Petra Wallet.
- Clone the Repository:
git clone https://github.com/niweshsah/krackhack_assembly.git cd krackhack_assembly/ - Install Dependencies
cd frontend/ npm install cd .. cd backend/ npm install cd ..
- Set Up Aptos CLI:
-
Install the Aptos CLI:
curl -fsSL https://aptos.dev/scripts/install_cli.py | python3 -
Configure the Aptos CLI for the testnet:
aptos init --network testnet
-
Run the Frontend:
cd frontend/ npm run dev cd .. cd backend/ node server.js
-
Access the Application:
Open http://localhost:3000 or other in your browser.
The NFT smart contract is implemented in TypeScript using the Aptos SDK. The main contract logic is located in nft_code/src/main_nft.ts, which handles NFT creation and interactions.
To execute the contract, follow these steps:
- Navigate to the nft_code directory:
cd nft_code - Compile the TypeScript code:
npx tsc
- Run the generated JavaScript file:
node dist/main_nft.js
- Sample Execution Output
friday_code@JARVIS:~/Music/krackhack_assembly/nft_code$ npx tsc friday_code@JARVIS:~/Music/krackhack_assembly/nft_code$ node dist/main_nft.js 🎟 Starting NFT Ticketing System ================================ 1. Creating Accounts ------------------- [Aptos SDK] It is recommended that private keys are AIP-80 compliant (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md). You can fix the private key by formatting it with `PrivateKey.formatPrivateKey(privateKey: string, type: 'ed25519' | 'secp256k1'): string`. [Aptos SDK] It is recommended that private keys are AIP-80 compliant (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md). You can fix the private key by formatting it with `PrivateKey.formatPrivateKey(privateKey: string, type: 'ed25519' | 'secp256k1'): string`. Current Balances: Organizer Balance: 2.051887 APT User 1 Balance: 2.954989 APT 2. Creating Ticket Collection -------------------------- 🎨 Collection created successfully! 3.a Minting VIP Tickets ---------------- ✅ Starting to mint 2 VIP ticket NFTs... Minting ticket 1 of 2... Minting ticket 2 of 2... 🎟 All 2 Ticket NFTs minted successfully! 3.b Minting Normal Tickets ---------------- ✅ Starting to mint 2 NORMAL ticket NFTs... Minting ticket 1 of 2... Minting ticket 2 of 2... 🎟 All 2 Ticket NFTs minted successfully! 4. Initial Ticket Sales --------------------- 🛒 0xb5f96a6656d1b7353ea188666db490bdd9091ae7a987a75432e8c742c1995253 is buying a VIP ticket from 0x3e6d013285fe67aec5b7c757498378f31f1b188ff1796488baf0a1e88640edf0 for 0.1 APT sahu will give payment code 🎟 VIP ticket successfully transferred to 0xb5f96a6656d1b7353ea188666db490bdd9091ae7a987a75432e8c742c1995253 Balances after initial sales: Current Balances: Organizer Balance: 2.048351 APT User 1 Balance: 2.954989 APT Final Balances: Current Balances: Organizer Balance: 2.048351 APT User 1 Balance: 2.954989 APT
-
Mint Tickets:
-
Connect your wallet.
-
Fill in event details (name, date, seat number, price, royalty percentage).
-
Mint tickets as NFTs.
-
-
Track Sales and Royalties:
-
View all ticket sales and resales.
-
Receive automatic royalties on every resale.
-
-
Buy Tickets:
-
Browse available events.
-
Purchase tickets using your wallet.
-
-
Resell Tickets:
-
List your ticket on the secondary marketplace.
-
Set a price within the allowed range.
-
-
Transfer Tickets:
- Transfer tickets to another wallet securely.
-
Mint Ticket:
public fun mint_ticket(account: &signer, ticket_id: u64, event_name: String, event_date: String, seat_number: String, price: u64, royalty_percentage: u64): Ticket
-
Resell Ticket:
public fun resell_ticket(account: &signer, ticket: &mut Ticket, new_price: u64)
-
Royalty Distribution:
- Automatically calculates and distributes royalties to the organizer on every resale.
-
Smart Contract Complexity:
- Fixed royalty distribution logic in the resale function.
-
Frontend-Blockchain Integration:
- Learned and implemented Aptos TypeScript SDK for wallet integration.
-
Gas Fees and Scalability:
- Optimized smart contracts to reduce gas usage.
-
User Experience:
- Added tooltips and guides for non-crypto users.
<<<<<<< HEAD
aa2d933d742eafa8213ac1e0f41ffd1864346da2