Rocket Race, under the hood
The tour keeps it simple. Here is how a fair course actually gets made, written to be readable by anyone, with deeper asides for those who want them. The same ideas power every game in the arcade.
Verifiable randomness
beginnerLots of games need randomness: a race course, a card shuffle, a loot drop. On a blockchain there is no Math.random(), and the easy sources are unsafe, a block hash or timestamp can be nudged by the validator producing the block, and anything already on-chain can be read and exploited before you act.
The fix is commit-reveal randomness: each participant locks a secret (publishing only its hash), and once everyone is committed they reveal. The shared result is the hash of all the secrets, so no one party can predict it or steer it.
Lock two secrets, then reveal to see the course they produce:
Both players locked in a secret and published only its hash. Neither can see the other's.
Commit and reveal
beginnerA commitment lets you lock in a secret now and reveal it later, with two guarantees:
- Binding: you can't change what you committed. Any change to the data changes the root.
- Hiding: the commitment (just a hash) reveals nothing about the data.
You publish the root up front. Later, when challenged, you reveal a specific piece plus its Merkle proof. The other side checks the proof against the root you already locked, so you can neither lie about it nor have changed it.
Hashing
beginnerA hash function takes any data, a word, a file, a whole game board, and returns a short fixed-size fingerprint. These games use keccak256, which always returns 32 bytes (64 hex characters).
Three properties matter:
- Deterministic: the same input always gives the same hash.
- One-way: you cannot run it backward to recover the input.
- Avalanche: change one bit and the whole output changes.
Same input, same output, every time (deterministic). Change a single character and the whole result scrambles (the avalanche effect), and there is no way to run it backward. That is what makes a hash a tamper-evident fingerprint.
The honest part
We're upfront about the trust model and what is still to come:
- The real subtlety is the last revealer: whoever reveals last sees the seed first and could refuse to reveal a course they dislike. The standard fixes are a stake they forfeit for bailing, or a VRF that removes the choice entirely.
- Verifying that a posted time is a real, human run (not a bot or a sped-up replay) is its own problem. The usual approach records your live inputs as you fly the revealed course, then re-simulates them to confirm the time. Your inputs are always made in real time against the course you can see, the recording is just the receipt.
- No contract is deployed yet. This is the teaching tour; the playable, on-chain race is the next build.
Want the building blocks on their own? They live in the crypto encyclopedia, shared with every other game.