I has made some scripts to make a onchain bet system.
Sites like satoshibones or satoshidice are "OnChain" sites, that means; when we send our bet to a addy, an algorithm will deduct if that transaction its a winner, and then, payment will be made.
My script monitors a bitcoin address, every time that addy has a income transaction, the script takes the ID and with the secret sha256 it generate a random sha256 code, then change the last 4 digits from hex to decimal and if the num its lower than "X" the incoming transaction its a winner and get the profit payment.
In other words the script:
1.-Read the income transactions to a address
2.-Generate a number from the TX id
3.-Validate if the number its a winner
4.-Make the payment if the transaction its a winner
5.-keep monitoring the bitcoin address for new income transactions.
Output:
Tx id: 651c2000e4dff18365c8e4fc56a1b2031a32622c46a644569992348d6ae38106
Bet 0.001
Bettor: 1BtcBiGMcjo775hFYh5JLB9Jmzmv9uDEo
secret: 63e3e5972bfa21e9cf84a546fc1f5f624eab46ddcf0c602098cf2feaaca78b53 -
sha256: 651c2000e4dff18365c8e4fc56a1b2031a32622c46a644569992348d6ae38106:sato:63e3e5972bfa21e9cf84a546fc1f5f624eab46ddcf0c602098cf2feaaca78b53 -
Validation: 4b23940623e82ba2bdda7511741b8b9071b808bcf13da7664eae118e0c6aed2b -
Last 4 Digits: ED2B
Bet: 60715
***********************
60715 > 32750 Lost Bet
***********************
If some one is interested in buy this code, PM me and i can make a demostration of how it works.