ZK Viper Race is an example of a ZK arcade game that uses the NFT project Viper, consisting of cute snakes that wander randomly. In this game you race them and create ZK proofs of your results. Submit results on-chain to record high-scores and win prizes.
ZK Viper Racer is an example of a ZK game that is played off-chain and the results are verified on-chain. This game works like a high-score arcade with a reward for breaking the top score. Put a quarter in the machine and get back a random hash to start your game. Play the game in the browser and generate a ZK proof of the outcome. Submit the proof to the blockchain to confirm a successful play. If you beat the high-score, you take home all of the quarters collected since the last time the high-score was broken.
The project is built with circom, solidity and js. The Viper NFT project was launched in the summer but for this hackathon I took the wander algorith and painstakingly translated it to circom. I used a fork of the 0xparc circom-starter repo to begin. Next I re-wrote the Viper RNG algorithm to use the block hash as entropy so that it would match the outcome of the circom circuits. After testing that the outcomes matched I generated the zk files and solidity verifier. Then I wrote an arcade smart contract that imports the verifier to verify the outcome of the game and whether or not a player wins the big prize. Finally I made a simple front-end that imports the Viper.js package, uses the modified RNG and provides interfaces for the user to play the game and claim the prize.