---
eip: 998
label: ERC-998
title: Composable Non-Fungible Token
status: Draft
type: Standards Track
category: ERC
created: 2018-07-07
requires: 20, 165, 721
official: https://eips.ethereum.org/EIPS/eip-998
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-998.md
canonical: https://eips.huatuo.xyz/eip-998/
lang: en
tldr: A Draft extension that lets an ERC-721 NFT own other NFTs and ERC-20 balances, forming trees that move together when the top token is transferred.
tags: [nft, composable, token, draft]
---

# ERC-998: Composable Non-Fungible Token

> Extends a ERC-721 to own other ERC-721 and ERC-20 tokens.

**TL;DR:** A Draft extension that lets an ERC-721 NFT own other NFTs and ERC-20 balances, forming trees that move together when the top token is transferred.

## What problem does it solve?

An [ERC-721](/eip-721/) token can be owned only by an address. Many designs want tokens that hold other tokens: a game character that owns its sword and armour, a bundle of NFTs sold as one item, or an NFT that carries a token balance. Without a standard, each project invents its own nesting scheme, and wallets and marketplaces cannot see what is inside.

ERC-998 defines **composable** NFTs. Tokens form a tree with one address at the root, and moving the root token moves everything under it in one transaction.

## How it works

There are four interfaces. A contract may implement more than one.

| Interface | Kind | What it does |
| --- | --- | --- |
| `ERC998ERC721TopDown` | ERC-721 parent | Holds and transfers child ERC-721 tokens |
| `ERC998ERC20TopDown` | ERC-721 parent | Holds and transfers ERC-20 balances |
| `ERC998ERC721BottomUp` | ERC-721 child | Records which parent token it belongs to |
| `ERC998ERC20BottomUp` | ERC-20 child | Lets balances be owned by an ERC-721 token |

**Top-down** parents track their children. Any ordinary ERC-721 can be added as a child. **Bottom-up** children track their parent, so they can attach to any ordinary ERC-721.

Key behaviour:

- **Adding a child.** Call `safeTransferFrom(from, composable, childId, data)` on the child's contract, with the parent token ID in `data`. The composable's `onERC721Received` records it. For older NFTs without `safeTransferFrom`, `approve` and then call `getChild`.
- **Removing a child** uses explicit functions such as `transferChild(fromTokenId, to, childContract, childTokenId)`. They always name *from*, *to* and *what*.
- **Plain `transferFrom` must fail** for a token that is owned by another token. This stops an operator moving it without saying which parent it comes from.
- **Root owner.** `rootOwnerOf(tokenId)` walks up the tree and returns a `bytes32`: the magic value `0xcd740db5` in the first 4 bytes and the owner address in the last 20.
- Each interface has an [ERC-165](/eip-165/) ID, for example `0xcde244d9` for ERC-721 top-down.

## Sample code

Putting NFT `#3` inside composable token `#6`, then reading the root owner:

```solidity
// Attach child: the parent tokenId goes in `data`
ERC721(childContract).safeTransferFrom(msg.sender, composable, 3, abi.encode(uint256(6)));

// Who ultimately owns token 6 (and therefore child #3)?
bytes32 r = ERC998ERC721TopDown(composable).rootOwnerOf(6);
require(bytes4(r) == 0xcd740db5, "not ERC-998");
address owner = address(uint160(uint256(r)));
```

## Things to know

- **This proposal is still a Draft.** Its Security Considerations section says "Needs discussion", and the interfaces are written in Solidity 0.4 syntax.
- ERC-20 composables also rely on ERC-223-style `transfer(to, value, data)` and `tokenFallback`, which most ERC-20 tokens do not support. `getERC20` is the fallback.
- Gas grows with tree depth, because ownership checks walk up to the root.
- Later standards cover similar ground. [ERC-6551](/eip-6551/) gives each NFT its own smart-contract account that can hold any asset, and [ERC-7401](/eip-7401/) defines parent-governed NFT nesting.


---

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