The unofficial ERC-404 token standard has captured the imagination of the blockchain community by merging the functionalities of fungible (ERC-20) and non-fungible tokens (ERC-721) into a groundbreaking hybrid model. This innovation, also one of the top NFT trends in 2024, paves the way for the creation of "semi-fungible" tokens, a unique blend that allows for the representation of digital assets on the blockchain in both unique and divisible forms. The concept of semi-fungible tokens is particularly revolutionary as it enables the partial ownership of a non-fungible token (NFT), thus allowing individuals to hold fractions of an otherwise indivisible asset. This development not only enhances the utility and accessibility of NFTs but also opens up new possibilities for asset management and investment on the blockchain, offering a more versatile and nuanced approach to digital asset representation.

What is ERC-404 and How Does it Work?

what is ERC-404 and how does it work - aelf

ERC-404 is a new token standard that combines the features of ERC-20 fungible tokens and ERC-721 non-fungible tokens, adding native liquidity and fractional ownership capabilities in the Web3 and crypto space. This standard aims for a seamless fusion of fungible and non-fungible tokens, offering a predictable range of NFT token IDs through a first-in-first-out (FIFO) queue, a departure from the ever-increasing token ID model of ERC-721. This approach enhances the predictability and consistency of NFT collections on the blockchain.

A key innovation of ERC-404 is its streamlined token transfer process where transferring ERC-20 tokens also moves the related ERC-721 tokens to the new owner with the burn and mint mechanism. The standard provides clarity with specific events for transfers and approvals, distinguishing between ERC-20 and ERC-721-related actions.

ERC-404 introduces functions to manage the balances easily and total supplies of both token types, simplifying transfer logic and offering efficient minting functions. It is compatible with key Ethereum Improvement Proposals (EIP) like EIP-2612 for permit approvals and EIP-165 for standard interface detection, ensuring interoperability and enhancing security. Lastly, ERC-404 also brings optimisations for gas savings and improved performance, representing a significant step forward in the combined management and use of fungible and non-fungible tokens on the blockchain.

An ERC-404 contract innovatively streamlines the management of digital assets by simultaneously creating NFTs and native tokens at a preset ratio, establishing a linked relationship between the two. This design simplifies the complexity of dealing with both fungible (native tokens) and NFTs by maintaining a one-to-one relationship, where ownership of 1 full native token in a wallet guarantees the possession of a corresponding NFT from the collection. Consequently, the quantity of NFTs in existence directly mirrors the number of full native tokens held, creating a seamless and intuitive system for managing these intertwined assets.

For example, DEFROGS -> 1.43627 DEFROGS will also hold 1 DEFROGS NFT.

For example, PANDORA -> 3.28708 PANDORA will also hold 3 Pandora NFTs.

An ERC-404 Code Sample

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {IERC-404} from "./interfaces/IERC-404.sol";
import {DoubleEndedQueue} from "./lib/DoubleEndedQueue.sol";

abstract contract ERC-404 is IERC-404 {
    using DoubleEndedQueue for DoubleEndedQueue.Uint256Deque;

    // Declarations of important state variables
    string public name;
    string public symbol;
    uint8 public immutable decimals;
    uint256 public immutable units;
    uint256 public totalSupply;
    uint256 public minted;

    // Mappings for ERC-20 and ERC-721
    mapping(address => uint256) public balanceOf;
    mapping(address => mapping(address => uint256)) public allowance;
    mapping(uint256 => address) public getApproved;
    mapping(address => mapping(address => bool)) public isApprovedForAll;
    mapping(uint256 => uint256) internal _ownedData;
    mapping(address => uint256[]) internal _owned;
    mapping(address => bool) internal _erc721TransferExempt;
    mapping(address => uint256) public nonces;

    // ERC-721 token queue
    DoubleEndedQueue.Uint256Deque private _storedERC721Ids;

    // ERC-20 and ERC-721 events
    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
    event Approval(address indexed owner, address indexed spender, uint256 indexed tokenId);
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    // Constructor
    constructor(string memory name_, string memory symbol_, uint8 decimals_) {
        name = name_;
        symbol = symbol_;
        decimals = decimals_;
        units = 10 ** decimals;
    }

    // ERC-20 functions
    function approve(address spender, uint256 valueOrId) public virtual override returns (bool) {}
    function erc20Approve(address spender, uint256 id) public virtual {}
    function erc20TransferFrom(address from, address to, uint256 value) public virtual returns (bool) {}
    function transfer(address to, uint256 value) public virtual returns (bool) {}

    // ERC-721 functions
    function erc721TransferFrom(address from, address to, uint256 id) public virtual {}
    function safeTransferFrom(address from, address to, uint256 id) public virtual {}
    function safeTransferFrom(address from, address to, uint256 id, bytes memory data) public virtual {}

    // ERC-404 specific functions
    function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {}
    function setSelfERC721TransferExempt(bool state) public virtual {}
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {}
}

