This project implements a decentralized event ticketing system using Solidity smart contracts. It allows event organizers to create events, issue tickets as NFTs, and manage attendee registration and verification. Attendees can register for events and receive tickets as NFTs, which can then be verified at the event.
This contract implements an ERC721 NFT representing a ticket. Each ticket is unique and can be transferred.
mint(address _to): Mints a new ticket NFT to the specified address. Only the contract owner can call this function.
This is the main contract that manages events, ticket creation, registration, and verification.
createEvent(...): Creates a new event with details like title, description, start/end dates, fee, type (free/paid), expected guest count, etc. It also generates a newTicketNFTcontract for the event. Only the contract owner can call this function.registerForEvent(uint256 _event_id): Allows users to register for an event. For paid events, it requires the correct fee to be sent. Mints a ticket NFT to the registrant.createEventTicket(...): Creates an event ticket (NFT contract instance). This is called internally bycreateEvent.purchaseTicket(...): Mints the NFT to the user. This is called internally byregisterForEvent.verifyAttendance(uint256 _eventId, uint256 _ticketId): Allows the event organizer to verify a ticket.isVerifiedTicket(uint256 _ticketId, uint256 _eventId): Checks if a ticket has been verified.getHasRegistered(uint256 _eventId, address _address): Checks if an address has registered for an event.getTicketIds(uint256 _ticketId): Retrieves the event ID associated with a ticket ID.withdrawForEvent(uint256 eventId): Allows the event organizer to withdraw the funds collected for a paid event.
Deploys the EventContract to the network.
Interacts with the deployed EventContract to create a new event.
Interacts with the deployed EventContract to register a user for an event.
Interacts with the deployed EventContract to verify a ticket.
Interacts with the deployed EventContract to withdraw funds from an event.
Combines all the above operations in a single script, allowing to perform them in a sequence.
Contains unit tests for the EventContract using Hardhat's testing framework and Chai assertions. Covers various scenarios for event creation, registration, verification, and withdrawals.
- Clone the repository:
git clone <repository_url> - Install dependencies:
npm install - Compile contracts:
npx hardhat compile - Deploy contracts:
npx hardhat run scripts/deploy.js - Run scripts:
npx hardhat run scripts/<script_name>.js - Run tests:
npx hardhat test
- Node.js and npm
- Hardhat
- ethers.js