AlertSourceDiscuss
Skip to content

ERC-4521: 721/20-compatible transfer

Recommends a simple extension to make NFTs compatible with apps and contracts that handle fungibles.

🚧 StagnantERC

Stagnant

This EIP has had no recent activity for at least 6 months, and has automatically been marked as stagnant. This EIP should not be used in production.

If you are interested in helping move this EIP to final, create a PR to move this EIP back to Draft and add yourself as an author, and an EIP editor will help guide you through the process. Thank you!

AuthorsRoss Campbell (@z0r0z)
Created2021-12-13

Abstract ​

ERC-721, the popular standard for non-fungible tokens (NFTs), includes send functions, such as transferFrom() and safeTransferFrom(), but does not include a backwards-compatible transfer() found in fungible ERC-20 tokens. This standard provides references to add such a transfer().

Motivation ​

This standard proposes a simple extension to allow NFTs to work with contracts designed to manage ERC-20s and many consumer wallets which expect to be able to execute a token transfer(). For example, if an NFT is inadvertently sent to a contract that typically handles ERC-20, that NFT will be locked. It should also simplify the task for contract programmers if they can rely on transfer() to both handle ERC-20 and NFTs.

Specification ​

The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.

The interface for ERC-4521 transfer() MUST conform to ERC-20 and resulting transfers MUST fire the Transfer event as described in ERC-721.

sol
function transfer(address to, uint256 tokenId) external returns (bool success);

Rationale ​

Replicating ERC-20 transfer() with just a minor change to accurately reflect that a unique tokenId rather than fungible sum is being sent is desirable for code simplicity and to make integration easier.

Backwards Compatibility ​

This EIP does not introduce any known backward compatibility issues.

Reference Implementation ​

A reference implementation of an ERC-4521 transfer():

sol
function transfer(address to, uint256 tokenId) public virtual returns (bool success) {
        require(msg.sender == ownerOf[tokenId], "NOT_OWNER");

        unchecked {
            balanceOf[msg.sender]--; 
        
            balanceOf[to]++;
        }
        
        delete getApproved[tokenId];
        
        ownerOf[tokenId] = to;
        
        emit Transfer(msg.sender, to, tokenId); 
        
        success = true;
}

Security Considerations ​

Implementers must be sure to include the relevant return bool value for an ERC-4521 in order to conform with existing contracts that use ERC-20 interfaces, otherwise, NFTs may be locked unless a safeTransfer is used in such contracts.

Copyright and related rights waived via CC0.

Citation

Please cite this document as:

Ross Campbell, "ERC-4521: 721/20-compatible transfer[DRAFT]," Ethereum Improvement Proposals, no. 4521, 2021. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-4521.