ERC-6220 · Final · ERC · 2022-12-20
ERC-6220: Composable NFTs utilizing Equippable Parts
Lets an NFT be built from parts in a shared Catalog and equip other NFTs it owns into slots, so composites like game avatars with swappable gear are defined on-chain and an item can only be worn by one token at a time.
What problem does it solve?
NFT projects often want tokens made of pieces: an avatar with a background, a body, a hat and a weapon. Without a standard, the pieces are tracked in a private database, or a game simply looks at every NFT in your wallet and guesses which ones to use. That also means one "hat" NFT can appear on 500 avatars in 500 games at once, so scarcity is only cosmetic.
ERC-6220 puts composition on-chain. The token itself records which parts it shows and which child NFTs are equipped in which slots, and an item equipped in one token cannot be equipped elsewhere at the same time.
How it works
It builds on two earlier standards from the same authors:
- ERC-5773 multi-asset: one token can have several assets (renderings or metadata), for example a 2D and a 3D version.
- ERC-6059 nestable: an NFT can own other NFTs as children.
ERC-6220 adds a Catalog contract that defines parts, each with a z layer for rendering order and a metadataURI:
- Fixed parts — the same for every token that uses them (a frame, a body). Defined once, never replaced.
- Slot parts — an empty slot (say, "hat") into which NFTs from approved collections can be equipped. The catalog lists which collections are allowed (
checkIsEquippable,checkIsEquippableToAll).
A token asset points to a catalog and a list of part ids (getAssetAndEquippableData). To fill a slot, the owner first nests the child NFT into the parent, then calls equip({tokenId, childIndex, assetId, slotPartId, childAssetId}). The child collection must have marked its asset group as valid for that parent and slot (ValidParentEquippableGroupIdSet). unequip reverses it. Equipping does not mint anything; it just adds a component to render.
isChildEquipped lets the contract block transferring a child while it is equipped. That is the scarcity guarantee.
Sample code
Equipping a hat and reading what is in the slot (ethers v6):
// 1. hat NFT has already been nested into avatar #7 via ERC-6059 (it is child index 0)
await avatar.equip({
tokenId: 7n,
childIndex: 0n,
assetId: 1n, // the avatar asset that uses the catalog
slotPartId: 3n, // "hat" slot in the catalog
childAssetId: 2n, // the hat's asset designed for this slot
});
const eq = await avatar.getEquipment(7n, catalogAddress, 3n);
console.log(eq.childEquippableAddress, eq.childId);
const [uri, groupId, catalog, partIds] = await avatar.getAssetAndEquippableData(7n, 1n);
Catalog part model from the spec:
enum ItemType { None, Slot, Fixed }
struct Part {
ItemType itemType;
uint8 z; // render layer
address[] equippable; // collections allowed in this slot
string metadataURI;
}
Things to know
- Status: Final. ERC-165 id of
IERC6220is0x28bc9ae4. - Implementing it means implementing ERC-721, ERC-5773 and ERC-6059 as well, which is a fairly large contract surface.
- There is no built-in "list all equipped parts" call; use events or an indexer.
- Composites are only as trustworthy as the catalog owner and the collections it allows. Audit equip/accept/burn logic as you would any NFT contract.
- Final rendering of the layered image happens off-chain from the part metadata.