Securing Royalties with Before Transfer Hooks
TL;DR: Example code to implement handlers / registry hooks in your own NFT contract here: https://github.com/proofofplay/operator-filter-example/
A couple days before we did our mint for Pirate Nation’s Founder’s Pirates, there was a Twitter thread by OpenSea introducing the Operator Filter Registry.
The filter registry essentially acts as a denylist ensuring that any marketplace smart contract that does not honor creator royalties is prevented from transferring tokens. OpenSea’s implementation allows a contract to subscribe to their registry of bad-actor contracts so that individual projects do not need to maintain their own list. In exchange for including it, OpenSea would enforce creator royalties on the behalf of the NFT creators both at the contract-level and at the UI-level.
We knew that we might want the capability to implement this functionality in the future but didn’t have adequate time before our mint to add it in and test it. So instead, we added support to define a custom handler hook that could be updated post-deploy. The code for this was fairly simple:
Just a few short days after Founder’s Pirates successfully minted out, Blur.io also announced that they were going to enforce creator royalties, but only if contracts implemented the Operator Registry like OpenSea. We decided to quickly create the registry hook contract and set the handler on our existing NFT contract. We deployed our code within 36 hours of Blur’s announcement and were likely the first collection to have royalties enforced on both OpenSea and Blur. If we had implemented the registry directly into our NFT contract, we would have never been able to respond so quickly to Blur’s announcement.
We’re certain that other creators are facing the same problem as us so we’re sharing the code for an example contract + registry implementation that uses our handler solution. We’ve said from the start that we value creators and we want to do whatever we can to help them succeed. We feel that this solution is one that prevents a creator from being tied to platform-specific code and can adapt as the NFT ecosystem’s way of enforcing royalties evolves, allowing creators to have their cake and eat it too.
Check it out here and share your thoughts: https://github.com/proofofplay/operator-filter-example/
Proof of Play Team