---
eip: 1900
label: ERC-1900
title: dType - Decentralized Type System for EVM
status: Stagnant
type: Standards Track
category: ERC
created: 2019-03-28
official: https://eips.ethereum.org/EIPS/eip-1900
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-1900.md
canonical: https://eips.huatuo.xyz/ja/eip-1900/
lang: ja
tldr: dType は、Solidity の型（構造体とそのライブラリ）のオンチェーンレジストリを提案する。プロジェクト間でデータ定義を共有でき、ツールがデータを一貫してデコードできる。
tags: [types, registry, abi, solidity, interoperability]
---

# ERC-1900: dType - Decentralized Type System for EVM

> The EVM and related languages such as Solidity need consensus on an extensible Type System in order to further evolve into the Singleton Operating System (The World Computer).

**TL;DR:** dType は、Solidity の型（構造体とそのライブラリ）のオンチェーンレジストリを提案する。プロジェクト間でデータ定義を共有でき、ツールがデータを一貫してデコードできる。

## 何を解決するのか

Ethereum のあらゆるプロジェクトは、同じものを表す場合でも、それぞれ独自の構造体を定義します。どちらも「残高」や「トークン量」の型を持つ 2 つのプロトコルは、独自の接着コードなしにはデータを渡し合えず、ブロックエクスプローラーはデコードのために各コントラクトの ABI を個別に教えてもらう必要があります。

dType（「分散型の型システム」）は、共有されるオンチェーンの**型レジストリ**を提案します。型は、ABI を再構築できるだけのメタデータとともに一度登録され、誰でもそれを再利用したり、より大きな型に組み合わせたり、それを使うデータをデコードしたりできます。

## 仕組み

**型ライブラリ。** 各型は、`struct` と、`isInstanceOf`（検証）、`structureBytes` / `destructureBytes`（エンコードとデコード）、`map`、`filter`、`reduce` などの高階関数といった補助関数を含む、Solidity のライブラリで定義されます。型は他の型を含むことができ、常に有向非巡回グラフを形成します。

**レジストリのレコード。** 各型について、レジストリは次を保存します。

- `name`: Solidity の型名。必要に応じてバージョンを付けます
- `typeChoice`: `BaseType`、`PayableFunction`、`StateFunction`、`ViewFunction`、`PureFunction`、`Event` のいずれか
- `contractAddress`: 型ライブラリのアドレス
- `source`: ソースコードの Swarm ハッシュ
- `types`: 直接のサブフィールド。それぞれ `name`、`label`、配列の `dimensions` を持ちます（`[""]` は `T[]`、`["2","3"]` は `T[2][3]` を意味します）

レコードの識別子は `keccak256(abi.encodePacked(name))` です。インターフェースは `insert`、`remove`、`count`、`get`、`getByIdentifier`、`getTypeIdentifier`、`isRegistered` を提供し、`LogNew` / `LogUpdate` / `LogRemove` イベントがあります。

**仕様にある合成の例。** `myBalance = (string accountName, uint256 amount)` と `myToken = (address token, myBalance balance)` から、`myToken` の ABI タプル `(address,(string,uint256))` が得られます。

## サンプルコード

合成された型のレジストリメタデータ（JSON）:

```json
{
  "typeChoice": 0,
  "contractAddress": "0x...",
  "source": "0x...",
  "name": "myToken",
  "types": [
    { "name": "address",   "label": "token",   "dimensions": [] },
    { "name": "myBalance", "label": "balance", "dimensions": [] }
  ]
}
```

レジストリインターフェースの抜粋版:

```solidity
interface IDType {
    enum TypeChoices { BaseType, PayableFunction, StateFunction, ViewFunction, PureFunction, Event }
    struct dTypes { string name; string label; string[] dimensions; }
    struct dType  { TypeChoices typeChoice; address contractAddress; bytes32 source;
                    string name; dTypes[] types; }

    event LogNew(bytes32 indexed identifier, uint256 indexed index);

    function insert(dType calldata data) external returns (bytes32 identifier);
    function get(string memory name) external view returns (dType memory);
    function isRegistered(bytes32 identifier) external view returns (bool);
}
```

## 知っておくべきこと

- **ステータス: Stagnant。** 当時まだ実験的だった ABIEncoderV2 を使い、Solidity 0.5 向けに書かれたもので、テストケースは追加されませんでした。
- ガバナンス（誰が型を追加・削除できるか）と権限は明示的にスコープ外です。著者らは更新をサポートしないことを提案し、`remove` は危険だと述べています。
- 単純な名前をキーにすると、名前の買い占め（ネームスクワッティング）を招きます。仕様は、当初は英単語 1 語の名前を禁止することを提案しているだけです。
- これは、現在の EIP 一覧の外にあるフォローアップの提案で説明されている、より大きな構想（型付きストレージ、関数レジストリ）の第一歩として設計されました。


---

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