Wolfram Language

Use Contracts to Explore CryptoKitties Genome

The Wolfram Language makes it easy to interact with contracts on blockchains. This example exploits this functionality to sequence the genomes of a CryptoKitty and its parents. A visualization of the these sequences illustrates gene inheritance.

CryptoKitties is a video game developed by Axiom Zen that operates on the Ethereum blockchain. Players can buy, sell, collect and breed different types of unique virtual cats. Each CryptoKitty has an ID and a genome. The virtual phenotype is manifested as attributes called cattributes that can be passed down from the parents to next generations.

Start by extracting the CryptoKitties contract address.

Use BlockchainContractValue to call the getKitty function of the contract on the CryptoKitty with ID 949502.

From the different data fields about the CryptoKitty, extract the genes and parents' IDs.

Now retrieve the genes of the parents.

Genes are encoded using the game's Kai-notation, which is a single-letter Base58 representation of the integer value of 5-bit segments. The following function converts the integer representation to a list of genes, using the fact that there are only 180 bits currently in use.

Get the genes of the CryptoKitty and its parents.

Isolate the distinct genes present in the CryptoKitty and its parents.

Create color rules for each gene.

Finally, generate an ArrayPlot of the three sequences. Each group of four genes defines a cattribute that can be interpreted according to the rules of the game.

Related Examples

de es fr ja ko pt-br zh