This is the open-book, open-Internet, open-everything except for messaging apps and talking midterm. You may not collaborate — any attempts to cheat will be met with FIRE AND FURY. I have failed people last semester due to cheating. Seriously, don’t do it. I’m not interested in filing any SJACS forms. Grading is automated through GitHub Actions. What you see is what you get. Absolutely no exceptions.

Submission guidelines: Modify contracts/Midterm.sol in the given template repository and push. Make sure you push often.

GitHub Classroom invite: https://classroom.github.com/a/7Bgpktti

Deadline: Oct 25, 2022, 23:59 PST


1) Contract Structure

These are all already done for you in the template. Failure to compile will result in a zero.

  1. Set open-source license to UNLICENSED.
  2. Enforce compiler version 0.8.0 or above.
  3. Contract should be named Midterm

2) Pure Functions (5%)

  1. Implement addArrays(uint256[] calldata array0, uint256[] calldata array1), which returns an array where each element is the sum of the elements of the same index in the input arrays. For example, calling the function with [1, 2, 3] and [4, 5, 6] returns [5, 7, 9].
    1. [5, 7, 9] is obtained from [1+4, 2+5, 3+6].
    2. Assume both input arrays are of the same length.

3) Russian Slavic Roulette (25%)

Overview

You will implement a game of Slavic Roulette where each player must deposit a certain amount of Ether into the contract and guess a number within a range (inclusive). The catch is, every time a player takes a wrong guess, the deposited money is lost and the next guess would cost double the amount of Ether. Whoever guesses correctly will win the game and receive all Ether deposited by previous players.

The game starts off in a paused state. It can only begin after the owner defines the range (floor & ceiling), the hash of the solution, and the base deposit. After a player wins the game, the game will return to a paused state until the owner defines a new range and a new solution.

The owner can only define the range, solution, and base deposit when the game is paused to prevent abuse.

Events are given in the interface and should be emitted at the appropriate time, per description.

Interface requirements

You must implement the given interfaces within the skeleton code.