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:
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.
it was a fun project 😊…
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?
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…).
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.
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:
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
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…