Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

This article examines ERC-1921, which proposes registering smart contract pure and view functions in the ERC-1900 dType registry to improve reusability.

This explanation is based on the following specification.

For other Ethereum improvement proposals, see the following page.

Overview

ERC-1921 extends the decentralized type system (dType) defined in ERC-1900 by enabling contracts to register functions in a dType registry.

dType provides a mechanism for defining and sharing common data types and structures on Ethereum. ERC-1921 extends this approach to functions.

Registered functions can be managed through the registry, allowing smart contracts to share and reuse function definitions.

For more information about ERC-1900, see the following article.

ERC-1900: Standardizing Smart Contract Types

ERC-1921 is part of a series of extensions to the decentralized type system. It defines data structures and interfaces for registering individual smart contract functions so that they can be registered, discovered, and identified in a manner similar to type definitions.

Motivation

The proposal is motivated by a vision of the Ethereum Virtual Machine (EVM) as a singleton operating system.

Achieving this vision requires a standardized way to register functions executed on the EVM and make them easier for other contracts and applications to discover and invoke.

Function registration could help provide the following capabilities.

  • A shared registry of function locations and interfaces.
  • More structured function invocation by automated tools and analysis systems.
  • Advanced functionality in contract IDEs, security analysis tools, and block explorers using dType information.

As with ERC-1900, the proposal describes consensus-based registration mechanisms intended to avoid unnecessarily expanding blockchain state. Such mechanisms aim to prevent duplicate or inappropriate registrations.

ERC-1921 therefore seeks to improve both the reusability of EVM functions and the surrounding smart contract development environment.

Specification

Supported Function Types

The proposal focuses on pure and view functions. These functions do not modify blockchain state, making them suitable for a type system designed around reusable computations and queries. Their declarations alone do not establish that their results are trustworthy.

Function Registration Information

A function registered in the dType registry is represented as a structured object containing the following information.

Field Meaning
name Unique function name, represented as a string according to ERC-1900; required for identification
types Types and labels of the function's input parameters, defined according to ERC-1900 for all inputs
outputs Types and labels of return values; introduced by ERC-1921 and required when outputs exist
contractAddress Address of the implementing contract; may be omitted when registering an interface
source Optional bytes32 value representing an external source code reference

These definitions describe function inputs and outputs so that other smart contracts and tools can reuse the registered interface.

Registration Object Example

The following JSON object illustrates registration of a function named setStaked.

json
{
  "name": "setStaked",
  "types": [
    {"name": "TypeA", "label": "typeA", "relation": 0, "dimensions": []}
  ],
  "typeChoice": 4,
  "contractAddress": "<コントラクトのアドレス>",
  "source": "<ソースコードを参照するbytes32ハッシュ>",
  "outputs": [
    {"name": "TypeB", "label": "typeB", "relation": 0, "dimensions": []}
  ]
}

The placeholders identify the contract address and a bytes32 hash referencing the source code.

The object is registered through dTypeRegistry.insert({...}).

Setting Output Types Separately

Output information can also be added or updated after registration. The proposal introduces the following setOutputs function.

solidity
function setOutputs(
    bytes32 identifier,
    dTypes[] memory outputs
) public

Here, identifier is a type identifier defined by ERC-1900, and outputs is an array describing the output types.

Storage in an Implementation

The proposed registry implementation manages function output information using the following mapping.

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

This enables output types to be stored and retrieved by function identifier.

Citation

Loredana Cirstea (@loredanacirstea), Christian Tzurcanu (@ctzurcanu), "ERC-1921: dType Functions Extension [DRAFT]," Ethereum Improvement Proposals, no. 1921, April 2019. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-1921.

Conclusion

ERC-1921 extends the ERC-1900 dType registry to describe and register smart contract functions, supporting discovery and reuse of their interfaces.