---
eip: 7589
label: ERC-7589
title: Semi-Fungible Token Roles
status: Draft
type: Standards Track
category: ERC
created: 2023-12-28
requires: 165, 1155
official: https://eips.ethereum.org/EIPS/eip-7589
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7589.md
canonical: https://eips.huatuo.xyz/eip-7589/
lang: en
tldr: "A draft standard for lending out the use of ERC-1155 tokens: owners commit a balance, then grant time-limited, optionally revocable roles on it to other accounts without transferring ownership."
tags: [erc-1155, roles, rental, gaming, sft]
---

# ERC-7589: Semi-Fungible Token Roles

> Role Management for Semi-Fungible Tokens (SFTs). Enables accounts to share the utility of SFTs via expirable role assignments.

**TL;DR:** A draft standard for lending out the use of ERC-1155 tokens: owners commit a balance, then grant time-limited, optionally revocable roles on it to other accounts without transferring ownership.

## What problem does it solve?

[ERC-1155](/eip-1155/) tracks who owns how many of each token, but says nothing about who may **use** them. Games and apps often want to rent out an in-game item, let a guild member use a pass, or delegate rights for a fixed period, without giving away the tokens themselves.

ERC-7589 adds a standard role layer for semi-fungible tokens, similar in spirit to [ERC-7432](/eip-7432/) for NFTs. Each role assignment goes to one grantee and expires automatically.

## How it works

Granting is a two-step process:

1. **Commit tokens.** `commitTokens(grantor, tokenAddress, tokenId, amount)` locks a specific amount (by depositing it in the roles contract or freezing it) and returns a `commitmentId`.
2. **Grant a role.** `grantRole(commitmentId, role, grantee, expirationDate, revocable, data)` assigns a `bytes32` role on that commitment. `type(uint64).max` is recommended for a permanent role.

Other pieces:

- `revokeRole` ends an assignment. The grantee can always give it up; the grantor can revoke only if it is revocable or expired.
- `releaseTokens(commitmentId)` returns the committed tokens, but must revert while any non-revocable, unexpired role remains.
- `setRoleApprovalForAll(tokenAddress, operator, approved)` lets an operator (e.g. a rental marketplace) commit and grant on the owner's behalf. These approvals are separate from ERC-1155 approvals.
- Views: `grantorOf`, `tokenAmountOf`, `roleExpirationDate`, `isRoleRevocable`, `roleData`, and others.
- Role IDs are recommended to be `keccak256` of the role name and arguments, e.g. `keccak256("Player(uint256)")`.
- Optional extensions: `commitTokensAndGrantRole` (one transaction) and `roleBalanceOf` (total amount granted to a user for a role). There is also an optional `roles` section for ERC-1155 metadata JSON.
- ERC-165 interface ID for the core interface: `0xc4c8a71d`.

## Sample code

Renting 5 units of an item for 7 days (ethers v6):

```ts
import { Contract, Wallet, JsonRpcProvider, id } from "ethers";

const provider = new JsonRpcProvider(process.env.RPC_URL);
const owner = new Wallet(process.env.PRIVATE_KEY!, provider);
const roles = new Contract(rolesAddress, [
  "event TokensCommitted(address indexed _grantor, uint256 indexed _commitmentId, address indexed _tokenAddress, uint256 _tokenId, uint256 _tokenAmount)",
  "function commitTokens(address,address,uint256,uint256) returns (uint256)",
  "function grantRole(uint256,bytes32,address,uint64,bool,bytes)",
], owner);

const receipt = await (await roles.commitTokens(owner.address, itemAddress, 42n, 5n)).wait();
const commitmentId = roles.interface.parseLog(receipt!.logs.find(l => l.address === rolesAddress)!)!.args._commitmentId;

const expires = BigInt(Math.floor(Date.now() / 1000) + 7 * 24 * 3600);
await roles.grantRole(commitmentId, id("Player()"), renterAddress, expires, false, "0x");
```

## Things to know

- **Status: Draft.**
- Apps that honour roles must check `roleExpirationDate` themselves; expiry is not enforced by the token contract.
- Commit may transfer or freeze balances, so access control on `commitTokens` and `releaseTokens` is security-critical. The spec also calls out reentrancy.
- A non-revocable role locks the grantor's tokens until it expires.
- For single NFTs see [ERC-7432](/eip-7432/); for a simpler "user" field on ERC-1155 rentals see [ERC-5006](/eip-5006/).


---

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