{"eip":7589,"title":"Semi-Fungible Token Roles","description":"Role Management for Semi-Fungible Tokens (SFTs). Enables accounts to share the utility of SFTs via expirable role assignments.","authors":["Ernani São Thiago (@ernanirst)","Daniel Lima (@karacurt)"],"status":"Draft","type":"Standards Track","category":"ERC","created":"2023-12-28","requires":[165,1155],"discussionsTo":"https://ethereum-magicians.org/t/eip-7589-semi-fungible-token-roles/17967","repo":"ERCs","label":"ERC-7589","officialUrl":"https://eips.ethereum.org/EIPS/eip-7589","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7589.md","url":"https://eips.huatuo.xyz/eip-7589/","tldr":{"en":"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.","ja":"ERC-1155 トークンの利用権を貸し出すための標準のドラフト。所有者が残高をコミットし、所有権を移転せずに、その上で期限付きで任意に取り消し可能なロールを他のアカウントに付与する。","ko":"ERC-1155 토큰의 사용권을 빌려주기 위한 표준 초안. 소유자가 잔액을 커밋(commit)한 뒤, 소유권을 이전하지 않고 그 위에 기한이 있고 선택적으로 취소 가능한 역할(role)을 다른 계정에 부여한다.","zh":"一个出借 ERC-1155 代币使用权的标准草案：所有者提交（commit）一部分余额，然后在不转移所有权的情况下，把基于该余额的、有时限且可选择可撤销的角色授予其他账户。"},"tags":["erc-1155","roles","rental","gaming","sft"],"explainers":{"en":{"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"],"related":[1155,7432,5006,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-7589/","markdown":"## What problem does it solve?\n\n[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.\n\nERC-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.\n\n## How it works\n\nGranting is a two-step process:\n\n1. **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`.\n2. **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.\n\nOther pieces:\n\n- `revokeRole` ends an assignment. The grantee can always give it up; the grantor can revoke only if it is revocable or expired.\n- `releaseTokens(commitmentId)` returns the committed tokens, but must revert while any non-revocable, unexpired role remains.\n- `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.\n- Views: `grantorOf`, `tokenAmountOf`, `roleExpirationDate`, `isRoleRevocable`, `roleData`, and others.\n- Role IDs are recommended to be `keccak256` of the role name and arguments, e.g. `keccak256(\"Player(uint256)\")`.\n- 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.\n- ERC-165 interface ID for the core interface: `0xc4c8a71d`.\n\n## Sample code\n\nRenting 5 units of an item for 7 days (ethers v6):\n\n```ts\nimport { Contract, Wallet, JsonRpcProvider, id } from \"ethers\";\n\nconst provider = new JsonRpcProvider(process.env.RPC_URL);\nconst owner = new Wallet(process.env.PRIVATE_KEY!, provider);\nconst roles = new Contract(rolesAddress, [\n  \"event TokensCommitted(address indexed _grantor, uint256 indexed _commitmentId, address indexed _tokenAddress, uint256 _tokenId, uint256 _tokenAmount)\",\n  \"function commitTokens(address,address,uint256,uint256) returns (uint256)\",\n  \"function grantRole(uint256,bytes32,address,uint64,bool,bytes)\",\n], owner);\n\nconst receipt = await (await roles.commitTokens(owner.address, itemAddress, 42n, 5n)).wait();\nconst commitmentId = roles.interface.parseLog(receipt!.logs.find(l =\u003e l.address === rolesAddress)!)!.args._commitmentId;\n\nconst expires = BigInt(Math.floor(Date.now() / 1000) + 7 * 24 * 3600);\nawait roles.grantRole(commitmentId, id(\"Player()\"), renterAddress, expires, false, \"0x\");\n```\n\n## Things to know\n\n- **Status: Draft.**\n- Apps that honour roles must check `roleExpirationDate` themselves; expiry is not enforced by the token contract.\n- Commit may transfer or freeze balances, so access control on `commitTokens` and `releaseTokens` is security-critical. The spec also calls out reentrancy.\n- A non-revocable role locks the grantor's tokens until it expires.\n- For single NFTs see [ERC-7432](/eip-7432/); for a simpler \"user\" field on ERC-1155 rentals see [ERC-5006](/eip-5006/).\n"},"ja":{"lang":"ja","tldr":"ERC-1155 トークンの利用権を貸し出すための標準のドラフト。所有者が残高をコミットし、所有権を移転せずに、その上で期限付きで任意に取り消し可能なロールを他のアカウントに付与する。","tags":["erc-1155","roles","rental","gaming","sft"],"related":[1155,7432,5006,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-7589/","markdown":"## 何を解決するのか\n\n[ERC-1155](/eip-1155/) は、各トークンを誰がいくつ所有しているかを追跡しますが、誰がそれを**使える**かについては何も定めていません。ゲームやアプリでは、トークン自体を手放さずに、ゲーム内アイテムを貸し出したり、ギルドメンバーにパスを使わせたり、一定期間だけ権利を委任したりしたい場合がよくあります。\n\nERC-7589 は、NFT 向けの [ERC-7432](/eip-7432/) と趣旨の似た、セミファンジブルトークン向けの標準ロールレイヤーを追加します。各ロールの割り当ては 1 人の被付与者に対して行われ、自動的に失効します。\n\n## 仕組み\n\n付与は 2 ステップで行います。\n\n1. **トークンをコミットする。** `commitTokens(grantor, tokenAddress, tokenId, amount)` が、特定の量をロックし（ロールコントラクトに預けるか凍結することで）、`commitmentId` を返します。\n2. **ロールを付与する。** `grantRole(commitmentId, role, grantee, expirationDate, revocable, data)` が、そのコミットメントに対して `bytes32` のロールを割り当てます。永続的なロールには `type(uint64).max` が推奨されます。\n\nその他の要素:\n\n- `revokeRole` は割り当てを終了させます。被付与者はいつでも放棄できます。付与者は、取り消し可能（revocable）であるか、すでに失効している場合にのみ取り消せます。\n- `releaseTokens(commitmentId)` はコミットしたトークンを返しますが、取り消し不可で未失効のロールが残っている間はリバートしなければなりません。\n- `setRoleApprovalForAll(tokenAddress, operator, approved)` により、オペレーター（たとえばレンタルのマーケットプレイス）が所有者の代わりにコミットと付与を行えます。これらの承認は ERC-1155 の承認とは別です。\n- ビュー関数: `grantorOf`、`tokenAmountOf`、`roleExpirationDate`、`isRoleRevocable`、`roleData` など。\n- ロール ID は、ロール名と引数の `keccak256`、たとえば `keccak256(\"Player(uint256)\")` とすることが推奨されます。\n- 任意の拡張: `commitTokensAndGrantRole`（1 トランザクション）と `roleBalanceOf`（あるロールについてユーザーに付与された合計量）。ERC-1155 メタデータ JSON 用の任意の `roles` セクションもあります。\n- コアインターフェースの ERC-165 インターフェース ID: `0xc4c8a71d`。\n\n## サンプルコード\n\nアイテム 5 個を 7 日間レンタルする例（ethers v6）:\n\n```ts\nimport { Contract, Wallet, JsonRpcProvider, id } from \"ethers\";\n\nconst provider = new JsonRpcProvider(process.env.RPC_URL);\nconst owner = new Wallet(process.env.PRIVATE_KEY!, provider);\nconst roles = new Contract(rolesAddress, [\n  \"event TokensCommitted(address indexed _grantor, uint256 indexed _commitmentId, address indexed _tokenAddress, uint256 _tokenId, uint256 _tokenAmount)\",\n  \"function commitTokens(address,address,uint256,uint256) returns (uint256)\",\n  \"function grantRole(uint256,bytes32,address,uint64,bool,bytes)\",\n], owner);\n\nconst receipt = await (await roles.commitTokens(owner.address, itemAddress, 42n, 5n)).wait();\nconst commitmentId = roles.interface.parseLog(receipt!.logs.find(l =\u003e l.address === rolesAddress)!)!.args._commitmentId;\n\nconst expires = BigInt(Math.floor(Date.now() / 1000) + 7 * 24 * 3600);\nawait roles.grantRole(commitmentId, id(\"Player()\"), renterAddress, expires, false, \"0x\");\n```\n\n## 知っておくべきこと\n\n- **ステータス: Draft。**\n- ロールを尊重するアプリは、`roleExpirationDate` を自分で確認しなければなりません。失効はトークンコントラクトによって強制されません。\n- コミットは残高を移転または凍結することがあるため、`commitTokens` と `releaseTokens` のアクセス制御はセキュリティ上きわめて重要です。仕様はリエントランシーにも言及しています。\n- 取り消し不可のロールは、失効するまで付与者のトークンをロックします。\n- 単一の NFT については [ERC-7432](/eip-7432/) を、ERC-1155 のレンタルに対するよりシンプルな「user」フィールドについては [ERC-5006](/eip-5006/) を参照してください。\n"},"ko":{"lang":"ko","tldr":"ERC-1155 토큰의 사용권을 빌려주기 위한 표준 초안. 소유자가 잔액을 커밋(commit)한 뒤, 소유권을 이전하지 않고 그 위에 기한이 있고 선택적으로 취소 가능한 역할(role)을 다른 계정에 부여한다.","tags":["erc-1155","roles","rental","gaming","sft"],"related":[1155,7432,5006,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-7589/","markdown":"## 어떤 문제를 해결하나요?\n\n[ERC-1155](/eip-1155/)는 각 토큰을 누가 몇 개 소유하는지는 추적하지만, 누가 그것을 **사용**할 수 있는지는 정하지 않습니다. 게임과 앱은 토큰 자체를 넘기지 않고 게임 내 아이템을 대여하거나, 길드원이 패스를 쓰게 하거나, 일정 기간 권한을 위임하고 싶을 때가 많습니다.\n\nERC-7589는 NFT를 위한 [ERC-7432](/eip-7432/)와 취지가 비슷한, 세미 펑저블 토큰용 표준 역할 계층을 추가합니다. 각 역할 할당은 한 명의 피부여자에게 가며 자동으로 만료됩니다.\n\n## 어떻게 동작하나요?\n\n부여는 두 단계로 이루어집니다.\n\n1. **토큰 커밋.** `commitTokens(grantor, tokenAddress, tokenId, amount)`가 특정 수량을 잠그고(역할 컨트랙트에 예치하거나 동결하는 방식) `commitmentId`를 반환합니다.\n2. **역할 부여.** `grantRole(commitmentId, role, grantee, expirationDate, revocable, data)`가 해당 커밋먼트에 `bytes32` 역할을 할당합니다. 영구 역할에는 `type(uint64).max`를 권장합니다.\n\n그 밖의 요소:\n\n- `revokeRole`은 할당을 종료합니다. 피부여자는 언제든 포기할 수 있고, 부여자는 취소 가능(revocable)하거나 이미 만료된 경우에만 취소할 수 있습니다.\n- `releaseTokens(commitmentId)`는 커밋한 토큰을 돌려주지만, 취소 불가능하고 만료되지 않은 역할이 남아 있는 동안에는 revert해야 합니다.\n- `setRoleApprovalForAll(tokenAddress, operator, approved)`로 오퍼레이터(예: 대여 마켓플레이스)가 소유자를 대신해 커밋하고 부여할 수 있습니다. 이 승인은 ERC-1155 승인과 별개입니다.\n- 조회 함수: `grantorOf`, `tokenAmountOf`, `roleExpirationDate`, `isRoleRevocable`, `roleData` 등.\n- 역할 ID는 역할 이름과 인자의 `keccak256`, 예를 들어 `keccak256(\"Player(uint256)\")`으로 하는 것을 권장합니다.\n- 선택적 확장: `commitTokensAndGrantRole`(한 번의 트랜잭션)과 `roleBalanceOf`(어떤 역할에 대해 사용자에게 부여된 총량). ERC-1155 메타데이터 JSON을 위한 선택적 `roles` 섹션도 있습니다.\n- 코어 인터페이스의 ERC-165 인터페이스 ID: `0xc4c8a71d`.\n\n## 샘플 코드\n\n아이템 5개를 7일간 대여하는 예제(ethers v6):\n\n```ts\nimport { Contract, Wallet, JsonRpcProvider, id } from \"ethers\";\n\nconst provider = new JsonRpcProvider(process.env.RPC_URL);\nconst owner = new Wallet(process.env.PRIVATE_KEY!, provider);\nconst roles = new Contract(rolesAddress, [\n  \"event TokensCommitted(address indexed _grantor, uint256 indexed _commitmentId, address indexed _tokenAddress, uint256 _tokenId, uint256 _tokenAmount)\",\n  \"function commitTokens(address,address,uint256,uint256) returns (uint256)\",\n  \"function grantRole(uint256,bytes32,address,uint64,bool,bytes)\",\n], owner);\n\nconst receipt = await (await roles.commitTokens(owner.address, itemAddress, 42n, 5n)).wait();\nconst commitmentId = roles.interface.parseLog(receipt!.logs.find(l =\u003e l.address === rolesAddress)!)!.args._commitmentId;\n\nconst expires = BigInt(Math.floor(Date.now() / 1000) + 7 * 24 * 3600);\nawait roles.grantRole(commitmentId, id(\"Player()\"), renterAddress, expires, false, \"0x\");\n```\n\n## 알아둘 점\n\n- **상태: Draft.**\n- 역할을 존중하는 앱은 `roleExpirationDate`를 직접 확인해야 합니다. 만료는 토큰 컨트랙트가 강제하지 않습니다.\n- 커밋은 잔액을 이전하거나 동결할 수 있으므로 `commitTokens`와 `releaseTokens`의 접근 제어는 보안상 매우 중요합니다. 사양은 재진입도 언급합니다.\n- 취소 불가능한 역할은 만료될 때까지 부여자의 토큰을 잠급니다.\n- 단일 NFT는 [ERC-7432](/eip-7432/)를, ERC-1155 대여에 대한 더 단순한 \"user\" 필드는 [ERC-5006](/eip-5006/)을 참고하세요.\n"},"zh":{"lang":"zh","tldr":"一个出借 ERC-1155 代币使用权的标准草案：所有者提交（commit）一部分余额，然后在不转移所有权的情况下，把基于该余额的、有时限且可选择可撤销的角色授予其他账户。","tags":["erc-1155","roles","rental","gaming","sft"],"related":[1155,7432,5006,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-7589/","markdown":"## 它解决什么问题？\n\n[ERC-1155](/eip-1155/) 记录每种代币谁拥有多少，但没有说明谁可以**使用**它们。游戏和应用常常希望出租游戏内物品、让公会成员使用通行证，或在固定期限内委托权利，而不必把代币本身送出去。\n\nERC-7589 为半同质化代币增加了一个标准的角色层，其理念与面向 NFT 的 [ERC-7432](/eip-7432/) 类似。每个角色分配只授予一个被授权者，并会自动过期。\n\n## 它如何运作\n\n授权分两步进行：\n\n1. **提交代币。** `commitTokens(grantor, tokenAddress, tokenId, amount)` 锁定特定数量（通过存入角色合约或冻结），并返回一个 `commitmentId`。\n2. **授予角色。** `grantRole(commitmentId, role, grantee, expirationDate, revocable, data)` 在该承诺上分配一个 `bytes32` 角色。永久角色推荐使用 `type(uint64).max`。\n\n其他部分：\n\n- `revokeRole` 结束一次分配。被授权者随时可以放弃；授权者只有在该角色可撤销或已过期时才能撤销。\n- `releaseTokens(commitmentId)` 返还已提交的代币，但只要还存在任何不可撤销且未过期的角色，就必须回滚。\n- `setRoleApprovalForAll(tokenAddress, operator, approved)` 让操作员（例如租赁市场）代表所有者提交和授权。这些授权与 ERC-1155 的授权是分开的。\n- 视图函数：`grantorOf`、`tokenAmountOf`、`roleExpirationDate`、`isRoleRevocable`、`roleData` 等。\n- 建议角色 ID 取角色名称和参数的 `keccak256`，例如 `keccak256(\"Player(uint256)\")`。\n- 可选扩展：`commitTokensAndGrantRole`（一笔交易完成）和 `roleBalanceOf`（针对某个角色授予某用户的总量）。此外还有一个供 ERC-1155 元数据 JSON 使用的可选 `roles` 部分。\n- 核心接口的 ERC-165 接口 ID：`0xc4c8a71d`。\n\n## 示例代码\n\n把某物品的 5 个单位出租 7 天（ethers v6）：\n\n```ts\nimport { Contract, Wallet, JsonRpcProvider, id } from \"ethers\";\n\nconst provider = new JsonRpcProvider(process.env.RPC_URL);\nconst owner = new Wallet(process.env.PRIVATE_KEY!, provider);\nconst roles = new Contract(rolesAddress, [\n  \"event TokensCommitted(address indexed _grantor, uint256 indexed _commitmentId, address indexed _tokenAddress, uint256 _tokenId, uint256 _tokenAmount)\",\n  \"function commitTokens(address,address,uint256,uint256) returns (uint256)\",\n  \"function grantRole(uint256,bytes32,address,uint64,bool,bytes)\",\n], owner);\n\nconst receipt = await (await roles.commitTokens(owner.address, itemAddress, 42n, 5n)).wait();\nconst commitmentId = roles.interface.parseLog(receipt!.logs.find(l =\u003e l.address === rolesAddress)!)!.args._commitmentId;\n\nconst expires = BigInt(Math.floor(Date.now() / 1000) + 7 * 24 * 3600);\nawait roles.grantRole(commitmentId, id(\"Player()\"), renterAddress, expires, false, \"0x\");\n```\n\n## 需要注意\n\n- **状态：Draft。**\n- 遵循角色的应用必须自行检查 `roleExpirationDate`；过期并不由代币合约强制执行。\n- 提交可能会转移或冻结余额，因此 `commitTokens` 和 `releaseTokens` 的访问控制对安全至关重要。规范还特别提到了重入问题。\n- 不可撤销的角色会锁定授权者的代币，直到其过期。\n- 单个 NFT 请参阅 [ERC-7432](/eip-7432/)；对于 ERC-1155 租赁中更简单的 \"user\" 字段，请参阅 [ERC-5006](/eip-5006/)。\n"}}}
