EIPs Explained

ERC-6059 · Final · ERC · 2022-11-15

ERC-6059: Parent-Governed Nestable Non-Fungible Tokens

Lets an NFT own other NFTs, even from different collections: children are proposed into a parent, accepted by the parent's root owner, and move together with it, enabling bundles, equippable items and membership perks.

What problem does it solve?

With plain ERC-721, an NFT is owned by an address (a wallet or contract), never by another NFT. That makes some common ideas awkward:

  • Bundling tokens from several collections and selling them in one transfer.
  • Collecting related tokens under one "folder" token, or attaching soulbound traits to a parent (e.g. each leg of a shipping container's journey).
  • Membership perks minted straight into a DAO membership NFT.
  • Delegation by nesting your voting NFT into a delegate's token.

ERC-6059 makes "owned by an NFT" a first-class concept, with the parent's owner firmly in control of what gets attached.

How it works

Ownership. A token's direct owner can be an address or another NFT. ownerOf keeps its ERC-721 meaning but walks up the chain to the root owner, the first non-NFT owner. directOwnerOf(tokenId) returns the immediate owner (address, parentTokenId, isNft). Token ID 0 is reserved to mean "not an NFT", so real IDs must be non-zero.

Propose, then accept. Anyone can send a child to a parent with nestTransferFrom(from, to, tokenId, destinationId) (or a nest-mint). The child first lands in the parent's pending list, which should be capped at 128 entries to limit spam. The parent's root owner (or an approved party) then:

  • acceptChild(parentId, index, childAddress, childId) – move it to the active list.
  • rejectAllChildren(parentId, maxRejections) – clear the pending list.
  • transferChild(...) – reject, abandon, unnest, send to an address, or move into another parent.

Functions take an array index plus the expected collection and ID, which keeps gas constant and guards against index races.

Parent governs. While a token is nested, its own transferFrom, nestTransferFrom and burn can only be triggered via the parent through transferChild. A token cannot be nested into one of its own descendants, which would create an unmanageable loop. nestTransferFrom must check the destination supports the interface (ERC-165 ID 0x42b0e56f), so there is no separate "safe" variant.

Sample code

Nesting an item into a character, then accepting it (ethers v6):

import { Contract } from "ethers";

const abi = [
  "function nestTransferFrom(address from, address to, uint256 tokenId, uint256 destinationId)",
  "function pendingChildrenOf(uint256) view returns ((uint256 tokenId, address contractAddress)[])",
  "function acceptChild(uint256 parentId, uint256 childIndex, address childAddress, uint256 childId)",
  "function childrenOf(uint256) view returns ((uint256 tokenId, address contractAddress)[])",
];
const items = new Contract(itemsAddr, abi, owner);
const characters = new Contract(charactersAddr, abi, owner);

// 1. Send item #7 into character #1 (lands in pending).
await (await items.nestTransferFrom(owner.address, charactersAddr, 7n, 1n)).wait();

// 2. Root owner of character #1 accepts it.
const pending = await characters.pendingChildrenOf(1n);
const i = pending.findIndex((c: any) => c.contractAddress === itemsAddr && c.tokenId === 7n);
await (await characters.acceptChild(1n, i, itemsAddr, 7n)).wait();

console.log(await characters.childrenOf(1n)); // [[7n, itemsAddr]]

Things to know

  • Status: Final.
  • Both the parent and child collections must implement ERC-6059; you cannot nest an ordinary ERC-721 that lacks it.
  • Marketplace risk: the owner of a listed parent can remove children right before a sale. Marketplaces should verify expected children at fill time.
  • To burn a nested token it must first be transferred out to an address.
  • Alternatives: ERC-6551 gives each NFT its own account that can hold any asset, without changing the token contracts; ERC-6150 builds a tree within one collection; ERC-998 is an older composable-NFT design.

#nft #erc-721 #nesting #composable #rmrk

Details

Authors
Bruno Škvorc (@Swader), Cicada (@CicadaNCR), Steven Pineda (@steven2308), Stevan Bogosavljevic (@stevyhacker), Jan Turk (@ThunderDeliverer)
Status
Final
Type
Standards Track / ERC
Created
2022-11-15
Requires
Required by

Machine-readable: Markdown · JSON