Question
Create a solidity smart contract for Ticketing application with the following features: Declare two state variables: owner : The account deploying the contract will be
Create a solidity smart contract for Ticketing application with the following features:
Declare two state variables:
owner : The account deploying the contract will be set as the owner.
countTickets[address(this)] : It holds the total tickets and count should be initialized to 100.
Provide a function getCountTickets()to track tickets remaining(contract).
Use the default getter on countTickets to track the tickets owned by each account.
Provide a function addTickets() to increase/add the count of available tickets(contract) and only the owner should be able to do it.
Provide a function purchaseTickets() to enable purchase of tickets. This function should receive ETH and be successful only if there are enough funds transferred (2ETH per ticket) and enough tickets are remaining.
One can buy more than one ticket at once (count required passed as parameter to purchaseTickets() ) and the corresponding ETH transfer should be cross checked.
Provide a function useTickets() so the holder of tickets can use a certain number of tickets if the balance is sufficient and balance should be updated.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started