Here i have one questions, as i have been told, every btc transation code (hash) is random and uncalculatable.
For example, transation 467c33cc084ce12cfafbb59f45ba5b414dfe7d061bbe121093bb5e3dc16f2e44, will it be possible for us to calculation the first code '4' or any other codes before we send this transation?
We are working on a BTC project right now and your answer in details would be much appreciated and important to us.
If you know the contents of the transaction (and you don't have the transaction hash), then you can calculate the entire transaction hash.
If you have the transaction hash (and you don't have any of the contents of the transaction), then you can not calculate any of the contents of the transaction.
Until you have all the contents of a transaction and calculate the hash, it is impossible to predict what any of the numbers of the hash will be.
If a person wants to create a transaction hash that starts with (or ends with) a particular set of characters, then they can generate a transaction without broadcasting it and see if it starts (or ends) the way they want it to. If it doesn't, then they can discard the transaction, and create a new slightly different transaction to see if it starts (or ends) the way they want it to. They can repeat this process until they get a transaction ID that they like, and broadcast that transaction to the network.
We are working on a game based on the hash prediction, what u explained that means we have to abandon this project... could we have any other way to avoid this being happening?
Avoid what happening?
Generally "provably fair" systems require 2 pieces.
The game provider generates a list of random information before the game starts. They keep this list private and secret. They then calculate the SHA256 hash of each of the elements in the list, and publish the list of SHA256 hashes. As long as the random information is large enough, it is impossible for anyone to figure out what the elements are from the published hashes.
Then the transaction ID from the player's transaction is combined with an element from the secret information (for example with concatenation), and a hash is calculated from the combined user transaction AND game provider secret. The value of the resulting hash is the information that is used to determine the outcome of the game.
Since the player doesn't know what the secret information is, they can't know if their transactionID will win until after they submit the transaction to the network. Since the game provider doesn't know what the player's transactionID will be, they can't know if the player will win until after the player submits the transaction to the network.
Then after the results of the game are determined, the game provider can publish the secret value that they used. This way everyone can calculate the SHA256 hash of that secret and compare to the previously published list of SHA256 values. That way the game provider can prove that they generated the "random" secret BEFORE the player submitted their transaction.
Many thanks for your quick reply. We are now working on a betting game based on the btc transation code. As you know, every hash has number 0 to 9 and letter a, b,c,d,e,f. We consider a as number 10, b as 11, c as 12, d as 13, e as 14 and f as 15, then we have 0 to 15, totally 16 number, if player bet the first hash number is below 8, and the result comes out is b/w 0 and 7, then they will have 2 time of what they bet back.
As u mentioned, 'If a person wants to create a transaction hash that starts with (or ends with) a particular set of characters, then they can generate a transaction without broadcasting it and see if it starts (or ends) the way they want it to. If it doesn't, then they can discard the transaction, and create a new slightly different transaction to see if it starts (or ends) the way they want it to. They can repeat this process until they get a transaction ID that they like, and broadcast that transaction to the network.'
is that means our game is very risky coz player can get the transaction ID that they like...?