---
eip: 7401
label: ERC-7401
title: Parent-Governed Non-Fungible Tokens Nesting
status: Final
type: Standards Track
category: ERC
created: 2023-07-26
requires: 165, 721
official: https://eips.ethereum.org/EIPS/eip-7401
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7401.md
canonical: https://eips.huatuo.xyz/ko/eip-7401/
lang: ko
tldr: ERC-721 NFT가 다른 NFT를 소유할 수 있게 한다. 어떤 자식 토큰을 받아들이고, 보유하고, 내보낼지는 부모 토큰 소유자가 완전히 통제한다.
tags: [nft, nesting, erc721, composable]
---

# ERC-7401: Parent-Governed Non-Fungible Tokens Nesting

> An interface for Non-Fungible Tokens Nesting with emphasis on parent token's control over the relationship.

**TL;DR:** ERC-721 NFT가 다른 NFT를 소유할 수 있게 한다. 어떤 자식 토큰을 받아들이고, 보유하고, 내보낼지는 부모 토큰 소유자가 완전히 통제한다.

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

일반 [ERC-721](/eip-721/)에서 NFT는 지갑이나 컨트랙트가 소유할 수는 있지만 다른 NFT가 소유할 수는 없습니다. 그래서 흔한 아이디어들이 어색해집니다. 여러 NFT 묶음을 한 트랜잭션으로 파는 것, 게임 캐릭터가 아이템을 "들고" 있는 것, 에어드롭된 혜택을 받는 멤버십 패스, 여정의 구간마다 소울바운드 기록을 모으는 컨테이너 토큰 같은 것들입니다.

ERC-7401은 NFT가 다른 NFT를 소유하는 표준 방식을 정의합니다. 설계는 같지만 인터페이스 ID가 공개된 인터페이스와 맞지 않았던 [ERC-6059](/eip-6059/)를 대체하며, ERC-7401은 이를 고쳤고 그 외에는 기능적으로 동일합니다.

## 어떻게 동작하나요?

- **부모와 자식.** 토큰은 자식(부모 토큰 하나가 소유)이면서 부모(여러 자식을 소유)일 수 있습니다. 토큰을 중첩하는 일은 전송과 비슷하지만, `nestTransferFrom`으로 `(contract, tokenId)` 쌍을 대상으로 합니다.
- **루트 소유자.** `ownerOf`는 트리를 따라 올라가 NFT가 아닌 첫 소유자(지갑 또는 수신 컨트랙트)를 반환합니다. `directOwnerOf`는 바로 위 소유자를 `(address, parentTokenId, isNft)`로 반환합니다.
- **제안한 뒤 수락.** 누구나 부모에게 자식을 보낼 수 있지만 *대기(pending)* 목록에 들어갑니다(권장 최대 128개). 루트 소유자(또는 승인된 주체)만 `acceptChild`로 *활성(active)* 목록에 넣거나 `rejectAllChildren`을 할 수 있습니다. 아무도 토큰을 억지로 떠넘길 수 없습니다.
- **부모가 관장.** 토큰이 중첩되어 있는 동안에는 부모만 그것을 옮길 수 있습니다. 루트 소유자가 부모 컨트랙트의 `transferChild`를 호출하면, 자식을 지갑으로 꺼내거나(unnest), 다른 부모로 옮기거나(거기서 다시 대기 상태가 됨), 거부하거나, 포기할 수 있습니다.
- **소각.** `burn(tokenId, maxRecursiveBurns)`는 자식도 재귀적으로 소각하며, 한도보다 많은 자식이 있으면 revert됩니다.
- `NestTransfer`, `ChildProposed`, `ChildAccepted`, `AllChildrenRejected`, `ChildTransferred` 이벤트로 인덱서가 트리를 재구성할 수 있습니다.

ERC-165 인터페이스 ID는 `0x42b0e56f`입니다.

## 샘플 코드

토큰을 부모에 중첩하고 수락하기(ethers v6):

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

const abi = [
  "function nestTransferFrom(address from, address to, uint256 tokenId, uint256 destinationId, bytes data)",
  "function pendingChildrenOf(uint256 parentId) view returns (tuple(uint256 tokenId, address contractAddress)[])",
  "function acceptChild(uint256 parentId, uint256 childIndex, address childAddress, uint256 childId)",
  "function directOwnerOf(uint256 tokenId) view returns (address, uint256, bool)",
];
const signer = new Wallet(process.env.PRIVATE_KEY!, new JsonRpcProvider(process.env.RPC_URL));
const items = new Contract(itemsAddr, abi, signer);     // child collection
const heroes = new Contract(heroesAddr, abi, signer);   // parent collection

// 1. Send item #7 into hero #1 (lands in the hero's pending list)
await (await items.nestTransferFrom(signer.address, heroesAddr, 7n, 1n, "0x")).wait();

// 2. As the hero's root owner, accept it
const pending = await heroes.pendingChildrenOf(1n);
const i = pending.findIndex((c: any) => c.contractAddress === itemsAddr && c.tokenId === 7n);
await (await heroes.acceptChild(1n, i, itemsAddr, 7n)).wait();

console.log(await items.directOwnerOf(7n)); // [heroesAddr, 1n, true]
```

## 알아둘 점

- 상태는 **Final**입니다. 새 컨트랙트에는 [ERC-6059](/eip-6059/) 대신 이것을 사용하세요.
- 토큰 ID `0`은 사용할 수 없습니다. `directOwnerOf`에서 `0`은 "NFT가 소유하지 않음"을 뜻하기 때문입니다. 이것이 ERC-721과의 유일한 비호환입니다.
- `balanceOf`는 직접 소유한 토큰만 세며, 더 깊이 중첩된 것은 세지 않습니다.
- 마켓플레이스 위험: 판매자가 판매 직전에 등록된 부모에서 자식을 빼낼 수 있습니다. 마켓플레이스는 정산 시점에 예상한 자식이 있는지 확인해야 합니다.
- 같은 생태계의 관련 표준으로 토큰당 다중 에셋([ERC-5773](/eip-5773/))과 온체인 속성([ERC-7508](/eip-7508/))이 있습니다.


---

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