Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

This article explains ERC-5380, a proposal for granting NFT usage rights to other addresses.

The following specification is the basis for this explanation.

Overview

The proposal defines a new interface that allows an ERC-721 NFT owner to authorize another address to use the NFT in a limited way.

Motivation

There are many situations in which an NFT owner may want to grant limited usage rights to another address. NFT rentals are one example.

Consider a trading card game (TCG) in which the cards are NFTs. A player may want to use a card in the game without purchasing the NFT itself.

The card owner can grant the borrower an entitlement to play with the card. In this example, the entitlement should be assigned to only one person at a time; otherwise, multiple people could rent the same card simultaneously.

Interface Implementation

javascript
interface ERC5380Entitlement is ERC165 {
    event EntitlementChanged(address indexed user, address indexed contract, uint256 indexed tokenId);

    function entitle(address user, address contract, uint256 tokenId) external;

    function maxEntitlements(address contract, uint256 tokenId) external view (uint256 max);

    function entitlementOf(address user, address contract, uint256 tokenId) external view returns (uint256 amt);
}

EntitlementChanged

This event records changes to a user's entitlement amount. The original article describes the zero-address case as identifying the NFT owner as the zero address.

entitle

When the caller (msg.sender) is the owner, this function grants an address a particular entitlement associated with an NFT identified by its token ID.

The original article states that the operation should not revert even if the caller is not the NFT owner.

Parameters

  • user: Address receiving the entitlement.
  • contract: Contract address.
  • tokenId: ID of the NFT for which the entitlement is granted.

maxEntitlements

Returns the maximum number of users who can receive the specified entitlement.

Parameters

  • contract: Contract address to query.
  • tokenId: NFT token ID to query.

entitlementOf

Queries the entitlement associated with the specified user address, contract, and NFT token ID.

By default, the value returned by maxEntitlements(contract, tokenId) is assigned to contract.ownerOf(tokenId).

Parameters

  • user: Address to query.
  • contract: Contract address to query.
  • tokenId: NFT token ID to query.

Other Requirements

supportsInterface returns true when called with the interface ID of ERC5380Entitlement.

Extensions

Enumeration

javascript
interface ERC5380EntitlementEnumerable is ERC5380Entitlement { // Also implicitly supports ERC-165
    function entitlementOfUserByIndex(address user, uint256 index) external view returns (address contract, uint256 tokenId);
}

This function enumerates NFTs for which the specified address has an entitlement amount of at least one and returns the entry at a particular index.

Parameters

  • user: Address to query.
  • index: Index to query.

Metadata

javascript
interface ERC5380InteroperabilityMetadata is InteroperabilityMetadata {
    erc5380?: boolean | undefined;
}

The erc5380 field is set to true for ERC-5380 token metadata and omitted otherwise.

Token URI

Token metadata must conform to the following interface.

javascript
interface ERC5380TokenMetadata {
    interop: ERC5380InteroperabilityMetadata;
    
    name?: string;
    
    symbol?: string;
    
    description?: string;
    
    images?: string[];
    
    icons?: string[];
}

interop

Distinguishes between different token types and their corresponding URIs.

name

Name of the ERC-5380 token.

symbol

Symbol of the ERC-5380 token.

description

A concise, single-paragraph description of the ERC-5380 token, without markup or line breaks.

images

One or more images with aspect ratios ranging from 1.91:1 to 4:5.

icons

One or more images with a 1:1 aspect ratio and transparent backgrounds.

Additional Considerations

ERC-20 and ERC-1155 are not supported because tracking ownership is more complicated than determining whether an account owns a particular NFT.

Security

The security considerations of ERC-721 and ERC-1046 apply.

Conclusion

ERC-5380 proposes a mechanism for assigning limited NFT usage rights to other addresses without transferring ownership.

The interface examples and behavioral descriptions above are retained from the original article. Consult the linked specification before implementing them.