EIPs Explained

ERC-8074 · Draft · ERC · 2025-10-30

ERC-8074: Self-Describing Bytes via EIP-712 Selectors

Tags data inside generic bytes parameters with a 4-byte selector taken from its EIP-712 type string, plus a DataList wrapper, so contracts can recognize and decode multiple payload types.

What problem does it solve?

Many interfaces include a trailing bytes data parameter for extensibility: safeTransferFrom in ERC-721 and ERC-1155, and the general pattern in ERC-5750. What goes inside is ad hoc. A receiving contract has to guess how to decode it, cannot easily accept several kinds of payload, and a payload forwarded across contracts may be read differently by each.

ERC-8074 adds a tiny convention so the bytes say what they are.

How it works

Single payload

  • Take the struct's canonical EIP-712 type string, e.g. TransferNote(bytes32 reference,string comment,uint256 deadline).
  • Its selector is bytes4(keccak256(typeString)), here 0xf91f3a24.
  • Encoding is selector ++ abi.encode(fields...).

Multiple payloads

  • Wrap them in DataList(bytes[] items), selector 0xae74f986: 0xae74f986 ++ abi.encode(items).
  • Each item must itself be a valid single payload.

Decoding rules

  • Read the first 4 bytes. If it is 0xae74f986, decode bytes[] and process each item.
  • If it is a selector you know, decode the rest as that struct.
  • Unknown selectors must be ignored. Order doesn't matter; producers should avoid duplicates.

Contracts that know nothing about this ERC can still treat the payload as opaque bytes.

Sample code

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

contract NoteReceiver {
    bytes4 constant TRANSFER_NOTE =
        bytes4(keccak256("TransferNote(bytes32 reference,string comment,uint256 deadline)")); // 0xf91f3a24
    bytes4 constant DATA_LIST = bytes4(keccak256("DataList(bytes[] items)"));                 // 0xae74f986

    event Note(bytes32 reference, string comment, uint256 deadline);

    function encodeNote(bytes32 ref, string calldata c, uint256 d) external pure returns (bytes memory) {
        return abi.encodePacked(TRANSFER_NOTE, abi.encode(ref, c, d));
    }

    function handle(bytes calldata data) public {
        if (data.length < 4) return;
        bytes4 sel = bytes4(data[:4]);
        if (sel == DATA_LIST) {
            bytes[] memory items = abi.decode(data[4:], (bytes[]));
            require(items.length <= 8, "too many items");
            for (uint256 i = 0; i < items.length; i++) this.handle(items[i]);
        } else if (sel == TRANSFER_NOTE) {
            (bytes32 r, string memory c, uint256 d) = abi.decode(data[4:], (bytes32, string, uint256));
            emit Note(r, c, d);
        }
        // unknown selectors: ignore
    }
}

Things to know

  • Status is Draft.
  • Bound the work when parsing DataList: the spec suggests limits such as at most 8 items and 8 KB total, and stopping once all expected selectors are found.
  • A 4-byte selector identifies a type, not a trusted sender. Authenticate the data separately (e.g. an EIP-712 signature) when it matters.
  • Type strings must be canonical EIP-712 (no spaces after commas, exact parameter names), or selectors won't match.

#abi #encoding #eip-712 #extensibility #bytes

Details

Authors
Andrew Richardson (@awrichar)
Status
Draft
Type
Standards Track / ERC
Created
2025-10-30
Requires

Machine-readable: Markdown · JSON