Take Your Chances at The Ether Auction Game

Written by pabloruiz55 | Published 2017/11/13
Tech Story Tags: ethereum | smart-contracts | blockchain | blockchain-technology | ether-auction-game

TLDRvia the TL;DR App

Photo by NeONBRAND on Unsplash

Disclaimer: This smart contract is based on the Dollar Auction game designed by economist Martin Shubik.

Disclaimer 2: This article, companion code and deployed smart contract have been written with academic purposes only. The game has been deployed to Ethereum Main network meaning that, if you try it, you will be bidding with REAL money. Participate at your own risk. I’m not responsible for money lost by playing the game whether it is caused by being outbid or due to a bug.* You might be wondering why, if this is only for academic purposes, I deployed the contract to work with real money. I believe it is the only way for the experiment to work as people that do participate will have some skin in the game.

Disclaimer 3: Full disclosure. Since there’s no way to prevent the auctioneer from using some other address or asking a friend to outbid someone, it’s practically impossible for him/her to lose. If someone bid 0.05 eth and he was about to win, the auctioneer could use one of his accounts to outbid them each time until the auction at least went over 1 eth so he breaks even. As they say, the house always wins.

The Ether Auction

The ether auction is strictly based on the Dollar Auction game. According to Wikipedia:

The dollar auction is a non-zero sum sequential game designed by economist Martin Shubik to illustrate a paradox brought about by traditional rational choice theory in which players with perfect information in the game are compelled to make an ultimately irrational decision based completely on a sequence of apparently rational choices made throughout the game.

In the ether auction, the auctioneer volunteers 1 ether which participants can bid for. The bid starts at 0.05 eth and goes up by 0.05 eth as well. The person who bids the higher amount, by the end of the auction gets the 1 eth.There’s a caveat though, the second highest bidder loses his money.

So, when the auction starts people don’t have to give it much thought. They are looking at some easy profit. By bidding 0.05 eth they can win 1eth.

As the auction progresses it will turn into a battle between 2 people which will try to outbid the other in order to win the auction, even though they end up winning a few wei or even breaking even. (winning the auction by bidding 1 eth to get 1 eth).

At this point, things get interesting. The person who is now losing the battle will now try to minimize his loses. After all, they are looking at a 0.95 eth loss. If they now bid 1.05 eth they will only lose 0.05 eth. This can go on and on until one of the two parties decides to cut his losses and stop bidding.

This article by Douglas Noll explains very well the psychological reasons as to why someone will keep pushing while knowing that even if they win or lose the auction, they will lose money anyways.

There is actually a globally optimal solution, which is to not play the game at all unless one is certain that there are no other players. — Wikipedia

Building the Ether Auction in Ethereum

I first learned about this game in this Reddit post, where the OP warned about how people could get scammed. He writes:

[…]However, there is a high probability that this scam is going to catch on once smart contract goes mainstream, considered how many people bought bitconnect coins when crypto currencies went somewhat mainstream.

We need to educate the public and try to prevent this type of scams in order to ensure a quick and trouble free deployment of the smart contract technology, if for no other reason than to protect the value of the ethereum we own.

Is it really a scam? I’m not sure, probably. While it is true that the only way to actually win this game is that you are the only person playing (so a bidding war is not started), people DO know (or should know) the rules. The rules are crystal-clear, you know that if you are outbid you will lose your money.

While we are on the crystal-clear rules subject, you can find the code for the contract below with comments and some explaining of each function.If you don’t care about code and want to participate in the game, feel free to skip this section. I wouldn’t recommend participating in this game or other similar games — or ICOs for that matter — where your eth is involved if you don’t understand or care about the code, though.

The code is also available on my Github repo and it has been verified on Etherscan.

Contract initialization

The only thing we are doing in the constructor is making the person who deploys the contract the auctioneer. At this point he doesn’t have to send the money that will be auctioned, we will do that later.In the case of the smart contract I linked above, I am the auctioneer.

Starting the auction

