<blockquote>
  <p>If Bitcoin has smart contracts, I would like to see how to create a simple "hello world" auction - winner wins, those who didn't win get refunded.</p>
</blockquote>

<p>Your question isn't clear about the details of how you would expect this to work, so I'll start with some assumptions:</p>

<ul>
<li>The seller has put something up for auction. There are two possibilities: the item being sold is a digital asset native to the Bitcoin chain, or it is not. </li>
<li>The bidders are placing bids (assumedly using BTC, but any on-chain asset will do I suppose)</li>
<li>The 'auctioneer' that orchestrates all of this is some sort of 'smart contract', that sends the winning bid to the seller, the item sold to the winning bidder, and returns all other bids to the non-winning bidders, if necessary. </li>
</ul>

<p>So the 'auctioneer' must be some bitcoin script, that is capable of determining the result of the auction. Here we encounter a problem: Bitcoin script does not allow us to create a transaction which considers the status of other transactions in order to determine how the transaction being created can be spent. In other words, you can't use Bitcoin script to create some logic that says <em>"after some time, forward the largest payment sent to <code>auction_address</code> on to <code>seller_address</code>, and return all other payments to back to the non-winning bidders".</em></p>

<p>The 'smart-contracting' capabilities of Bitcoin Script are intentionally limited, to quote the article you referenced: </p>

<blockquote>
  <p>Bitcoin’s solution to this problem is to simply not have Turing-completeness. This makes the contracts easier to analyze as the possible states of the program are easier to enumerate and examine.</p>
</blockquote>

<p>All of that said, if we do not expect the entire logic of the auction to fit neatly into a single transaction's script, then we can perhaps use some more 'simple' constructions and protocols to accomplish our goal. For example, <a href="https://bitcoin.stackexchange.com/questions/17179/how-to-make-sure-that-bidders-in-an-auction-have-sufficient-bitcoin-without-stor">see this clever answer by Luke-jr</a>. In this case there is no fancy smart-contract used, just financial incentives (to take the highest bid), coupled with consensus rules (a coin cannot be double-spent). <a href="https://bitcoin.stackexchange.com/questions/30607/is-it-possible-to-force-a-person-to-honor-a-conditional-promise-to-pay">This answer elaborates</a> further on this type of construction.</p>

<p>More broadly, and as mentioned in the article you referenced, the <em>oracle problem</em> is a critical consideration: in order to participate in this auction, do you need to trust any third party? If the answer is yes, then it is prudent to consider if using a smart contract is a reasonable approach to solving your problem. For example, if the item up for auction is not a native digital asset, but is instead physically deliverable, then you need to trust the seller to deliver in any case! </p>

<hr>

<p>All this isn't to say that Bitcoin script can't be utilized to create a 'better auction experience'. For example, by using a multi-sig constructions, bidders and auction-houses could enjoy a more trust-minimized set up of certifying and transferring funds to be used in the auction. But 'smart contracts' don't just magically enable us to 'make everything trustless', and indeed in many cases such a thing isn't possible anyways. </p>

<p>Additionally, it is possible to create a protocol that includes a Turing-complete language that runs on top of Bitcoin (eg the RSK EVM you mentioned), but this seems to be outside the scope of the question.</p>

CC BY-SA 4.0
2020-01-07T04:07:20.657Z
2020-01-07T04:07:20.657Z
chytrik
<p>I recently read an article: <a href="https://medium.com/@jimmysong/the-truth-about-smart-contracts-ae825271811f" rel="nofollow noreferrer">https://medium.com/@jimmysong/the-truth-about-smart-contracts-ae825271811f</a></p>

<blockquote>
  <p>Because of a lot of centralized marketing from Ethereum, there’s a mistaken belief that Smart Contracts only exist in Ethereum. This is not true. Bitcoin has had, from the very beginning in 2009, a pretty extensive smart contract language called Script.</p>
</blockquote>

<p><a href="https://i.sstatic.net/eFKxB.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/eFKxB.png" alt="enter image description here"></a></p>

<p>If Bitcoin has smart contracts, I would like to see how to create a simple "hello world" auction - winner wins, those who didn't win get refunded.</p>

