ERC-2193 dType alias system (dType Alias Extension - Decentralized Type System)
Stagnant · Names & metadata · created 2019-07-16
It allows human-readable names to be assigned not only to Ethereum addresses but also to individual pieces of data inside a smart contract (such as struct instances), making it possible to identify on-chain resources beyond the address level.
Why it is needed
Existing standards like ENS (EIP-137) can only assign human-readable names to Ethereum addresses, and they follow the DNS-style subdomain.domain.tld format (leaf toward root). This is counterintuitive because in programming languages a dot (.) usually means root toward leaf (such as accessing an object's property). In addition, a smart contract can contain heterogeneous data belonging to different accounts; for example, a PaymentChannel contract itself may have a domain name, but there is no way to attach a subdomain to an individual item within it, such as the Alice-Bob channel data. This makes it difficult to build protocols that both humans and machines can read.
What to implement
event AliasSet(bytes32 dtypeIdentifier, bytes1 separator, string name, bytes32 indexed identifier);: An event that records dtypeIdentifier, separator, name, and identifier when an alias is set.function setAlias(bytes32 dtypeIdentifier, bytes1 separator, string memory name, bytes32 identifier, bytes memory signature) external;: A function that registers or updates dtypeIdentifier, separator, name, and identifier along with the owner's signature.function getAliased(bytes1 separator, string memory name) view external returns (bytes32 identifier);: A function that looks up the identifier registered under a given separator and name.
In depth
Alias registry structure
Alias is a registry contract that tracks human-readable identifiers for resources held in a dType storage contract. dtypeIdentifier is a type identifier registered in the dType registry; it is checked for existence in the dType registry and used to link to that type's data storage contract to verify the identifier's existence and the signer's ownership. name is the human-readable name chosen by the user, and identifier is the resource that name actually points to.
The four separators
separator is the character that separates name from the rest of the alias, and four are allowed. The dot (.) is used for general root-to-leaf domain separation, as in domain.subdomain.resource. @ is used for leaf-to-root identification of actor (user) related data, as in alice@socialnetwork.profile. # is used for root-to-leaf concept identification, as in topicX#postY. / is used for defining general root-to-leaf resource paths, as in resourceRoot/resource.
Verifying ownership via signature
Anyone can set an alias in the Alias registry, but the Ethereum address that signs must own the corresponding resource in the dType storage contract. The signature covers dtypeIdentifier, identifier, name, separator, nonce, aliasAddress, and chainId. nonce is a monotonically increasing counter that prevents replay attacks, and aliasAddress and chainId, as described in EIP-155, specify which chain and which Alias contract the signature applies to, also preventing replay attacks. The owner can update or delete the alias at any time.
Two ways to access a resource
A resource can be accessed either by directly concatenating its bytes32 identifier (for example, 0x0b5e76559822448f6243a6f76ac7864eba89c810084471bdee2a63429c92d2e7@0x9dbb9abe0c47484c5707699b3ceea23b1c2cca2ac72681256ab42ae01bd347da) or by a human-readable name such as alice@socialnetwork. Both methods resolve to the same content.
Multiple aliases for one resource
A single resource can have multiple aliases using different names or different separators. Each separator can have its own standard for displaying and processing data according to its meaning.
Difference from ENS
Existing standards like ENS (EIP-137) target only Ethereum addresses and are based on concepts inherited from HTTP and DNS, which makes them inconvenient for machine processing. Combining dType (EIP-1900) with the dType storage contract (EIP-2157) enables general content addressing through type information and a reference to the contract storing instances of that type.
Incomplete state
This ERC is in Stagnant status. The Backwards Compatibility and Test Cases sections have no content yet in the original ("Will be added"), and the Implementation section is also a work in progress stated to be updated once consensus is reached on the specification. In other words, this is a proposal that is either still changing or has stalled.