In April 2024, OpenSea announced that creators can now use ERC721-C from Limit Break to set and enforce their own creator earnings on OpenSea (link).
The article stated that its also applicable for the creator who's using ERC721-C or ERC1155-C compatible custom smart contract. I've found examples from LimitBreak's github repo to serve that purpose but it doesn't suit my needs. So, I decided to make a simple extension based on OpenSea's Creator Fee Enforcement docs without having to inherit to LimitBreak's ERC721-C.
This repository is about a simple contract extension to be inherited by any ERC721-based implementation contract to comply with OpenSea's creator fee enforcement. There are two examples of its implementation:
- Implementation contract MUST inherit to
ERC721TransferValidator.sol
(link). The inherited contract itself implements interfaces fromICreatorToken.sol
(link) andITransferValidator721.sol
(link). - Implementation contract MUST implement
setTransferValidator
(link) external function as its defined atICreatorToken.sol
with an access control (in this case, only contract's owner can invoke the function). - In this case, implementation contract inherits to ERC2981 (NFT Royalty Standard) contract by Solady.
- Override
supportsInterface
function to also returnstrue
for0xad0d7f6c
as ICreatorToken's interface ID and0x2a55205a
as ERC2981's interface ID. - Override
_beforeTokenTransfer
hook (ERC721C / ERC721AC) to facilitatevalidateTransfer
as its defined atITransferValidator.sol
before token is transferred from and to non-zero address. - There are two ways to set transfer validator contract:
- At contract deployment by defining
_setTransferValidator
(link) and_setDefaultRoyalty
(link) values inside the constructor OR - After contract deployment (runtime) by:
- Call
setTransferValidator
external function OR - Hit
Turn on enforced earnings
at OpenSea collection page's settings (see examples below) to invoke a transaction to callsetTransferValidator
function and automatically sets thevalidator
contract toCreatorTokenTransferValidator.sol
by Limit Break (link).
- Call
- At contract deployment by defining
Contract | Address | OpenSea(testnets) |
---|---|---|
ERC721C | 0x1FeB3f98e42Ccb79DDb9462d2f041d0DAded4c05 | Simple-ERC721C-Example |
ERC721AC | 0x68Db515f9FC5173E78153E6449C8420De07bEE02 | Simple-ERC721AC-Example |
These examples are based on deployed ERC721C and its OpenSea's collection page at testnets (above).
-
This is what we MUST see at
Creator earnings
tab at OpenSea's collection page settings when transfer validator contract is not set - meaninggetTransferValidator
(link) returns zero address, but since our custom contract is comply we always have an option to enforce it. -
After fees were configured via OpenSea without setting transfer validator contract.
-
The owner of a NFT has an option to not paying creator fee (creator fee sets to 0%), when transfer validator contract is not set.
-
Transaction hash when listed NFT (#4) is bought: https://sepolia.basescan.org/tx/0x37ee9e0b79e79da2b60a542cabff589f757e8cccb1daf57e305afa5f5f966b5e
-
This is what we see at
Creator earnings
tab when transfer validator contract is set (transaction's log). -
The owner of a NFT has NO option to not paying creator fee (creator fee is enforced), when transfer validator contract has been set.
-
Transaction hash when listed NFT (#7) is bought: https://sepolia.basescan.org/tx/0xa1aceeb4d754c681090d4534d76b8280aeac0f6d27a236ac05f29bdf88ef6c54
It's just example contracts that demonstrates how to implement creator fee enforcement for ERC721-based contracts, so do NOT blindly copy anything here into production code unless you really know what you are doing. Test thoroughly before implements it to your custom contract.