<p><em>(I've heard that RSK is EVM-compatible but that's more involved)</em></p>

<smartcontracts>
Simple, default, "hello world" smart contract for an auction? (winner wins, all the rest gets refunded)
Mars Robertson
# Simple, default, "hello world" smart contract for an auction? (winner wins, all the rest gets refunded)

(Asked by: username_0 on 2020-01-06)

I recently read an article: <https://medium.com/@jimmysong/the-truth-about-smart-contracts-ae825271811f>

> Because of a lot of centralized marketing from Ethereum, there’s a mistaken belief that Smart Contracts only exist in Ethereum. This is not true. Bitcoin has had, from the very beginning in 2009, a pretty extensive smart contract language called Script.

[![enter image description here](https://i.sstatic.net/eFKxB.png)](https://i.sstatic.net/eFKxB.png)

If Bitcoin has smart contracts, I would like to see how to create a simple "hello world" auction - winner wins, those who didn't win get refunded.

*(I've heard that RSK is EVM-compatible but that's more involved)*

**Tags:** smartcontracts


---

## 1 answers

### Answer by username_1 on 2020-01-07. Score: 2

> If Bitcoin has smart contracts, I would like to see how to create a simple "hello world" auction - winner wins, those who didn't win get refunded.

Your question isn't clear about the details of how you would expect this to work, so I'll start with some assumptions:

* The seller has put something up for auction. There are two possibilities: the item being sold is a digital asset native to the Bitcoin chain, or it is not.
* The bidders are placing bids (assumedly using BTC, but any on-chain asset will do I suppose)
* The 'auctioneer' that orchestrates all of this is some sort of 'smart contract', that sends the winning bid to the seller, the item sold to the winning bidder, and returns all other bids to the non-winning bidders, if necessary.

So the 'auctioneer' must be some bitcoin script, that is capable of determining the result of the auction. Here we encounter a problem: Bitcoin script does not allow us to create a transaction which considers the status of other transactions in order to determine how the transaction being created can be spent. In other words, you can't use Bitcoin script to create some logic that says *"after some time, forward the largest payment sent to `auction_address` on to `seller_address`, and return all other payments to back to the non-winning bidders".*

The 'smart-contracting' capabilities of Bitcoin Script are intentionally limited, to quote the article you referenced:

> Bitcoin’s solution to this problem is to simply not have Turing-completeness. This makes the contracts easier to analyze as the possible states of the program are easier to enumerate and examine.

All of that said, if we do not expect the entire logic of the auction to fit neatly into a single transaction's script, then we can perhaps use some more 'simple' constructions and protocols to accomplish our goal. For example, [see this clever answer by Luke-jr](https://bitcoin.stackexchange.com/questions/17179/how-to-make-sure-that-bidders-in-an-auction-have-sufficient-bitcoin-without-stor). In this case there is no fancy smart-contract used, just financial incentives (to take the highest bid), coupled with consensus rules (a coin cannot be double-spent). [This answer elaborates](https://bitcoin.stackexchange.com/questions/30607/is-it-possible-to-force-a-person-to-honor-a-conditional-promise-to-pay) further on this type of construction.

More broadly, and as mentioned in the article you referenced, the *oracle problem* is a critical consideration: in order to participate in this auction, do you need to trust any third party? If the answer is yes, then it is prudent to consider if using a smart contract is a reasonable approach to solving your problem. For example, if the item up for auction is not a native digital asset, but is instead physically deliverable, then you need to trust the seller to deliver in any case!

---

All this isn't to say that Bitcoin script can't be utilized to create a 'better auction experience'. For example, by using a multi-sig constructions, bidders and auction-houses could enjoy a more trust-minimized set up of certifying and transferring funds to be used in the auction. But 'smart contracts' don't just magically enable us to 'make everything trustless', and indeed in many cases such a thing isn't possible anyways.

Additionally, it is possible to create a protocol that includes a Turing-complete language that runs on top of Bitcoin (eg the RSK EVM you mentioned), but this seems to be outside the scope of the question.


---