Explanation of the Functions of ERC-404 Code Sample

  1. ERC-20 Functions: approve, erc20Approve, erc20TransferFrom, transfer for standard ERC-20 token operations.
  2. ERC-721 Functions: erc721TransferFrom, safeTransferFrom for ERC-721 token transfers.
  3. ERC-404 Specific Functions: DOMAIN_SEPARATOR to get the domain separator for EIP-712, setSelfERC721TransferExempt to toggle whether an address is exempt from ERC-721 transfer restrictions, supportsInterface to check if a contract supports a given interface.

The Mechanics of ERC-404 Tokens

The ERC-404 token standard introduces a dynamic approach to the mechanics of buying, selling, and transferring digital assets. This innovative standard operates under the principle that NFTs are minted automatically when the balance of the associated token in a wallet exceeds a whole number, essentially turning the excess into a unique, tradable asset. Conversely, when the token balance drops below this threshold, these NFTs are burned—their records are permanently detached from the accounts and the fungible token. This mechanism seamlessly integrates the fluidity of standard cryptocurrency transactions with the distinct, collectable nature of NFTs, providing users with a straightforward yet versatile means of engaging with digital assets. Through this, ERC-404 tokens embody a new level of interactivity and utility in the blockchain space, marrying the concepts of fungibility and uniqueness in a single, coherent framework.

ERC-404 fundamentally changes the way users interact with digital assets. Here's a breakdown of its buying, selling, and transfer mechanics:

  • Automated NFT Minting and Burning: As described earlier, ERC-404 automates the creation and destruction of NFTs based on the native token balance in a wallet. This eliminates the need for manual NFT creation or burning processes, streamlining user experience.
  • Seamless Transactions: ERC-404 transactions inherit the efficiency of standard token transfers on the Ethereum blockchain. Users can buy, sell, or transfer both the native tokens and their corresponding NFTs in a single transaction, reducing complexity and transaction fees.

This dynamic approach fosters a new level of interactivity and utility for digital assets. ERC-404 tokens bridge the gap between fungible and non-fungible tokens, creating a more versatile framework for users to engage with the blockchain.

Example (using $T as the symbol for native tokens):

ERC404 mint burn mechanism - aelf
ERC404 - Mint/burn mechanism
  1. Buying 0.8 $T results in 0 NFTs.
  2. Purchasing an additional 0.3 $T, making the balance 1.1 $T, triggers NFT minting.
  3. Selling 0.2 $T lowers the balance below 1, leading to NFT burning.
  4. Buying back 0.2 $T results in the minting of another NFT to your wallet

How ERC-404 combines the functionality of ERC20 and ERC721 tokens:

{{unpacking-erc404}}

The Potential Impact of ERC-404

The emergence of ERC-404 has the potential to significantly alter the landscape of NFTs and digital assets as a whole. Here's a closer look at its potential impact:

  • Enhanced Accessibility: ERC-404 fosters inclusivity by expanding access to high-value digital assets by enabling fractional ownership of NFTs. This breakthrough democratises the realm of rare collectibles and artworks, formerly accessible only to affluent individuals or institutions.
  • Integration with DeFi: ERC-404 tokens' fungibility feature seamlessly integrates them into DeFi ecosystems. This integration unlocks avenues for innovative financial products and services, such as utilising fractionalised NFTs as collateral for loans or tapping into yield-generating opportunities on the blockchain.
  • Increased Liquidity: Fractional ownership inherently enhances the divisibility and tradability of NFTs, thereby enhancing liquidity in the NFT market. This heightened liquidity attracts a broader investor base, potentially elevating the overall value of these digital assets.

Overall, ERC-404 presents a paradigm shift in digital ownership and investment. It unlocks a new era of possibilities for creators, collectors, and investors alike, fostering a more inclusive and dynamic digital asset ecosystem. And key example of this on the aelf blockchain is Project Schrodinger, which harnesses the power of Artificial Intelligence (AI) and aelf's advanced multi-token contract capabilities to revolutionise the NFT space. The project hints at the development of a potentially new ACS-404 standard on the aelf blockchain, which will introduce innovative combined features such as inscriptions, multi-tokens, and AI capabilities.

*Disclaimer: The information provided on this blog does not constitute investment advice, financial advice, trading advice, or any other form of professional advice. Aelf makes no guarantees or warranties about the accuracy, completeness, or timeliness of the information on this blog. You should not make any investment decisions based solely on the information provided on this blog. You should always consult with a qualified financial or legal advisor before making any investment decisions.

About aelf

aelf, the pioneer Layer 1 blockchain, features modular systems, parallel processing, cloud-native architecture, and multi-sidechain technology for unlimited scalability. Founded in 2017 with its global hub based in Singapore, aelf is the first in the industry to lead Asia in evolving blockchain with state-of-the-art AI integration, transforming blockchain into a smarter and self-evolving ecosystem.

aelf facilitates the building, integrating, and deploying of smart contracts and decentralised apps (dApps) on its Layer 1 blockchain with its native C# software development kit (SDK) and SDKs in other languages, including Java, JS, Python, and Go. aelf’s ecosystem also houses a range of dApps to support a flourishing blockchain network. aelf is committed to fostering innovation within its ecosystem and remains dedicated to driving the development of Web3, blockchain and the adoption of AI technology.

Find out more about aelf and stay connected with our community:
Website | X | Telegram | Discord

Back to Blog