{"eip":1921,"title":"dType Functions Extension","description":"In the context of dType, the Decentralized Type System described in EIP-1900, we are proposing to add support for registering functions (with a preference for pure and view) in the dType Registry.","authors":["Loredana Cirstea (@loredanacirstea)","Christian Tzurcanu (@ctzurcanu)"],"status":"Stagnant","type":"Standards Track","category":"ERC","created":"2019-04-06","requires":[1900],"discussionsTo":"https://github.com/ethereum/EIPs/issues/1921","repo":"ERCs","label":"ERC-1921","officialUrl":"https://eips.ethereum.org/EIPS/eip-1921","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-1921.md","url":"https://eips.huatuo.xyz/eip-1921/","tldr":{"en":"Extends the dType on-chain type registry so individual pure and view functions, with their input and output types, can be registered and discovered as first-class entries.","ja":"dType のオンチェーン型レジストリを拡張し、個々の pure/view 関数を、その入力型と出力型とともに、第一級のエントリとして登録・発見できるようにする。","ko":"dType 온체인 타입 레지스트리를 확장해, 개별 pure 및 view 함수를 입력과 출력 타입과 함께 일급 항목으로 등록하고 찾을 수 있게 한다.","zh":"扩展 dType 链上类型注册表，使单个 pure 和 view 函数连同其输入输出类型可以作为一等条目被注册和发现。"},"tags":["registry","types","functions","abi"],"explainers":{"en":{"lang":"en","tldr":"Extends the dType on-chain type registry so individual pure and view functions, with their input and output types, can be registered and discovered as first-class entries.","tags":["registry","types","functions","abi"],"related":[1900],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-1921/","markdown":"## What problem does it solve?\n\n[EIP-1900](/eip-1900/) (dType) proposes a global on-chain registry of data types, so contracts and tools can share and reuse type definitions. That registry describes data, not behaviour.\n\nERC-1921 adds **functions** to the registry, focusing on `pure` and `view` functions. The authors' goal is a global, non-custodial catalogue of functions that tools (block explorers, IDEs, security analysers) and even other contracts can find and run automatically, building towards their idea of the EVM as a shared \"operating system\".\n\n## How it works\n\nA function entry reuses the dType type record and adds outputs:\n\n| Field | Meaning |\n| --- | --- |\n| `name` | Unique function name (as in EIP-1900) |\n| `types` | Inputs, each referring to an already registered dType type plus a label |\n| `outputs` | Outputs, same format as inputs (new in this EIP) |\n| `contractAddress` | Where the function is deployed (optional for interfaces) |\n| `source` | `bytes32` reference to the source code (optional) |\n\nThe registry gains one function:\n\n```solidity\nfunction setOutputs(bytes32 identifier, dTypes[] memory outputs) public;\n```\n\nBecause inputs and outputs point to registered types instead of raw ABI strings, very little ABI data is stored per function, and you can search for \"all functions that take `TypeA` and return `TypeB`\", which helps composition and function chaining.\n\nThe rationale also suggests registering helper functions that compute a function's signature, so the scheme could survive a change of selector format.\n\n## Sample code\n\nA function registration object, as passed to the dType registry's `insert` (from the spec, with placeholders):\n\n```json\n{\n  \"name\": \"setStaked\",\n  \"types\": [\n    { \"name\": \"TypeA\", \"label\": \"typeA\", \"relation\": 0, \"dimensions\": [] }\n  ],\n  \"typeChoice\": 4,\n  \"contractAddress\": \"\u003cdeployed contract address\u003e\",\n  \"source\": \"\u003cbytes32 source reference\u003e\",\n  \"outputs\": [\n    { \"name\": \"TypeB\", \"label\": \"typeB\", \"relation\": 0, \"dimensions\": [] }\n  ]\n}\n```\n\nSuggested storage for outputs in a registry implementation:\n\n```solidity\nmapping(bytes32 =\u003e dTypes[]) public outputs;\n```\n\n## Things to know\n\n- Status is **Stagnant**, as is its base proposal [EIP-1900](/eip-1900/). There are no test cases, and the spec says the implementation is a work in progress.\n- Only `pure` and `view` functions are targeted, which avoids state side effects when tools call registered functions.\n- Storing `contractAddress` on every function of the same contract is redundant; the authors acknowledge the storage cost trade-off but leave detailed cost analysis for later.\n- Today, function metadata is usually distributed off-chain (ABIs, verified source on explorers) rather than registered on-chain.\n"},"ja":{"lang":"ja","tldr":"dType のオンチェーン型レジストリを拡張し、個々の pure/view 関数を、その入力型と出力型とともに、第一級のエントリとして登録・発見できるようにする。","tags":["registry","types","functions","abi"],"related":[1900],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-1921/","markdown":"## 何を解決するのか\n\n[EIP-1900](/eip-1900/)（dType）は、コントラクトやツールが型定義を共有・再利用できるよう、データ型のグローバルなオンチェーンレジストリを提案します。このレジストリが記述するのはデータであり、振る舞いではありません。\n\nERC-1921 はレジストリに**関数**を追加し、特に `pure` と `view` の関数に焦点を当てます。著者たちの目標は、ツール（ブロックエクスプローラー、IDE、セキュリティ解析ツール）や、他のコントラクトまでもが自動的に見つけて実行できる、グローバルでノンカストディアルな関数のカタログです。これは、EVM を共有の「オペレーティングシステム」とみなす彼らの構想に向けた一歩です。\n\n## 仕組み\n\n関数のエントリは、dType の型レコードを再利用し、出力を追加します。\n\n| フィールド | 意味 |\n| --- | --- |\n| `name` | 一意の関数名（EIP-1900 と同じ） |\n| `types` | 入力。それぞれ、登録済みの dType の型とラベルを参照する |\n| `outputs` | 出力。入力と同じ形式（この EIP で新規） |\n| `contractAddress` | 関数がデプロイされている場所（インターフェースでは任意） |\n| `source` | ソースコードへの `bytes32` 参照（任意） |\n\nレジストリには関数が 1 つ追加されます。\n\n```solidity\nfunction setOutputs(bytes32 identifier, dTypes[] memory outputs) public;\n```\n\n入力と出力は生の ABI 文字列ではなく、登録済みの型を指すため、関数ごとに保存される ABI データはごくわずかで、「`TypeA` を受け取り `TypeB` を返すすべての関数」を検索できます。これは合成や関数のチェーン化に役立ちます。\n\n設計の根拠では、関数のシグネチャを計算するヘルパー関数も登録することを提案しており、セレクター形式が変わってもこの仕組みが生き残れるようにしています。\n\n## サンプルコード\n\ndType レジストリの `insert` に渡す関数登録オブジェクト（仕様より、プレースホルダー付き）:\n\n```json\n{\n  \"name\": \"setStaked\",\n  \"types\": [\n    { \"name\": \"TypeA\", \"label\": \"typeA\", \"relation\": 0, \"dimensions\": [] }\n  ],\n  \"typeChoice\": 4,\n  \"contractAddress\": \"\u003cdeployed contract address\u003e\",\n  \"source\": \"\u003cbytes32 source reference\u003e\",\n  \"outputs\": [\n    { \"name\": \"TypeB\", \"label\": \"typeB\", \"relation\": 0, \"dimensions\": [] }\n  ]\n}\n```\n\nレジストリ実装で出力を保存するための提案:\n\n```solidity\nmapping(bytes32 =\u003e dTypes[]) public outputs;\n```\n\n## 知っておくべきこと\n\n- ステータスは **Stagnant** で、土台となる提案 [EIP-1900](/eip-1900/) も同様です。テストケースはなく、仕様は実装が作業中であると述べています。\n- 対象は `pure` と `view` の関数だけで、ツールが登録された関数を呼び出す際にステートへの副作用が生じないようになっています。\n- 同じコントラクトのすべての関数に `contractAddress` を保存するのは冗長です。著者たちはストレージコストのトレードオフを認めていますが、詳細なコスト分析は後に回しています。\n- 今日、関数のメタデータは、オンチェーンに登録されるのではなく、通常はオフチェーン（ABI、エクスプローラー上の検証済みソース）で配布されています。\n"},"ko":{"lang":"ko","tldr":"dType 온체인 타입 레지스트리를 확장해, 개별 pure 및 view 함수를 입력과 출력 타입과 함께 일급 항목으로 등록하고 찾을 수 있게 한다.","tags":["registry","types","functions","abi"],"related":[1900],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-1921/","markdown":"## 어떤 문제를 해결하나요?\n\n[EIP-1900](/eip-1900/)(dType)은 컨트랙트와 도구가 타입 정의를 공유하고 재사용할 수 있도록 데이터 타입의 전역 온체인 레지스트리를 제안합니다. 이 레지스트리는 데이터를 기술할 뿐 동작을 기술하지는 않습니다.\n\nERC-1921은 레지스트리에 **함수**를 추가하며, 특히 `pure`와 `view` 함수에 집중합니다. 작성자들의 목표는 도구(블록 익스플로러, IDE, 보안 분석기)와 심지어 다른 컨트랙트까지도 자동으로 찾아 실행할 수 있는 전역적이고 비수탁형인 함수 카탈로그이며, EVM을 공유 \"운영 체제\"로 보는 그들의 구상을 향한 한 걸음입니다.\n\n## 어떻게 동작하나요?\n\n함수 항목은 dType의 타입 레코드를 재사용하고 출력을 추가합니다.\n\n| 필드 | 의미 |\n| --- | --- |\n| `name` | 고유한 함수 이름(EIP-1900과 같음) |\n| `types` | 입력. 각각 이미 등록된 dType 타입과 레이블을 참조 |\n| `outputs` | 출력. 입력과 같은 형식(이 EIP에서 새로 추가) |\n| `contractAddress` | 함수가 배포된 위치(인터페이스에서는 선택) |\n| `source` | 소스 코드에 대한 `bytes32` 참조(선택) |\n\n레지스트리에는 함수 하나가 추가됩니다.\n\n```solidity\nfunction setOutputs(bytes32 identifier, dTypes[] memory outputs) public;\n```\n\n입력과 출력이 원시 ABI 문자열이 아니라 등록된 타입을 가리키므로 함수당 저장되는 ABI 데이터가 아주 적고, \"`TypeA`를 받아 `TypeB`를 반환하는 모든 함수\"를 검색할 수 있어 조합과 함수 체이닝에 도움이 됩니다.\n\n설계 근거에서는 함수의 시그니처를 계산하는 헬퍼 함수도 등록하자고 제안하는데, 그러면 셀렉터 형식이 바뀌어도 이 방식이 살아남을 수 있습니다.\n\n## 샘플 코드\n\ndType 레지스트리의 `insert`에 전달하는 함수 등록 객체(명세에서 가져왔으며 자리표시자 포함):\n\n```json\n{\n  \"name\": \"setStaked\",\n  \"types\": [\n    { \"name\": \"TypeA\", \"label\": \"typeA\", \"relation\": 0, \"dimensions\": [] }\n  ],\n  \"typeChoice\": 4,\n  \"contractAddress\": \"\u003cdeployed contract address\u003e\",\n  \"source\": \"\u003cbytes32 source reference\u003e\",\n  \"outputs\": [\n    { \"name\": \"TypeB\", \"label\": \"typeB\", \"relation\": 0, \"dimensions\": [] }\n  ]\n}\n```\n\n레지스트리 구현에서 출력을 저장하는 방식에 대한 제안:\n\n```solidity\nmapping(bytes32 =\u003e dTypes[]) public outputs;\n```\n\n## 알아둘 점\n\n- 상태는 **Stagnant**이며, 기반 제안인 [EIP-1900](/eip-1900/)도 마찬가지입니다. 테스트 케이스가 없고 명세는 구현이 진행 중이라고 밝힙니다.\n- `pure`와 `view` 함수만 대상으로 하므로, 도구가 등록된 함수를 호출할 때 상태에 부작용이 생기지 않습니다.\n- 같은 컨트랙트의 모든 함수에 `contractAddress`를 저장하는 것은 중복입니다. 작성자들은 스토리지 비용의 트레이드오프를 인정하지만 자세한 비용 분석은 나중으로 미룹니다.\n- 오늘날 함수 메타데이터는 보통 온체인에 등록되지 않고 오프체인(ABI, 익스플로러의 검증된 소스)으로 배포됩니다.\n"},"zh":{"lang":"zh","tldr":"扩展 dType 链上类型注册表，使单个 pure 和 view 函数连同其输入输出类型可以作为一等条目被注册和发现。","tags":["registry","types","functions","abi"],"related":[1900],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-1921/","markdown":"## 它解决什么问题？\n\n[EIP-1900](/eip-1900/)（dType）提出了一个全局的链上数据类型注册表，让合约和工具可以共享并复用类型定义。这个注册表描述的是数据，而不是行为。\n\nERC-1921 把**函数**加入注册表，重点是 `pure` 和 `view` 函数。作者的目标是建立一个全局的、非托管的函数目录，让工具（区块浏览器、IDE、安全分析器）乃至其他合约都能自动找到并运行其中的函数，朝着他们设想的把 EVM 作为共享\"操作系统\"的方向迈进。\n\n## 它如何运作\n\n函数条目复用 dType 的类型记录，并增加输出：\n\n| 字段 | 含义 |\n| --- | --- |\n| `name` | 唯一的函数名（与 EIP-1900 相同） |\n| `types` | 输入，每一项引用一个已注册的 dType 类型，外加一个标签 |\n| `outputs` | 输出，格式与输入相同（本 EIP 新增） |\n| `contractAddress` | 函数部署的位置（对接口而言可选） |\n| `source` | 指向源代码的 `bytes32` 引用（可选） |\n\n注册表新增一个函数：\n\n```solidity\nfunction setOutputs(bytes32 identifier, dTypes[] memory outputs) public;\n```\n\n由于输入和输出指向已注册的类型，而不是原始的 ABI 字符串，每个函数需要存储的 ABI 数据非常少，并且你可以搜索\"所有接受 `TypeA` 并返回 `TypeB` 的函数\"，这有助于组合和函数链式调用。\n\n设计理由还建议注册用于计算函数签名的辅助函数，这样即便选择器格式发生变化，这套方案也能继续适用。\n\n## 示例代码\n\n传给 dType 注册表 `insert` 的函数注册对象（来自规范，含占位符）：\n\n```json\n{\n  \"name\": \"setStaked\",\n  \"types\": [\n    { \"name\": \"TypeA\", \"label\": \"typeA\", \"relation\": 0, \"dimensions\": [] }\n  ],\n  \"typeChoice\": 4,\n  \"contractAddress\": \"\u003cdeployed contract address\u003e\",\n  \"source\": \"\u003cbytes32 source reference\u003e\",\n  \"outputs\": [\n    { \"name\": \"TypeB\", \"label\": \"typeB\", \"relation\": 0, \"dimensions\": [] }\n  ]\n}\n```\n\n注册表实现中建议的输出存储方式：\n\n```solidity\nmapping(bytes32 =\u003e dTypes[]) public outputs;\n```\n\n## 需要注意\n\n- 状态是 **Stagnant**，它的基础提案 [EIP-1900](/eip-1900/) 也是如此。没有测试用例，规范称实现仍在进行中。\n- 只针对 `pure` 和 `view` 函数，这样工具调用已注册函数时就不会产生状态副作用。\n- 对同一合约的每个函数都存储 `contractAddress` 是冗余的；作者承认这是存储成本上的权衡，但把详细的成本分析留到以后。\n- 如今，函数元数据通常是在链下分发（ABI、浏览器上已验证的源码），而不是在链上注册。\n"}}}
