TokenMaster is a decentralized application (dApp) similar to Ticketmaster.com, enabling users to purchase tickets by interacting with the blockchain. The tickets are represented as NFTs (Non-Fungible Tokens) using the ERC721 standard from OpenZeppelin.
TokenMaster allows users to list events and buy tickets for these events. Each ticket is minted as an NFT, ensuring the uniqueness and ownership of each ticket. The contract owner (deployer) has special permissions to list events and withdraw funds.
The smart contract is written in Solidity and uses the OpenZeppelin library for ERC721 token functionality.
- Event Listing: Only the contract owner can list new events.
- Ticket Purchase: Users can purchase tickets for listed events. Each ticket is an NFT.
- Ownership Management: The contract owner can withdraw the collected funds.
function list(
string memory _name,
uint256 _cost,
uint256 _maxTickets,
string memory _date,
string memory _time,
string memory _location
) public onlyOwner
Lists a new event. Only callable by the contract owner.
function mint(uint _id, uint256 _seat) public payable
Allows users to buy tickets for a specific event. Each ticket is an NFT.
function getOccasion(uint256 _id) public view returns (Occasion memory)
Returns details of a specific event.
function getSeatsTaken(uint256 _id) public view returns (uint256[] memory)
Returns the list of seats taken for a specific event.
function withdraw() public onlyOwner
Allows the contract owner to withdraw funds collected from ticket sales.
To deploy the contract, use the deploy.js
script located in the scripts
directory.
npx hardhat run scripts/deploy.js --network <network_name>
Replace <network_name>
with the name of the network you want to deploy to (e.g., rinkeby
, mainnet
).
To run the tests for the smart contract, use the following command:
npx hardhat test
Ensure you have configured your test environment correctly in hardhat.config.js
.
-
Clone the repository:
git clone https://github.com/Chizitere01/TokenMaster.git cd TokenMaster
-
Install dependencies:
yarn install
-
Compile the contract:
npx hardhat compile
-
Deploy the contract:
npx hardhat run scripts/deploy.js --network <network_name>
-
Interact with the contract:
- Use the Hardhat console or write scripts to interact with the deployed contract.
- Ensure to update the contract address and other relevant details in your interaction scripts.
This project is licensed under the MIT License. See the LICENSE file for details.