ERC-8074 Self-describing bytes keyed by EIP-712 selectors (Self-Describing Bytes via EIP-712 Selectors)

Draft · Other · created 2025-10-30

Indicates what struct the data in a contract's bytes parameter represents using a 4-byte selector derived from the EIP-712 type string, so that multiple contracts can consistently identify and interpret the same payload.

Why it is needed

Standards like ERC-721 and ERC-1155 include an empty bytes parameter on functions for extensibility, but there is no common way to indicate what data it contains. As a result, each contract distinguishes data in its own way, and when a single contract needs to accept multiple kinds of payloads, ad hoc rules must be invented each time. When the flow of data passing through multiple contracts grows complex, each contract may also end up interpreting the same bytes differently, causing confusion. Ultimately, without a standardized identification convention, interoperability suffers, and the burden of agreeing on new parsing rules each time remains.

In depth

Defining the type selector

The type selector is the first 4 bytes of the keccak256 hash of the EIP-712 type string. The formula is typeSelector(T) = bytes4(keccak256(bytes(T))). For example, the first 4 bytes of the keccak256 hash of the type string TransferNote(bytes32 reference,string comment,uint256 deadline) is 0xf91f3a24. This follows the same principle as the function selector Solidity uses to identify function calls.

Single-payload encoding structure

A payload carrying a single struct is built by appending the abi.encode of that struct's fields after the type selector: encoding = typeSelector(T) ++ abi.encode(<fields of T>). In the example, this encodes as 0xf91f3a24 ++ abi.encode(reference, comment, deadline). A receiver can first check just the first 4 bytes to determine whether it is a known selector, then decode the rest.

The DataList multi-payload wrapper

When multiple typed payloads need to be packed together into a single bytes value, the shared wrapper type DataList(bytes[] items) is used. This type's selector is fixed at 0xae74f986, and the encoding is encoding = 0xae74f986 ++ abi.encode(items). Each element of the items array (items[i]) MUST be a valid single payload carrying its own selector.

Decoding procedure

Decoding begins by reading the first 4 bytes of the bytes value as the selector. If the selector is 0xae74f986, the rest is decoded as (bytes[] items) and each item is recursively parsed again. If it is another known selector, the rest is interpreted accordingly; an unknown selector MUST be ignored (treated as a no-op rather than an error). The order between payloads carries no meaning, and producers SHOULD avoid including duplicate items.

Compatibility with existing standards

It is designed to be used alongside ERC-5750, which further solidifies the practice of passing bytes data, for standards like ERC-721 and ERC-1155 that use bytes parameters for extensions. Existing contracts that are unaware of this ERC can simply treat the bytes as meaningless data, so backwards compatibility is not broken.

Design rationale

Instead of creating a new schema syntax, it reuses the EIP-712 type strings already used in the signing ecosystem to maintain consistency. The reason for using a 4-byte selector is to keep things concise by following Solidity's function selector convention as-is. The DataList wrapper enables multiplexing multiple payloads into a single bytes value without adding special parsing rules or a new ABI specification.

Standard status

This ERC is currently in Draft status. Since it is still an early proposal that has not been finalized, keep in mind that the specification may change or discussion may stall going forward.

Things to watch out for

Original ERC · ← ERCs