Categories: Help me Write Essay

Blockchain Smart Contract

Design a smart contract for the following applications.

1.

Electric vehicle charging stations.

BaboCharge owns a large number of electric vehicle charging stations. Each charging station is connected to Eversource, which supplies its electricity and bills BaboCharge once a month for the electricity used. The billing and payment relationship between BaboCharge and Eversource is NOT mediated by the smart contract. However, BaboCharge will charge car users a higher price than what Eversource charges so that it can make a profit.

The contract is written so that, BaboCharge can update the price (in dollars) the contract will charge users any time it wants to. Car owners create an account with BaboCharge’s smart contract by sending bitcoin from an address in their bitcoin wallet to the contract’s address.

This transaction should also include a password that the car owner would like to use when charging their car. When drivers want to use a charging station, they enter the address they used to create their account (or scan a QR code of that address) at the station and enter their password. The station displays the price per kwh (kilowatt-hour) in btc, which it calculates based on Babocharge’s previously entered price for electricity and the conversion rate between bitcoin and dollars, which the charging station obtains at the time of the charge from coinmarketcap.com via its internet connection.

You may assume that the charging station includes a computer that can perform these calculations and store data. When the user’s vehicle is fully charged or when the plug is removed from the vehicle, the user’s prepaid balance is reduced by the amount of electricity consumed (in kwh) times the price the contract had displayed to the user. A user can increase his/her balance at any time by sending funds from the same address to the smart contract. The user can terminate the contract by sending a terminate transaction to the contract, at which point the contract will send the user’s account balance to the address the user used to set up the account.

Similarly, BaboCharge can withdraw funds from the contract balance by sending an appropriate transaction to it. Your design should prohibit the charging station from dispensing more electricity than the user’s contract balance will pay. Note that the interaction between the charging station and coinmarketcap.com does not directly involve the smart contract and should not be included as a smart contract transaction. Similarly, the charging station’s calculations are not part of the smart contract.

2.

Flight insurance.

BaboInsure has a website at which users can purchase flight insurance two or more days before they are due to fly. BaboInsure can set the cost in dollars, per $100 of insurance, at any time by sending an appropriate transaction to the contract it has created and by updating the website. A user purchases insurance at the website specifying the airline, flight number, date, and amount of insurance requested.

The website calculates the price in BTC by obtaining the conversion rate between BTC and dollar from a coinmarketcap.com API. It then provides the user with a code to use to purchase the insurance. It also sends the code to the contract. The user then has 10 minutes to send the specified amount of BTC to the contract along with the code received from the website. If the contract receives the BTC within 40 minutes of receiving the code from the website, it registers the user’s insurance (we will call this an insurance contract, abbreviated as IC, to differentiate it from the smart contract) and sends a confirmation.

If the BTC is received too late, it is returned to the user with an indication that the transaction failed. If the user’s flight is more than two hours late or fails to fly, the user can receive the insurance amount by going to the website and entering the code used to purchase the IC. The website will use a flightstats.com API to verify the user’s claim. If verified, the site will determine the BTC/$ conversion rate using a coinmarketcap.com API and will calculate the amount of BTC due to the user.

The website will send a transaction to the contract to trigger sending the calculated amount to the address the user used to purchase the IC. At any time, BaboInsure can send funds to or withdraw funds from the contract balance by sending an appropriate transaction to it. Your design should prohibit the contract from accepting a purchase if the contract balance is insufficient to pay all the open ICs (those for flights that have not yet flown) plus 20% to account for the volatility of the BTC/$ conversion rate.

Note that interactions between the website and the user and between the website and other parties, such as coinmarketcap.com and flightstats.com, do not directly involve the smart contract and should not be included as smart contract transactions.

Your design should identify the transactions the contract will receive. For each transaction it receives, your design must specify four things (please number them in your submission):

What money or assets should be received?
What data should the transaction contain?
How should the data stored in the contract be changed?
What transactions should the contract generate?
In addition, you must summarize the data that the contract must keep.

Submit your design as a Microsoft Word document