Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions

Question

Define Management or What is Management?

Answered: 1 week ago

Question

What do you understand by MBO?

Answered: 1 week ago

Question

What is meant by planning or define planning?

Answered: 1 week ago