---
eip: 1921
label: ERC-1921
title: dType Functions Extension
status: Stagnant
type: Standards Track
category: ERC
created: 2019-04-06
requires: 1900
official: https://eips.ethereum.org/EIPS/eip-1921
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-1921.md
canonical: https://eips.huatuo.xyz/eip-1921/
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]
---

# ERC-1921: dType Functions Extension

> 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.

**TL;DR:** 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](/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:

```solidity
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):

```json
{
  "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:

```solidity
mapping(bytes32 => dTypes[]) public outputs;
```

## Things to know

- 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.
- Only `pure` and `view` functions are targeted, which avoids state side effects when tools call registered functions.
- 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.
- Today, function metadata is usually distributed off-chain (ABIs, verified source on explorers) rather than registered on-chain.


---

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