[Solved] CMPE483 – Homework 1

30 $

File Name: CMPE483_–_Homework_1.zip
File Size: 207.24 KB

SKU: [Solved] CMPE483 – Homework 1 Category: Tag:

Or Upload Your Assignment Here:


Sp. Top. in CMPE Blockchain Programming

(The project can be done in groups of at most three students)

Implement an autonomous decentralized lottery (called Bogazici Lottery (BULOT) ) as a Solidity smart contract. One lottery round lasts two weeks and consists of two stages. A new lottery round starts right after the first stage of previous one is completed. A lottery ticket costs 10 TL.

Winner tickets will be selected by computing random numbers that determine each winner ticket. A random number is to be supplied by the ticket purchasers. The lottery should employ (i) ticket purchase and random number submission (ii) reveal stages. The details of how a random number can be generated in order to determine winners is given here:

https://ethereum.stackexchange.com/questions/191/how-can-i-securely-generate-a- randomnumber-in-my-smart-contract

The stages of each lottery round are scheduled as follows in an overlapping manner:

  1. Ticket purchase and random number submission stage : One
  2. Random number reveal stage : One Note that if previously submitted random numbers are not submitted correctly in the reveal stage, the chance of winning is lost. Also, no ticket refund is made in this case.
Purchase/Random NoSubmission(1 week) Reveal (1 week)
Purchase/Random NoSubmission(1 week) Reveal (1 week)

Lottery 1

Lottery 2

…. …

Let M be the amount money collected from the sale of tickets at the current lottery. The ith prize Pi will be awarded to the winners as follows:

Pi = ⌊M/2i⌋ + (⌊M/2i−1⌋ mod 2) i = 1,…,⌈lo g2(M )⌉

Note that a winning user should be able to withdraw his prize anytime after the lottery round ends. Also, it is possible that a ticket may win more than one ticket.

Your implementation should provide the following interface (and only the following interface) to the external world:

function buyTicket(bytes32 hash_rnd_number) publicfunction revealRndNumber(uint ticketno, uint rnd_number) public function getLastBoughtTicketNo(uint lottery_no) public view returns(uint) function getIthBoughtTicketNo(uint i,uint lottery_no) public view returns(uint)function checkIfTicketWon(uint lottery_no, uint ticket_no) public view returns (uint amount) function withdrawTicketPrize(uint lottery_no, uint ticket_no) publicfunction getIthWinningTicket(uint i, uint lottery_no) public view returns (uint ticket_no,uint amount) function getCurrentLotteryNo() public view returns (uint lottery_no)function getMoneyCollected(uint lottery_no) public view returns (uint amount)

You should also prepare a table of gas usages for the interface functions and discuss them.

Grading

Your project will be graded according to the following criteria:

Documentation (written document describing how you implemented your project and also showing the correctness of your implementation). You should also provide average gas usages for the interface functions. 30%
Comments in your code 10%
Correctly functioning Solidity code, test scripts and tests 60%

Timestamping

Project file should include your names in it. Please timestamp your project file using https://opentimestamps.org/ before you submit it. Keep the project file and its corresponding timestamp .ots file.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CMPE483 – Homework 1
30 $