EIPs Explained

ERC-5380 · Final · ERC · 2022-03-11

ERC-5380: ERC-721 Entitlement Extension

Lets an ERC-721 owner grant other addresses the right to use a specific property of their token, such as playing a card in a game, without transferring ownership.

What problem does it solve?

Owning an NFT and using it are often separate needs. Someone may want to play a trading card in an on-chain game without buying it, or license the media an NFT points to. Transferring the token to them hands over full ownership, which is far more than intended.

Some rights are scarce (only one player should hold a card at a time, or one owner could "rent" it to everybody), while others need not be (usage rights to media could be granted to many). ERC-5380 models both as entitlements: named properties of a token that the owner can assign, with a per-property cap on how many users can hold them.

How it works

An entitlement contract is a separate contract that represents one "property". Its key functions take the NFT contract address and token ID:

Function Purpose
entitle(user, contract, tokenId) The token's owner assigns this entitlement to user
maxEntitlements(contract, tokenId) How many users may hold it at once
entitlementOf(user, contract, tokenId) How much entitlement user has; by default the full amount belongs to the current owner

EntitlementChanged(user, contract, tokenId) is emitted on changes. entitle should not revert when the caller is not the owner (it just does nothing). Games or apps check entitlementOf before letting someone use the token.

Two optional, recommended extensions exist: an enumerable one (list tokens a user is entitled to) and a metadata one with tokenURI() following ERC-1046, whose interop block sets erc5380: true.

ERC-20 and ERC-1155 are deliberately unsupported, because partial ownership is much harder to track than "owns / does not own".

Sample code

The spec names a parameter contract, which is a reserved word in Solidity, so real code has to rename it. A compiling version of the base interface and a game-side check:

// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;

interface IERC5380Entitlement {
    event EntitlementChanged(address indexed user, address indexed tokenContract, uint256 indexed tokenId);
    function entitle(address user, address tokenContract, uint256 tokenId) external;
    function maxEntitlements(address tokenContract, uint256 tokenId) external view returns (uint256);
    function entitlementOf(address user, address tokenContract, uint256 tokenId) external view returns (uint256);
}

contract CardGame {
    IERC5380Entitlement public immutable playRight;
    address public immutable cards;

    constructor(IERC5380Entitlement _playRight, address _cards) {
        playRight = _playRight;
        cards = _cards;
    }

    function play(uint256 cardId) external {
        require(playRight.entitlementOf(msg.sender, cards, cardId) > 0, "not entitled");
        // ... game logic
    }
}

Things to know

  • Status: Final.
  • The spec's Solidity has small errors (the reserved name contract, a missing returns on maxEntitlements), so implementations rename parameters; this affects source code, not the ABI types.
  • It was proposed as an alternative design to ERC-4907, which adds a single time-limited user role directly to the NFT.
  • Entitlements are only meaningful if the consuming app checks them; holding an entitlement does not change ownerOf.

#nft #erc-721 #rental #delegation #permissions

Details

Authors
Gavin John (@Pandapip1), Tim Daubenschütz (@TimDaub)
Status
Final
Type
Standards Track / ERC
Created
2022-03-11
Requires

Machine-readable: Markdown · JSON