ethereum / EIPs

The Ethereum Improvement Proposal repository

Home Page:https://eips.ethereum.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ERC721Subordinate

sullof opened this issue · comments

Proposed Change

Premise

There are case where we need an NFT (the subordinate) which is totally subordinate to a primary NFT (the dominant)
In 2021, when we started Everdragons2, we had in mind of using the head of the dragons for a PFP token based on the Everdragons2 that you own. Here an example of a full dragon

https://github.com/ndujaLabs/ERC721Subordinate/blob/main/assets/Soolhoth.png

and just the head

https://github.com/ndujaLabs/ERC721Subordinate/blob/main/assets/Soolhoth_PFP.png

The question was, Should we allow people to transfer the PFP separately from the primary NFT? It didn't make much sense. At the same time, how to avoid that?

The solution is a token that delegates another token for anything related with the ownership.

The interface

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

// Authors: Francesco Sullo <francesco@sullo.co>

// ERC165 interface id is 0x60c8f291
interface IERC721Subordinate {

  // A subordinate contract has no control on its own ownership.
  // Whoever owns the main token owns the subordinate token.

  // The use cases where this is useful are many.
  // Some example:
  // - A token that represents a specific aspect of a dominant token.
  //      In Everdragons2, the dominant token is a dragon. The subordinate token is
  //      a PFP version of the dragon, that must follow the ownership of the dragon.
  // - A token that represent an asset of the dominant token.
  // - A token that adds missed features to the dominant token.

  // The function dominantToken() returns the address of the main token.
  function dominantToken() external view returns (address);

  // The dominant token has full control on the subordinate token.
  // All the functions of the subordinate token are delegated to the dominant token.

  // For example, the function ownerOf(uint256 tokenId) returns the owner of the main token.

  //    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
  //      return _dominant.ownerOf(tokenId);
  //    }

}

Having a standard interface for that allows exchanges to check if the NFT implements it and avoid spending gas due to the revert.

Implementations

I implemented it in

https://github.com/ndujaLabs/erc721subordinate

overriding ERC721 and ERC721Enumerable, upgradeable and not, from version 4.8.0 of

https://github.com/OpenZeppelin/openzeppelin-contracts
https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable

Discussion

https://ethereum-magicians.org/t/erc721subordinate/12479

This is not the correct place to create discussion links. Please create a thread on FEM.

Thanks