1

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.

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.

| improve this answer | |
  • 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 Aug 1 at 14:27
  • @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 Aug 1 at 20:45
  • ok TQ TQ! well, users kind of hard to be convinced. – Cisco Mmu Aug 2 at 5:55
1

Discreet Log Contracts can solve this problem. I confirmed in a meeting today. To discuss implementation details please join slack channel where dlc and p2p derivatives are being discussed.

Reason: No access to block headers from script.

I was assuming miniscricpt might help with some workaround but it just makes it easier to write script and doesn't add anything extra in terms of functionality.

| improve this answer | |
New contributor
Prayank is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.