A smart contract that enables secure, transparent blockchain-based event ticketing.
Supports both regular and VIP tickets, refund flows, user ticket data storage, and owner-controlled event management.
- Users can buy regular tickets (0.001 ETH by default).
- Users can buy VIP tickets (0.004 ETH by default).
- Prevents double purchases (one ticket type per user).
- Automatically assigns ticket numbers.
- Stores user details:
- Name
- Phone number
- Ticket ID
- Refunds available only before the event date.
- Regular and VIP refund logic handled independently.
- Updates ticket status on refund.
- Frees seat count for resale.
- Owner can:
- Withdraw funds after the event ends.
- Update ticket prices.
- Change event date.
- View personal ticket info.
- View VIP ticket info.
- Check total tickets sold.
- Check total VIP tickets sold.
- Get seat availability.
-
Deploy contract
- Event date set automatically (current timestamp + 7 days)
-
Users purchase tickets
payforticket()for regularBuyvipseats()for VIP
-
Before event date
- Users can call
refund()orrefundforvip()
- Users can call
-
After event date
- Owner calls
withdraw()to collect all ETH
- Owner calls
PurchasedTicket(buyer, ticketNo, amount)Refund(user, ticketNo, amount)Withdraw(owner, amount)ticketinfo(user, ticketNo)
- Solidity ^0.8.0
- EVM-compatible blockchain
- Remix / Hardhat for testing
- OpenZeppelin Ownable for access control
- Clone repo
- Deploy contract in Remix or Hardhat
payforticket("John", "john@mail.com", 9876543210)```
### 3. BuyVip Ticket
```solidity
Buyvipseats("Alice", "alice@mail.com", 9876512345)```
### 4. Refund (before event date)
```solidity
refund()
refundforvip()```
### 5. Check Ticket Info
```solidity
checkticket()
checkticketvip()```
### 6. Owner Withdraw (after event date)
```solidity
withdraw()```