---
eip: 7695
label: ERC-7695
title: Ownership Delegation and Context for ERC-721
status: Draft
type: Standards Track
category: ERC
created: 2024-04-02
requires: 165, 721
official: https://eips.ethereum.org/EIPS/eip-7695
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7695.md
canonical: https://eips.huatuo.xyz/ko/eip-7695/
lang: ko
tldr: "소유자가 NFT를 전송하지 않고도 앱별 '컨텍스트'에서 NFT를 사용하고, 잠그고, 일시적으로 위임까지 할 수 있는 ERC-721 확장. 스테이킹, 대여, 대출을 해도 소유자가 홀더 혜택을 잃지 않는다."
tags: [nft, erc721, delegation, rental, staking]
---

# ERC-7695: Ownership Delegation and Context for ERC-721

> Introduces contexts and ownership delegation for ERC-721 tokens, expanding dApps and financial use cases without transferring ownership

**TL;DR:** 소유자가 NFT를 전송하지 않고도 앱별 '컨텍스트'에서 NFT를 사용하고, 잠그고, 일시적으로 위임까지 할 수 있는 ERC-721 확장. 스테이킹, 대여, 대출을 해도 소유자가 홀더 혜택을 잃지 않는다.

## 어떤 문제를 해결하나요?

오늘날 ERC-721 NFT를 스테이킹하거나, 빌려주거나, 담보로 대출을 받으려면 보통 NFT를 프로토콜 컨트랙트로 전송해야 합니다. 그러면 NFT가 더 이상 내 지갑에 없으므로, 홀더에게 보상하는 다른 앱(에어드롭, 등급별 혜택)은 세상의 모든 스테이킹 컨트랙트를 연동하지 않는 한 나를 홀더로 인식하지 못합니다.

ERC-7695는 NFT를 소유자에게 그대로 두고, 대신 [ERC-721](/eip-721/) 위에 두 가지 개념을 추가합니다. 앱이 사용자를 지정하고 토큰을 잠글 수 있는 **컨텍스트**, 그리고 소유자가 소유권의 *권리*를 일시적으로 다른 사람에게 넘기는 **소유권 위임**입니다.

## 어떻게 동작하나요?

**컨텍스트.** 누구나 `createContext(controller, detachingDuration, ctxMsg)`를 호출할 수 있고, `ctxHash`가 반환됩니다. 각 컨텍스트에는 다음이 있습니다.

- 컨텍스트의 **User**를 설정(`setContextUser`)하고 해당 컨텍스트에서 토큰을 잠그거나 해제(`setContextLock`)할 수 있는 **Controller**
- `detachingDuration`. 컨트랙트의 `maxDetachingDuration()`이 상한입니다.

소유자는 `attachContext`로 토큰을 연결합니다. 빠져나오려면 `requestDetachContext`를 호출합니다. 토큰이 잠겨 있지 않으면 즉시 분리되고, 잠겨 있으면 `detachingDuration`만큼 기다린 뒤 `execDetachContext`를 호출해야 합니다. Controller는 이를 막을 수 없으므로, Controller를 잃어버리거나 악의적이어도 토큰이 영원히 갇히지 않습니다. 컨트랙트인 Controller는 콜백(`onAttached`, `onDetachRequested`, `onExecDetachContext`)을 받으며, 거부할 수 있는 것은 `onAttached`뿐입니다.

**소유권 위임.** 소유자가 `startDelegateOwnership(tokenId, delegatee, until)`을 호출하고, 위임받는 쪽이 `acceptOwnershipDelegation`으로 수락합니다. 만료 전까지 위임받은 쪽이 **소유권 관리자**가 되어 토큰을 전송하고 컨텍스트를 연결/분리할 수 있습니다. 소유권은 `until`에 자동으로 되돌아오며, 위임받은 쪽이 `stopOwnershipDelegation`을 호출하면 더 일찍 돌아옵니다.

**전송**은 모든 위임을 취소하고 모든 컨텍스트를 분리합니다. 잠긴 컨텍스트의 분리 대기가 끝나지 않았다면 revert됩니다.

인터페이스 ID는 `0x486b6fba`이고, 선택적 enumerable 확장은 `0xcebf44b7`, Controller 콜백 인터페이스는 `0xad0491f1`입니다.

## 샘플 코드

컨텍스트 Controller로서의 대여 앱(ethers v6):

```ts
import { Contract } from "ethers";

const nft = new Contract(nftAddress, [
  "function createContext(address,uint64,bytes) returns (bytes32)",
  "function attachContext(bytes32,uint256,bytes)",
  "function setContextUser(bytes32,uint256,address)",
  "function setContextLock(bytes32,uint256,bool)",
  "function getContextUser(bytes32,uint256) view returns (address)",
], signer);

// Owner attaches token 42 to the rental app's context
await (await nft.connect(owner).attachContext(ctxHash, 42n, "0x")).wait();

// The app (controller) locks it and assigns the renter as user
await (await nft.connect(controller).setContextLock(ctxHash, 42n, true)).wait();
await (await nft.connect(controller).setContextUser(ctxHash, 42n, renter)).wait();

console.log(await nft.getContextUser(ctxHash, 42n)); // renter
```

## 알아둘 점

- 상태는 **Draft**입니다.
- 대여만 필요한 경우에는 더 단순한 표준이 있습니다. [ERC-4907](/eip-4907/)과 [ERC-5006](/eip-5006/)은 기간 제한이 있는 "user" 역할을 추가합니다.
- **피싱:** 소유자를 속여 `startDelegateOwnership`을 실행하게 만드는 것은 악의적인 `setApprovalForAll`만큼 위험합니다. 위임받은 쪽이 토큰을 전송할 수 있기 때문입니다.
- 위임 위에 구축하는 시스템은 `maxDetachingDuration`보다 긴 위임 기간을 요구해야 합니다. 그렇지 않으면 소유자가 다른 컨텍스트에서 토큰을 잠가 위임이 끝나기 전까지 토큰을 옮길 수 없게 만들 수 있습니다.
- Controller의 콜백 함수는 `msg.sender`가 예상하는 토큰 컨트랙트인지 확인해야 합니다.
- 같은 앱의 두 컨텍스트가 같은 토큰을 이중으로 사용하게 할 수 있으므로, Controller끼리 조율해야 합니다.


---

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