Transaction Order Dependence
Why is this important?
Race Conditions can have tremendous impacts in the context of smart contracts. Transaction Order Dependence is a type of race condition inherent to Blockchains and relies on the fact that the order of transactions themselves can be easily manipulated.
Fixing Transaction Order Dependence
A possible way to fix race conditions is by submitting information in
exchange for a reward. This is called a commit reveal hash scheme. Instead of
submitting the answer, the party who has the answer submits
hash(salt, address, answer), where the salt is a number of their choosing.
The contract stores this hash and the sender's address. To claim the reward
the sender then submits a transaction with the salt, and answer. The contract
hashes (salt, msg.sender, answer) and checks the hash produced against the
stored hash, if the hash matches the contract then the reward is released.