This proposal builds on ERC-1155 and creates a standard for referring relationships and quantifiable attributes between non-isolated ERC-721 or ERC-1155 non-fungible tokens (NFTs). It enables users to build a graph of NFTs and set quantifiable attributes for each NFT, facilitating more complex NFT ecosystems. While a similar proposal exists for ERC-721 tokens, it does not provide a way to establish quantifiable relationships or object attributes.
The current standard for NFTs lacks the ability to establish relationships and attributes between tokens. This limitation makes it difficult for users to build more complex NFT ecosystems that require referring relationships and quantifiable attributes between tokens. For example, a user may create a derivative NFT that refers to the original NFT and sets a quantifiable attribute for the relationship between the two NFTs, but without a standardized way to establish relationships and attributes between NFTs, managing these ecosystems becomes increasingly difficult and inefficient.
This proposal aims to address this issue by extending the ERC-721 and ERC-1155 standards to include the ability to establish referring relationships and quantifiable attributes between NFTs.
By enabling users to build more complex NFT ecosystems, this proposal will enhance the NFT ecosystem and open up new possibilities for NFT use cases. However, it's important to consider potential drawbacks such as increased complexity and gas cost, and carefully design rules to mitigate these issues.
This EIP proposes the addition of five new functions to the ERC-721 and ERC-1155 standards: setRelationship, setAttribute, getRelationship, getAttribute, and getAttributeNames. These functions allow users to establish referring relationships and set quantifiable attributes between NFTs.
setRelationshipThe setRelationship function establishes a referring relationship between two NFTs. It takes the following parameters:
_originalID: the ID of the original NFT_derivativeID: the ID of the derivative NFT that refers to the original NFT_attribute: the quantifiable attribute for this relationship, which defaults to 1 if not specifiedWhen called, this function establishes a referring relationship between the two NFTs.
setAttributeThe setAttribute function sets a quantifiable attribute for an NFT. It takes the following parameters:
_id: the ID of the NFT_name: the name of the attribute to be set_value: the value of the attribute to be setWhen called, this function sets a quantifiable attribute for the NFT.
getAttributeThe getAttribute function allows anyone to retrieve the value of a specific attribute associated with an NFT. It takes the following parameters:
_id: The ID of the NFT for which you want to retrieve the attribute._name: The name of the attribute you wish to retrieve.This function returns the value of the specified attribute as a bytes32 data type.
getAttributeNamesThe getAttributeNames function allows anyone to retrieve the names of all attributes associated with an NFT. It takes the following parameter:
_id: The ID of the NFT for which you want to retrieve the attribute names.This function returns an array of bytes32 values representing the names of all attributes associated with the specified NFT.
getRelationshipThe getRelationship function allows anyone to retrieve the value of a referring relationship between two NFTs. It takes the following parameters:
_originalID: The ID of the original NFT._derivativeID: The ID of the derivative NFT that refers to the original NFT.This function returns the value of the referring relationship between the two NFTs as a uint256 data type.
By including these functions and methods in the specification, you establish a clear and standardized way for users and developers to read attributes associated with NFTs.
In developing this EIP, some key design decisions were made. For example, we limited the complexity of the relationship graph that can be created by only allowing for one referring relationship between two NFTs. This helps to ensure that the graph remains manageable and does not become too complex to be useful. Additionally, we kept the gas cost of setting attributes to a minimum by only allowing for one attribute to be set at a time.
While there are currently no similar features in other blockchain languages or standards, we drew inspiration from the concept of Graph Theory, which is a branch of mathematics that studies the relationships between objects. By adding the ability to establish relationships between NFTs and set quantifiable attributes for those relationships, we believe that the extended NFT standard will become even more useful and versatile for NFT creators and users.
This EIP is designed to be fully backward-compatible with existing ERC-721 and ERC-1155 contracts and tokens. Existing NFT contracts and tokens will continue to function as they did before, and the new setRelationship and setAttribute functions will only be available to contracts that explicitly implement this EIP.
To assist in understanding and implementing this proposal, we provide a reference Solidity interface and contract that define the functions for establishing relationships and reading attributes. Developers can use this interface as a foundation for integrating the NFT Relationship Enhancement into their own contracts.
The NFT Relationship Enhancement contract implements the ERC-165 standard interface to allow for interface detection. This enables smart contracts and applications to check if a given contract supports the functions defined in this proposal before interacting with it.
The INFTGraph interface specifies the functions for setting relationships and attributes, as well as retrieving attribute information and relationship values.
The NFTGraph contract implements the functions specified in the INFTGraph interface and provides storage for relationships and attributes.
Developers can use this reference interface and contract as a starting point for integrating the NFT Relationship Enhancement functionality into their own projects. The interface provides a clear and standardized way to interact with the contract, promoting consistency and ease of integration.
When implementing this proposal, contract developers should consider the following security aspects:
By addressing these considerations, developers can enhance the security of their contracts and protect the integrity of the NFT ecosystem.
Copyright and related rights waived via CC0.