Example: a public puzzle answer
A contract pays the first account to submit the correct answer:- A user broadcasts a transaction containing the answer.
- The block producer sees the answer before executing the transaction.
- The block producer creates a transaction with the same answer and orders it first.
- The copied transaction claims the reward; the original solver receives nothing.
Use commit-reveal
Commit-reveal hides the answer until every participant has committed: The commitment binds the answer to a secret value that only the user knows. A copied commitment is useless because the observer cannot reveal the secret. Bind the commitment to the account and round, set deadlines for both phases, and define what happens when a user does not reveal.Other mitigations
- Use batch auctions or fixed clearing rules instead of ordering by arrival.
- Set slippage limits and deadlines for price-sensitive operations.
- Randomize allocation only with an appropriate randomness design.
- Add deposits when failing to reveal creates costs for other participants.
- Use private submission infrastructure only if its trust assumptions fit your application.
Review before deployment
- Search for rewards based on being first.
- Assume pending arguments and expected state changes may be observed.
- Test copied, reordered, delayed, and replayed transactions.
- Make ordering, tie-breaking, deadlines, and cancellation behavior explicit.