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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!