This post was first published on Medium.
Sealed auctions are a well-established method for trading and selling goods and services. With the advent of blockchain technology, sealed auctions can now be implemented on-chain, offering a number of advantages over traditional auctions.
In this article, we will implement of a collateralized sealed auction on UTXO-based smart contract blockchains such as Bitcoin.
What is a Sealed Auction?
A sealed auction is a type of auction in which bidders submit their bids privately, typically in sealed envelopes or electronically, without knowing the bids of other participants. The bids are usually submitted to a neutral third party, such as an auctioneer or organizer, who collects and then opens them at a predetermined time or date. This ensures that bidders cannot strategically adjust their bids based on the bids of others.
Sealed auctions have a number of advantages over traditional auctions, including:
- Confidentiality: Bids are kept secret, which can be important for sensitive items or when bidders do not want their competitors to know how much they are willing to pay.
- Efficiency: Sealed auctions can be conducted more efficiently than traditional auctions, as they do not require an auctioneer to be present.
- Transparency: All bids are disclosed at the end of the auction, which ensures that the auction is fair and impartial.
This sealed auction contract, ensures that bidders are penalized for abandoning the auction after submitting their bids. This is achieved by introducing collateralization.
Phase 1: The Bidding Phase
A user submits their bid in the form of a double SHA256 hash. This hash represents the bid amount, plus a random value (salt) to ensure its secrecy. This salt ensures that other bidders can’t determine the bid amount even if two bidders bid the same amount.
Bidders also lock up a specified collateral amount. This ensures that bidders have a stake in the auction and are less likely to abandon their bids.
Phase 2: The Reveal Phase
Once the bidding phase ends (as enforced by the contract using a time lock), the reveal phase starts. During this phase, bidders disclose their actual bid amounts.
The smart contract is designed to automatically track the highest revealed bid. It will store this information until the end of the reveal phase.
Phase 3: Close
- Auctioneer Withdrawal: After the reveal phase concludes, the auctioneer can withdraw the highest bid.
- Collateral Retrieval: Bidders can then retrieve their collateral. The winning bidder, however, only retrieves the difference between their bid and the collateral.
The full code of the smart contract is available on GitHub.
To prevent bidders from abandoning their bids, we will use collateralization. In this approach, bidders must lock up a specified amount of collateral when they submit their bids. If a bidder does not reveal their bid in the reveal phase, their collateral is forfeited.
Watch CoinGeek Weekly Livestream with Craig Mason: Bitcoin transactions at scale are cheaper
New to blockchain? Check out CoinGeek’s Blockchain for Beginners section, the ultimate resource guide to learn more about blockchain technology.