Skip to content

BDSKMN/simple-ERC721C-extension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple ERC721 Creator Fee Enforcement Extension

Background

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.

About

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:

  1. ERC721C is for ERC721-based contract.
  2. ERC721AC is for ERC721A-based contract.

Implementations

Diagram

  1. Implementation contract MUST inherit to ERC721TransferValidator.sol (link). The inherited contract itself implements interfaces from ICreatorToken.sol (link) and ITransferValidator721.sol (link).
  2. Implementation contract MUST implement setTransferValidator(link) external function as its defined at ICreatorToken.sol with an access control (in this case, only contract's owner can invoke the function).
  3. In this case, implementation contract inherits to ERC2981 (NFT Royalty Standard) contract by Solady.
  4. Override supportsInterface function to also returns true for 0xad0d7f6c as ICreatorToken's interface ID and 0x2a55205a as ERC2981's interface ID.
  5. Override _beforeTokenTransfer hook (ERC721C / ERC721AC) to facilitate validateTransfer as its defined at ITransferValidator.sol before token is transferred from and to non-zero address.
  6. 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 call setTransferValidator function and automatically sets the validator contract to CreatorTokenTransferValidator.sol by Limit Break (link).

Deployed Contracts at Base Sepolia Testnet

Contract Address OpenSea(testnets)
ERC721C 0x1FeB3f98e42Ccb79DDb9462d2f041d0DAded4c05 Simple-ERC721C-Example
ERC721AC 0x68Db515f9FC5173E78153E6449C8420De07bEE02 Simple-ERC721AC-Example

Example of Implementations

These examples are based on deployed ERC721C and its OpenSea's collection page at testnets (above).

  1. This is what we MUST see at Creator earnings tab at OpenSea's collection page settings when transfer validator contract is not set - meaning getTransferValidator (link) returns zero address, but since our custom contract is comply we always have an option to enforce it. 1

  2. After fees were configured via OpenSea without setting transfer validator contract. 2

  3. 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. 3

  4. Listed NFT when transfer validator contract is not set. 4

  5. Transaction hash when listed NFT (#4) is bought: https://sepolia.basescan.org/tx/0x37ee9e0b79e79da2b60a542cabff589f757e8cccb1daf57e305afa5f5f966b5e

  6. This is what we see at Creator earnings tab when transfer validator contract is set (transaction's log). 5

  7. The owner of a NFT has NO option to not paying creator fee (creator fee is enforced), when transfer validator contract has been set. 6

  8. Listed NFT when transfer validator contract is set. 7

  9. Transaction hash when listed NFT (#7) is bought: https://sepolia.basescan.org/tx/0xa1aceeb4d754c681090d4534d76b8280aeac0f6d27a236ac05f29bdf88ef6c54

Important Notes

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.

About

Simple ERC721-C extension to enforce royalty fee payment for ERC721-based implementation contract

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published