---
eip: 5334
label: ERC-5334
title: EIP-721 User And Expires And Level Extension
status: Stagnant
type: Standards Track
category: ERC
created: 2022-07-25
requires: 165, 721
official: https://eips.ethereum.org/EIPS/eip-5334
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-5334.md
canonical: https://eips.huatuo.xyz/eip-5334/
lang: en
tldr: Proposed ERC-721 extension that adds a time-limited user role with a numeric level, so NFT owners can rent out usage rights that expire automatically without a second transaction.
tags: [nft, rental, erc721, user-role, gaming]
---

# ERC-5334: EIP-721 User And Expires And Level Extension

> Add a time-limited role with restricted permissions to EIP-721 tokens.

**TL;DR:** Proposed ERC-721 extension that adds a time-limited user role with a numeric level, so NFT owners can rent out usage rights that expire automatically without a second transaction.

## What problem does it solve?

Many NFTs are useful, not just collectible: virtual land you build on, game items you play with. The owner and the person using the NFT are not always the same, for example when it is rented out. A "user" should be able to use the NFT but not sell it or hand it on.

Managing that by hand needs two transactions per rental (grant, then revoke at the end). EIP-5334 adds a `user` role with an `expires` timestamp so the right lapses on its own, plus a `level` so apps can distinguish tiers of usage rights.

It is essentially [ERC-4907](/eip-4907/) (rental NFTs) with an extra `level` field.

## How it works

On top of ERC-721, each token gets three values: `user`, `expires` (UNIX timestamp) and `level` (`uint8`).

| Member | Purpose |
| --- | --- |
| `setUser(tokenId, user, expires, level)` | Set or clear the user; zero address means no user |
| `userOf(tokenId)` | Current user, or the zero address if none or expired |
| `userExpires(tokenId)` | Expiry timestamp; zero if no user |
| `userLevel(tokenId)` | User level; zero if no user |
| `event UpdateUser(tokenId, user, expires, level)` | Must be emitted whenever any of the three changes |

Apps that honour the role check `userOf` (and `userLevel` if they care) to decide who may use the token. After `expires`, `userOf` returns the zero address without anyone sending a transaction. Ownership and transfers stay governed by ERC-721.

## Sample code

Minimal implementation on OpenZeppelin `ERC721`:

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";

contract RentableItem is ERC721 {
    struct UserInfo { address user; uint64 expires; uint8 level; }
    mapping(uint256 => UserInfo) internal _users;

    event UpdateUser(uint256 indexed tokenId, address indexed user, uint64 expires, uint8 level);

    constructor() ERC721("Item", "ITM") {}

    function setUser(uint256 tokenId, address user, uint64 expires, uint8 level) external {
        address owner = ownerOf(tokenId); // reverts for a nonexistent token
        require(_isAuthorized(owner, msg.sender, tokenId), "not owner nor approved");
        _users[tokenId] = UserInfo(user, expires, level);
        emit UpdateUser(tokenId, user, expires, level);
    }

    function userOf(uint256 tokenId) external view returns (address) {
        UserInfo memory u = _users[tokenId];
        return u.expires >= block.timestamp ? u.user : address(0);
    }

    function userExpires(uint256 tokenId) external view returns (uint256) { return _users[tokenId].expires; }
    function userLevel(uint256 tokenId) external view returns (uint256) { return _users[tokenId].level; }
}
```

## Things to know

- Status: **Stagnant**. The spec's rationale is "TBD" and the ERC-165 interface ID is left as a TODO, so integrators cannot reliably detect it.
- The spec does not say what `level` means; that is up to each application.
- It also does not say whether the user should be cleared on transfer. The ERC-4907 reference implementation clears it on transfer; decide explicitly and document it.
- For new projects, [ERC-4907](/eip-4907/) (Final) or [ERC-5006](/eip-5006/) (Final, for ERC-1155) are the established rental standards.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-5334
