◀ BACK TO THE POND
ABOUT
ErgoFishing was made to learn ErgoScript, Ergo's smart contract language, not to run a casino. Reading docs is dry; writing a small game yourself, running it on chain, with real players pressing the buttons, is where you meet every corner: where the money sits, who may spend which box, when, and what happens when one side walks away halfway.
Fishing was picked because it needs exactly the hardest parts of a fair contract: both sides put money in, the result is random and nobody knows it in advance, and the money always has a way back when one side stops.
WHAT YOU LEARN
- The eUTXO model. There is no "contract account": every cast is a chain of boxes, Bait → Cast → Revealed, each locked by a script. To move on you spend the old box and create a new one exactly as the script demands.
- Registers. Boxes carry data in R4–R9: the player's key,
hash(salt),hash(secret), the deadline, the bait. Scripts read them withSELF.R4[...]and check that output boxes carry the right registers. - Commit-reveal. The player locks
hash(salt), the house lockshash(secret), and only then are the secrets revealed. The script recomputesblake2b256(secret ++ salt)to pay out: nobody can pick the result. - Contracts chaining contracts. Bait may only be spent into the right Cast (comparing
blake2b256(propositionBytes)with the constantcastHash), Cast only into the right Revealed. So they compile in the order Revealed → Cast → Bait. - Block deadlines.
HEIGHTdecides who may do what: the house must reveal before the deadline, after it the player takes the whole box. This is how eUTXO handles "one side walks away". - Context extensions. To claim, the salt travels in the transaction's
getVar[Coll[Byte]](0)instead of a signature: anyone may send it, and the script only pays the player's wallet. - Sigma propositions.
housePkand the player's key areSigmaProps, combined with plain conditions through&&,||andsigmaProp(...).
The source of all 3 contracts, their constants and how to compile them to check the addresses are at the bottom of the
Rules page. A box-flow diagram is in the project's docs/ folder.
PLAY IN THE RIGHT SPIRIT
- The game uses real ERG and the result is random: on average a cast returns 96.5% of the bait (94.7–96.2% after network fees), so playing long means slowly losing. Treat the ERG you cast as tuition, not as a way to earn.
- Use small amounts: the smallest bait, 0.1 ERG, is enough to watch the whole box flow on an explorer.
- To learn without spending anything: read the source, run the tests (Fleet SDK's mock chain) or deploy it yourself on testnet.
- Do not play if you are under age where you live, or if games of chance are banned there.
BY THE SAME AUTHOR
ErgoFishing is made by @dungvn3000, who also built:
- ErgoDrop: a free ERG faucet, one drop per wallet a day. New to Ergo? Grab a few drops there to pay your transaction fees.
- ErgoFlip: a provably fair coin flip on Ergo. Both stakes go into one smart-contract box and the winner takes all.
- Learn Me An Ergo: Ergo explained for everyone, from boxes and eUTXO to ErgoScript and Autolykos, illustrated with live mainnet data. In English and Vietnamese.
- ergo_php: an Ergo wallet library for PHP apps, built on Fleet SDK. ErgoFishing signs and sends the house's transactions with it.
Want the background before reading the contracts? Start with Learn Me An Ergo.
TECH
ErgoScript (3 contracts), Fleet SDK building transactions right in the browser, the Nautilus wallet signing (the server never holds your keys), CodeIgniter 4 + SQLite on the server, Alpine.js, Tailwind and daisyUI for the interface, pixel art drawn on a canvas, sound synthesized with Web Audio.