Homework 3 FI 8462

Please complete this assignment carefully and make sure everything both works and is clearly documented. I will need labeled screenshots and a clear understanding of the logic behind each part.

All contracts must be compiled using Solidity version 0.4.16. Do not use a newer compiler version. Ensure everything compiles cleanly without errors.

In Part 1(a), we deploy the SimpleTokenERC20 contract. This is a basic ERC20-style token contract. Note that decimals is set to 0, meaning 1 token equals 1 unit. Even though the instructions mention approving 100e18, this is simply a raw integer value and the contract does not enforce decimal logic. You must understand and be able to explain how balanceOf works, how transfer works, how approve works, and how transferFrom works. The approve function sets an allowance, and transferFrom allows a spender to move tokens on behalf of the owner. You must switch accounts in Remix to simulate different users and understand that msg.sender changes depending on which account is selected. Take screenshots of deployment, balance checks, transfer, approve, transferFrom, and final balances.

In Part 1(b), we deploy EventFeedApi. This contract simulates an oracle because smart contracts cannot directly access real-world data. The contract stores eventEnded and eventResult values, and setResult manually updates them. You must show screenshots before and after setting the result. Then modify the contract to add an eventTime mapping, update it using now inside setResult, and create a getter function to retrieve it. Redeploy the modified contract, call setResult again, and show a screenshot of the timestamp being stored.

In Part 1(c), we deploy BinaryOption. This contract represents a binary option between a seller and a buyer. The seller deploys the contract and calls initialize() while sending 10 ether as collateral. The buyer calls validate() and sends 5 ether as the option premium. The buyer then calls exercise(), and the contract checks the event result from EventFeedApi. Depending on the result, the contract transfers ether to the correct party. You must understand msg.sender, msg.value, require statements, contract balance, and transfer. Show screenshots of deployment, initialize, validate, exercise, and account balances before and after each step. Make sure the EventFeedApi address is correctly passed into the BinaryOption constructor, otherwise exercise() will fail.

Finally, modify BinaryOption so that the seller can call a refund function if the event result is false. The function must verify that the event has ended, confirm the result is false, and restrict access to the seller. Redeploy the contract, set the event result to false, call the refund function, and provide a screenshot showing the seller receiving the funds.

Label all screenshots according to the PDF sections (1a, 1b, 1c), include the modified code for both contracts, and ensure that all transactions are successful without reverts. Everything must compile under Solidity 0.4.16.

Website – https://remix.ethereum.org/

Attached Files (PDF/DOCX): Homework 3 FI 8462.pdf

Note: Content extraction from these files is restricted, please review them manually.

WRITE MY PAPER