When I fell into the rabbit hole of crypto, one of the things that captivated me were NFTs, and especially generative art. I believe that generative art has truly found its place in the blockchain and it's an excellent use case for crypto. I find it remarkable how the space has survived the ups and downs of the markets and how it appears that the space is still as vibrant and moving forward.
Without doubt, ArtBlocks is the reference in the generative art space. They've done an amazing job promoting and curating artists. And without them, most probably it would've taken a few more years for the space to reach to the levels it is right now.
I built this site as a final project for the UNIC NFTs And Metaverse course and the Alchemy's Ethereum Bootcamp and as a way to celebrate and appreciate the work that Art Blocks and the artists who published their work through them have done in the past years.
If you get interested in generative art (and more specifically Art Blocks) , there's a few sites that will help you navigate the space:
However, given my technical background, I was especially interested in knowing how Art Blocks works internally: How the Art Blocks contracts are structured, how to access the code behind the collections, and how the art is generated. CodArt allows you to explore the Art Blocks collections, and let you view and play with the code to see how the different outputs are generated.
This is just a quick summary on how the collections and tokens are stored in the Art Blocks contracts. For more detailed information about the different Art Blocks contracts, referer to this post.
All the Art block collections are stored in the same contract. Since its launch there has been three versions of the Art Blocks Core contract:
|AB Core V0||0x059EDD72Cd353dF5106D2B9cC5ab83a52287aC3a||0-2|
|AB Core V1||0xa7d8d9ef8D8Ce8992Df33D8b8CF4Aebabd5bD270||3-373|
|AB Core V3||0x99a9B7c1116f9ceEB1652de04d5969CcE509B069||374-Current|
But how are the different collections stored in the same contract? Let's take the item #195 of Renders Game, one of the latest Art Block collections, as an example. If you open the item in OpenSea and check out the item details or the address bar you'll notice the address of the Art Blocks Core contract, in this case pointing to the latest the AB Core V3. and the Token ID: 415000195. The Token ID is formed by the collection ID (415 which corresponds to Renders Game) and the Token ID within the collection (#195).
Now, we can head to the AB Core V3 contract in etherscan and call the tokenURI function with the token ID 415000195. We'll get an address on the Art Blocks API pointing to the JSON file holding the token metadata (including the URL to the still image of the item), which is what OpenSea uses to display the token information:
Both the token metadata and the link to the image are hosted on the Art Blocks servers. Some may argue that Art Blocks could use a decentralized storage like IPFS to store this information, but in reality, and this is something specific for generative art NFTs, even in the case that the Art Blocks servers become unavailable, the code to be able to reproduce the image will be still accessible on-chain. This is a good post about Art Blocks and decentralization if you're interested in this topic.
So how can you access the script and the token hash (the random number generated at the time of minting that will produce the unique output)? Back to the AB Core V3 contract in etherscan, we can retrieve the collection script and the token hash with the functions tokenIdToHash and projectScriptByIndex respectively:
Generally, the script includes a placeholder for the token Hash (you can search for tokenData in the script). Also, the projectScriptDetails function returns the library used by the project:
And that's all the information you need to be able to recreate a specific output for a given token ID. With a simple html page, you could import the required library, the script from the collection and the token hash, and generate the output as seen in OpenSea.
It's worth noting that the majority of the projets use p5.js:
CodArt allows you to explore the Art Blocks collections, retrieve and run the scripts associated with the collections and see the different outputs for the tokens minted.
With CodArt you can also create and deploy your own generative art collections, either based on an existing collection, or writing your own scripts from scratch.