on my on-chain generative erc-721

tl; dr

today i go over the smart contract i created two years ago for a nft collection celebrating the sunset of filmmaker dao.

it was called theย โ€œstorytelling cardโ€, and folks were able to generate their unique nfts on the fly by inputting an int up to 1337:

.the collection is still alive at generativestory.com.
.the collection is still alive at generativestory.com.

my contract was loosely based on the loot project, and it deployed a (sort of) generative erc-721 collection in the ethereum mainnet (for the cost of ~$2k or so). here is the source code.

.377 peeps hold my nft; that was pretty cool.
.377 peeps hold my nft; that was pretty cool.

it was a fun project ๐Ÿ˜Šโ€ฆ


๐ŸŽถ todayโ€™s mood


can you guess how these nfts were generated on-chain?

the idea of this collection was to create unique, randomized, and limitless narratives generated and stored on-chain, as a novel approach to storytelling.

here are some of my favorites:

do you see the pattern?

if you are an engineer, could you guess how these cards were (pseudo-)randomly generated?

the smart contract

long story short, the dao was about to dissolve because our investor backed off. so this project was my farewell token for the community.

for this reason, i wanted the contract to be immutable and self-contained. there was no reason to deploy it on a proxy, because it wasnโ€™t supposed to be upgraded. andโ€ฆ there was no payable function.

yeap, you read it right: the contract was not for profit. part of the narrative was that it was never meant to be cashed out (sort of an easter egg - but also the sort of thing you only do once in life and during a bull marketโ€ฆ).

.mev burning.
.mev burning.

i also remember that the contract size limit hit hard during my first attempt to deploy it to the ethereum mainnet (or when i was testing it on rinkeby). i had to move things around to fit the size limit of 24577 bytes. i customized (and consequently, prettified) every canonical library before everything was imported.

.note to self: stop slacking with the commit messages.
.note to self: stop slacking with the commit messages.

and, off-course, i needed a nice intro =p:

now, the contract was a pretty straightforward erc-721 instance, with the sale price intentionally hard-coded:

the magick trick was carried out by ten arrays that would mesh together, creating the narratives: genres, medium, cities, archetypes, verbs, objects, titles, adjectives, locations, and, of course, colors.

the pseudo-random function was very simple and predictable, with the tokenID as the input string:

to create a cardโ€™s generative SVG image on-chain, a function called tokenURI was crafted, outputting an array composed of one element of each of the sets above, plus some image customization (this part needed some work):

the last pieces of the contract were the mintCard and ownerClaim methods:


deploying the contract

at that time, foundry wasnโ€™t a thing, so i used hardhat.

here was the config file (with PRIVATE_KEY , API_ENDPOINT, API_ETHERSCAN in an .env file):

if you are not a blockchain developer, donโ€™t worry, all you would need to do to compile the contract was:

npx hardhat compile

and then deploy with a simple javascript script:

npx hardhat run scripts/deploy.js

another easter egg

all right, here is some teasing, my dear anon.

if you are puzzled about how i ended up writing this collection for filmmaker dao, here is how everything started, during the bull of summerโ€™21โ€ฆ

crypto can be wildโ€ฆ


โ—ป๏ธโ™„

Subscribe to go outside labs
Receive the latest updates directly to yourย inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.