{"eip":7695,"title":"Ownership Delegation and Context for ERC-721","description":"Introduces contexts and ownership delegation for ERC-721 tokens, expanding dApps and financial use cases without transferring ownership","authors":["Duc Tho Tran (@ducthotran2010)"],"status":"Draft","type":"Standards Track","category":"ERC","created":"2024-04-02","requires":[165,721],"discussionsTo":"https://ethereum-magicians.org/t/erc-7695-ownership-delegation-and-context-for-non-fungible-token/19716","repo":"ERCs","label":"ERC-7695","officialUrl":"https://eips.ethereum.org/EIPS/eip-7695","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7695.md","url":"https://eips.huatuo.xyz/eip-7695/","tldr":{"en":"An ERC-721 extension that lets an NFT be used, locked and even temporarily delegated in different app 'contexts' without the owner ever transferring it, so staking, rentals and loans don't cost owners their holder benefits.","ja":"オーナーが NFT を転送することなく、アプリごとの「コンテキスト」で NFT を利用・ロック・一時的な委任までできる ERC-721 拡張。ステーキング、レンタル、ローンでもオーナーが保有者特典を失わない。","ko":"소유자가 NFT를 전송하지 않고도 앱별 '컨텍스트'에서 NFT를 사용하고, 잠그고, 일시적으로 위임까지 할 수 있는 ERC-721 확장. 스테이킹, 대여, 대출을 해도 소유자가 홀더 혜택을 잃지 않는다.","zh":"一个 ERC-721 扩展，让 NFT 无需所有者转移，就能在不同应用的\"上下文\"中被使用、锁定甚至临时委托，使质押、租赁和借贷不再让所有者失去持有者权益。"},"tags":["nft","erc721","delegation","rental","staking"],"explainers":{"en":{"lang":"en","tldr":"An ERC-721 extension that lets an NFT be used, locked and even temporarily delegated in different app 'contexts' without the owner ever transferring it, so staking, rentals and loans don't cost owners their holder benefits.","tags":["nft","erc721","delegation","rental","staking"],"related":[721,165,4907,5006],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-7695/","markdown":"## What problem does it solve?\n\nTo stake, rent out or borrow against an ERC-721 NFT today, you usually transfer it into a protocol contract. The NFT then no longer sits in your wallet, so other apps that reward holders (airdrops, tiered perks) stop recognising you, unless they integrate every staking contract out there.\n\nERC-7695 keeps the NFT with its owner and instead adds two concepts on top of [ERC-721](/eip-721/): **contexts**, where an app can assign a user and lock the token, and **ownership delegation**, where the owner temporarily hands the *rights* of ownership to someone else.\n\n## How it works\n\n**Contexts.** Anyone can `createContext(controller, detachingDuration, ctxMsg)`, which returns a `ctxHash`. Each context has:\n\n- a **Controller** that can set the context's **User** (`setContextUser`) and lock or unlock the token in that context (`setContextLock`);\n- a `detachingDuration`, capped by the contract's `maxDetachingDuration()`.\n\nThe owner attaches the token with `attachContext`. To leave, they call `requestDetachContext`: if the token is unlocked it detaches immediately; if locked, they must wait `detachingDuration` and then call `execDetachContext`. The controller cannot block this, so a lost or malicious controller cannot trap a token forever. A controller that is a contract gets callbacks (`onAttached`, `onDetachRequested`, `onExecDetachContext`); only `onAttached` can reject.\n\n**Ownership delegation.** The owner calls `startDelegateOwnership(tokenId, delegatee, until)`; the delegatee confirms with `acceptOwnershipDelegation`. Until expiry the delegatee is the **ownership manager**: they can transfer and attach/detach contexts. Ownership reverts automatically at `until`, or earlier if the delegatee calls `stopOwnershipDelegation`.\n\n**Transfers** revoke any delegation and detach every context; they revert if a locked context has not finished its detach wait.\n\nThe interface ID is `0x486b6fba`; the optional enumerable extension is `0xcebf44b7` and the controller callback interface is `0xad0491f1`.\n\n## Sample code\n\nA rental app as context controller (ethers v6):\n\n```ts\nimport { Contract } from \"ethers\";\n\nconst nft = new Contract(nftAddress, [\n  \"function createContext(address,uint64,bytes) returns (bytes32)\",\n  \"function attachContext(bytes32,uint256,bytes)\",\n  \"function setContextUser(bytes32,uint256,address)\",\n  \"function setContextLock(bytes32,uint256,bool)\",\n  \"function getContextUser(bytes32,uint256) view returns (address)\",\n], signer);\n\n// Owner attaches token 42 to the rental app's context\nawait (await nft.connect(owner).attachContext(ctxHash, 42n, \"0x\")).wait();\n\n// The app (controller) locks it and assigns the renter as user\nawait (await nft.connect(controller).setContextLock(ctxHash, 42n, true)).wait();\nawait (await nft.connect(controller).setContextUser(ctxHash, 42n, renter)).wait();\n\nconsole.log(await nft.getContextUser(ctxHash, 42n)); // renter\n```\n\n## Things to know\n\n- Status is **Draft**.\n- For rental-only use cases, simpler standards exist: [ERC-4907](/eip-4907/) and [ERC-5006](/eip-5006/) add a time-limited \"user\" role.\n- **Phishing:** tricking an owner into `startDelegateOwnership` is as dangerous as a malicious `setApprovalForAll`, since the delegatee can transfer the token.\n- Systems built on delegation should request a delegation period longer than `maxDetachingDuration`, otherwise the owner could lock the token in another context so it cannot be moved before delegation ends.\n- Controllers' callback functions should check that `msg.sender` is the expected token contract.\n- Two contexts in the same app can lead to the same token being used twice; controllers should coordinate.\n"},"ja":{"lang":"ja","tldr":"オーナーが NFT を転送することなく、アプリごとの「コンテキスト」で NFT を利用・ロック・一時的な委任までできる ERC-721 拡張。ステーキング、レンタル、ローンでもオーナーが保有者特典を失わない。","tags":["nft","erc721","delegation","rental","staking"],"related":[721,165,4907,5006],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-7695/","markdown":"## 何を解決するのか\n\n現在、ERC-721 NFT をステーキングしたり、貸し出したり、担保に借り入れたりするには、通常はプロトコルのコントラクトに NFT を転送します。するとその NFT はウォレットからなくなるため、保有者に報酬を出す他のアプリ（エアドロップ、段階別の特典）は、世の中のすべてのステーキングコントラクトに対応していない限り、あなたを保有者として認識できなくなります。\n\nERC-7695 は NFT をオーナーの手元に残したまま、[ERC-721](/eip-721/) の上に 2 つの概念を追加します。アプリがユーザーを割り当ててトークンをロックできる**コンテキスト**と、オーナーが所有権の*権利*を一時的に他者へ渡す**所有権の委任**です。\n\n## 仕組み\n\n**コンテキスト。** 誰でも `createContext(controller, detachingDuration, ctxMsg)` を呼べ、`ctxHash` が返ります。各コンテキストには次があります。\n\n- コンテキストの **User** を設定（`setContextUser`）し、そのコンテキストでトークンをロック／アンロック（`setContextLock`）できる **Controller**\n- `detachingDuration`。コントラクトの `maxDetachingDuration()` が上限\n\nオーナーは `attachContext` でトークンをアタッチします。抜けるには `requestDetachContext` を呼びます。トークンがアンロック状態なら即座にデタッチされ、ロック状態なら `detachingDuration` だけ待ってから `execDetachContext` を呼ぶ必要があります。Controller はこれを妨げられないため、Controller を失ったり悪意があったりしても、トークンが永久に閉じ込められることはありません。コントラクトである Controller にはコールバック（`onAttached`、`onDetachRequested`、`onExecDetachContext`）が呼ばれ、拒否できるのは `onAttached` だけです。\n\n**所有権の委任。** オーナーが `startDelegateOwnership(tokenId, delegatee, until)` を呼び、委任先が `acceptOwnershipDelegation` で承諾します。期限まで、委任先が**所有権マネージャー**となり、転送やコンテキストのアタッチ／デタッチができます。所有権は `until` で自動的に元に戻り、委任先が `stopOwnershipDelegation` を呼べばそれより早く戻ります。\n\n**転送**はあらゆる委任を取り消し、すべてのコンテキストをデタッチします。ロック中のコンテキストでデタッチの待機が終わっていない場合は revert します。\n\nインターフェース ID は `0x486b6fba` で、任意の enumerable 拡張は `0xcebf44b7`、Controller のコールバックインターフェースは `0xad0491f1` です。\n\n## サンプルコード\n\nコンテキストの Controller としてのレンタルアプリ（ethers v6）:\n\n```ts\nimport { Contract } from \"ethers\";\n\nconst nft = new Contract(nftAddress, [\n  \"function createContext(address,uint64,bytes) returns (bytes32)\",\n  \"function attachContext(bytes32,uint256,bytes)\",\n  \"function setContextUser(bytes32,uint256,address)\",\n  \"function setContextLock(bytes32,uint256,bool)\",\n  \"function getContextUser(bytes32,uint256) view returns (address)\",\n], signer);\n\n// Owner attaches token 42 to the rental app's context\nawait (await nft.connect(owner).attachContext(ctxHash, 42n, \"0x\")).wait();\n\n// The app (controller) locks it and assigns the renter as user\nawait (await nft.connect(controller).setContextLock(ctxHash, 42n, true)).wait();\nawait (await nft.connect(controller).setContextUser(ctxHash, 42n, renter)).wait();\n\nconsole.log(await nft.getContextUser(ctxHash, 42n)); // renter\n```\n\n## 知っておくべきこと\n\n- ステータスは **Draft** です。\n- レンタル専用の用途なら、より単純な規格があります。[ERC-4907](/eip-4907/) と [ERC-5006](/eip-5006/) は期間限定の「user」ロールを追加します。\n- **フィッシング:** オーナーをだまして `startDelegateOwnership` を実行させるのは、悪意ある `setApprovalForAll` と同じくらい危険です。委任先がトークンを転送できるためです。\n- 委任の上に構築するシステムは、`maxDetachingDuration` より長い委任期間を要求すべきです。そうしないと、オーナーが別のコンテキストでトークンをロックし、委任が終わるまでトークンを移動できなくする可能性があります。\n- Controller のコールバック関数は、`msg.sender` が想定するトークンコントラクトであることを確認すべきです。\n- 同じアプリ内の 2 つのコンテキストで同じトークンが二重に使われる可能性があります。Controller 同士で調整してください。\n"},"ko":{"lang":"ko","tldr":"소유자가 NFT를 전송하지 않고도 앱별 '컨텍스트'에서 NFT를 사용하고, 잠그고, 일시적으로 위임까지 할 수 있는 ERC-721 확장. 스테이킹, 대여, 대출을 해도 소유자가 홀더 혜택을 잃지 않는다.","tags":["nft","erc721","delegation","rental","staking"],"related":[721,165,4907,5006],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-7695/","markdown":"## 어떤 문제를 해결하나요?\n\n오늘날 ERC-721 NFT를 스테이킹하거나, 빌려주거나, 담보로 대출을 받으려면 보통 NFT를 프로토콜 컨트랙트로 전송해야 합니다. 그러면 NFT가 더 이상 내 지갑에 없으므로, 홀더에게 보상하는 다른 앱(에어드롭, 등급별 혜택)은 세상의 모든 스테이킹 컨트랙트를 연동하지 않는 한 나를 홀더로 인식하지 못합니다.\n\nERC-7695는 NFT를 소유자에게 그대로 두고, 대신 [ERC-721](/eip-721/) 위에 두 가지 개념을 추가합니다. 앱이 사용자를 지정하고 토큰을 잠글 수 있는 **컨텍스트**, 그리고 소유자가 소유권의 *권리*를 일시적으로 다른 사람에게 넘기는 **소유권 위임**입니다.\n\n## 어떻게 동작하나요?\n\n**컨텍스트.** 누구나 `createContext(controller, detachingDuration, ctxMsg)`를 호출할 수 있고, `ctxHash`가 반환됩니다. 각 컨텍스트에는 다음이 있습니다.\n\n- 컨텍스트의 **User**를 설정(`setContextUser`)하고 해당 컨텍스트에서 토큰을 잠그거나 해제(`setContextLock`)할 수 있는 **Controller**\n- `detachingDuration`. 컨트랙트의 `maxDetachingDuration()`이 상한입니다.\n\n소유자는 `attachContext`로 토큰을 연결합니다. 빠져나오려면 `requestDetachContext`를 호출합니다. 토큰이 잠겨 있지 않으면 즉시 분리되고, 잠겨 있으면 `detachingDuration`만큼 기다린 뒤 `execDetachContext`를 호출해야 합니다. Controller는 이를 막을 수 없으므로, Controller를 잃어버리거나 악의적이어도 토큰이 영원히 갇히지 않습니다. 컨트랙트인 Controller는 콜백(`onAttached`, `onDetachRequested`, `onExecDetachContext`)을 받으며, 거부할 수 있는 것은 `onAttached`뿐입니다.\n\n**소유권 위임.** 소유자가 `startDelegateOwnership(tokenId, delegatee, until)`을 호출하고, 위임받는 쪽이 `acceptOwnershipDelegation`으로 수락합니다. 만료 전까지 위임받은 쪽이 **소유권 관리자**가 되어 토큰을 전송하고 컨텍스트를 연결/분리할 수 있습니다. 소유권은 `until`에 자동으로 되돌아오며, 위임받은 쪽이 `stopOwnershipDelegation`을 호출하면 더 일찍 돌아옵니다.\n\n**전송**은 모든 위임을 취소하고 모든 컨텍스트를 분리합니다. 잠긴 컨텍스트의 분리 대기가 끝나지 않았다면 revert됩니다.\n\n인터페이스 ID는 `0x486b6fba`이고, 선택적 enumerable 확장은 `0xcebf44b7`, Controller 콜백 인터페이스는 `0xad0491f1`입니다.\n\n## 샘플 코드\n\n컨텍스트 Controller로서의 대여 앱(ethers v6):\n\n```ts\nimport { Contract } from \"ethers\";\n\nconst nft = new Contract(nftAddress, [\n  \"function createContext(address,uint64,bytes) returns (bytes32)\",\n  \"function attachContext(bytes32,uint256,bytes)\",\n  \"function setContextUser(bytes32,uint256,address)\",\n  \"function setContextLock(bytes32,uint256,bool)\",\n  \"function getContextUser(bytes32,uint256) view returns (address)\",\n], signer);\n\n// Owner attaches token 42 to the rental app's context\nawait (await nft.connect(owner).attachContext(ctxHash, 42n, \"0x\")).wait();\n\n// The app (controller) locks it and assigns the renter as user\nawait (await nft.connect(controller).setContextLock(ctxHash, 42n, true)).wait();\nawait (await nft.connect(controller).setContextUser(ctxHash, 42n, renter)).wait();\n\nconsole.log(await nft.getContextUser(ctxHash, 42n)); // renter\n```\n\n## 알아둘 점\n\n- 상태는 **Draft**입니다.\n- 대여만 필요한 경우에는 더 단순한 표준이 있습니다. [ERC-4907](/eip-4907/)과 [ERC-5006](/eip-5006/)은 기간 제한이 있는 \"user\" 역할을 추가합니다.\n- **피싱:** 소유자를 속여 `startDelegateOwnership`을 실행하게 만드는 것은 악의적인 `setApprovalForAll`만큼 위험합니다. 위임받은 쪽이 토큰을 전송할 수 있기 때문입니다.\n- 위임 위에 구축하는 시스템은 `maxDetachingDuration`보다 긴 위임 기간을 요구해야 합니다. 그렇지 않으면 소유자가 다른 컨텍스트에서 토큰을 잠가 위임이 끝나기 전까지 토큰을 옮길 수 없게 만들 수 있습니다.\n- Controller의 콜백 함수는 `msg.sender`가 예상하는 토큰 컨트랙트인지 확인해야 합니다.\n- 같은 앱의 두 컨텍스트가 같은 토큰을 이중으로 사용하게 할 수 있으므로, Controller끼리 조율해야 합니다.\n"},"zh":{"lang":"zh","tldr":"一个 ERC-721 扩展，让 NFT 无需所有者转移，就能在不同应用的\"上下文\"中被使用、锁定甚至临时委托，使质押、租赁和借贷不再让所有者失去持有者权益。","tags":["nft","erc721","delegation","rental","staking"],"related":[721,165,4907,5006],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-7695/","markdown":"## 它解决什么问题？\n\n如今要对 ERC-721 NFT 进行质押、出租或抵押借款，通常需要把它转入协议合约。这样 NFT 就不再留在你的钱包里，其他奖励持有者的应用（空投、分级福利）就不再认得你，除非它们集成了所有的质押合约。\n\nERC-7695 让 NFT 留在所有者手中，转而在 [ERC-721](/eip-721/) 之上增加两个概念：**上下文（context）**，应用可以在其中指定使用者并锁定代币；以及**所有权委托**，所有者临时把所有权的*权利*交给别人。\n\n## 它如何运作\n\n**上下文。**任何人都可以调用 `createContext(controller, detachingDuration, ctxMsg)`，它会返回一个 `ctxHash`。每个上下文包含：\n\n- 一个 **Controller**，可以设置该上下文的 **User**（`setContextUser`），并在该上下文中锁定或解锁代币（`setContextLock`）；\n- 一个 `detachingDuration`，上限为合约的 `maxDetachingDuration()`。\n\n所有者通过 `attachContext` 附加代币。要离开时调用 `requestDetachContext`：如果代币未锁定则立即分离；如果已锁定，则必须等待 `detachingDuration`，然后调用 `execDetachContext`。Controller 无法阻止这一过程，因此丢失或恶意的 Controller 无法把代币永远困住。作为合约的 Controller 会收到回调（`onAttached`、`onDetachRequested`、`onExecDetachContext`）；只有 `onAttached` 可以拒绝。\n\n**所有权委托。**所有者调用 `startDelegateOwnership(tokenId, delegatee, until)`；被委托方通过 `acceptOwnershipDelegation` 确认。到期之前，被委托方是**所有权管理者**：可以转移代币，并附加/分离上下文。所有权在 `until` 自动恢复，或在被委托方调用 `stopOwnershipDelegation` 时提前恢复。\n\n**转移**会撤销所有委托并分离所有上下文；如果某个已锁定的上下文尚未完成分离等待，转移会 revert。\n\n接口 ID 为 `0x486b6fba`；可选的 enumerable 扩展为 `0xcebf44b7`，Controller 回调接口为 `0xad0491f1`。\n\n## 示例代码\n\n作为上下文 Controller 的租赁应用（ethers v6）：\n\n```ts\nimport { Contract } from \"ethers\";\n\nconst nft = new Contract(nftAddress, [\n  \"function createContext(address,uint64,bytes) returns (bytes32)\",\n  \"function attachContext(bytes32,uint256,bytes)\",\n  \"function setContextUser(bytes32,uint256,address)\",\n  \"function setContextLock(bytes32,uint256,bool)\",\n  \"function getContextUser(bytes32,uint256) view returns (address)\",\n], signer);\n\n// Owner attaches token 42 to the rental app's context\nawait (await nft.connect(owner).attachContext(ctxHash, 42n, \"0x\")).wait();\n\n// The app (controller) locks it and assigns the renter as user\nawait (await nft.connect(controller).setContextLock(ctxHash, 42n, true)).wait();\nawait (await nft.connect(controller).setContextUser(ctxHash, 42n, renter)).wait();\n\nconsole.log(await nft.getContextUser(ctxHash, 42n)); // renter\n```\n\n## 需要注意\n\n- 状态为 **Draft**。\n- 如果只是租赁场景，有更简单的标准：[ERC-4907](/eip-4907/) 和 [ERC-5006](/eip-5006/) 增加了限时的\"user\"角色。\n- **钓鱼风险：**诱骗所有者调用 `startDelegateOwnership` 与恶意的 `setApprovalForAll` 一样危险，因为被委托方可以转移代币。\n- 基于委托构建的系统应要求比 `maxDetachingDuration` 更长的委托期，否则所有者可能在另一个上下文中锁定代币，使其在委托结束前无法移动。\n- Controller 的回调函数应检查 `msg.sender` 是否为预期的代币合约。\n- 同一应用中的两个上下文可能导致同一代币被重复使用；Controller 之间应当协调。\n"}}}
