---
eip: 7721
label: ERC-7721
title: Lockable Extension for ERC-1155
status: Draft
type: Standards Track
category: ERC
created: 2023-05-25
requires: 165, 1155
official: https://eips.ethereum.org/EIPS/eip-7721
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7721.md
canonical: https://eips.huatuo.xyz/ko/eip-7721/
lang: ko
tldr: ERC-1155 확장. 보유자가 자신의 지갑 안에서 토큰 수량을 지정한 locker 아래에 잠글 수 있게 하여, 에스크로 없이 대출과 대여를 가능하게 한다.
tags: [erc-1155, nft, lock, nftfi, token]
---

# ERC-7721: Lockable Extension for ERC-1155

> Interface for enabling locking of ERC-1155 using locker and token id based approvals

**TL;DR:** ERC-1155 확장. 보유자가 자신의 지갑 안에서 토큰 수량을 지정한 locker 아래에 잠글 수 있게 하여, 에스크로 없이 대출과 대여를 가능하게 한다.

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

오늘날 NFT를 대출 담보로 쓰거나 빌려주려면 보통 프로토콜의 에스크로 컨트랙트로 옮겨야 합니다. 그곳에 있는 동안에는 NFT의 효용(게임 접근, Discord 역할 등)을 잃고, 다른 금융 도구와 함께 쓸 수 없으며, 해당 에스크로 컨트랙트의 버그에도 노출됩니다.

ERC-7721은 [ERC-1155](/eip-1155/) 토큰에 네이티브 잠금을 추가합니다. 토큰은 소유자의 지갑에 그대로 남아 있지만, 선택된 *locker* 주소가 특정 수량이 언제 다시 이동할 수 있는지를 제어합니다. ERC-721용으로 같은 아이디어를 담은 것이 [ERC-7066](/eip-7066/)입니다.

## 어떻게 동작하나요?

잠금은 `tokenId`별, `account`별, `locker`별, 그리고 **수량**별로 이루어집니다(ERC-1155 잔액은 수량이기 때문입니다).

- `lock(tokenId, account, locker, amount)`: 소유자가 `amount`를 잠그고 별도의 `locker`를 지정합니다.
- `lock(tokenId, account, amount)`: 소유자 또는 승인된 operator가 `amount`를 잠그고, 호출자가 locker가 됩니다.
- `unlock(tokenId, account, amount)`: locker만 해제할 수 있습니다.
- `setApprovalForId(tokenId, operator, amount)`: ERC-1155의 전부 아니면 전무인 `setApprovalForAll`보다 세밀한 승인입니다.
- `transferAndLock(from, to, tokenId, amount, setApprove)`: 수신자에게 전송하고 그곳에서 잠그는 것을 한 번에 수행하며, 선택적으로 호출자에게 승인을 주어 나중에 토큰을 되찾을 수 있게 합니다(대여나 선구매 후불에 유용합니다).
- `getLocked(tokenId, account, operator)`는 잠긴 수량을 반환합니다.

`safeTransferFrom`은 잠긴 단위를 이동시키게 되는 경우 revert해야 합니다. 전송 가능한 최대 수량은 `balance - locked`입니다. `Lock`과 `Unlock` 이벤트로 인덱서가 상태를 추적할 수 있습니다.

## 샘플 코드

인터페이스와 전송 규칙을 강제하는 헬퍼입니다.

```solidity
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;

import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";

interface IERC7721 is IERC1155 {
    event Lock(uint256 indexed tokenId, address account, address _locker, uint256 amount);
    event Unlock(uint256 indexed tokenId, address account, address _locker, uint256 amount);

    function lock(uint256 tokenId, address account, uint256 amount) external;
    function lock(uint256 tokenId, address account, address _locker, uint256 amount) external;
    function unlock(uint256 tokenId, address account, uint256 amount) external;
    function transferAndLock(address from, address to, uint256 tokenId, uint256 amount, bool setApprove) external;
    function getLocked(uint256 tokenId, address account, address operator) external view returns (uint256);
    function setApprovalForId(uint256 tokenId, address operator, uint256 amount) external;
}

// Inside an implementation's transfer hook:
// uint256 free = balanceOf(from, id) - totalLocked[id][from];
// require(amount <= free, "ERC7721: amount locked");
```

TypeScript에서 잠긴 수량 확인하기(ethers v6):

```ts
const lockable = new Contract(tokenAddr, [
  "function getLocked(uint256,address,address) view returns (uint256)",
], provider);
const locked = await lockable.getLocked(tokenId, holder, lenderContract);
```

## 알아둘 점

- **상태: Draft.** 함수 시그니처는 아직 바뀔 수 있습니다.
- `getLocked`의 인터페이스 주석에는 지갑을 반환한다고 되어 있지만 명세 본문에는 수량을 반환한다고 되어 있습니다. 구현체는 수량으로 해석합니다.
- locker가 접근할 수 없는 주소이거나 잠금 해제 경로가 없는 컨트랙트이면 토큰이 영원히 잠길 수 있습니다. 잠그기 전에 locker를 검토하세요.
- 잠긴 단위를 전송하면 revert되므로, 마켓플레이스는 등록 전에 잠긴 수량을 확인해야 합니다.


---

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