[Solved] Blockchain-Homework 8

30 $

SKU: [Solved] Blockchain-Homework 8 Category: Tag:
  1. Read about Ethereum smart contract security:
    1. https://consensys.github.io/smartcontractbestpractices/
    2. Your score on the homework will be reduced if you submit insecure code.
  2. Start up the vagrant-managed virtual machine included in the homework 8 zip, log into it using ssh. Then, start the Ethereum node server, and then use truffle to test the provided contracts. The tests should run, but most should not pass. Note: You must run “npm install” once under the homework8/auction directory before running truffle. The command installs code packages needed for the project.
  3. Read about Dutch auctions: https://en.wikipedia.org/wiki/Dutch_auction
  4. Read and thoroughly understand the provided code
    1. contracts/DutchAuction.sol: an incomplete, skeletal implementation of a Dutch auction.
    2. test/<k>_dutch_auction.js: mocha tests for the contract
    3. test/framework.js: a testing harness to make tests easier to write 5. Part A: You will write a smart contract that implements a Dutch auction.
    4. The seller instantiates a DutchAuction contract to manage the auction of a single, physical item at a single auction event. The contract is initialized with the following parameters:
      1. reservePrice: the minimum amount of wei that the seller is willing to accept for the item
      2. numBlocksAuctionOpen: the number of blockchain blocks that the auction is open for
  • offerPriceDecrement: the amount of wei that the auction price should decrease by during each subsequent block.
  1. judgeAddress: used by another part in this assignment.
  1. The seller is the owner of the contract.
  2. The auction begins at the block in which the contract is created.
  3. The initial price of the item is derived from reservePrice, numBlocksAuctionOpen, and offerPriceDecrement: initialPrice = reservePrice + numBlocksAuctionOpen*offerPriceDecrement
  4. A bid can be submitted by any Ethereum externally-owned account.
  5. The first bid processed by the contract that sends wei greater than or equal to the current price is the winner. The wei should be transferred immediately to the sender and the contract should not accept any more bids. All bids besides the winning bid should be refunded immediately.
  1. Part B: You will enhance the DutchAuction contract so that a judge can be designated for the auction. The judge behaves like an escrow in that he ensures that the seller received the wei of the winning bid if and only if the winner receives the item. A judge is specified by the judgeAddress parameter in the contract constructor. If a judgeAddress is not provided then, the contract should behave exactly as in Part A. However, if a judge is specified, then the behavior of the contract should be enhanced as follows:
    1. The wei of the winning bid is no longer automatically sent to the seller.
    2. Instead, a call to the finalize() function is now required after the winning bid is made, which will send the wei of the winning bid to the seller.
    3. The finalize() function can either be called by the judge or by the winner. The winner is expected to call this function to acknowledge that he received the physical item. If the winner doesn’t call it, the judge may intervene and call the finalize() function himself to forcibly send the wei to the seller.
    4. If the winner does not call finalize() and the judge also does not call finalize, then the judge can call the refund() function to send the wei of the bid back to the winner. You must ensure that the judge can only call one of these functions once and that the judge cannot send the wei to himself.
  2. Notes:
    1. You may assume Ethereum block numbers are sequential and consecutive.
    2. The ganache-cli test utility is configured by default to generate a new block for each transaction submitted to the local Ethereum test network. You may assume this behavior when writing your tests.
    3. Minimal tests are provided for you, but you are required to thoroughly test your work. The tests used to grade your submission will be different than the provided tests.
    4. You may only make modifications to DutchAuction.sol. All other code changes will be ignored during grading.
    5. Truffle may not properly recompile your code unless you first delete the build directory and then run “truffle compile”.


There are no reviews yet.

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

Shopping Cart
[Solved] Blockchain-Homework 8
30 $