EIP-6786: Royalty Debt Registry

EIP-6786: Royalty Debt Registry

Simple Summary

A standard used for providing a way to pay royalties to a NFT’s creator and also cumulate the total paid value for a specific NFT and make it accessible to every NFT marketplace or ecosystem users.

Abstract

This standard allows anyone to pay royalties for a certain NFT and also to keep track of the royalties amount paid. It will cumulate the value each time a payment is executed through it and make the information public.

Motivation

There are many marketplaces which do not enforce any royalty payment to the NFT creator every time the NFT is sold or re-sold and/or providing a way for doing it. There are some marketplaces which use specific system of royalties, however that system is applicable for the NFTs creates on their platform.

In this context, there is a need of a way for paying royalties, as it is a strong incentive for creators to keep contributing to the NFTs ecosystem.

Additionally, this standard will provide a way of computing the amount of royalties paid to a creator for a certain NFT. This could be useful in the context of categorising NFTs in terms of royalties. The term “debt“ is used because the standard aims to provide a way of knowing if there are any royalties left unpaid for the NFTs trades that took place in a marketplace that does not support them and, in that case, expose a way of paying them.

Not only the owner of it, but anyone could pay royalties for a certain NFT. This could be a way of supporting a creator for his work.

Specification

The keywords “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.

Every contract compliant with EIP-6786 MUST implement the IERC6786 interface defined as follows:

Contract Interface

// @title Royalty Debt Registry
/// Note: the EIP-165 identifier for this interface is 0x253b27b0

interface IERC6786 {

    // Logged when royalties were paid for a NFT
    /// @notice Emitted when royalties are paid for the NFT with address tokenAddress and id tokenId
    event RoyaltiesPaid(address indexed tokenAddress, uint256 indexed tokenId, uint256 amount);

    /// @notice sends msg.value to the creator of a NFT
    /// @dev Throws if there are no on-chain informations about the creator
    /// @param tokenAddress The address of NFT contract
    /// @param tokenId The NFT id
    function payRoyalties(address tokenAddress, uint256 tokenId) external payable;

    /// @notice Get the amount of royalties which was paid for a NFT
    /// @dev 
    /// @param tokenAddress The address of NFT contract
    /// @param tokenId The NFT id
    /// @return The amount of royalties paid for the NFT
    function getPaidRoyalties(address tokenAddress, uint256 tokenId) external view returns (uint256);
}

All functions defined as view MAY be implemented as pure or view

Function payRoyalties MAY be implemented as public or external

The event RoyaltiesPaid MUST be emitted when the payRoyalties function is called

The supportsInterface method MUST return true when called with 0x253b27b0

Rationale

With a lot of places made for trading NFTs dropping down the royalty payment or having a centralised approach, we want to provide a way for anyone to pay royalties to the creators.

The payment can be made in native coins so it is easy to aggregate the amount of paid royalties. We want this information to be public, so anyone could tell if a creator received royalties in case of under the table trading or in case of marketplaces which don’t support royalties.

The function used for payment can be called by anyone (not only the NFTs owner) to support the creator at any time. There is a way of seeing the amount of paid royalties in any token, also available for anyone.

For fetching creator on-chain data we will use EIP-2981, but any other on-chain method of getting the creator address is accepted.

Backwards Compatibility

This EIP is not introducing any backward incompatibilities.

Test Cases

Tests are included in ERC6786.test.js.

Reference Implementation

// SPDX-License-Identifier: CC0
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import "./IERC6786.sol";
import "./utils/IERC2981.sol";

contract ERC6786 is IERC6786, ERC165 {

    //Mapping from token (address and id) to the amount of paid royalties
    mapping(address => mapping(uint256 => uint256)) private _paidRoyalties;

    /*
     *     bytes4(keccak256('payRoyalties(address,uint256)')) == 0xf511f0e9
     *     bytes4(keccak256('getPaidRoyalties(address,uint256)')) == 0xd02ad759
     *
     *     => 0xf511f0e9 ^ 0xd02ad759 == 0x253b27b0
     */
    bytes4 private constant _INTERFACE_ID_ERC6786 = 0x253b27b0;

    /*
     * bytes4(keccak256('royaltyInfo(uint256,uint256)')) == 0x2a55205a
     */
    bytes4 private constant _INTERFACE_ID_ERC2981 = 0x2a55205a;

    /// @notice This is thrown when there is no creator related information
    /// @param tokenAddress -> the address of the contract
    /// @param tokenId -> the id of the NFT
    error CreatorError(address tokenAddress, uint256 tokenId);

    /// @notice This is thrown when the payment fails
    /// @param creator -> the address of the creator
    /// @param amount -> the amount to pay
    error PaymentError(address creator, uint256 amount);

    function checkRoyalties(address _contract) internal view returns (bool) {
        (bool success) = IERC165(_contract).supportsInterface(_INTERFACE_ID_ERC2981);
        return success;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return
        interfaceId == type(IERC5666).interfaceId ||
        super.supportsInterface(interfaceId);
    }

    function payRoyalties(address tokenAddress, uint256 tokenId) external override payable {
        if (!checkRoyalties(tokenAddress)) {
            revert CreatorError(tokenAddress, tokenId);
        }
        (address creator,) = IERC2981(tokenAddress).royaltyInfo(tokenId, 0);
        (bool success,) = payable(creator).call{value : msg.value}("");
        if(!success) {
            revert PaymentError(creator, msg.value);
        }
        _paidRoyalties[tokenAddress][tokenId] += msg.value;

        emit RoyaltiesPaid(tokenAddress, tokenId, msg.value);
    }

    function getPaidRoyalties(address tokenAddress, uint256 tokenId) external view override returns (uint256) {
        return _paidRoyalties[tokenAddress][tokenId];
    }
}

Security Considerations

There are no security considerations related directly to the implementation of this standard.

Copyright

Copyright and related rights waived via EIPs/LICENSE.md at master · ethereum/EIPs · GitHub.

Have you looked at ERC-4910?

Hi! This is interesting. The difference is that the registry allows paying and tracking royalties for any ERC721 regardless of other extensions that the NFT contract might implement (considering having a way of retrieving the creator address on-chain).