Skip to content

A decentralized ticket sale platform built on Ethereum (Sepolia testnet) that enables secure ticket purchasing, swapping, and reselling with automated service fee handling. The platform features a beautiful Tihar Festival-themed UI with dark/light mode support.

Notifications You must be signed in to change notification settings

sajanpoudel/Tihar-Ticket-Sell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Tihar Festival Ticket Sale Platform - Festival of Joy

A decentralized ticket sale platform built on Ethereum (Sepolia testnet) that enables secure ticket purchasing, swapping, and reselling with automated service fee handling. The platform features a beautiful Tihar Festival-themed UI with dark/light mode support.

πŸ“ Project Structure

Tihar-Ticket-Sell/
β”œβ”€β”€ contracts/
β”‚   └── TicketSale.sol         # Smart contract
β”œβ”€β”€ pages/
β”‚   β”œβ”€β”€ _app.js               # Next.js app wrapper
β”‚   └── index.js              # Main UI page
β”œβ”€β”€ styles/
β”‚   β”œβ”€β”€ globals.css           # Global styles
β”‚   └── Home.module.css       # Component styles
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ compile.js            # Contract compilation
β”‚   └── deploy.js             # Contract deployment
β”œβ”€β”€ artifacts/                # Compiled contract files
β”œβ”€β”€ .env                      # Environment variables
β”œβ”€β”€ config.json              # Contract configuration
β”œβ”€β”€ hardhat.config.js        # Hardhat configuration
└── package.json             # Project dependencies

πŸ“± Application Preview

Wallet Connection & Dashboard

Connect wallet interface and main dashboard view

Ticket Management

Ticket management interface and swap functionality

Resale & Manager Controls

Ticket resale system and manager control panel

Theme Support

οΏ½οΏ½ Tech Stack

Blockchain

  • Solidity ^0.8.17 (Smart Contract)
  • Hardhat (Development Environment)
  • Ethers.js v5.7.2 (Blockchain Interaction)
  • Web3Modal (Wallet Connection)
  • Sepolia Testnet

Frontend

  • Next.js 15.0.2
  • React 18.3.1
  • CSS Modules
  • Web3.js

πŸ“‹ Prerequisites

  1. Node.js (v14 or higher)
  2. MetaMask wallet
  3. Sepolia testnet ETH
  4. Infura account

πŸ”§ Installation & Setup

  1. Clone the repository:
git clone <repository-url>
cd Tihar-Ticket-Sell
  1. Install dependencies:
npm install
  1. Environment Setup:

Create a .env file in the root directory:

INFURA_URL=https://sepolia.infura.io/v3/YOUR_INFURA_PROJECT_ID
PRIVATE_KEY=YOUR_WALLET_PRIVATE_KEY
MANAGER_ADDRESS=YOUR_MANAGER_WALLET_ADDRESS

Where to get these values:

  • INFURA_URL:

    1. Sign up at infura.io
    2. Create new project
    3. Select Sepolia network
    4. Copy the HTTPS endpoint
  • PRIVATE_KEY:

    1. Open MetaMask
    2. Click three dots β†’ Account Details
    3. Export Private Key
    4. Copy the key (never share this!)
  • MANAGER_ADDRESS:

    1. Your MetaMask wallet address
    2. This will be the contract manager
  1. Compile the contract:
npx hardhat clean
npx hardhat compile
  1. Deploy to Sepolia:
npx hardhat run scripts/deploy.js --network sepolia

Example output:

sajanpoudel@iPhone Ticket-Sale-Contract % npx hardhat run scripts/deploy.js --network sepolia
Deploying contracts with account: 0x60776F9B7B8F8060Bc24c1F29D46FC532a71b343
Deploying with options: {
  numTickets: 100,
  ticketPrice: '0.001',
  gasLimit: 8000000,
  gasPrice: '1774917942'
}
TicketSale deployed to: 0x408c5313592161d69Ae7acbca2A9b744FB6aBB9a
Contract deployed with:
- Number of tickets: 100
- Ticket price: 0.001 ETH
- Manager address: 0x60776F9B7B8F8060Bc24c1F29D46FC532a71b343
  1. Test the contract:
