Deep dive: eZKasino, fully-proven blackjack

The Hyli testnet includes, of course, an eZKasino: a fully proven game of blackjack, complete with a Windows XP interface, just because we can.

Deep dive: eZKasino, fully-proven blackjack

The Hyli testnet includes, of course, a gambling den: a fully proven game of blackjack, complete with a Windows XP interface, just because we can. Here’s a deep dive into the technical choices we made when building this trustless onchain game.

At one glance

Purpose Gambling, the true crypto experience
Proof systems Risc0
Key Hyli feature Pipelined proving
Source code https://github.com/hyli-org/ezcasino

How eZKasino works

Fund your wallet

Use the Hyli wallet to put tokens on your gambling table via the faucet.

Play blackjack

image.png

When the player requests a new card by clicking on «hit», a blob transaction is created, indicating that they have indeed requested a new card. This blob is sequenced.

The sequencing info includes a transaction hash: eZKasino uses it to generate a random number and update the state of its transaction. Then, the flow breaks in two thanks to pipelined proving.

On the one hand, the state is optimistically updated on the back-end, and the dealer adds a card to the blackjack game as requested without having to wait for the proof generation.

On the other side of the flow, eZKasino is working hard: the proof, generated in Risc0 by our partners at RISC Zero, verifies that the game logic used the transaction hash as its source of randomness and that the card dealt corresponds to that input. Hyli verifies and settles the transaction.

Each action results in a signed blob that's sequenced and executed optimistically. In parallel, a Risc0 proof validates the move. Once the proof is verified by Hyli, the new balance on the user's wallet is settled on Hyli and updated in the Hyli wallet.

Win (or lose)

When the game is finished, a proof of whether the game was won or lost is generated and settled on Hyli.

When the user has proof of winning, they receive $VIT to heal sick Hyligotchi and reclaim their $ORANJ; when they lose, they receive nothing.

What Hyli brings: seamless user experience with pipelined proving

If you’re proving every single card draw, you’ll need a smooth UX. That’s what Hyli offers: with pipelined proving, you can keep playing and verify the validity of the draw later instead of having to wait for every proof to be generated and settled.

The two steps of sequencing, followed by settlement, also allow for the random factor we’re using. You receive a transaction hash when the draw is made, and we can use that hash as an input for the proof transaction itself.

Outside of pipelined proving, there’s the simple question of composition. eZKasino uses the chain’s native token $ORANJ. There’s no bridging, no obstacles. Moreover, we’re using the Hyli wallet for all the minigames in the Hyli testnet: you get $ORANJ from the faucet, bet it in the eZKasino, and receive precious $VIT when you win. And, of course, they don’t even need to be written in the same language or use the same proving schemes! Native cross-contract composition is simple and powerful.

Finally, a simple upside to building a game like eZKasino with Hyli is that there is no learning curve. You get to write your game in Rust, slap a zkVM on top of it, and get going.

Fun fact: the eZKasino team won our very first internal hackathon. It’s only gotten better since then!

The Hyli testnet is currently live! You can play eZKasino at hyli.fun if you have an invite code or start building your own apps right now.