EIP-5380: EIP-721 Entitlement Extension
Allows token owners to grant the ability for others to use specific properties of those tokens
作者 | Pandapip1, Tim Daubenschütz |
---|---|
讨论-To | https://ethereum-magicians.org/t/pr-5380-eip-4907-alternative-design/10190 |
状态 | Draft |
类型 | Standards Track |
分类 | ERC |
创建日期 | 2022-03-11 |
依赖 | 165, 721 |
英文版 | https://eips.ethereum.org/EIPS/eip-5380 |
目录
Abstract
This EIP proposes a new interface that allows EIP-721 token owners to grant limited usage of those tokens to other addresses.
Motivation
There are many scenarios in which it makes sense for the owner of a token to grant certain properties to another address. One use case is renting tokens. If the token in question represents a trading card in an on-chain TCG (trading card game), one might want to be able to use that card in the game without having to actually buy it. Therefore, the owner might grant the renter the “property” of it being able to be played in the TCG. However, this property should only be able to be assigned to one person at a time, otherwise a contract could simply “rent” the card to everybody. If the token represents usage rights instead, the property of being allowed to use the associated media does not need such a restriction, and there is no reason that the property should be as scarce as the token.
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.
Base
/// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.0;
interface ERC721Entitlement is ERC165 {
/// @notice Emitted when the amount of entitlement a user has changes. If user is the zero address, then the user is the owner
event EntitlementChanged(address indexed user, address indexed contract, uint256 indexed tokenId);
/// @notice Set the user associated with the given EIP-721 token as long as the owner is msg.sender.
/// @dev SHOULD NOT revert if the owner is not msg.sender.
/// @param user The user to grant the entitlement to
/// @param contract The property to grant
/// @param tokenId The tokenId to grant the properties of
function entitle(address user, address contract, uint256 tokenId) external;
/// @notice Get the maximum number of users that can receive this entitlement
/// @param contract The contract to query
/// @param tokenId The tokenId to query
function maxEntitlements(address contract, uint256 tokenId) external view (uint256 max);
/// @notice Get the user associated with the given contract and tokenId.
/// @dev Defaults to contract.ownerOf(tokenId)
/// @param contract The contract to query
/// @param tokenId The tokenId to query
function entitlementOf(address contract, uint256 tokenId) external view returns (address user);
}
supportsInterface
MUST return true when called with ERC721Entitlement
’s interface ID.
Enumerable
This OPTIONAL interface is RECOMMENDED.
/// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.0;
interface ERC721EntitlementEnumerable is ERC721Entitlement /* , ERC165 */ {
/// @notice Enumerate tokens assigned to a user
/// @dev Throws if the index is out of bounds or if user == address(0)
/// @param user The user to query
/// @param index A counter
function tokenOfUserByIndex(address user, uint256 index) external view returns (address contract, uint256 tokenId);
}
supportsInterface
MUST return true when called with ERC721EntitlementEnumerable
’s interface ID.
Rationale
EIP-20 and EIP-1155 are unsupported as partial ownership is much more complex to track than boolean ownership.
向后兼容性
No backward compatibility issues were found.
Security Considerations
Needs discussion.
Copyright
Copyright and related rights waived via CC0.
参考文献
Please cite this document as:
Pandapip1, Tim Daubenschütz, "EIP-5380: EIP-721 Entitlement Extension [DRAFT]," Ethereum Improvement Proposals, no. 5380, March 2022. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-5380.