MoonCats On-Chain Guide

Brooks Boyd
MoonCatRescue
Published in
6 min readFeb 15, 2024

The MoonCatRescue project launched in 2017, which is before such standards like ERC721 and ERC1155 were established to determine what “an NFT” should present itself as. In those early days of blockchain exploration, developers were experimenting with what was possible for on-chain data storage. The original development team for the MoonCatRescue project (ponderware) created a method of compressing the data for each MoonCat down to a five-byte data value. When each individual MoonCat was rescued, and inscribed into the blockchain, all the parameters for what makes that MoonCat unique were inscribed onto the blockchain via that five-byte value.

MoonCats as seen in the original Adoption Center, with their five-byte identifiers

Those five byte identifiers (commonly called the “Hex ID” of each MoonCat) are data-dense and innovative for the time the project was launched, but aren’t that human-friendly. They record the “recipe” needed to recreate each MoonCat’s visual, but not the final product (the image itself). At the beginning of 2022, the ponderware team added five more smart contracts to the blockchain, to make it even easier for humans and other smart contracts to parse the information in the original MoonCatRescue contract. The guide over here looks at the deeper technical analysis of the five-byte Hex ID value, and this guide will take a look at those five additional smart contracts, and what additional data they make available to MoonCat owners and everyone else who wishes to analyze MoonCats a little further.

Five New Contracts

On January 13, 2022, five new smart contracts got deployed to the blockchain: MoonCatTraits, MoonCatColors, MoonCatSVGs, MoonCatAccessoryImages, and MoonCatReference.

What do MoonCat owners need to do to take advantage of these new contracts? Nothing! These contracts have functions that can be queried for information without an on-chain transaction, so MoonCat owners don’t need to take any specific action to activate them.

Those contracts include all the data required to generate your MoonCats. You can ask the MoonCat contract to produce the image file for you, straight from the chain. No centralized servers. No external image links. No IPFS. No nonsense. Your MoonCats are 100% on-chain. Accessories from the MoonCat Boutique have always been completely on-chain, and now with these contracts you can produce MoonCat images from the Ethereum blockchain with, and without the accessories that MoonCat owns.

MoonCatTraits

0x9330BbfBa0C8FdAf0D93717E4405a410a6103cC2

The most data-dense section of the MoonCat’s five-byte identifier is the second byte. It is what the original MoonCatRescue Javascript parser refers to as a MoonCat’s k value, and defines which direction a MoonCat faces, whether it has pale coloration or not, what fur pattern it has, what facial expression it has, and what pose it’s in, all in one byte of data!

Breakdown of MoonCat 1289’s “k” value. Each MoonCat can pull up a fact sheet like this from their Photobooth page on ChainStation

The traitsOf function of the MoonCatTraits contract is the primary function for humans to understand that k value. The four options for fur pattern, expression, and pose have all been given human-friendly names, and this function outputs them as strings, to make them easy to read.

The kTraitsOf function of the MoonCatTraits contract is designed for other smart contracts to absorb. It’s more difficult for smart contracts to compare strings, so this function outputs the values numerically.

MoonCatColors

0x2fd7E0c38243eA15700F45cfc38A7a7f66df1deC

A distinctive part of the MoonCatRescue project are the colors of each MoonCat. Each rescued MoonCat has one color code embedded in their five-byte identifier, which then gets extrapolated through some color math into a palette of five colors for their main image, plus several other colors for accessory complements.

The colorsOf function of the MoonCatColors contract gives a return value that’s a list of 24 numbers. Those are the red, green, and blue values for 8 different colors for that MoonCat, in order. First is their “glow” color (which is the original color code stored in their five-byte identifier), then the five colors used in their base image, finished by two complimentary colors.

MoonCat 1289’s color details

MoonCatSVGs

0xB39C61fe6281324A23e079464f7E697F8Ba6968f

The original parser script for the MoonCatRescue project was a JavaScript script that rendered to PNG images on the MoonCatRescue website. This MoonCatSVG contract assembles SVG images on-demand, to generate the appearance for every MoonCat.

Calling imageOf is the primary use-case for this smart contract, which outputs the SVG data as a text string.

MoonCatAccessoryImages

0x91CF36c92fEb5c11D3F5fe3e8b9e212f7472Ec14

The MoonCatAccessories contract allows anyone to create an Accessory, and includes marketplace functions for buying and donning Accessories, which end users can access via the Boutique web front-end. The Accessory data stored on-chain in this contract is PNG data for each Accessory, but because Accessories can change color depending on which MoonCat they’re attached to, the separate MoonCatAccessories contract was created to combine the previous contract (MoonCatSVGs) with the PNG Accessory data.

The MoonCatAccessoryImages contract has built in the checksum-verification logic that PNG files need, so it can assemble a whole PNG of what an Accessory looks like on each MoonCat. The accessoryPNG function does that, outputting just the Accessory (without any MoonCat) and gives the result as a base64-encoded data URI.

The accessorizedImageOf function combines that Accessory image with the SVG of a MoonCat from the previous contract. Calling the function with just a MoonCat’s rescue order gets that MoonCat wearing the Accessories its current owner has chosen. You can call the function with a list of accessories to preview what that MoonCat would look like if they were to wear that Accessory.

MoonCatReference

0x0B78C64bCE6d6d4447e58b09E53F3621f44A2a48

The on-chain “glue” linking these contracts together. When smart contracts are deployed, they can reference other contracts that exist on the blockchain, but can’t easily reference contracts that don’t exist yet. Also, some types of contracts have text labels for what they are (e.g. ERC20 and ERC721 standards can have name and symbol values, but they’re optional), but not all.

Many block explorers allow humans to submit names, tags, and descriptions for different contracts, but those are not on-chain values. The MoonCatReference contract saves a set of human-friendly text descriptions of smart contracts. Calling totalContracts reveals how many contracts it has annotations for, and calling contractAddressByIndex allows iterating through all the addresses this contract knows about.

Putting an index number or address into the doc function then returns the annotation this contract knows about it. Note that this contract includes information about contracts that were deployed long before it (like the MoonCatRescue original contract), and those deployed alongside it (all the other reference contracts in this article). For all the reference contracts in this article, they were built with a doc function of their own that takes no parameters. When called it pulls the documentation from the MoonCatReference contract, for the contract you called doc on. In that way they can show the developers of that contract consider the MoonCatReference contract a trusted source for information about that contract. That’s the beginnings of a “web of trust” where if you’re not sure if the MoonCatReference contract should be trusted to give an annotation for the original MoonCatRescue contract (because the MoonCatRescue contract doesn’t reference it at all), then you can see the MoonCatReference contract is given trust by other MoonCat-related smart contracts, and you can trust MoonCatReference at least at a friend-of-a-friend level.

Conclusion

These contracts being on-chain, with relatively simple outputs means any block explorer can be used to query the blockchain for this data.

Alternatively, the ChainStation website shows this information for each MoonCat on their profile page under the “On-Chain”.

MoonCat 1289’s on-chain details

If you’re developing your own web application and wanting to use this data, the ChainStation site is open source, and the code for that on-chain tab is over here, if you’d like it as an example for this sort of display.

--

--

Brooks Boyd
MoonCatRescue

Teaching computers / to make art with just some code. / It is what I do.