Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

ERC-6150 introduces a way to organize NFTs into a hierarchy resembling a Linux filesystem.

This article explains the proposal, with additional context and examples.

Overview

ERC-6150 extends ERC-721 to represent hierarchical NFTs resembling a multi-level filesystem. It provides interfaces for querying parent and child tokens and determining whether a token is a root or a leaf.

Motivation

The proposal standardizes an interface for hierarchical NFTs and provides a reference implementation. Hierarchies are common in filesystems, as illustrated by the Linux Filesystem Hierarchy Standard (FHS).

Linux filesystem hierarchy Source: https://eips.ethereum.org/EIPS/eip-6150

Websites also frequently organize content into hierarchies. Examples include eBay (Home → Electronics → Video Games → Xbox → Product), Twitter (Home → Lists → List → Tweet), and Reddit (Home → r/ethereum → Posts → Hot).

Website hierarchy Source: https://eips.ethereum.org/EIPS/eip-6150

A single smart contract can represent the hierarchy, with directories or categories modeled as individual NFTs. Each NFT's tokenURI may refer to another contract, a website, or other metadata.

The design offers several potential advantages:

  • Hierarchical relationships can be stored entirely on-chain and governed through additional DAO contracts.
  • A single contract can manage and modify the relationships.
  • Ownership of directories or categories can be transferred as NFTs, which may be useful for on-chain forums.
  • Frontends can query the hierarchy without requiring special permission.
  • The structure is suitable for familiar applications such as e-commerce and forums.
  • The interfaces are conceptually similar to filesystem operations, making them accessible to developers.

Possible use cases include the following.

An on-chain forum like Reddit

A contract can serve as the common root of a forum, with categories and topics represented by individual NFTs. Users can hold tokens associated with categories or threads and interact through the application. Posts and comments can be recorded on-chain to make discussions auditable, subject to the application's privacy and moderation design.

On-chain social media like Twitter

Accounts can be represented as NFTs, while posts, follows, and reposts can be recorded through smart contract operations. This makes relationships and interactions traceable where the application chooses to record them.

An on-chain organization

Departments and roles can be represented by individual NFTs, allowing organizational relationships and responsibilities to be modeled hierarchically. Projects and task progress could also be recorded on-chain.

On-chain e-commerce platforms like eBay or individual stores

Stores and products can be represented as NFTs, with product information and transaction history managed by the application. Purchases and sales may be recorded on-chain to support transparent transaction records.

Other applications with tree structures

Education platforms

Courses can be parent nodes, with lectures and learning materials as children. Access permissions, progress, and assessment records could be associated with the corresponding tokens. Advances in data availability and permissionless storage networks may support increasingly decentralized storage of application content, although ERC-6150 itself does not provide storage guarantees.

Project management tools

A project can form the root of a tree containing tasks and subtasks. Team members can hold or be assigned task tokens, while the application tracks progress and priorities.

Creative writing platforms

Stories can be organized into chapters and episodes, with NFTs representing individual nodes. Readers could obtain the corresponding tokens to access parts of a work, provided the application enforces those access rights.

Data visualization tools

A dataset can form a root node, with charts and other visualization elements arranged below it. Applications can associate tokens with resources for exploration and analysis.

Specification

IERC6150

Conforming contracts must implement the ERC-721 and ERC-165 interfaces alongside the hierarchical NFT interface.

javascript
pragma solidity ^0.8.0;

interface IERC6150 /* is IERC721, IERC165 */ {
    event Minted(
        address indexed minter,
        address indexed to,
        uint256 parentId,
        uint256 tokenId
    );

    function parentOf(uint256 tokenId) external view returns (uint256 parentId);

    function childrenOf(
        uint256 tokenId
    ) external view returns (uint256[] memory childrenIds);

    function isRoot(uint256 tokenId) external view returns (bool);

    function isLeaf(uint256 tokenId) external view returns (bool);
}

Minted

An event emitted when a token is minted under a specified parent.

