---
eip: 5521
label: ERC-5521
title: Referable NFT
status: Final
type: Standards Track
category: ERC
created: 2022-08-10
requires: 165, 721
official: https://eips.ethereum.org/EIPS/eip-5521
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-5521.md
canonical: https://eips.huatuo.xyz/eip-5521/
lang: en
tldr: An ERC-721 extension that records which NFTs a token references and which NFTs reference it, forming an on-chain citation graph that can span contracts.
tags: [nft, erc721, references, provenance, creators]
---

# ERC-5521: Referable NFT

> An ERC-721 extension to construct reference relationships among NFTs

**TL;DR:** An ERC-721 extension that records which NFTs a token references and which NFTs reference it, forming an on-chain citation graph that can span contracts.

## What problem does it solve?

Creative work builds on earlier work: a remix samples two songs, an artwork derives from another, a game item upgrades a previous one. A plain [ERC-721](/eip-721/) token has no idea any of this happened. Each NFT stands alone, sales are one-off events, and original creators have no on-chain trail showing how their work was reused.

ERC-5521 introduces the **Referable NFT** (rNFT). Each token stores the tokens it refers to and the tokens that refer to it, so the relationships form a directed acyclic graph (DAG) that anyone can query, including across different NFT contracts.

## How it works

Every rNFT tracks three things:

- **referring** (out-edges): the tokens this token cites, grouped by contract address.
- **referred** (in-edges): the tokens that cite this one.
- **createdTimestamp**: `block.timestamp` at creation, so references can be ordered in time.

Main functions:

| Function | Purpose |
| --- | --- |
| `setNode(tokenId, addresses[], tokenIds[][])` | Set the tokens `tokenId` refers to, and update each target's referred list |
| `referringOf(contract, tokenId)` | What a token cites |
| `referredOf(contract, tokenId)` | What cites a token |
| `createdTimestampOf(contract, tokenId)` | Creation time of a token |

The `UpdateNode` event carries the token, its owner and both lists so indexers can rebuild the graph.

For references to **another contract**, that contract implements a `TargetContract` interface with `setNodeReferredExternal`, which the referring contract calls (after an [ERC-165](/eip-165/) check) to record the incoming edge there.

Rules in the spec: `addresses` and `tokenIds` must have equal length, inner arrays must be non-empty, and a token may not refer to itself in the same contract.

## Sample code

Minting a new rNFT that cites two existing ones (ethers v6, against a contract following the reference implementation, which exposes `safeMint(tokenId, addresses, tokenIds)`):

```ts
import { Contract } from "ethers";

const abi = [
  "function safeMint(uint256 tokenId, address[] addresses, uint256[][] tokenIds)",
  "function referringOf(address, uint256) view returns (address[], uint256[][])",
  "function referredOf(address, uint256) view returns (address[], uint256[][])",
];
const rnft = new Contract(RNFT_ADDRESS, abi, signer);

// New token 42 refers to token 1 and 2 in this contract, and token 7 in another.
await (await rnft.safeMint(
  42n,
  [RNFT_ADDRESS, OTHER_RNFT_ADDRESS],
  [[1n, 2n], [7n]],
)).wait();

const [addrs, ids] = await rnft.referredOf(RNFT_ADDRESS, 1n);
console.log("token 1 is cited by", addrs, ids); // includes token 42
```

## Things to know

- **Status: Final.**
- References are independent of ownership. Transferring an NFT does not change its edges, and any profit-sharing built on top must define its own rules.
- The reference implementation lets **anyone** mint and set references, by design (compared in the spec to open academic citation). Expect spurious or spammy references and filter accordingly.
- Timestamps are per block, so two tokens minted in the same block cannot be ordered.
- Referring to a token does not automatically refer to its descendants; build an explicit chain if that is what you mean.
- The spec suggests combining rNFTs with rental extensions such as [ERC-5006](/eip-5006/).


---

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