{"eip":2069,"title":"Recommendation for using YAML ABI in ERCs/EIPs","description":"Recommendation for including contract ABI descriptions in EIPs and ERCs as YAML.","authors":["Alex Beregszaszi (@axic)"],"status":"Stagnant","type":"Informational","created":"2017-02-11","discussionsTo":"https://ethereum-magicians.org/t/eip-2069-recommendation-for-using-yaml-abi-in-specifications/3347","repo":"EIPs","label":"EIP-2069","officialUrl":"https://eips.ethereum.org/EIPS/eip-2069","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2069.md","url":"https://eips.huatuo.xyz/eip-2069/","tldr":{"en":"An informational recommendation that EIPs and ERCs describe contract interfaces as YAML-formatted ABI, which is language-neutral like JSON but allows comments, instead of as Solidity code.","ja":"EIP や ERC がコントラクトインターフェースを Solidity コードではなく YAML 形式の ABI で記述することを勧める情報提供（Informational）の推奨。JSON と同じく言語中立で、コメントも書ける。","ko":"EIP와 ERC가 컨트랙트 인터페이스를 Solidity 코드 대신 YAML 형식의 ABI로 기술하도록 권장하는 정보성(Informational) 제안. YAML은 JSON처럼 언어 중립적이면서 주석을 쓸 수 있다.","zh":"一项信息性（Informational）建议：EIP 和 ERC 应使用 YAML 格式的 ABI 而不是 Solidity 代码来描述合约接口，YAML 与 JSON 一样不依赖具体语言，但允许写注释。"},"tags":["abi","yaml","specification","process","informational"],"explainers":{"en":{"lang":"en","tldr":"An informational recommendation that EIPs and ERCs describe contract interfaces as YAML-formatted ABI, which is language-neutral like JSON but allows comments, instead of as Solidity code.","tags":["abi","yaml","specification","process","informational"],"related":[20],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-2069/","markdown":"## What problem does it solve?\n\nMost interface standards, such as [ERC-20](/eip-20/), present their API as a Solidity `interface`. The author points out three drawbacks:\n\n- It favours one language and can disadvantage others (Vyper, Fe, hand-written bytecode, off-chain tooling).\n- It ties the spec to a particular Solidity version and syntax, which changes over time.\n- Solidity can express things that do not map cleanly onto the ABI, which puts other languages at a further disadvantage.\n\nThe neutral description of a contract interface is the **Contract ABI**, normally written as JSON. But JSON cannot contain comments, and a specification needs explanations next to each function.\n\n## How it works\n\nThe recommendation is simple: write the ABI in **YAML**. YAML is a superset of JSON, so the content is the same ABI that compilers and libraries already understand, and converting between the two is mechanical. Unlike JSON, YAML allows `#` comments, so authors can document each function inline.\n\nAuthors are encouraged to add comments to the YAML ABI. The allowed fields and values are exactly those in the Solidity Contract ABI specification; this EIP does not invent a new description language. The spec points to `yamabi`, a JavaScript tool for converting between YAML and JSON ABI.\n\n## Sample code\n\nThe spec's example, a `transfer` function in YAML:\n\n```yaml\n# The transfer function. Takes the recipient address\n# as an input and returns a boolean signaling the result.\n- name: transfer\n  type: function\n  stateMutability: nonpayable\n  inputs:\n  - name: recipient\n    type: address\n  - name: amount\n    type: uint256\n  outputs:\n  - name: ''\n    type: bool\n```\n\nLoading it into ethers v6 (any YAML parser works; the result is a normal JSON ABI):\n\n```ts\nimport { readFileSync } from \"node:fs\";\nimport { parse } from \"yaml\";\nimport { Interface } from \"ethers\";\n\nconst abi = parse(readFileSync(\"transfer.abi.yaml\", \"utf8\"));\nconst iface = new Interface(abi);\nconsole.log(iface.getFunction(\"transfer\")!.selector); // \"0xa9059cbb\"\n```\n\n## Things to know\n\n- Status is **Stagnant**. It is an Informational recommendation, not a requirement, and in practice most ERCs still present interfaces in Solidity.\n- The spec's YAML example also includes the legacy `payable` and `constant` fields; current ABI output uses `stateMutability` alone, which is why they are omitted above.\n- Comments are dropped when converting YAML to JSON, so keep the YAML file as the documented source of truth.\n"},"ja":{"lang":"ja","tldr":"EIP や ERC がコントラクトインターフェースを Solidity コードではなく YAML 形式の ABI で記述することを勧める情報提供（Informational）の推奨。JSON と同じく言語中立で、コメントも書ける。","tags":["abi","yaml","specification","process","informational"],"related":[20],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-2069/","markdown":"## 何を解決するのか\n\n[ERC-20](/eip-20/) のような多くのインターフェース標準は、API を Solidity の `interface` で示します。著者は次の 3 つの欠点を指摘しています。\n\n- 特定の言語に有利で、他の言語（Vyper、Fe、手書きのバイトコード、オフチェーンのツール）が不利になりうる。\n- 仕様が特定の Solidity のバージョンと構文に縛られ、それらは時間とともに変わる。\n- Solidity には ABI にきれいに対応しない表現ができてしまい、他の言語がさらに不利になる。\n\nコントラクトインターフェースの中立的な記述は **Contract ABI** で、通常は JSON で書かれます。しかし JSON にはコメントを書けず、仕様には各関数の横に説明が必要です。\n\n## 仕組み\n\n推奨内容はシンプルで、ABI を **YAML** で書くことです。YAML は JSON のスーパーセットなので、中身はコンパイラやライブラリがすでに理解している ABI と同じで、両者の変換は機械的に行えます。JSON と違って YAML では `#` コメントが使えるため、著者は各関数をインラインで説明できます。\n\n著者には YAML ABI にコメントを付けることが推奨されています。使える項目と値は Solidity の Contract ABI 仕様のものとまったく同じで、この EIP が新しい記述言語を作るわけではありません。仕様は、YAML と JSON の ABI を相互変換する JavaScript ツール `yamabi` を紹介しています。\n\n## サンプルコード\n\n仕様の例、YAML で書いた `transfer` 関数:\n\n```yaml\n# The transfer function. Takes the recipient address\n# as an input and returns a boolean signaling the result.\n- name: transfer\n  type: function\n  stateMutability: nonpayable\n  inputs:\n  - name: recipient\n    type: address\n  - name: amount\n    type: uint256\n  outputs:\n  - name: ''\n    type: bool\n```\n\nethers v6 に読み込む例（YAML パーサーなら何でも使えます。結果は通常の JSON ABI です）:\n\n```ts\nimport { readFileSync } from \"node:fs\";\nimport { parse } from \"yaml\";\nimport { Interface } from \"ethers\";\n\nconst abi = parse(readFileSync(\"transfer.abi.yaml\", \"utf8\"));\nconst iface = new Interface(abi);\nconsole.log(iface.getFunction(\"transfer\")!.selector); // \"0xa9059cbb\"\n```\n\n## 知っておくべきこと\n\n- ステータスは **Stagnant** です。これは要件ではなく Informational の推奨であり、実際にはほとんどの ERC が今でもインターフェースを Solidity で示しています。\n- 仕様の YAML 例には、旧来の `payable` と `constant` フィールドも含まれています。現在の ABI 出力は `stateMutability` だけを使うため、上のコードでは省いています。\n- YAML から JSON に変換するとコメントは失われるので、ドキュメント付きの YAML ファイルを正（source of truth）として保管してください。\n"},"ko":{"lang":"ko","tldr":"EIP와 ERC가 컨트랙트 인터페이스를 Solidity 코드 대신 YAML 형식의 ABI로 기술하도록 권장하는 정보성(Informational) 제안. YAML은 JSON처럼 언어 중립적이면서 주석을 쓸 수 있다.","tags":["abi","yaml","specification","process","informational"],"related":[20],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-2069/","markdown":"## 어떤 문제를 해결하나요?\n\n[ERC-20](/eip-20/) 같은 대부분의 인터페이스 표준은 API를 Solidity `interface`로 보여 줍니다. 작성자는 세 가지 단점을 지적합니다.\n\n- 한 언어에 유리하고 다른 언어(Vyper, Fe, 손으로 쓴 바이트코드, 오프체인 도구)에는 불리할 수 있습니다.\n- 명세가 특정 Solidity 버전과 문법에 묶이는데, 이것들은 시간이 지나며 바뀝니다.\n- Solidity는 ABI에 깔끔하게 대응되지 않는 것도 표현할 수 있어서 다른 언어가 더 불리해집니다.\n\n컨트랙트 인터페이스의 중립적인 기술 방식은 **Contract ABI**이며 보통 JSON으로 씁니다. 하지만 JSON에는 주석을 넣을 수 없고, 명세에는 각 함수 옆에 설명이 필요합니다.\n\n## 어떻게 동작하나요?\n\n권장 사항은 간단합니다. ABI를 **YAML**로 쓰는 것입니다. YAML은 JSON의 상위 집합이므로 내용은 컴파일러와 라이브러리가 이미 이해하는 ABI와 같고, 둘 사이의 변환은 기계적으로 이루어집니다. JSON과 달리 YAML은 `#` 주석을 허용하므로 작성자가 각 함수를 인라인으로 설명할 수 있습니다.\n\n작성자는 YAML ABI에 주석을 달도록 권장됩니다. 허용되는 필드와 값은 Solidity Contract ABI 명세에 있는 것과 정확히 같으며, 이 EIP가 새로운 기술 언어를 만들지는 않습니다. 명세는 YAML과 JSON ABI를 서로 변환하는 JavaScript 도구 `yamabi`를 소개합니다.\n\n## 샘플 코드\n\n명세의 예시, YAML로 쓴 `transfer` 함수:\n\n```yaml\n# The transfer function. Takes the recipient address\n# as an input and returns a boolean signaling the result.\n- name: transfer\n  type: function\n  stateMutability: nonpayable\n  inputs:\n  - name: recipient\n    type: address\n  - name: amount\n    type: uint256\n  outputs:\n  - name: ''\n    type: bool\n```\n\nethers v6에 불러오기(어떤 YAML 파서든 됩니다. 결과는 일반 JSON ABI입니다):\n\n```ts\nimport { readFileSync } from \"node:fs\";\nimport { parse } from \"yaml\";\nimport { Interface } from \"ethers\";\n\nconst abi = parse(readFileSync(\"transfer.abi.yaml\", \"utf8\"));\nconst iface = new Interface(abi);\nconsole.log(iface.getFunction(\"transfer\")!.selector); // \"0xa9059cbb\"\n```\n\n## 알아둘 점\n\n- 상태는 **Stagnant**입니다. 요구 사항이 아니라 Informational 권장이며, 실제로는 대부분의 ERC가 여전히 인터페이스를 Solidity로 보여 줍니다.\n- 명세의 YAML 예시에는 예전 방식의 `payable`과 `constant` 필드도 들어 있습니다. 현재 ABI 출력은 `stateMutability`만 쓰므로 위 코드에서는 생략했습니다.\n- YAML을 JSON으로 변환하면 주석이 사라지므로, 문서화된 YAML 파일을 기준 원본(source of truth)으로 보관하세요.\n"},"zh":{"lang":"zh","tldr":"一项信息性（Informational）建议：EIP 和 ERC 应使用 YAML 格式的 ABI 而不是 Solidity 代码来描述合约接口，YAML 与 JSON 一样不依赖具体语言，但允许写注释。","tags":["abi","yaml","specification","process","informational"],"related":[20],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-2069/","markdown":"## 它解决什么问题？\n\n大多数接口标准（如 [ERC-20](/eip-20/)）都用 Solidity 的 `interface` 来呈现 API。作者指出了三个缺点：\n\n- 偏向某一种语言，可能让其他语言（Vyper、Fe、手写字节码、链下工具）处于劣势。\n- 把规范绑定到某个 Solidity 版本和语法上，而它们会随时间变化。\n- Solidity 能表达一些无法干净地映射到 ABI 的东西，让其他语言进一步处于劣势。\n\n合约接口的中立描述是 **Contract ABI**，通常写成 JSON。但 JSON 不能包含注释，而规范需要在每个函数旁边写说明。\n\n## 它如何运作\n\n建议很简单：用 **YAML** 编写 ABI。YAML 是 JSON 的超集，因此内容就是编译器和库已经能理解的同一份 ABI，两者之间的转换是机械的。与 JSON 不同，YAML 允许使用 `#` 注释，作者可以在行内为每个函数写文档。\n\n鼓励作者为 YAML ABI 添加注释。允许的字段和取值与 Solidity Contract ABI 规范完全一致；本 EIP 并没有发明新的描述语言。规范提到了 `yamabi`，这是一个在 YAML 和 JSON ABI 之间转换的 JavaScript 工具。\n\n## 示例代码\n\n规范中的示例，用 YAML 写的 `transfer` 函数：\n\n```yaml\n# The transfer function. Takes the recipient address\n# as an input and returns a boolean signaling the result.\n- name: transfer\n  type: function\n  stateMutability: nonpayable\n  inputs:\n  - name: recipient\n    type: address\n  - name: amount\n    type: uint256\n  outputs:\n  - name: ''\n    type: bool\n```\n\n加载到 ethers v6（任何 YAML 解析器都可以；结果是普通的 JSON ABI）：\n\n```ts\nimport { readFileSync } from \"node:fs\";\nimport { parse } from \"yaml\";\nimport { Interface } from \"ethers\";\n\nconst abi = parse(readFileSync(\"transfer.abi.yaml\", \"utf8\"));\nconst iface = new Interface(abi);\nconsole.log(iface.getFunction(\"transfer\")!.selector); // \"0xa9059cbb\"\n```\n\n## 需要注意\n\n- 状态为 **Stagnant**。这是信息性建议，不是强制要求，实际上大多数 ERC 仍然用 Solidity 呈现接口。\n- 规范中的 YAML 示例还包含旧版的 `payable` 和 `constant` 字段；当前的 ABI 输出只使用 `stateMutability`，所以上面省略了它们。\n- 把 YAML 转成 JSON 时注释会丢失，因此请把 YAML 文件作为带文档的权威来源保留。\n"}}}
