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.
This article covers ERC-7590, a proposal that allows NFTs (ERC-721) to hold and manage fungible tokens (ERC-20) and enables the bundled assets to be traded together.
This article explains the following proposal, with additional context and examples.
I also cover other EIPs, BIPs, SLIPs, CAIPs, ENSIPs, RFCs, and ACPs.
Overview
ERC-7590 extends ERC-721, a standard for individually identifiable, non-fungible tokens, to facilitate the exchange of ERC-20 tokens, which represent fungible units of the same asset.
This extension enables an individual NFT to hold and manage balances of multiple ERC-20 assets and control deposits into and withdrawals from those balances. Specifically, the NFT contract exposes a method that pulls ERC-20 tokens into the contract and attributes the deposited balance to a particular token ID. The NFT owner or an authorized account can subsequently transfer those assets out.
The standard also introduces a transfer-out nonce, a counter incremented when ERC-20 tokens are withdrawn. Marketplaces can check this counter against the value recorded in a listing to prevent a seller from withdrawing the bundled assets immediately before a sale. The nonce is not itself a universal replay protection mechanism.
Motivation
Interoperability between different token standards is important in blockchain and decentralized ecosystems. Extending ERC-721 to manage ERC-20 assets allows NFTs to participate in composite transactions involving fungible assets, non-fungible assets, and potentially several asset classes within a single protocol.
The extension provides opportunities in several areas.
-
Expanded use cases
NFTs that manage other tokens can serve as bundles of assets in gaming, digital collectibles, decentralized finance (DeFi), and supply chain management. For example, a game could associate a character NFT with in-game currency and upgrade materials. ERC-20 materials can be held through ERC-7590, while ERC-721 materials would require additional functionality. Bundling these assets can simplify sales and lending.
-
Composite transactions
A single NFT can represent a transaction involving both fungible and non-fungible assets. For example, when an NFT is transferred on a marketplace, control of its associated ERC-20 balances can pass to the new owner. This consolidates the exchange and can reduce the number of user interactions and the associated gas overhead.
-
Market liquidity and value creation
If an NFT acts as a vault for several tokens, selling or transferring a bundle becomes easier. This can create additional trading opportunities for ERC-20 and ERC-721 assets and potentially improve liquidity. Flexible combinations of assets may also support new pricing models and financial products.
Utility
The central idea of ERC-7590 is that an NFT holds and manages ERC-20 balances associated with its ownership. The owner or an authorized account can use the contract's methods to manage deposits and withdrawals.
The transfer-out nonce allows an integration to detect withdrawals that occurred after an earlier observation, helping protect a sale against front-running. An integration can also use nonce checks as part of its own replay-prevention logic, but the ERC-7590 withdrawal function does not take an expected nonce.
The following table summarizes how the extension differs from conventional ERC-721.
| Aspect | Conventional ERC-721 | ERC-721 with the ERC-20 holder extension |
|---|---|---|
| Supported assets | Non-fungible tokens | Non-fungible tokens with bundled fungible balances |
| Unit of ownership | Individual token ID | Individual token ID with associated ERC-20 balances |
| Typical operations | NFT transfers | NFT transfers and ERC-20 deposits and withdrawals |
| Security | Ownership and approval checks | Ownership and approval checks plus nonce-based protection against sale front-running |
Expanded use cases
In gaming, a character or item NFT can hold in-game currency, enabling the character, currency, and other fungible materials to be traded as a bundle.
In digital collectibles, benefit or governance tokens can be associated with an NFT so that its ownership carries additional functionality or rights.
In DeFi, a collateral NFT might be associated with ERC-20 assets that fund yield, making the position easier to transfer.
In supply chain management, an NFT could identify a physical item and hold ERC-20 tokens representing fees or deposits, simplifying settlement when ownership changes.
Composite transactions
Grouping assets under one NFT can reduce the effort required for signing, approvals, and transfers. Transferring ownership of the NFT can also transfer control over the ERC-20 balances associated with it.
Using a pull mechanism allows the NFT contract to retrieve the required quantity of an ERC-20 token after the user grants an appropriate allowance through the ordinary ERC-20 approve function.
Market liquidity and value creation
A bundled NFT can be presented as a package, making it easier for buyers and sellers to evaluate the complete set of assets. Bundles also support combined valuations and package discounts.
These features may create opportunities for marketplaces to improve inventory turnover and earn fees, although the actual economic benefits depend on demand and the implementation.
Specification
Interface
interface IERC7590 /*is IERC165, IERC721*/ {
/**
* @notice Used to notify listeners that the token received ERC-20 tokens.
* @param erc20Contract The address of the ERC-20 smart contract
* @param toTokenId The ID of the token receiving the ERC-20 tokens
* @param from The address of the account from which the tokens are being transferred
* @param amount The number of ERC-20 tokens received
*/
event ReceivedERC20(
address indexed erc20Contract,
uint256 indexed toTokenId,
address indexed from,
uint256 amount
);
/**
* @notice Used to notify the listeners that the ERC-20 tokens have been transferred.
* @param erc20Contract The address of the ERC-20 smart contract
* @param fromTokenId The ID of the token from which the ERC-20 tokens have been transferred
* @param to The address receiving the ERC-20 tokens
* @param amount The number of ERC-20 tokens transferred
*/
event TransferredERC20(
address indexed erc20Contract,
uint256 indexed fromTokenId,
address indexed to,
uint256 amount
);
/**
* @notice Used to retrieve the given token's specific ERC-20 balance
* @param erc20Contract The address of the ERC-20 smart contract
* @param tokenId The ID of the token being checked for ERC-20 balance
* @return The amount of the specified ERC-20 tokens owned by a given token
*/
function balanceOfERC20(
address erc20Contract,
uint256 tokenId
) external view returns (uint256);
/**
* @notice Transfer ERC-20 tokens from a specific token.
* @dev The balance MUST be transferred from this smart contract.
* @dev MUST increase the transfer-out-nonce for the tokenId
* @dev MUST revert if the `msg.sender` is not the owner of the NFT or approved to manage it.
* @param erc20Contract The address of the ERC-20 smart contract
* @param tokenId The ID of the token to transfer the ERC-20 tokens from
* @param amount The number of ERC-20 tokens to transfer
* @param data Additional data with no specified format, to allow for custom logic
*/
function transferHeldERC20FromToken(
address erc20Contract,
uint256 tokenId,
address to,
uint256 amount,
bytes memory data
) external;
/**
* @notice Transfer ERC-20 tokens to a specific token.
* @dev The ERC-20 smart contract must have approval for this contract to transfer the ERC-20 tokens.
* @dev The balance MUST be transferred from the `msg.sender`.
* @param erc20Contract The address of the ERC-20 smart contract
* @param tokenId The ID of the token to transfer ERC-20 tokens to
* @param amount The number of ERC-20 tokens to transfer
* @param data Additional data with no specified format, to allow for custom logic
*/
function transferERC20ToToken(
address erc20Contract,
uint256 tokenId,
uint256 amount,
bytes memory data
) external;
/**
* @notice Nonce increased every time an ERC20 token is transferred out of a token
* @param tokenId The ID of the token to check the nonce for
* @return The nonce of the token
*/
function erc20TransferOutNonce(
uint256 tokenId
) external view returns (uint256);
}ReceivedERC20
event ReceivedERC20(
address indexed erc20Contract,
uint256 indexed toTokenId,
address indexed from,
uint256 amount
);Emitted when ERC-20 tokens are deposited into a particular NFT's associated balance. The event identifies the deposit from an external account and its destination NFT token ID. Wallets and applications can use this information to track which ERC-20 assets a given NFT received.
Parameters
erc20Contract- The address of the ERC-20 token contract.
toTokenId- The token ID of the NFT receiving the ERC-20 tokens.
from- The address supplying the tokens.
amount- The amount of ERC-20 tokens received.
TransferredERC20
event TransferredERC20(
address indexed erc20Contract,
uint256 indexed fromTokenId,
address indexed to,
uint256 amount
);Emitted when ERC-20 tokens held on behalf of an NFT are transferred to an external address. It records a withdrawal by the NFT owner or an authorized account and identifies the source NFT and recipient address.
Parameters
erc20Contract- The address of the relevant ERC-20 contract.
fromTokenId- The token ID of the NFT from which tokens were withdrawn.
to- The address receiving the ERC-20 tokens.
amount- The amount of ERC-20 tokens transferred.
balanceOfERC20
function balanceOfERC20(
address erc20Contract,
uint256 tokenId
) external view returns (uint256);Returns the balance of a specified ERC-20 asset held on behalf of an NFT. Given an ERC-20 contract address and an NFT token ID, the function reports the balance attributed to that token ID. Applications can use the result to display the assets associated with an NFT.
Parameters
erc20Contract- The address of the relevant ERC-20 contract.
tokenId- The token ID whose ERC-20 balance is queried.
Return value
uint256- The balance of the specified ERC-20 token held on behalf of the NFT.
transferHeldERC20FromToken
function transferHeldERC20FromToken(
address erc20Contract,
uint256 tokenId,
address to,
uint256 amount,
bytes memory data
) external;Transfers ERC-20 tokens held on behalf of an NFT to an external address. Only the NFT owner or an account approved to manage it may execute the operation.
Each successful withdrawal must increase the transfer-out nonce for that token ID. Integrations can use the counter to detect intervening withdrawals and reject stale operations, such as marketplace sales based on an earlier asset balance.
The data parameter allows implementations to supply additional information for custom logic, such as application-specific operations.
Parameters
erc20Contract- The address of the relevant ERC-20 contract.
tokenId- The token ID of the NFT supplying the tokens.
to- The destination address.
amount- The quantity of ERC-20 tokens to transfer.
data- Additional data.
- May contain arbitrary custom information.
transferERC20ToToken
function transferERC20ToToken(
address erc20Contract,
uint256 tokenId,
uint256 amount,
bytes memory data
) external;Deposits ERC-20 tokens from an external account into a balance associated with an NFT. The source account (msg.sender) must first authorize the NFT contract to spend its tokens, ordinarily through approve.
The NFT contract pulls the ERC-20 tokens and records the balance for the specified token ID. Additional data can support custom behavior for particular applications or protocols.
Parameters
erc20Contract- The address of the relevant ERC-20 contract.
tokenId- The token ID of the NFT receiving the deposit.
amount- The quantity of ERC-20 tokens to deposit.
data- Additional data.
- May contain arbitrary information.
erc20TransferOutNonce
function erc20TransferOutNonce(
uint256 tokenId
) external view returns (uint256);Returns the transfer-out nonce for a particular NFT. The counter increases every time ERC-20 tokens are transferred out of that NFT.
The nonce is maintained separately for each token ID. Marketplaces can use it to prevent execution of a sale after an intervening withdrawal; application-level replay protection can also incorporate a check of the nonce.
Parameters
tokenId- The NFT token ID whose nonce is queried.
Return value
uint256- The current transfer-out nonce.
Rationale
Pull mechanism
ERC-7590 uses a pull mechanism rather than relying on the NFT contract to receive unsolicited token transfers. The NFT contract initiates the transfer of tokens into its own address and attributes them to the designated NFT.
There are two reasons for this approach.
- Hooks allow flexible customization.
- ERC-20 does not define a standardized transfer with a receiver callback.
Customization through hooks
A hook is a mechanism for inserting custom logic before or after a particular operation, such as a token transfer. Because the receiving contract initiates a pull transfer, it can execute application-specific logic at the appropriate points.
For example, before pulling ERC-20 tokens into an NFT's balance, an implementation could perform:
- Ownership or authorization checks.
- Fee calculations.
- Validation of specific conditions.
After the transfer, it could emit additional events or execute other business logic.
ERC-20 has no standardized transfer callback
ERC-20 does not provide a standard method that notifies the receiving contract when tokens are transferred to it. ERC-721 and ERC-1155, by contrast, define safe transfer methods that invoke receiver callbacks. These callbacks allow the recipient to react to the transfer.
ERC-20 transfer and transferFrom do not automatically notify the recipient through such a callback. A plain transfer also does not specify the NFT token ID to which the recipient should attribute the deposit.
A push-based mechanism therefore lacks a reliable, standardized way to associate incoming ERC-20 tokens with the intended NFT. ERC-7590 addresses this limitation by having the NFT contract initiate the transfer itself.
Drawback of the pull mechanism
The drawback identified by the proposal is the need to grant approval before transferring tokens. To let the NFT contract pull a user's tokens, the user first grants an allowance as illustrated below.
ERC20(トークンコントラクト).approve(NFTコントラクトのアドレス, 金額);Without sufficient authorization, the NFT contract cannot pull the user's ERC-20 tokens. Requiring an explicit allowance also offers a security benefit by establishing an authorization boundary. However, users must still assess the approved contract and allowance amount, particularly when granting reusable or unlimited allowances.
Granular versus generic design
Two approaches were considered for the proposal.
| Approach | Description | Characteristics |
|---|---|---|
| Granular | Defines a separate interface for each type of held token. | Can be optimized for each token standard, reducing gas overhead. |
| Generic | Uses one general interface for ERC-20, ERC-721, and ERC-1155. | Consolidates the interface but introduces additional complexity. |
Granular design
This approach provides separate interfaces for ERC-20, ERC-721, and ERC-1155 assets. Each interface can optimize its methods for the relevant token standard without requiring unnecessary parameters, such as an asset ID or amount when it is not applicable.
-
Advantages
- Simpler implementations that are easier to understand.
- Lower gas overhead due to fewer unnecessary parameters and operations.
- Smaller contracts when implementations support only the token types they need.
-
Disadvantages
- Adding another token standard may require an additional interface.
Generic design
This approach uses a unified interface to manage ERC-20, ERC-721, and ERC-1155 tokens. It provides common methods for deposits and withdrawals across asset types.
-
Advantages
- Centralizes the interface and can make extending support to more token standards easier.
- Allows different asset types to be managed using the same methods.
-
Disadvantages
- Always handling both
idandamountintroduces unnecessary parameters for some asset types. - Additional complexity may increase execution costs.
- Always handling both
ERC-20 does not require an individual asset ID, while an ERC-721 transfer does not require an amount. A generic design therefore introduces redundant parameters in these cases.
Why the granular approach was chosen
The granular approach was chosen for the following reasons.
- ERC-20 lacks a standardized safe transfer method with a callback.
ERC-721 and ERC-1155 can notify receiving contracts through safe transfer callbacks. ERC-20 does not define the equivalent functionality, so a dedicated management interface addresses this specific limitation.
- ERC-721 and ERC-1155 already have receiver interfaces.
Interfaces such as IERC721Receiver and IERC1155Receiver define how contracts accept safe transfers. These existing mechanisms reduce the need for a new generic receiver interface covering those token types.
- Gas efficiency and simplicity.
A granular design avoids unnecessary operations and is efficient for applications that only require support for particular asset types.
Reference implementation
https://eips.ethereum.org/assets/eip-7590/contracts/ERC7590Mock.sol
Security
Risks shared with ERC-721
As with ERC-721, implementations may contain hidden logic in internal or externally accessible functions. For example, the following functions could contain unexpected or malicious behavior. They are examples of application-specific functionality, not functions required by ERC-7590.
| Function | Potential risk |
|---|---|
burn |
Burning a token could incorrectly remove other associated data or assets. |
addResource |
Resource insertion could perform unauthorized operations, such as taking assets belonging to another user. |
acceptResource |
Resource acceptance could introduce unintended reentrancy vulnerabilities. |
Such logic in unaudited contracts can expose users to asset loss or unauthorized control. Exercise particular caution when interacting with contracts that have not been audited.
Identifying the source of deposited tokens
When an NFT contract pulls ERC-20 tokens into an NFT, the implementation must use msg.sender as the source address.
The contract relies on prior ERC-20 approval to transfer tokens from the caller. If the implementation incorrectly allows a different source address, the following problems could arise.
| Problem | Consequence |
|---|---|
| The contract uses the wrong source address. | Previously approved tokens may be deposited into an unintended NFT. |
| An attacker substitutes another source address. | The implementation could permit unauthorized withdrawal of tokens covered by someone else's allowance. |
The pull operation must therefore always use msg.sender as the source.
Transfer amount discrepancies and fee-on-transfer tokens
Some ERC-20 tokens charge fees on transfers. For example, a transfer requesting 100 tokens may deliver only 95 tokens to the recipient. Incorrect handling of such fee-on-transfer tokens can corrupt the NFT holder contract's internal balance accounting.
The proposal identifies two valid approaches.
| Approach | Description | Characteristics |
|---|---|---|
| Strict balance check | Compare balances before and after the transfer, and revert if the change does not match the expected amount. | Explicitly rejects incompatible fee-on-transfer behavior. |
| Account for the measured change | Compute the balance difference and use it to account for the actual amount transferred. | Can accommodate fee-on-transfer tokens with appropriate accounting. |
The following example illustrates transfer balance verification.
function _safeTransferERC20(address token, address to, uint256 expectedAmount) internal {
uint256 beforeBal = IERC20(token).balanceOf(address(this));
IERC20(token).transfer(to, expectedAmount);
uint256 afterBal = IERC20(token).balanceOf(address(this));
uint256 actualSent = beforeBal - afterBal;
require(actualSent == expectedAmount, "Transfer amount mismatch");
}Measuring the balance change directly can help support fee-on-transfer tokens. Alternatively, rejecting transfers whose observed balance change differs from the expected amount offers simpler accounting. Both approaches require careful handling of deposits and withdrawals, particularly when token fees affect the sender and recipient differently.
Front-running protection
An NFT containing ERC-20 assets introduces a marketplace risk: a seller might withdraw the bundled assets just before the NFT sale executes. The buyer could then receive an NFT without the assets they expected.
To mitigate this risk, marketplaces must check the erc20TransferOutNonce, which counts withdrawals of ERC-20 tokens from the NFT.
| Mitigation | Description |
|---|---|
| Record the nonce when listing the NFT. | Establish the transfer-out counter observed at listing time. |
| Check the nonce immediately before executing the sale. | Revert the sale if the nonce has changed, indicating an intervening withdrawal. |
This check prevents a sale from executing against a stale transfer-out nonce after the seller has withdrawn assets. It does not prevent withdrawals themselves or detect every possible change in asset balances.
Risk of losing ERC-20 tokens sent directly to the NFT contract
Do not send ERC-20 tokens directly to the NFT contract using a plain token transfer. For example, a user might mistakenly invoke the following operation.
ERC20(<トークンコントラクト>).transfer(<NFTコントラクトのアドレス>, 100);The NFT contract does not receive a standardized ERC-20 callback indicating which token ID should receive the deposit. The tokens may consequently be unaccounted for and become unrecoverable unless the implementation provides a separate recovery mechanism.
This problem stems from the lack of a standardized ERC-20 safe transfer with a callback. Use transferERC20ToToken instead, explicitly specifying the destination NFT's tokenId.
References
Steven Pineda (@steven2308), Jan Turk (@ThunderDeliverer), "ERC-7590: ERC-20 Holder Extension for NFTs [DRAFT]," Ethereum Improvement Proposals, no. 7590, January 2024. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-7590.
Conclusion
This article covered ERC-7590, which proposes an interface for NFTs to hold and manage fungible ERC-20 tokens and trade the bundled assets together. I hope it helped clarify the mechanism.
If you have questions, feel free to reach out by direct message on Twitter.
I also publish content on other platforms.



