Create a Simple Blockchain Gambling Game
A computational contract can be as simple as a piece of code, triggered by a specific event, that interacts with a blockchain. Blockchain transactions can be prepared and signed off-chain and kept in that state until submitted to the blockchain when conditions are met.
This example demonstrates how to prepare a Bitcoin transaction that will be submitted to the testnet blockchain triggered by a weather query, gambling that the temperature in Lima, Peru, will never exceed 33 Celsius.
First create a transaction that on output sends bitcoins to a specified address.
Sign the transaction with a private key.
Create a scheduled task that checks the temperature in Lima each hour and submits the transaction if the temperature rises above 33 Celsius.