<p>You can't.</p>
<p>Bitcoin Scripts have no access to the block hash, and cannot determine if it is odd or even. You would need an external oracle for this.</p>

CC BY-SA 4.0
2020-08-01T14:27:27.093Z
would it be possible to do so in the future? cause all the data for oracle decision making will be available in the bitcoin blockchain.
Cisco Mmu
CC BY-SA 4.0
2020-08-01T20:45:16.827Z
@CiscoMmu you would need to write code that does this (new OP codes), and then convince the vast majority of users running nodes to run your code (soft fork the network). If the benefit is just 'gambling on the blockchain', I kind of doubt users will be willing to change the protocol for it.
chytrik
CC BY-SA 4.0
2020-08-02T05:55:38.467Z
ok TQ TQ! well, users kind of hard to be convinced.
Cisco Mmu
CC BY-SA 4.0
2020-08-01T04:11:23.730Z
2020-08-01T04:11:23.730Z
Raghav Sood
<p>User1 bet the hash of Block 999,000 that hash(block(999,000) = even</p>
<p>user2 bet the hash of Block 999,000 that hash(block(999,000) = odd</p>
<p>Both users pay/sign 1 BTC in a CoinJoin for that bet to a P2SH. The winner will win 1.99BTC and 0.01 BTC is the tx fee.</p>
<p>How to make the scripts that can perform such action?</p>
<ol>
<li><p>Script1 that perform the betting section.(that specify the criteria for redemption).</p>
</li>
<li><p>Script2. Redeem script (based on the output of block 999,000) that transfers the fund to the winner new PubKey Hash.</p>
</li>
</ol>

<oracle>
Betting using Bitcoin Blockchain
Cisco Mmu
# Betting using Bitcoin Blockchain

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

User1 bet the hash of Block 999,000 that hash(block(999,000) = even

user2 bet the hash of Block 999,000 that hash(block(999,000) = odd

Both users pay/sign 1 BTC in a CoinJoin for that bet to a P2SH. The winner will win 1.99BTC and 0.01 BTC is the tx fee.

How to make the scripts that can perform such action?

1. Script1 that perform the betting section.(that specify the criteria for redemption).
2. Script2. Redeem script (based on the output of block 999,000) that transfers the fund to the winner new PubKey Hash.

**Tags:** oracle


---

## 1 answers

### Answer by username_1 on 2020-08-01. Score: 1

You can't.

Bitcoin Scripts have no access to the block hash, and cannot determine if it is odd or even. You would need an external oracle for this.

> **Comments:**
> **username_0**: would it be possible to do so in the future? cause all the data for oracle decision making will be available in the bitcoin blockchain.  
> **username_2**: @username_0 you would need to write code that does this (new OP codes), and then convince the vast majority of users running nodes to run your code (soft fork the network). If the benefit is just 'gambling on the blockchain', I kind of doubt users will be willing to change the protocol for it.  
> **username_0**: ok TQ TQ! well, users kind of hard to be convinced.  

---

