Nebulaeth

Published: 2/19/2022

Nebulaeth started as an experiment focused on going deeper into generative SVGs. There were a lot of variations along the way before turning to on-chain SVGs.

Things all began in-browser. A simple api built with NextJS that could use unique url paths as a seed. Messy code available here: https://github.com/iammatthias/globs.

loading...

You can generate new globs by changing the number in the url path: https://globs.xyz/glob/1.

Next up was getting the hex colors from an eth address. Since an address is 42 hexadecimal characters, you can get 7 color codes out it. Only caveat is that you need to replace the x at the start with one of 0123456789abcdef.

loading...

You can generate your own unique sphere by changing the address in the url path: https://globs.xyz/sphere/0x429f42fb5247e3a34d88d978b7491d4b2bee6105.

When I started to put it all together to form the basis of Nebulaeth the project was still looking at in-browser SVG generation.

loading...

You can mess around with the original implementation by changing the address in the url path: https://globs.xyz/nebula/0x429f42fb5247e3a34d88d978b7491d4b2bee6105.

I built a standalone rough front end with WAGMI, got wallets to connect, and then ran into a problem. Writing the SVG to the chain from the browser was a massive and unpredictable transaction, and was more likely to fail than to succeed. On top of that, the cache was misconfigured, allowing the results to expire any time a component reloaded. The contract is on Rinkeby (unverified), and the front end can be explored here: https://nebulaeth.vercel.app/. Do not try to mint this. It is on a testnet, and everything is broken. You can preview the nebulaeth, though!

loading...

This is when I started looking at on-chain SVG generation. I had messed with the concept a bit to build Alchemical, a Loot derived messabout that never saw the light of day.

Somewhere along the way I came across gwei-slim-erc721, and soon I had the Loot svg renderer I had used for Alchemical in a new contract. The pieces were all coming together.

loading...

Nebulaeth is now fully realized. The entirity of the NFT is generated on-chain—the SVG and the metadata. Randomness is derived from the current block number, plus @jemgold_'s Epochs: https://epochs.cosmiccomputation.org. The current epoch is called on-chain, and determines the positioning of the stars, the dithering of the nebulaeth, and the variation in its form. All string manipulation, include parsing the minter's eth address to color codes happens on-chain.

This was a wonderfully fun project. I learned a lot through the process, and discovered new oddities I would like to explore.

loading...