Published: January 19, 2023
7
20
62

A technical exploration of @1337skulls and the possibilities enabled by the combination of CC0 and on-chain NFTs. โ›“๐Ÿ’€๐Ÿงต 1/20

Image in tweet by wkm

CC0 licenses make it possible for culture to spread through new extensions. By allowing others to use, build upon and share creative works without copyright restrictions, it enables the growth and evolution of culture. https://a16zcrypto.com/cc0-nft... 2/20

Combined with fully on-chain NFTs, it becomes possible for other smart contracts to build directly on top of the original source. As we saw in the world of DeFi, composable building blocks are one of the superpowers of web3. 3/20

Through the combination of CC0 and on-chain art, we are able to use composition in the context of NFTs. Projects like @lootproject, @nounsdao or @chain_runners spawned many derivatives that built directly upon the logic and data from the original collection. 4/20

I took inspiration from CRISPR Lab by abranti, which allowed you to create runners with custom DNA sequences, to explore the possibilities of something similar within the context of 1337 skulls. 5/20

The 1337 skulls collection was created through @Indelible_Labs, a no-code on-chain NFT creation platform by @0xHirsch. Several of the techniques in the contract are inspired by @chain_runners and @AnonymiceNFT with some differences. 6/20

Many on-chain pixel-art projects store image data as a sequence of pixel colors for each trait, often limiting the color palette to reduce the number of bytes needed for each pixel. @nounsdao uses additional compression techniques like run-length encoding and DEFLATE. 7/20

Trait images for 1337 skulls are stored on-chain as PNG and GIF, together with their MIME type. Instead of turning a sequence of pixel colors into a grid of SVG rectangles, images for different trait layers can be rendered as SVG backgrounds through CSS. 8/20

The advantage of this technique is that these images use advanced compression techniques that don't require on-chain decoding in order to be rendered. This results in cheaper storage costs and reduces the complexity of combining trait layers into the final SVG element. 9/20

One downside is that you don't have easy access to pixel color information on-chain which would allow you to take the color palette from your token images or individual traits and reuse them in other contexts. 10/20

Trait selection is heavily inspired by Anonymice, but with one key difference. A random seed is generated during contract deployment, determining the traits of the entire collection. This method guarantees exact control over the trait distribution within the collection. 11/20

Trait frequencies are stored in a long array, and the trait selection algorithm will scan through this array one by one in order to pick an element according to the defined frequencies. When a collection has over 600 possible traits, this requires a lot of storage reads. 12/20

Traits are sorted according to rarity, with the rarest options first. This results in an average of 540 SLOADs, each costing 2100 gas, to calculate the traits of a specific token, which is over 1 million gas, making this very expensive to use during transactions. 13/20

One option would be to simply reverse the order of traits so you don't need to traverse as much of the array, although it doesn't solve the worst-case scenario. A better option would be to store the cumulative trait frequencies and use a binary search. 14/20

A specific combination of traits is represented as a hash string, similar to the hash or dna sequences that we see in Anonymice or Chain Runners. Each section of 3 digits specifies the index of the trait for that layer. 15/20

For example the hash 052151119080067128 means the first layer, 5p3c141, has trait index 52 (n0n3), the second layer, 0v32, index 151 (h00d 0ff wh173) and so on. As traits are sorted according to rarity, lower indices indicate rarer traits. 16/20

The contract provides methods to query the image data and trait information for a given layer and trait index. This makes it possible to reuse individual traits in other contracts without data duplication. 17/20

The contract also provides methods to generate SVG images or metadata given a custom (valid) hash. This allows you to take your own hash creation logic, like CRISPR Lab, and generate new skull combinations using only the logic and data defined in the 1337 skulls contract. 18/20

I have used these techniques to create https://c215p2.xyz, which lets you select individual traits, generates the hash for that trait combination and calls the 1337 skulls contract to get the resulting SVG image. 19/20

While this is just a frontend to explore new and interesting trait combinations, the next step is to take some of these ideas and build an on-chain extension that hopefully drives attention and value to the original collection in true CC0 fashion. 20/20

@wakemi18 @1337skulls nice! can i ask how you are serving the image data for the front end? is it calling direct from the contract each time i random for example?

@WhenLambo6135 @1337skulls Each time you press random or change a trait, I calculate the new hash and call the hashToSVG method on the contract, which returns the svg as a base64 encoded data uri.

@wakemi18 @1337skulls This is great!

@wakemi18 @1337skulls Great thread, v32y 1337 0f y0u 70 5h423

@wakemi18 @1337skulls Very 1337 thread ๐Ÿซก

@wakemi18 @1337skulls The @Indelible_Labs method to have all trait data accessible on-chain is amazing! And allow for our little experiment in on-chain composability. We have an overarching rendering contract that composes traits from different collections. Powered by #onchain #cc0

Share this thread

Read on Twitter

View original thread

Navigate thread

1/26