ERC-1921 · Stagnant · ERC · 2019-04-06
ERC-1921: dType Functions Extension
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.
What problem does it solve?
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.
ERC-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".
How it works
A function entry reuses the dType type record and adds outputs:
| Field | Meaning |
|---|---|
name |
Unique function name (as in EIP-1900) |
types |
Inputs, each referring to an already registered dType type plus a label |
outputs |
Outputs, same format as inputs (new in this EIP) |
contractAddress |
Where the function is deployed (optional for interfaces) |
source |
bytes32 reference to the source code (optional) |
The registry gains one function:
function setOutputs(bytes32 identifier, dTypes[] memory outputs) public;
Because 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.
The rationale also suggests registering helper functions that compute a function's signature, so the scheme could survive a change of selector format.
Sample code
A function registration object, as passed to the dType registry's insert (from the spec, with placeholders):
{
"name": "setStaked",
"types": [
{ "name": "TypeA", "label": "typeA", "relation": 0, "dimensions": [] }
],
"typeChoice": 4,
"contractAddress": "<deployed contract address>",
"source": "<bytes32 source reference>",
"outputs": [
{ "name": "TypeB", "label": "typeB", "relation": 0, "dimensions": [] }
]
}
Suggested storage for outputs in a registry implementation:
mapping(bytes32 => dTypes[]) public outputs;
Things to know
- Status is Stagnant, as is its base proposal EIP-1900. There are no test cases, and the spec says the implementation is a work in progress.
- Only
pureandviewfunctions are targeted, which avoids state side effects when tools call registered functions. - Storing
contractAddresson every function of the same contract is redundant; the authors acknowledge the storage cost trade-off but leave detailed cost analysis for later. - Today, function metadata is usually distributed off-chain (ABIs, verified source on explorers) rather than registered on-chain.