EIPs Explained

ERC-7528 · Final · ERC · 2023-10-03

ERC-7528: ETH (Native Asset) Address Convention

Standardises 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE as the address that means native ETH wherever a contract or event would otherwise hold an ERC-20 token address.

What problem does it solve?

Many protocols treat ETH and ERC-20 tokens the same way: a swap has an "input token", a vault has an "asset", an event logs "which token moved". ETH, however, is not a contract and has no address. Protocols worked around this in different ways: some forced users into WETH, some emitted separate events for ETH, and some picked a placeholder address such as 0x0, 0x1, 0xe or 0xeeee…eeee.

Every indexer, wallet and aggregator then had to learn each protocol's private convention. ERC-7528 picks one placeholder so off-chain tools can read "this token is ETH" consistently.

How it works

  • Whenever an address field or event would hold an ERC-20 token address but the token is actually native ETH, it MUST be 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.
  • If the token is a wrapped ERC-20 version of ETH (such as WETH9), use that contract's real address, not the placeholder.
  • Use the EIP-55 checksummed form where appropriate: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE.
  • On other EVM chains, the same address stands for that chain's native asset.

A key use case is an ERC-4626 vault, for example a liquid staking token, whose underlying asset() is native ETH: it can return this address and still fit the 4626 tooling.

Why this address? Low addresses such as 0x0, 0x1 or 0xe could collide with precompiles and are less recognisable. The 0xeeee… form was already the most widely used and cannot clash with a precompile.

Sample code

Handling both ETH and ERC-20 deposits with one code path and one event:

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

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

contract Deposits {
    using SafeERC20 for IERC20;

    address public constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

    event Deposit(address indexed user, address indexed token, uint256 amount);

    function deposit(address token, uint256 amount) external payable {
        if (token == ETH) {
            require(msg.value == amount, "bad value");
        } else {
            require(msg.value == 0, "no ETH");
            IERC20(token).safeTransferFrom(msg.sender, address(this), amount);
        }
        emit Deposit(msg.sender, token, amount);
    }
}

Off-chain (TypeScript):

const NATIVE = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
const isNative = (token: string) => token.toLowerCase() === NATIVE.toLowerCase();

Things to know

  • Status is Final. It is a naming convention, not a new interface; nothing is deployed at the address.
  • Never call ERC-20 functions on the placeholder. Branch on it first, as in the sample.
  • Handling raw ETH means sending value to arbitrary addresses, which opens the door to re-entrancy. Follow checks-effects-interactions or use a re-entrancy guard.
  • Compare addresses case-insensitively off-chain, since some code uses the lowercase form and some the checksummed one.

#eth #erc20 #convention #defi

Details

Authors
Joey Santoro (@joeysantoro)
Status
Final
Type
Standards Track / ERC
Created
2023-10-03
Requires
Required by

Machine-readable: Markdown · JSON