The Smart Contracts Behind Donation NFTs

Today, Showtime made the following announcement:

https://twitter.com/tryShowtime/status/1501602399839940610

There are a couple interesting things about choosing to donate this way:

  • because it is on Polygon, it is possible to have a very low barrier to entry ($1) that would not make sense on mainnet

  • because it is an ERC1155, you can donate as much as you want by buying more copies

  • as a result of your donation, you get an NFT that can be displayed in your collection

  • 100% of the money goes to the charity (Showtime pays for the gas fees and takes no commission)

  • and because it is an NFT with EIP-2981 royalties, any secondary sale will keep generating an income stream for the charity instead of a one-time donation

There have been plenty of NFT sales and auctions raising money for various causes, but they typically rely on someone promising to send the funds to the designated recipient.

This sale works a little differently, because the seller is not a regular Showtime user but a smart contract. As a result, anyone can actually verify that the only possible recipient of the funds is UkraineDAO. How?

Verifying where the raised money goes

Let’s head to the NFT detail page:

https://showtime.io/t/polygon/0x8a13628dd5d600ca1e8bf9dbc685b735f615cb90/20649

The owner history section shows that the NFT was minted by the verified Showtime Gallery account, and then transferred to a different address, x3a99ea152dd2eacc8e95addfb943e714db9ecc22

A look at PolygonScan reveals that:

  • this is a verified smart contract called ShowtimeBakeSale

  • the smart contract is immutable

  • it inherits from OpenZeppelin’s PaymentSplitter, meaning that it can receive payments and split them among a number of immutable payees

  • there is a single payee, configured in the constructor: payees (address[]): 0x633b7218644b83d57d90e7299039ebab19698e9c

And this is indeed the address of UkraineDAO:

https://twitter.com/Ukraine_DAO/status/1497274679823941632

Additionally, you can verify on the Showtime NFT contract that this NFT is configured with 50% royalties sent to the UkraineDAO address:

verifying EIP-2981 settings for a given token id
verifying EIP-2981 settings for a given token id

So how does this work exactly?

As we have seen before, the NFT was minted by the Showtime Gallery account and then transferred to the ShowtimeBakeSale contract.

We then called createSale on ShowtimeBakeSale, which creates a listing on the showtime.io marketplace where ShowtimeBakeSale is the seller (which it can do because it owns the NFT).

When someone donates money by purchasing one or more copies of the NFT:

  • half of the donation goes directly to UkraineDAO, because they are the royalties recipients

  • the rest of the donation accrues at the address of the ShowtimeBakeSale contract

In order to release the accrued tokens, anyone can call release(ERC20, payee) on ShowtimeBakeSale. In this case, because the currency used for donations is USDC and the only valid payee is UkraineDAO, that means calling release(0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174, 0x633b7218644b83D57d90e7299039ebAb19698e9C) (using any other payee address will result in an error).

What does this mean for you?

If you just want to donate money to this cause, hopefully this gives you confidence that everything is done transparently and correctly, with no intermediaries and no hidden fees.

But there’s more, this use case shows something about the composability of smart contracts. I happen to be working on smart contracts at Showtime, but really anyone could have developed some version of the bake sale contract. In fact, I hope that this post will inspire more builders to do so!

This is not a one-off event, anybody can replicate the setup described here and do fundraising for a 3rd party, all verifiable on-chain. However, we still need to work on a couple things to make this a more seamless experience:

  • we need to deploy a factory for the ShowtimeBakeSale contract, so that you can easily deploy your own instance configured with the payees of your choice

  • we need to improve support for contract profile pages, exposing an interface that any contract can implement to properly render as a Showtime profile page (including things like a banner, profile picture, bio, social links, etc)

Contact

If you have feedback or would like to discuss anything related to composability and trustless, verifiable systems, I can be found at:

twitter.com/0xkarmacoma

showtime.io/karmacoma

Acknowledgements

Thanks to @m4rio_eth and @ethcall for providing feedback on the ShowtimeBakeSale contract

Thanks to @_ltatis and @henryfontanier for helping build this feature with a super quick turnaround

Thanks to @Ukraine_DAO for facilitating donations and supporting people who need it

❤️