The auctioneer now has to start the auction by calling the function below:

StartAuction is a payable function that only the auctioneer can call, once, in order to get the auction running. He has to send the 1 eth to the contract which will be auctioned. Finally, we set the auction to end 7 days after it has been deployed. Now that the auction has started, other people can send their bids to it.

Participating in the auction

The bid() function receives the eth sent and makes sure that the bid is correct (that the person bidding is sending 0.05 eth more than the highest bid). Then, it updates the bidders. The previous highest bidder is now the second highest bidder, and the person who called this function becomes the highest bidder.Finally, if the auction is about to end, it extends it in order to prevent the so called auction sniping.

Finalizing the auction

Once the 7 days pass, the auction can be finalized by calling finalizeAuction().

By calling this function, ether will be distributed accordingly for participants to withdraw.

  • The highest bidder will receive the 1 eth and his bid will be transferred to the auctioneer.
  • The second highest bidder will lose the money he bid and it will be transferred to the auctioneer.
  • The rest of the participants will be able to withdraw the money they bid.
  • * If for some reason no bids were received, the auctioneer will be able to withdraw the eth he volunteered.

Playing the Ethereum Auction game

Ok, enough theory!

I have deployed the Ethereum Auction game at address: 0x2e63cceffa42b095f0bd6d0fcadb521200b8fef5.I already started the auction by volunteering the necessary 1 eth. The auction will run for 7 days and will end on Tuesday, November 21, 2017 10:52:19 AM GMT.If someone bids within 1 hour before the auction ends, the auction will be extended by an additional hour until no one bids anymore.

*If no one ends up bidding, which as discussed in the article would be the wisest, once the auction ends I will be able to get my 1 eth back.

The easiest way to interact with the contract is using MyEtherWallet with the Metamask Chrome extension. You will need to enter the contract’s address (which I shared above) as well as the contract’s ABI which you can find here.

In order to submit a bidding you have to execute the bid() function on the contract and send the correct amount of eth alongside. You can check the current highest bid by calling the highestBid() function. You must submit a bid that is 0.05 eth higher than the current highest bid.

Have in mind that your bids accumulate and you won’t be able to withdraw the money until after the auction finishes. Since the bids you make accumulate you will only have to bid the eth necessary to outbid the current highest bidder. For example, if you bid for the first time 0.15 eth and then you want to outbid the highest bid at 0.45 eth, instead of submitting 0.50 eth you will only have to send 0.35 eth as you had already sent 0.15 eth before.In order to know how much you have sent so far you can call myLatestBid() function.

Once the auction has finished, you can withdraw your funds by calling the withdrawBalance() function. Calling this function will return all the outstanding eth you have from the contract, whether it is the eth you won or your previous bids. If yours was the second highest bid, remember you will lose your money.

You can find out when the auction ends by calling auctionEndTime() which will give you the date in Unix Epoch time. You can convert the number here to get the exact date. You can also call timeRemaining() to know how many seconds remain.

So, tu sum up. In order to participate you have to:1- Call highestBid() to know what’s the highest bid so far.2- Call myLatestBid() to know what was your latest bid.3- Call Bid() while supplying the corresponding eth. (The highest bid plus 0.05 eth, minus whatever you had already sent in your previous bid).4- Wait for the auction to finish and call withdrawBalance() to get the corresponding eth you are entitled to. Unless yours was the second highest bid, in which case… bummer.

Where to go next?

I have an issue with the transparency of this contract. Given that it’s in the auctioneer’s best interest to have people bid so he doesn’t lose money, he certainly could keep outbidding people until the threshold where he breaks even is reached. Even though we are preventing the auctioneer from directly bidding in his auction, nothing stops him from doing it from another account or asking someone else to bid from him.This leads to a huge transparency issue. Someone playing this game can’t trust the auctioneer to be honest. One way to mitigate the risk of “the house” cheating would be to take a cut from each bid and use that for the prize instead of having the auctioneer provide it.


Published by HackerNoon on 2017/11/13