npx hardhat test



  TicketSale Contract
    Deployment
      βœ” Should set the right owner
      βœ” Should set the correct ticket price
      βœ” Should set the correct number of tickets
    Ticket Purchase
      βœ” Should allow buying a ticket
      βœ” Should not allow buying with incorrect price
      βœ” Should not allow buying same ticket twice
      βœ” Should not allow buying multiple tickets
    Ticket Swapping
      βœ” Should allow offering a swap
      βœ” Should allow accepting a swap
      βœ” Should not allow swap without ownership
    Ticket Resale
      βœ” Should allow listing ticket for resale
      βœ” Should allow buying resale ticket
      βœ” Should transfer service fee to manager
    Manager Functions
      βœ” Should allow manager to update ticket price
      βœ” Should allow manager to add tickets
      βœ” Should not allow non-manager to update price


  16 passing (1s)
  1. Update Configuration:

After deployment, you'll get a contract address. Update these files:

config.json:

{
  "contractAddress": "YOUR_DEPLOYED_CONTRACT_ADDRESS",
  "numTickets": 100,
  "ticketPrice": "1000000000000000",
  "deployedAt": "2024-10-29T22:31:49.475Z",
  "network": "sepolia",
  "managerAddress": "YOUR_MANAGER_ADDRESS"
}

pages/index.js:

const contractAddress = "YOUR_DEPLOYED_CONTRACT_ADDRESS";
  1. Start the development server:
npm run dev

🎫 Smart Contract Functions

User Functions

  • buyTicket(uint ticketId): Purchase a ticket
  • getTicketOf(address person): Check ticket ownership
  • offerSwap(uint ticketId): Offer to swap tickets
  • acceptSwap(uint ticketId): Accept a swap offer
  • resaleTicket(uint price): List ticket for resale
  • acceptResale(uint ticketId): Buy a resale ticket

Manager Functions

  • updateTicketPrice(uint newPrice): Update ticket price
  • addTickets(uint additionalTickets): Add more tickets
  • getTotalAvailableTickets(): Check available tickets

🎨 UI Features

Theme

  • Tihar Festival theme
  • Dark/light mode
  • Festival animations
  • Responsive design

Components

  1. Wallet Connection

    • MetaMask integration
    • Account display
    • Network validation
  2. Ticket Management

    • Purchase tickets
    • Swap tickets
    • Resale functionality
    • Ticket validation
  3. Manager Dashboard

    • Add tickets
    • Update prices
    • View statistics

πŸ” Security

  1. Environment Variables

    • Never commit .env file
    • Keep private keys secure
    • Use separate development wallet
  2. Contract Security

    • One ticket per address
    • Manager-only functions
    • Automated fee handling

🌐 Network Setup

  1. Add Sepolia to MetaMask:

  2. Get Test ETH:

πŸ§ͺ Testing

Run the test suite:

npx hardhat test

πŸ“± Deployment

  1. Build for production:
npm run build
  1. Start production server:
npm start

πŸ” Troubleshooting

  1. MetaMask Connection Issues:

    • Ensure Sepolia network is selected
    • Check if you have test ETH
    • Clear MetaMask cache if needed
  2. Transaction Failures:

    • Check gas prices
    • Verify contract address
    • Ensure sufficient balance
  3. UI Issues:

    • Clear browser cache
    • Check console for errors
    • Verify contract connection

🎯 Features Demonstrated in Screenshots

  1. Connect Wallet Interface

    • MetaMask integration
    • Network validation
    • Account display
  2. Available Tickets Display

    • Day-based categorization
    • Price information
    • Ticket availability status
  3. Ticket Management Interface

    • Owned ticket display
    • Ticket details
    • Management options
  4. Ticket Swap Interface

    • Swap offer creation
    • Swap acceptance
    • Current offers display
  5. Ticket Resale Section

    • Price setting
    • Available resale tickets
    • Purchase interface
  6. Manager Control Panel

    • Price updates
    • Ticket addition
    • Statistics overview
  7. Dark Mode Theme

    • Theme toggle
    • Improved visibility
    • Festival-themed elements
  8. Transaction History

    • Recent activities
    • Transaction details
    • Status tracking

About

A decentralized ticket sale platform built on Ethereum (Sepolia testnet) that enables secure ticket purchasing, swapping, and reselling with automated service fee handling. The platform features a beautiful Tihar Festival-themed UI with dark/light mode support.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published