This project is a smart contract-based ticketing system built on Ethereum using Solidity. It includes two contracts:
- NftTicket: This contract manages the creation of events and allows users to register for events if they hold a specific ERC721 NFT.
- NFT: This contract mints and manages NFTs, which are used as tickets for registering for events.
Users can register for events as long as they meet the necessary criteria, such as owning the required NFT, and can check their registration status for events.
This contract allows users to create events, register for them, and check the registration status. It interacts with an ERC721 contract (NFT ticket) to ensure users hold the required NFT for registration.
- Event Creation: Allows users to create events with details such as name, description, location, event date, maximum capacity, and registration deadline.
- Event Registration: Users can register for events as long as they hold an NFT ticket and the event is not full or past the registration deadline.
- Event Details: View all events or a specific event's details.
- Check Registration: Allows users to check if they are registered for a particular event.
- createEvent: Creates a new event with provided details.
- registerForEvent: Registers a user for an event if they hold an NFT and meet the registration conditions.
- getAllEvents: Returns a list of all events created.
- viewEvent: Returns details of a specific event by ID.
- checkRegistrationValidity: Checks if a particular user is registered for an event.
This contract is responsible for minting the ERC721 NFT used as tickets for the events. Only the owner of the contract can mint new NFTs.
- Mint NFT: The owner of the contract can mint a new NFT for any recipient, along with a unique metadata URI for that token.
- mintNFT: Mints a new NFT with the provided token URI and transfers it to the specified recipient.
- Node.js and npm: Ensure you have Node.js and npm installed.
- Hardhat: Install Hardhat for testing, deploying, and interacting with smart contracts.
- MetaMask: For interacting with the smart contract on Ethereum test networks.
-
Clone the repository:
git clone https://github.com/Superior212/NftTicketing cd NftTicketing
-
Install dependencies:
npm install
-
Compile the contracts:
npx hardhat compile
-
Deploy the contracts:
First, configure your network and private key settings in
hardhat.config.js
.Deploy the
NFT.sol
contract:npx hardhat ignition deploy ./ignition/modules/EventNft.ts --network <network-name>
Deploy the
NftTicket.sol
contract:npx hardhat ignition deploy ./ignition/modules/NftTicketing.ts --network <network-name>
-
Run tests:
npx hardhat test
-
Mint NFT: The contract owner can mint an NFT by calling the
mintNFT
function from the NFT contract. -
Create Event: After deploying
NftTicket
, users can callcreateEvent
to create events with specified parameters. -
Register for Event: Users holding an NFT can register for events using the
registerForEvent
function. They must provide the event ID and meet all the registration criteria. -
Check Event Details: Call
viewEvent
to get details of a specific event orgetAllEvents
to retrieve all events. -
Check Registration Status: Users can check if they are registered for an event using the
checkRegistrationValidity
function.
id
: Unique ID for the event.name
: Name of the event.description
: Description of the event.location
: Event location.date
: The date when the event takes place.maxCapacity
: Maximum number of users allowed to register.registrationDeadline
: Deadline for registering for the event.registeredUsers
: List of registered users.
- Only users holding an NFT (from the
NFT
contract) can register for events. - Users must register before the registration deadline and only if the event is not full.
This project is licensed under the MIT License. See the LICENSE file for more details.