Drawing with MATH
So, it’s-a-me, Mario.
You might be asking yourself, how did the world’s favorite plumber find himself as tokenized pixel art on the blockchain?
The story begins with MATH…
If you’re new to the tokenized asset/Nifty/NFT space — here’s a good article to get you up to speed. Also, join the TokenSmart Discord server and ask lots of questions.
Assuming you’re up to speed with some projects like CryptoKitties and CryptoPunks– you may not be aware that 2020 has issued in a lot of new experimental projects, particularly around NFT art-on-chain — the idea that you can store the entire image data on the blockchain, not just a reference to an image stored in the cloud.
Alex Hansen found the essence of simplicity in creating the MATH token under a simple premise– starting with the number 1 the token only does one thing, add 2 tokens together. So with 2 of MATH #1, you can create MATH #2. Combine MATH #1 and MATH #2 and you get MATH #3.
This simple premise took off, and people made some fun numbers like 42 and 1973 — Alex and the community soon realized that the limit these numbers, imposed by the Ethereum blockchain, is 2²⁵⁶-1.
A very big number. So big, in fact, if you write it in binary, you have 256 digits. If you wrap that number every 16th digit, you get a 16x16 grid of 1’s and 0’s — which is essentially a bitmap image.
In other words, you take a huge number like 25882832319781335299281632399333714574812225552588534835121392925540352 and get this smiley face:
Of course, trying to figure out how to create that huge number using smaller numbers might seem like an impossible task– unless we use a trick of binary algebra.
If you take a number 4, written in binary as 0010, and a number 1, written as 0001 — you get a sum equal to 5, written as 0011.
In other words, we can add powers of 2 together and fill individual pixels in our 16x16 pixel canvas.
I started out by generating all the powers 2 from 2⁰ to 2²⁵⁵ and then plotting them out an adding them to a running sum. To help other people do the same I made this handy spreadsheet visualizing a grid as powers of 2.
What is brilliant about the MATH NFT is that it neatly contains a lot of benchmark goals for art-on-chain:
- Composability — you can build bitmaps in parts and add them together.
- Commission— when you use someone else’s token, they receive the share of the minting fee.
- and of course the data is 100% on-chain, stored in the Ethereum smart contract.
In fact, this is all so early on the adoption curve that most of these projects haven’t finished their front-end dApps yet, and you need to access the contract directly.
I quickly realized that I was still too far down the rabbit-hole for people to follow, so I spent the weekend building a little tool to make it easier to build these images:
This should make it a little bit easier to plan out your drawings, and make it MUCH easier to queue up all the transactions using Metamask. (Don’t expect this to be a robust, tested solution.)
In the meantime, Alex was busy developing the next token, RGB – which uses MATH tokens as the building blocks.
How it works is that each RGB token is comprised of 3 MATH tokens representing the Red, Green and Blue layers. So if you were to put MATH #1 as the R-input, MATH #2 as the B-input, and MATH #4 as the G-input, you’ll get an RGB token with 3 pixels in the lower right corner, in the order Green-Blue-Red. This is because your layers are red: ‘0001’, blue: ‘0010’ and green ‘0100’ — each selecting a single pixel in the 1st, 2nd and 3rd place.
If you overlap colors, say putting a Red+Blue pixel — you’ll get Magenta. If you put all 3 colors, you get white. This will be familiar if you’re used to how colors work in HTML (additive) and you imagine that each pixel is assigning #FF in either the Red, Green or Blue position.
So if we deconstruct Mario into MATH parts — we can visualize it like this:
So there you have MARIO as 3 numbers:
- Red: 3505534788953441127217108406357731511454943793610692823818814811810410544188
- Green: 171151305508365566126104247414104006394195327934990612833853505536
- Blue: 1671884002823208311126590451900793274192229870315562875448341823488
And the great thing about composability is that, you can change the order of the images around (with a few tweaks to the Blue image because you can’t use the same MATH token in the same R/G/B slot twice) … and you get Luigi!