Parameters

  • minter: Address that minted the token.
  • to: Recipient of the minted token.
  • parentId: Parent token ID. Zero denotes a root-level token.
  • tokenId: ID of the minted token.

parentOf

Returns the parent ID of a specified token.

Parameter

  • tokenId: ID of the child token.

Return value

  • parentId: ID of the parent token.

childrenOf

Returns the IDs of a token's immediate children.

Parameter

  • tokenId: ID of the parent token.

Return value

  • childrenIds: Array of child token IDs.

isRoot

Checks whether the specified token is a root token.

Parameter

  • tokenId: ID of the token being queried.

Return value

True if the token is a root; otherwise false.

isLeaf

Checks whether the specified token is a leaf.

Parameter

  • tokenId: ID of the token being queried.

Return value

True if the token has no children; otherwise false.

IERC6150Enumerable

An optional extension supporting enumeration of child tokens.

javascript
interface IERC6150Enumerable is IERC6150 /* IERC721Enumerable */ {
    function childrenCountOf(uint256 parentId) external view returns (uint256);

    function childOfParentByIndex(
        uint256 parentId,
        uint256 index
    ) external view returns (uint256);

    function indexInChildrenEnumeration(
        uint256 parentId,
        uint256 tokenId
    ) external view returns (uint256);
}

childrenCountOf

Returns the number of immediate child tokens belonging to a parent.

Parameter

  • parentId: Parent token ID.

Return value

The number of children, rather than a parent ID.

childOfParentByIndex

Returns the child token ID at a specified index in the parent's child enumeration. A parent ID of zero refers to the root-level enumeration.

Parameters

  • parentId: Parent token ID.
  • index: Position in the enumeration.

Return value

The child token ID at the specified index.

indexInChildrenEnumeration

Returns the index of a token within a specified parent's child enumeration. The function reverts if the token does not occur in the enumeration. A parent ID of zero refers to root-level tokens.

Parameters

  • parentId: Parent token ID.
  • tokenId: ID of the token being located.

Return value

The token's index in the enumeration.

IERC6150Burnable

An optional extension supporting safe Burn operations.

javascript
interface IERC6150Burnable is IERC6150 {
    function safeBurn(uint256 tokenId) external;

    function safeBatchBurn(uint256[] memory tokenIds) external;
}

safeBurn

Burns a specified token.

Parameter

  • tokenId: ID of the token to burn.

Conditions

  1. The token must be a leaf.
  2. The token must be a valid NFT.
  3. Ownership must satisfy the relevant authorization requirements.
  4. The caller must be the owner, an approved operator, or an approved address for the token, subject to the implementation's rules.

The original explanation mentions an owner parameter, but the displayed interface accepts only the token ID.

safeBatchBurn

Burns multiple tokens in one operation.

Parameter

  • tokenIds: Array of token IDs to burn.

Conditions

  1. Every token must satisfy the leaf requirement when burned.
  2. Every token must be valid.
  3. The relevant ownership requirements must be met.
  4. The caller must have the required authorization for every token.

The implementation must enforce the applicable checks for the entire batch.

IERC6150ParentTransferable

An optional extension supporting changes to a token's parent.

javascript
interface IERC6150ParentTransferable is IERC6150 {
    event ParentTransferred(
        uint256 tokenId,
        uint256 oldParentId,
        uint256 newParentId
    );

    function transferParent(uint256 newParentId, uint256 tokenId) external;

    function batchTransferParent(
        uint256 newParentId,
        uint256[] memory tokenIds
    ) external;
}

ParentTransferred

Emitted when a token's parent changes.

Parameters

  • tokenId: ID of the token being moved.
  • oldParentId: Previous parent ID.
  • newParentId: New parent ID.

transferParent

Changes the parent of a specified token.

Parameters

  • newParentId: New parent ID.
  • tokenId: ID of the token being moved.

batchTransferParent

Changes the parent of several tokens in one operation.

Parameters

  • newParentId: New parent ID.
  • tokenIds: IDs of the tokens being moved.

A parent change updates a hierarchical relationship and should not be confused with a transfer of ERC-721 ownership.

