---
eip: 8074
label: ERC-8074
title: Self-Describing Bytes via EIP-712 Selectors
status: Draft
type: Standards Track
category: ERC
created: 2025-10-30
requires: 712
official: https://eips.ethereum.org/EIPS/eip-8074
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-8074.md
canonical: https://eips.huatuo.xyz/ko/eip-8074/
lang: ko
tldr: 일반 bytes 파라미터 안의 데이터에, EIP-712 타입 문자열에서 얻은 4바이트 셀렉터와 DataList 래퍼로 태그를 붙여, 컨트랙트가 여러 종류의 페이로드를 인식하고 디코딩할 수 있게 한다.
tags: [abi, encoding, eip-712, extensibility, bytes]
---

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

> Defines a convention for self-describing structured data in `bytes` parameters using 4-byte selectors derived from EIP-712 type strings.

**TL;DR:** 일반 bytes 파라미터 안의 데이터에, EIP-712 타입 문자열에서 얻은 4바이트 셀렉터와 DataList 래퍼로 태그를 붙여, 컨트랙트가 여러 종류의 페이로드를 인식하고 디코딩할 수 있게 한다.

## 어떤 문제를 해결하나요?

많은 인터페이스가 확장성을 위해 끝에 `bytes data` 파라미터를 둡니다. [ERC-721](/eip-721/)과 [ERC-1155](/eip-1155/)의 `safeTransferFrom`, 그리고 [ERC-5750](/eip-5750/)의 일반적인 패턴이 그렇습니다. 그 안에 무엇이 들어가는지는 제각각입니다. 받는 컨트랙트는 디코딩 방법을 추측해야 하고, 여러 종류의 페이로드를 쉽게 받을 수도 없으며, 컨트랙트 사이에서 전달된 페이로드는 각자 다르게 해석될 수 있습니다.

ERC-8074는 바이트가 자기가 무엇인지 알려 주는 아주 작은 규약을 추가합니다.

## 어떻게 동작하나요?

**단일 페이로드**

- 구조체의 정규 [EIP-712](/eip-712/) 타입 문자열을 가져옵니다. 예: `TransferNote(bytes32 reference,string comment,uint256 deadline)`
- 셀렉터는 `bytes4(keccak256(typeString))`이며, 여기서는 `0xf91f3a24`입니다.
- 인코딩은 `selector ++ abi.encode(fields...)`입니다.

**복수 페이로드**

- `DataList(bytes[] items)`(셀렉터 `0xae74f986`)로 감쌉니다: `0xae74f986 ++ abi.encode(items)`
- 각 item은 그 자체로 유효한 단일 페이로드여야 합니다.

**디코딩 규칙**

- 처음 4바이트를 읽습니다. `0xae74f986`이면 `bytes[]`를 디코딩해 각 item을 처리합니다.
- 알고 있는 셀렉터이면 나머지를 해당 구조체로 디코딩합니다.
- 알 수 없는 셀렉터는 **반드시** 무시해야 합니다. 순서는 상관없으며, 생산자는 중복을 피해야 합니다.

이 ERC를 전혀 모르는 컨트랙트도 페이로드를 불투명한 바이트로 계속 다룰 수 있습니다.

## 샘플 코드

```solidity
// 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
    }
}
```

## 알아둘 점

- 상태는 **Draft**입니다.
- `DataList`를 파싱할 때는 작업량에 한도를 두세요. 스펙은 최대 8개 item, 합계 8 KB 같은 제한과, 기대하는 셀렉터를 모두 찾으면 중단하는 것을 제안합니다.
- 4바이트 셀렉터가 식별하는 것은 *타입*이지 신뢰할 수 있는 발신자가 아닙니다. 중요한 경우에는 데이터를 따로(예: EIP-712 서명으로) 인증하세요.
- 타입 문자열은 정규 EIP-712 형식(쉼표 뒤에 공백 없음, 파라미터 이름 정확히 일치)이어야 하며, 그렇지 않으면 셀렉터가 일치하지 않습니다.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-8074
