HomeEIPs
EIPsERC-5007
ERC-5007

Time NFT, ERC-721 Time Extension

Add start time and end time to ERC-721 tokens.
FinalStandards Track: ERC
Created: 2022-04-13
Requires: EIP-165, EIP-721
Anders (@0xanders), Lance (@LanceSnow), Shrug <shrug@emojidao.org>
DiscussionsOriginal linkEdit
1 min read

The ERC-5007 standard is an extension of ERC-721 that proposes an additional role called "user" which can be granted to addresses for a limited time. This user role represents permission to "use" the NFT, but not the ability to transfer it or set users. This is useful for NFTs that have certain utilities, such as virtual land or game assets, where the owner may rent it out to a user. The actions that a user can take with the NFT would be different from the owner, so separate roles are needed to manage permissions accordingly. This standard provides a unified way for applications to collaborate and manage these roles.

Video
Anyone may contribute to propose contents.
Go propose
Original

Abstract

This standard is an extension of ERC-721. It proposes some additional functions (startTime, endTime) to help with on-chain time management.

Motivation

Some NFTs have a defined usage period and cannot be used outside of that period. With traditional NFTs that do not include time information, if you want to mark a token as invalid or enable it at a specific time, you need to actively submit a transaction—a process both cumbersome and expensive.

Some existing NFTs contain time functions, but their interfaces are not consistent, so it is difficult to develop third-party platforms for them.

By introducing these functions (startTime, endTime), it is possible to enable and disable NFTs automatically on chain.

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.

/** * @dev the ERC-165 identifier for this interface is 0xf140be0d. */ interface IERC5007 /* is IERC721 */ { /** * @dev Returns the start time of the NFT as a UNIX timestamp. * * Requirements: * * - `tokenId` must exist. */ function startTime(uint256 tokenId) external view returns (uint64); /** * @dev Returns the end time of the NFT as a UNIX timestamp. * * Requirements: * * - `tokenId` must exist. */ function endTime(uint256 tokenId) external view returns (uint64); }

The composable extension is OPTIONAL for this standard. This allows your NFT to be minted from an existing NFT or to merge two NFTs into one NFT.

/** * @dev the ERC-165 identifier for this interface is 0x75cf3842. */ interface IERC5007Composable /* is IERC5007 */ { /** * @dev Returns the asset id of the time NFT. * Only NFTs with same asset id can be merged. * * Requirements: * * - `tokenId` must exist. */ function assetId(uint256 tokenId) external view returns (uint256); /** * @dev Split an old token to two new tokens. * The assetId of the new token is the same as the assetId of the old token * * Requirements: * * - `oldTokenId` must exist. * - `newToken1Id` must not exist. * - `newToken1Owner` cannot be the zero address. * - `newToken2Id` must not exist. * - `newToken2Owner` cannot be the zero address. * - `splitTime` require(oldToken.startTime <= splitTime && splitTime < oldToken.EndTime) */ function split( uint256 oldTokenId, uint256 newToken1Id, address newToken1Owner, uint256 newToken2Id, address newToken2Owner, uint64 splitTime ) external; /** * @dev Merge the first token and second token into the new token. * * Requirements: * * - `firstTokenId` must exist. * - `secondTokenId` must exist. * - require((firstToken.endTime + 1) == secondToken.startTime) * - require((firstToken.assetId()) == secondToken.assetId()) * - `newTokenOwner` cannot be the zero address. * - `newTokenId` must not exist. */ function merge( uint256 firstTokenId, uint256 secondTokenId, address newTokenOwner, uint256 newTokenId ) external; }

Rationale

Time Data Type

The max value of uint64 is 18,446,744,073,709,551,615. As a timestamp, 18,446,744,073,709,551,615 is about year 584,942,419,325. uint256 is too big for C, C++, Java, Go, etc, and uint64 is natively supported by mainstream programming languages.

Backwards Compatibility

This standard is fully ERC-721 compatible.

Test Cases

Test cases are included in test.js.

Run in terminal:

cd ../assets/eip-5007 npm install truffle -g npm install truffle test

Reference Implementation

See ERC5007.sol.

Security Considerations

No security issues found.

Copyright and related rights waived via CC0.

Further reading
Anyone may contribute to propose contents.
Go propose
Adopted by projects
Anyone may contribute to propose contents.
Go propose

Not miss a beat of EIPs' update?

Subscribe EIPs Fun to receive the latest updates of EIPs Good for Buidlers to follow up.

View all
Serve Ethereum Builders, Scale the Community.
Resources
GitHub
Supported by