I was speaking with @kushti and he mentioned the idea that auctions are a potentially valuable unsolved problem in a UTXO system with a contract language like ErgoScript. I think I’ve come up with a pretty basic setup and thought it’d be good to give it some more form in a post here so others can poke at it and see if there’s any glaring obvious holes. (Do note I’ll be hand waving the actual script since I don’t have time to write it currently)

How It Would Work

Alice wishes to start an auction for a super special singleton token she created on top of Ergo. She decides that the auction is supposed to end on block #5000 and the winner of the auction is allowed to withdraw the won special token and pay out the winning auction bid Erg back to Alice (this is encoded in the script as the spending action allowed after block #5000).

R4 is the pre-defined registry which holds the current bidder address.

R5 is the pre-defined registry which holds the current bid amount.

To start the auction Alice creates a box locked under this script with the super special token as input, her own address in R4, the value 0.1 in R5, and provides an input with 0.1 erg as the “base bid”.

Now before the auction end block(5000 in this case), anyone is allowed to spend the box given that they:

Keep the script the same Increase the bid by putting a number greater than the previous bid in R5 (and locking an equivalent amount of Erg in the new box from one of their own inputs) Return the previous locked Erg to the address that was previously held in R4

Anyone who wishes to take part in the auction can do so by spending the box and making a new bid up until block 5000. After the end block no more bids can be made and thus the address that is in R4 is officially the winner of the auction. They now have the right to withdraw the super special token which Alice originally locked in the box, and must pay out the final bid value that is in R5 to Alice’s address by sending the Erg locked in the box to Alice.

The situation above was just to make it easier to understand how it would work, but essentially it should be possible to encode any sort of “auction success” condition depending on if it’s a token that’s being bid on, a physical product, or anything else.

If no one bids on the auction, then Alice’s address is the final one that is in R4, and thus Alice can withdraw her locked initial bid + her super special token.

Using EIP-001 and maybe having some sort of internal auction ID encoded within the script (or a token? some standard can be set for this pretty easily) can make it easy for wallets to follow along with the progression of the auction.

In general this seems like a pretty simple setup to me, and one that should work without too many issues. I’d like to hear some feedback from you guys, especially if I’m missing out on a clear hole and/or attack vector that makes this a bad solution. Otherwise this shouldn’t be too complicated to implement in ErgoScript, just the complexity of the auction success condition may be the most challenging depending on the given usecase.