This is why there is a slight delay when you wait for your next matchup after voting on the discord app - we are creating the next custom image, just for you!
For the Mundo-A-Mundo discord app, the biggest challenge was not navigating the discord bot creation process, or the myriad of permissions to decipher.
The main issue was getting 2 equal sized images in a single message!
I am lazy, which makes me a motivated engineer.
The answer is to create an image whenever one is needed. I created a hosted api route and had that api take in the 2 tokenids and create the image of the 2, side by side and the right order as it was needed.
From this code snippet you can see it is actually quite straightforward once you have the 2 images (from response 1 + 2).
This mechanism to dynamically generate pricing for an NFT in real-time may well be something we use in the future.
Treated correctly, side-quests and engineering cul de sacs are not necessarily wasted code. They are educational and while they certainly can eat up precious time in the short term, they can be leveraged for good in the long.
Within software development, there is an understudied topic on what some experts call software waste, which is to do with code that never makes it into production. I personally do not see this as waste, it is all part of the meandering nature of system engineering, even within traditionally structured models of development.
There is seldom a direct line between the start and the finish in delivering products, only hindsight has this property. The Del Mundos are no different.
One interesting side quest for the Del Mundos was the concept of off chain signing.
We then can check that signer and make sure they are the one we expect. If the data does not match the signature, is on a different chain or not aligned to the specific contract, this all fails.
The result: a self-maintaining top-90 leaderboard that sorts in O(n), auto-refunds losers trustlessly, and handles hot/cold wallet delegation without leaving stale data behind. All in ~60 lines of Solidity.
This is only really possible on the latest iterations of Ethereum where the gas price is at historic lows.
Testing showed that this approach works well enough for gas usage to keep the gas price for even a #1 bid in a full 90 array down to a small % of expected bid values - ie the most gas used possible.
This all means that our choice of Ethereum as a blockchain has been justified not just for the DelMundo NFTs, but for the wider Del Mundo and Climeta ecosystem.
How to manage a top 90 bid list on Ethereum?
The Editions 001 auction had a winnerList - an array of the top 90 bidders, kept in descending bid order at all times. Every time someone bids or is bumped, a function is called to keep it clean.
Let's break down this function: _updateBidderList, a piece of code that manages a live ranked list (and does the automatic refunds described in a previous post).
To add in the new bid, we use a tried and tested in-place insertion.
We push a placeholder to grow the array by one, then shift everyone from the tail up to the insertion point one slot to the right and then just drop the new bidder in.
If the list is now longer than maxWinners, the last entry just got outbid.
Their bid is cleared, their vault mappings are wiped to prevent stale state, and their ETH is refunded immediately β or queued for manual withdrawal if the transfer fails as previously described.