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-6864, a proposal that lets holders migrate existing ERC-20 tokens to another implementation while retaining the original token contract.
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-20 is one of the most widely used token standards on Ethereum, but deployed smart contract code is generally immutable. ERC-6864 addresses this limitation by defining an interface for upgrading and downgrading existing ERC-20 tokens while preserving users' holdings.
For more on ERC-20, see the following article.
[ERC20] ERC-20 Explained from the Ground Up
An interface is a set of externally exposed function specifications, including function names, parameters, and return values. ERC-6864 extends the existing ERC-20 standard with such an interface.
The main features are:
- Holders can upgrade an existing ERC-20 token to a new token contract or downgrade the upgraded token back to the base token.
- Users retain their holdings through conversion, making the operation resemble moving tokens to a new contract. Exact token quantities depend on the conversion function.
- Other smart contracts can continue to use the ERC-20 interface. For compatible implementations, integrations can generally reuse their existing logic by changing the token address, subject to differences in token behavior.
In short, ERC-6864 defines a standard interface for migrating to another token implementation while maintaining ERC-20 compatibility. Unlike a proxy upgrade, the upgraded token has a separate address and the original contract remains unchanged.
Motivation
Two important design principles in smart contracts are the immutability of deployed code and the minimal scope of token standards such as ERC-20. These principles help decentralized applications avoid unexpected changes and improve transparency and trust.
In practice, however, there are circumstances in which an ERC-20 token needs to evolve after deployment. ERC-6864 aims to address these requirements.
When token upgrades are desirable
Typical reasons for upgrading a token include:
-
Bug fixes and removal of limitations
Bugs may be discovered after deployment, or design limitations may make continued operation difficult. In these situations, migrating the token to a new implementation may be desirable, but ordinary ERC-20 contracts do not expose an upgrade mechanism.
-
Adoption of new features and standards
New token standards and extensions emerge over time, including meta-transactions, gasless transfers, and more sophisticated allowance management. Upgradeability makes it possible to adopt these features for an existing token ecosystem.
-
Responding to regulatory changes
Regulations and compliance requirements vary over time and across jurisdictions. An upgradeable token architecture may accommodate changes such as identity verification (KYC) and transaction restrictions.
An existing general-purpose solution: the proxy pattern
A common approach to upgradeability is the proxy pattern. In this architecture, a proxy contract acts as the entry point, while the implementation contract behind it can be replaced. Users and other contracts continue calling the same proxy address, which delegates execution to its implementation.
The EVM opcode delegatecall is commonly used for this purpose. It executes the target contract's code in the caller's execution context, including the caller's storage. This separates the proxy's state from the implementation's logic.
However, this approach has some limitations.
-
The contract must be designed and deployed as a proxy from the beginning
The proxy pattern requires a proxy and an implementation contract from the outset. A standalone, already deployed ERC-20 contract cannot generally be retrofitted into this architecture.
-
Upgrades can occur without individual user consent
A conventional administrator-controlled proxy allows its administrator to replace the implementation. Users retain their balances, but it can be difficult for them to track precisely when the logic changes and what changed. The proxy architecture itself does not provide each holder with an explicit choice to accept or reject the upgrade. Users may therefore interact with the new logic without having individually opted in.
A token-specific extension to ERC-20
ERC-6864 is designed as an ERC-20-specific extension, rather than a general-purpose mechanism for upgrading arbitrary contracts.
Narrowing its scope offers several advantages:
-
Compatibility with existing ERC-20 tokens
A new ERC-6864 token contract can implement the extension on top of an existing ERC-20 token. The original token does not have to have been deployed as a proxy or modified to expose upgrade functions, provided its behavior is compatible with the conversion mechanism. A compatible new contract handles upgrading and downgrading.
-
Simpler implementation and maintenance
Specializing the interface for ERC-20 tokens can simplify implementation, auditing, and maintenance compared with a general-purpose upgrade architecture.
-
Reversible and nested upgrades
After migrating to an upgraded token, holders can convert it back to the original token when appropriate. Multiple upgrades can also be layered by nesting implementations.
-
Two opportunities for users to confirm an upgrade
Each user can explicitly opt in to the upgrade. Rather than allowing an administrator to replace the implementation for everyone, the mechanism lets holders choose whether to migrate their own tokens.
Comparison with ERC-4931
ERC-4931 addresses a similar problem using a third contract, referred to as a bridge contract, to facilitate upgrades and downgrades.
For more on ERC-4931, see the following article.
[ERC4931] Converting ERC-20 Tokens into Another Token
The bridge contract intermediates between the original and the destination token contracts. This separates the token logic from the conversion logic.
However, ERC-4931 has the following limitations in the design discussed by the ERC-6864 proposal:
-
The destination token must be minted in advance and held by the bridge contract
Before users can upgrade, the bridge must already hold the destination tokens. ERC-6864 instead envisages creating the upgraded balance when the upgrade is invoked, using a just-in-time approach.
-
Limited support for upgrade-while-transfer and see-through functionality
ERC-6864 considers advanced use cases such as upgrading a token at the same time as transferring it, and providing combined views of balances and allowances across multiple token implementations. The proposal argues that the ERC-4931 architecture makes these behaviors more difficult to support.
Rather than providing a general-purpose solution like the proxy pattern, ERC-6864 aims to standardize a simple, explicitly opt-in approach to upgrading and downgrading existing and future ERC-20 tokens.
Specification
Overview
ERC-6864 defines an interface for upgrading and downgrading existing ERC-20 tokens. It standardizes how holders migrate tokens to an upgraded token contract and convert them back.
The optional ERC6864SeeThrough extension also provides a read interface for viewing combined information from the base ERC-20 and upgraded token contracts. It can be useful when applications want to display an integrated balance or total supply.
ERC6864
pragma solidity ^0.8.0;
/**
@title Upgradable Fungible Token
@dev See https://eips.ethereum.org/EIPS/eip-6864
*/
interface IERC6864 is IERC20 {
/**
@dev MUST be emitted when tokens are upgraded
@param from Previous owner of base ERC-20 tokens
@param to New owner of ERC-6864 tokens
@param amount The amount that is upgraded
*/
event Upgrade(address indexed from, address indexed to, uint256 amount);
/**
@dev MUST be emitted when tokens are downgraded
@param from Previous owner of ERC-6864 tokens
@param to New owner of base ERC-20 tokens
@param amount The amount that is downgraded
*/
event Downgrade(address indexed from, address indexed to, uint256 amount);
/**
@notice Upgrade `amount` of base ERC-20 tokens owned by `msg.sender` to ERC-6864 tokens under `to`
@dev `msg.sender` must directly own sufficient base ERC-20 tokens
MUST revert if `to` is the zero address
MUST revert if `msg.sender` does not directly own `amount` or more of base ERC-20 tokens
@param to The address to receive ERC-6864 tokens
@param amount The amount of base ERC-20 tokens to upgrade
*/
function upgrade(address to, uint256 amount) external;
/**
@notice Downgrade `amount` of ERC-6864 tokens owned by `from` to base ERC-20 tokens under `to`
@dev `msg.sender` must either directly own or be approved to spend sufficient ERC-6864 tokens for `from`
MUST revert if `to` is the zero address
MUST revert if `from` does not directly own `amount` or more of ERC-6864 tokens
MUST revret if `msg.sender` is not `from` and is not approved to spend `amount` or more of ERC-6864 tokens for `from`
@param from The address to release ERC-6864 tokens
@param to The address to receive base ERC-20 tokens
@param amount The amount of ERC-6864 tokens to downgrade
*/
function downgrade(address from, address to, uint256 amount) external;
/**
@notice Get the base ERC-20 smart contract address
@return The address of the base ERC-20 smart contract
*/
function baseToken() external view returns (address);
}Events
Upgrade
event Upgrade(address indexed from, address indexed to, uint256 amount);Emitted when tokens are upgraded from the base ERC-20 token to the ERC-6864 token. from identifies the original token holder, to identifies the recipient of the upgraded tokens, and amount records the quantity specified for the upgrade.
Parameters
from- The address that held the base ERC-20 tokens.
to- The address receiving the upgraded ERC-6864 tokens.
amount- The amount of tokens upgraded.
Downgrade
event Downgrade(address indexed from, address indexed to, uint256 amount);Emitted when ERC-6864 tokens are converted back to the base ERC-20 token. from identifies the holder of the upgraded tokens, to identifies the recipient of the base tokens, and amount records the amount specified for the operation.
Parameters
from- The address that held the ERC-6864 tokens.
to- The recipient of the base ERC-20 tokens.
amount- The amount of tokens downgraded.
Functions
upgrade
function upgrade(address to, uint256 amount) external;Converts base ERC-20 tokens held by the caller into upgraded ERC-6864 tokens for to. The operation must revert if to is the zero address or the caller does not directly hold enough base tokens. The caller must also authorize any required transfer of base tokens.
Parameters
to- The address receiving the upgraded ERC-6864 tokens.
amount- The quantity of base ERC-20 tokens to upgrade.
downgrade
function downgrade(address from, address to, uint256 amount) external;Converts ERC-6864 tokens back to the base ERC-20 token.
Details
Converts amount of the ERC-6864 tokens held by from and delivers the resulting base ERC-20 tokens to to. The operation must revert if to is the zero address or from has an insufficient upgraded balance. If the caller differs from from, the caller must have sufficient allowance to spend the upgraded tokens.
Parameters
from- The address supplying the ERC-6864 tokens.
to- The address receiving the converted base ERC-20 tokens.
amount- The amount to downgrade.
baseToken
function baseToken() external view returns (address);Returns the address of the underlying ERC-20 token contract. Callers use this function to determine which ERC-20 token forms the basis of the ERC-6864 contract. It identifies the token associated with both upgrade and downgrade operations.
Return value
address- The base ERC-20 contract address.
ERC6864SeeThrough
pragma solidity ^0.8.0;
interface IERC6864SeeThrough is IERC6864 {
/**
@notice Get the combined total token supply between this ERC-6864 and base ERC-20 smart contracts
@return The combined total token supply
*/
function combinedTotalSupply() external view returns (uint256);
/**
@notice Get the combined token balance of `account` between this ERC-6864 and base ERC-20 smart contracts
@param account The address that owns the tokens
@return The combined token balance
*/
function combinedBalanceOf(address account) external view returns (uint256);
/**
@notice Get the combined allowance that `spender` is allowed to spend for `owner` between this ERC-6864 and base ERC-20 smart contracts
@param owner The address that owns the tokens
@param spender The address that is approve to spend the tokens
@return The combined spending allowance
*/
function combinedAllowance(address owner, address spender) external view returns (uint256);
}Functions
combinedTotalSupply
function combinedTotalSupply() external view returns (uint256);Returns the combined total supply of the base ERC-20 and ERC-6864 tokens. This provides a consolidated view of supply before and after migration. It is useful for applications that need to understand the aggregate token supply. Implementations should follow the see-through interface's accounting rules, including avoiding double counting underlying tokens held by the wrapper.
Return value
uint256- The combined total supply calculated across both contracts.
combinedBalanceOf
function combinedBalanceOf(address account) external view returns (uint256);Returns the combined balance of an account across the base ERC-20 and ERC-6864 contracts. It includes the account's holdings in both contracts, which is useful when users have only partially upgraded or deliberately maintain balances in both.
Parameters
account- The address whose balance is queried.
Return value
uint256- The combined balance across both contracts.
combinedAllowance
function combinedAllowance(address owner, address spender) external view returns (uint256);Returns the combined allowance for the base ERC-20 and ERC-6864 tokens. It reports how many tokens spender is authorized to spend from owner across both token contracts. This provides a single aggregate value for allowances maintained separately by the two contracts; it does not itself grant or increase an allowance.
Parameters
owner- The token owner.
spender- The address authorized to spend tokens.
Return value
uint256- The combined allowance.
Rationale
Why extend ERC-20?
ERC-6864 aims to provide upgrade functionality while building on the existing ERC-20 standard. Reusing established data structures and functions helps preserve holders' balances through the migration mechanism.
Given the widespread adoption of ERC-20, defining an extension to that interface can preserve interoperability with other contracts, wallets, and tools. Reusing existing functionality instead of creating a new token standard from scratch reduces implementation effort and makes integration with the existing ecosystem easier.
ERC-6864 therefore adds token migration functionality while retaining the conventions of the existing ERC-20 standard.
Why support downgrading?
ERC-6864 supports downgrades as well as upgrades. This makes it possible to move between different ERC-6864 implementations built on the same base ERC-20 token, by returning to the base token and upgrading to another implementation.
This flexibility is useful if a user discovers a limitation or bug in an upgraded token or simply prefers another implementation.
An upgrade mechanism that works only in one direction can restrict users' choices. Downgrading gives holders control over which token implementation they use and provides an exit path when the conversion mechanism remains functional and adequately backed.
For operators, it offers a way to return to the base token if a new implementation has problems, reducing some of the risks associated with migration. It does not guarantee recovery if the upgraded contract itself is compromised or cannot honor redemptions.
The optional see-through extension
The ERC6864SeeThrough extension provides auxiliary functions for viewing aggregate values from the base ERC-20 and upgraded ERC-6864 contracts. It exposes consolidated total supply, balances, and allowances.
Although useful, these functions are optional for two reasons:
- They are straightforward to implement, and equivalent values can often be calculated using other public functions.
- Not every token contract or use case needs consolidated information.
Implementers can therefore adopt the extension when their applications require it.
Compatibility
ERC-6864 generally remains compatible with ERC-20. Standard operations such as transfer and balanceOf remain available.
There is, however, an important caveat.
Some contracts may implement transfer so that it works with a holder's combined balance across the base ERC-20 and ERC-6864 tokens. This design reduces friction by allowing holders to transfer tokens without manually managing their upgrade or downgrade status. A transfer may use balances held in either contract, subject to sufficient authorization and the implementation's conversion rules.
When adopting this design, the proposal recommends applying consistent combined accounting to the following functions:
totalSupplybalanceOf
Returning consolidated values across the base and upgraded contracts helps make these functions consistent with the transfer behavior. Wallets and DeFi integrations can then use the unified supply and balance values when interacting with the token, rather than assuming ordinary separate-contract accounting.
Reference implementation
import {IERC20, ERC20} from "@openzeppelin-contracts/token/ERC20/ERC20.sol";
contract ERC6864 is IERC6864, ERC20 {
IERC20 private immutable s_baseToken;
constructor(string memory name, string memory symbol, address baseToken_) ERC20(name, symbol) {
s_baseToken = IERC20(baseToken_);
}
function baseToken() public view virtual override returns (address) {
return address(s_baseToken);
}
function upgrade(address to, uint256 amount) public virtual override {
address from = _msgSender();
s_baseToken.transferFrom(from, address(this), amount);
_mint(to, amount);
emit Upgrade(from, to, amount);
}
function downgrade(address from, address to, uint256 amount) public virtual override {
address spender = _msgSender();
if (from != spender) {
_spendAllowance(from, spender, amount);
}
_burn(from, amount);
s_baseToken.transfer(to, amount);
emit Downgrade(from, to, amount);
}
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address from = _msgSender();
uint256 balance = balanceOf(from);
if (balance < amount) {
upgrade(from, amount - balance);
}
_transfer(from, to, amount);
return true;
}
function totalSupply() public view virtual override returns (uint256) {
return return super.totalSupply() + s_baseToken.totalSupply() - s_baseToken.balanceOf(address(this));
}
function balanceOf(address account) public view virtual override returns (uint256) {
return super.balanceOf(account) + s_baseToken.balanceOf(account);
}
}Security
Approval requirements and user responsibility
Before upgrading a base ERC-20 token through ERC-6864, users generally need to call approve on the base token contract so that the ERC-6864 contract can spend their tokens.
This authorizes the ERC-6864 contract to use a specified quantity of the user's base tokens before the upgrade takes place. Users therefore have two important responsibilities.
First, they must assess whether the ERC-6864 contract is trustworthy and secure. A vulnerable or malicious implementation may use the approved tokens in unexpected ways.
Second, they should determine an appropriate allowance. Approving more tokens than necessary increases the potential impact if the approved contract misuses that authority.
These are the same kinds of risks associated with ordinary ERC-20 approve operations, rather than a fundamentally new approval risk introduced by ERC-6864.
Conversion logic and the risk of front-running or sandwich attacks
An ERC-6864 contract may define its own conversion function for upgrades and downgrades. The conversion may use a fixed one-to-one rate, a linear function, or a nonlinear curve.
Nonlinear conversion functions in particular require careful consideration.
The result of an upgrade or downgrade can depend on other users' transactions. With a nonlinear curve, transactions immediately preceding an operation may affect its conversion rate, creating exposure to transaction-ordering risks such as front-running and sandwich attacks.
This behavior resembles that of automated market makers (AMMs) that use nonlinear pricing curves. As in an AMM, changes caused by other transactions can create adverse execution conditions for a user.
The conversion design therefore determines whether ERC-6864 upgrade and downgrade operations are exposed to the same types of transaction-ordering risks as an AMM.
Unlimited allowances and automatic upgrades reduce confirmation opportunities
An ERC-6864 contract may request an unlimited allowance, effectively granting unrestricted approval over the base token balance. It may also automatically upgrade tokens during a transfer, as demonstrated by the reference implementation.
A conventional upgrade workflow involves two explicit user actions:
- Call
approveto authorize spending of the base tokens. - Call
upgradeto perform the conversion.
Each action gives users an opportunity to confirm their intention.
With an unlimited allowance and automatic upgrades, however, the user has fewer occasions to explicitly consider whether they want to upgrade their tokens. The reduction in confirmation opportunities is a security concern: an approval may authorize subsequent conversions without a separate upgrade action.
Complexity introduced by multiple implementations and nesting
Multiple IERC6864 implementations can use the same base ERC-20 token. An ERC-6864 token can also serve as the underlying asset for another ERC-6864 token, creating nested layers.
Such arrangements make the state and flow of tokens more complex. Dashboards, block explorers, and analytics tools may have difficulty calculating balances or total supply correctly.
Different tools may disagree about which token represents the primary asset, or which layers should be included in aggregate figures. Heavy use of multiple implementations and nesting can therefore lead to inconsistent or incorrect reporting across the ecosystem.
References
Jeff Huang (@jeffishjeff), "ERC-6864: Upgradable Fungible Token [DRAFT]," Ethereum Improvement Proposals, no. 6864, April 2023. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-6864.
Conclusion
This article covered ERC-6864, a proposal for migrating existing ERC-20 tokens to another implementation while retaining the original token contract. 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.