IERC6150AccessControl

An optional extension exposing access-control queries.

javascript
interface IERC6150AccessControl is IERC6150 {
    function isAdminOf(uint256 tokenId, address account)
        external
        view
        returns (bool);

    function canMintChildren(
        uint256 parentId,
        address account
    ) external view returns (bool);

    function canBurnTokenByAccount(uint256 tokenId, address account)
        external
        view
        returns (bool);
}

isAdminOf

Checks whether an account is an administrator of a specified token. Implementations may recognize multiple administrators and define permissions for operations such as minting children, burning tokens, and changing parents.

Parameters

  • tokenId: Token ID being queried.
  • account: Account address being queried.

Return value

True if the account has the administrator role; otherwise false.

canMintChildren

Checks whether an account may mint children under a specified parent. A parent ID of zero refers to permission to mint root-level tokens.

Parameters

  • parentId: Parent token ID.
  • account: Account address being queried.

Return value

True if the account may mint children; otherwise false.

canBurnTokenByAccount

Checks whether an account may burn a specified token.

Parameters

  • tokenId: Token ID being queried.
  • account: Account address being queried.

Return value

True if the account has permission to burn the token; otherwise false.

Rationale

ERC-6150 aims to provide a simple interface for hierarchical NFTs. Several design decisions support this objective.

Relationships between NFTs

NFTs form a tree-like hierarchy of nodes. A node may be a root, leaf, parent, or child, depending on its position and whether it has descendants.

The Minted event records the parent-child relationship when a new node is minted. For a root-level token, parentId must be zero. Zero is therefore reserved as a sentinel, rather than used as an actual node's token ID.

The parentOf and childrenOf functions provide common ways to navigate upward and downward. The isRoot and isLeaf queries simplify checks of a node's position and whether it has children.

Enumerable extension

The three enumeration methods support querying child nodes without requiring the entire child array in a single call. For consistency, parentId zero denotes the root-level enumeration.

ParentTransferable extension

Filesystems allow directories and files to move between directories. This extension provides an analogous operation for hierarchical NFTs.

Access control

Hierarchical applications often need one or more accounts authorized to operate on particular nodes. Examples include minting children, transferring a node, and burning a node. The access-control extension standardizes queries for relevant permissions.

Backward compatibility

The proposal extends ERC-721 and is designed to retain backward compatibility with that standard.

Reference implementation

An example implementation is available here.

Source: https://eips.ethereum.org/EIPS/eip-6150

Security considerations

The original article states that the proposal identifies no special security considerations. Implementers should nevertheless prevent cycles, enforce authorization for parent changes, and maintain consistency between parent and child records and ownership state.

Citation

Keegan Lee (@keeganlee), msfew msfew@hyperoracle.io, Kartin kartin@hyperoracle.io, qizhou (@qizhou), "ERC-6150: Hierarchical NFTs," Ethereum Improvement Proposals, no. 6150, December 2022. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-6150.

Personal observations

I find the idea of representing a Linux-style hierarchy with NFTs interesting. Explicitly associating an NFT with another NFT opens up several possibilities.

For example, a root NFT could represent an author and leaf NFTs could represent articles, making their relationships easy to query. The author token could also be implemented as a soulbound token.

Games could use a similar arrangement, representing a player with a root token and items with child tokens. When an item changes hands, the parent-transfer extension could update its association to the new player's root token. The application would need to coordinate that association with actual token ownership.

There are many possibilities worth exploring in a prototype.

Example of an ERC-6150 hierarchy

Conclusion

ERC-6150 provides a standardized way to represent hierarchical relationships among NFTs, with optional enumeration, safe burning, parent changes, and access-control queries.

If you have questions, feel free to contact me on Twitter.

Twitter @cardene777

Historical recruitment notice

At the time of the original article, CryptoGames was recruiting people interested in blockchain, Web3, NFTs, and smart contract development.

The original notice highlighted opportunities to take ownership of work and grow as an engineer. Check the company's current recruitment information separately.