# CryptoHorses zkRollup This post comes in two parts. The first here as text. The second at devcon as a workshop. We hope that the combined format will help get people building with these tools. ## introduction We are using s[nt]arks to create state transitions. This allows us to build simple transfers and even atomic swaps. These applicatoins are build using r1cs to create “circuit” that validates the state transition. These cuiruits are very good at doing repeditive things. But are very bad at doing programable things. So for example its very expensive to create a snark that contains a while loop. Because you have to include every execution of your whileloop in every proof. Not just the one where you want to go follow that branch. The gas limit has enforced a similar limit on the complexity of smart contracts. To the point where specialize operations have to be added for cryptographic primitives. One way to mitigate this limitaion in smart contract land was to functionalize your program. Have uniqe functions you could call to perform certin state transitions. For exmaple you would have your breed operatoin in crypto kitties. Here we propose applying the same patterns to developing zkrollups for unique applications for zkrollupsique applications for zkrollups ## Application Let's try to get cyrptoHorses to work without filling up ethereum main chain using zkRollup! #### Leaf Structure Leaf structure can contain the following: - PubKey: Pubkey of user - State of horse: IsBreeding(0), IsCoolingDown(1), IsOnAuction(2), IsResting(3),IsIdle(4) - Horse DNA : Representation of horse via bytes, each bit represents a feature of horse. For example: Fur color So each leaf is (PubKey, State,DNA/ID) ### Possible functions Each function is a sperate snark - AddHorseToAuction(): Adds the kittie to auction for siring - Breed(cat1Index, cat2Index): Breeds two horses and creates new horses by XORing(or something else) the DNA. - SwapHorses(): Swap horses using dependant transactions. Questions: - Will each leaf only hold one kittie at a time? Kittie and erc20 balance cos you need to pay fees.