Discover more from smol farm gazette
RTFKT's Engineering Failures
A basic-level mistake in Nike-owned RTFKT's latest smart contract speaks to the importance of high-quality smart contract engineering.
When Nike-owned RTFKT (pronounced “artifact”) raffled away mints for its newest NFT drop, it made a critical and, frankly, newbie-level mistake in the smart contract. Though even carefully constructed, well-audited contracts can experience exploits, the nature of this failure is far below the level of the crypto equivalent of a gaming studio releasing AAA games. Understanding the problem is important for anyone wanting to write smart contracts — and might be interesting for those who aren’t.
Smart contracts are, at their core, code — backend apps that live on the blockchain. Their name comes from the fact that they are primarily intended to automate the exchange of goods in services in ways that comply with the contract’s terms. NFTs, being digital goods, are managed by smart contracts, which define things like who can mint NFTs and how much it costs.
In RTFKT’s case, that included a function that enabled raffle winners to mint an NFT. To do so in a way that prevents exploitation, you must keep track of redemptions in some fashion. Saving data permanently to the blockchain increases the gas costs (transaction fees), but it can be done in a cost-effective way, where it will add mere cents to the expense.
However, RTFKT failed to do this completely. Instead, all they did to try to prevent people from claiming their raffle win multiple times was check and see how many of the NFTs were currently in the user’s wallet. This makes exploiting the contract trivial: you simply move the NFT to another wallet and then re-run the raffle claim.
Though smol farm, given that we have a limited marketing budget, has largely relied on releases that don’t have any limitations on who can mint what, we did have a similar need with our official derivative of the Dastardly Ducks, the Moonducks. In that case, an owner of an original Dastardly Duck could claim one Moonduck for free.
Instead of examining the current state of their wallet, I instead used a “mapping” variable, which makes it cost-effective to store values on-chain indexed by another type of variable, in this case the wallet address. When someone claims their free duck, the boolean true/false value mapped to their address flips to true.
Though this marginally increases gas costs, it is a very small price to pay to prevent people from breaking the rules. There should be no relying on the “honor system” in something like this, given that there is no way to rectify problems later. If someone mints more of a limited-supply NFT than they are supposed to, there is no way to compel them to distribute those NFTs to their intended targets.
Smart contracts, though not guaranteed to be held up in court, should be treated like the code equivalent of legal contracts given the immutable nature of blockchains. This requires taking the software engineering side far more seriously than many coders are accustomed, who, in web2 roles, are typically more able to fix things after-the-fact. While doing so well takes diligence and learning, RTFKT’s failure is simply inexcusable given their prestige in this space. We should all expect far better.
smol farm gazette is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.