Highlights
Background
A variety of schemes are used to sell goods in such a way as to yield the highest profit for the seller. English Auctions, used in Australia for selling real estate, are probably the most familiar to you: bidders take turns to offer increasingly high prices, until one bidder remains who has offered the highest price, and no other bidder is prepared to offer any higher price. The auction is then declared closed by the auctioneer, and the highest bidder is declared the successful buyer, at a price equal to their highest bid. This approach has some disadvantages from the point of view of an unsuccessful bidder. During the course of the auction, they were required to reveal the highest price that they were prepared to pay. Other sellers wishing to sell similar items can then take advantage of this fact and refuse to sell for less than this price, depriving the purchaser of the possibility of a purchase at a lower price, even when there is no competition from other bidders. It would be preferable if the winning bidder for an auction were determined in a way that does not reveal the bids of the losing bidders. In part 1 of this assignment we develop a way to achieve this. Even better would be to also hide the identity of the losing bidders. This is addressed in a stretch goal in part 2 of the assignment. Hiding the bids of losing bidders can be achieved through use of a Dutch Auction. Such an auction swaps the roles of the buyers and seller, and proceeds by successive decreases of the price, until a buyer is found who is prepared to pay that price. That is, the seller first states a high price, and asks the buyers for an offer to buy at that price. If no buyer states that they are prepared to pay that price, the seller reduces the price, and again asks for an offer. This process repeats, with the price decreasing over time, until a buyer is found. In this assignment, we will apply this approach to develop a smart contract for a market where ERC-20 tokens can be bought and sold. Compared to the sale of a single item, we have some additional requirements. Consider a situation where a seller wishes to sell some number N of ERC-20 tokens of the same type. Suppose there are n ≥ 1 bidders, all offering to buy b1 bn tokens at the current seller price p per token. Bidder i may receive a number x ≤ bi tokens from this seller. Bidder i will pay.
If P i=1...n bi ≤ N, each buyer i should receive exactly bi tokens, leaving N − P i=1...n bi remaining to be sold. The seller has the option of further reducing the price to sell these tokens if they wish.
If P i=1...n bi > N, then there is contention for the tokens being sold, and we need a rule to determine how many tokens each buyer receives. We will take the attitude that the buyer who has been waiting to buy the longest will have their order filled first. For that, we need a way to determine which buyer that is, without revealing the price that they are prepared to pay too early. We resolve that by using bid blinding. We maintain a counter bid-number initially 0. When a buyer submits a buy order, it is assigned the current bid-number, and bid-number is incremented. The bid itself is blinded: it should not reveal the number of tokens that the buyer is offering to buy, nor the price they are prepared to pay for each token. When the seller’s price reaches the price that the buyer is prepared to pay, the buyer opens, or reveals their bid, making the number of tokens and the price public. It should not be possible for the buyer to cheat by revealing a number of tokens or a price that differs from the numbers used in their initial blinded bid. In the context of a market service, that provides matching between multiple sellers and buyers, there is a similar issue when multiple sellers are offering to sell the same kind of tokens, but at potentially different prices. ERC-20 tokens in the same asset (i.e., issued from the same smart contract) are fungible, so the buyers will not care which seller’s tokens they receive. When matching buy bids and sale offers, the bids should be matched against the lowest price sale offers first. For sale offers at the same price, the older sale offers should be used first to supply the buyers. To enable this, when a block of tokens is first offered for sale, it is associated with an offer-number. Note that where an offer to sell at price p is matched with a bid to buy at price q ≥ p, the buyer pays the lower price p. A bid to buy at a price q should not be matched with an offer to sell at a price p > q: such an open bid is left in the market for possible matching in later rounds.
For example, suppose we have the following sale offers and opened buy bids, all for the same token type, in a given matching round.
Then
Part
1. Develop a DutchMarket smart contract in Solidity implementing a market for ERC-20 tokens that implements the above ideas. More precisely, the contract should have the following functionality:
2. Stretch Goal
As noted above, blinded bids still reveal the identity of the bidder, at least by way of their Ethereum address, because a user will open an account with that address, and then submit bid transactions to the market smart contract that are signed with the key for that address. This may be an issue for bidder privacy, and other bidders may prefer not to bid when they see that there is a competing bidder with a large cash balance, or who has a reputation of placing very high bids. As a stretch goal, modify your solution to allow the bidder identity to be obscured by the following technique. Instead of placing blinded bids using transactions signed by the same address A under which they have opened an account at the market, users may submit blinded bids using transactions signed by another address B. These blinded bids state, as usual, the token type, number of tokens and a price. However, in addition, the bid states the address of the real bidder A. All of this information (except B) should be hidden, until the bid is opened. At the time of opening, the usual bid information, as well as A’s address, should be revealed, so that matching of the bid will affect A’s account in the usual way. Note that the information revealed at the time of opening such a bid should prove that it really was A’s intention to place the bid transaction signed by B. It should not be possible for any user other than the real bidder A to use this mechanism to cause changes to A’s account. For this, the information revealed by bid opening should be a message, signed using address A, that states the usual bid information. The market smart contract should verify this signature before accepting the bid as valid and assigning it to user A. (You might like to think of the mechanism as bids being like sealed envelopes containing signed letters.)
Deliverables
That it is not a requirement of the assignment to develop a Graphical User Interface for this application - where code other than Solidity code is necessary, invocation using command line instructions suffices to meet the requirements.
1. A report (pdf format) describing your design and implementation of the overall system.
This COMP6451 – IT and Computer Science has been solved by our PHD Experts at My Uni Paper.
© Copyright 2026 My Uni Papers – Student Hustle Made Hassle Free. All rights reserved.