ERC-4944 Single-NFT-only contract (Contract with Exactly One Non-fungible Token)

Stagnant · NFTs & multi-token · created 2022-03-25

Makes an ERC-721 contract issue only a single token, so that the contract address itself represents that NFT, and the NFT directly uses the ERC-20 tokens it holds.

Why it is needed

Normally, an ERC-721 contract can mint multiple tokens, so referencing a specific NFT always requires using a pair of contract address and token ID together. This makes it hard to cleanly bind one NFT to one contract on a one-to-one basis. Also, for an NFT to hold and use other ERC-721 or ERC-20 tokens as its own, like a composable token such as ERC-998, additional code is usually required. Without this standard, there is no simple standard way to create an autonomous asset where a digital asset (NFT) receives its own ERC-20 budget and uses it to protect or operate itself.

What to implement

In depth

The core idea of one token per contract

If an ERC-721 contract is made to mint exactly one token, that token is uniquely identified by the contract address alone, rather than by a pair of contract address and token ID. Adding just one more constraint that blocks further minting naturally grants, without any extra code, the capability that composable tokens like ERC-998 have: owning other ERC-721 or ERC-20 tokens as its own.

The motivation of an autonomous asset

An NFT created this way can use its own 'budget' (the ERC-20 it holds) to buy and sell other NFTs or manage its own ERC-20 assets. The original text describes this as an entity that, like an autonomous agent, can dispose of its own possessions on its own, citing preserving the value of digital assets as the first use case. The NFT can use its own ERC-20 budget to protect itself.

Specification: constructor and minting restriction

The specification stipulates that the constructor must mint the contract's sole token, after which the mint function must be restricted so that no further minting occurs. The reference implementation shows this approach using a bool variable _minted, minting token ID 0 in the constructor and then setting this variable to true.

Specification: the tokenTransfer function

The specification stipulates that a tokenTransfer function must be added to allow the contract owner (that is, the owner of this NFT) to trade the ERC-20 tokens held by the contract/NFT itself. When the contract receives ERC-20 tokens, the NFT owner must be able to withdraw and use those tokens from that contract wallet.

Reference implementation: the onlyOwner restriction and actual functions

The reference implementation confirms that the caller is the owner of this NFT using an onlyOwner modifier that checks balanceOf(msg.sender) > 0. transferTokens(IERC20 token, address recipient, uint256 amount), with this restriction applied, transfers the specified ERC-20 to the recipient, and balanceTokens(IERC20 token) is a view function that queries the balance of that ERC-20 held by the contract.

Compatibility with existing ERC-721 platforms

The Rationale for this standard lies in maintaining compatibility with existing ERC-721 platforms. It takes the approach of adding an extra constraint that limits the minted count to one, without changing the ERC-721 standard itself. The original text states that there are no backward compatibility issues.

Proposal status notice

This ERC is currently Stagnant, a proposal whose discussion has stalled without progress. It has not been finalized as a standard, so details may change or it may not be adopted in actual implementation.

Original ERC · ← ERCs