Ethereum Name Service 백서

Ethereum Name Service

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 26쪽

a bytes slice such as `BytesUtils.substring`, offchain by slicing the byte array). #### findExactRegistry and findNearestRegistry ##### findExactRegistry Walks top-down from root, calling `getSubregistry()` at each label. Returns the subregistry that the target name points to, or `address(0)` if any link in the chain is missing. For `nick.eth`: <MonoDiagram content={`root\n└── getSubregistry("eth") → .eth registry\n └── getSubregistry("nick") → nick.eth subregistry ← returned`} /> This is the registry where `nick.eth`'s subnames live. If `nick.eth` has no subregistry set, the final step returns `address(0)`. ##### findNearestRegistry The tolerant variant: instead of failing when the chain stops early, it returns the deepest registry found along the path, together with the offset of the ancestor name it belongs to, so that `findExactRegistry(name[offset:])` returns the same registry. An offset of `0` means the exact registry exists. #### findParentRegistry Walks top-down to find the registry that **contains** a name's entry, rather than the subregistry the name points to. It strips the first label and calls `findExactRegistry` on the parent suffix. For `nick.eth`: <MonoDiagram content={`root\n└── getSubregistry("eth") → .eth registry ← returned`} /> The `.eth` registry is where `nick` is an entry. Contrast with `findExactRegistry("nick.eth")`, which returns `nick.eth`'s own subregistry (one level deeper). This is the registry that holds ownership information for a name, which is what [`findExactOwner`](#findexactowner-and-findnearestowner) queries. #### findRegistries Walks top-down and builds the complete ancestry array for a name, from innermost to outermost. Each position in the array corresponds to one label in the name, with the root registry appended at the end. ``` findRegistries("") → [<root>] findRegistries("eth") → [<eth>, <root>] findRegistries("nick.eth") → [<nick>, <eth>, <root>] findRegistries("sub.nick.eth") → [address(0), <nick>, <eth>, <root>] ``` If a name has no subregistry at some level, that position in the array is `address(0)`. In the last example, `sub.nick.eth` has no subregistry, so the first element is zero, but its parent registries are all present. #### findCanonicalName <FrenCallout fren="earl" variant="note" title="Definition – Canonical Name"> A registry's **canonical name** is the DNS-encoded name produced by `findCanonicalName`: it walks up the verified [parent pointer](/ensv2/permissioned-registry#parent-pointer) chain from the registry to root, reconstructing the name at each step. </FrenCallout> Because registries have no inherent concept of "their name" (a registry can be mounted at multiple positions via [namespace aliasing](/ensv2/registry-hierarchy#namespace-aliasing)), a canonical name only exists when both directions of the hierarchy agree: `setParent()` establishes the backward pointer, and `findCanonicalName` verifies at each step that the parent's forward pointer (`getSubregistry`) points back to the same registry. For the `nick.eth` subregistry (walking upward): <MonoDiagram content={`nick.eth subregistry\n├── getParent() → (.eth registry, "nick")\n│ └── verify: eth.getSubregistry("nick") == nick.eth subregistry ✓\n└── .eth registry\n ├── getParent() → (root, "eth")\n │ └── verify: root.getSubregistry("eth") == .eth registry ✓\n └── root reached → canonical name: "nick.eth"`} /> Returns empty bytes if any link is broken: if a registry has no parent set, or if `parent.getSubregistry(label)` points to a different address. #### findCanonicalRegistry <FrenCallout fren="earl" variant="note" title="Definition – Canonical Registry"> The **canonical registry** for a name is the registry at that position in the hierarchy whose [canonical name](#findcanonicalname) equals the name. </FrenCallout> `findCanonicalRegistry` verifies this by combining both directions: For `nick.eth`: <MonoDiagram content={`Down: findExactRegistry("nick.eth")\n└── root.getSubregistry("eth") → .eth registry\n └── eth.getSubregistry("nick") → 0xABCD\n\nUp: findCanonicalName(0xABCD)\n├── 0xABCD.getParent() → (.eth registry, "nick")\n│ └── verify: eth.getSubregistry("nick") == 0xABCD ✓\n└── reconstructed name: "nick.eth" == input name ✓ → return 0xABCD`} /> The bidirectional check prevents aliasing attacks: a registry could be mounted at one position in the tree but claim (via `getParent()`) to be at another. This is the function to use when verifying a registry's legitimacy, for example in marketplaces or any context where a name is being purchased or trusted. #### findExactOwner and findNearestOwner ##### findExactOwner Finds the current owner of a name. `IOwnedRegistry` is a minimal interface that extends `IRegistry` with a single `findOwner(label)` function, returning the owner of a label. [PermissionedRegistry](/ensv2/permissioned-registry) implements it, but any custom registry with ownership can too. For `nick.eth`: <MonoDiagram content={`findParentRegistry("nick.eth") → .eth registry\n├── supports IOwnedRegistry? (ERC-165 check) ✓\n└── .eth.findOwner("nick") → 0x1234 ← returned`} /> Returns `address(0)` if the parent registry doesn't exist, doesn't implement `IOwnedRegistry`, or the label has no owner (unregistered, expired, or [reserved](/ensv2/permissioned-registry#name-lifecycle)). ##### findNearestOwner Returns the owner of the closest owned ancestor instead: the deepest owner found along the path, together with the offset of the ancestor it belongs to, so that `findExactOwner(name[offset:])` returns the same owner. An offset of `0` means the name itself is owned. This answers "who is responsible for this name?" for subnames that exist only as [resolver data](/ensv2/permissioned-resolver): a name with no registry entry of its own has no owner, but its closest registered ancestor does. ### Reference #### Universal Resolver Functions <ContractReference functions={[ { name: 'findResolver', description: 'Find the resolver for a name by walking down the registry hierarchy.', params: [ { name: 'name', type: 'bytes', description: 'DNS-encoded name to search' }, ], returns: [ { name: 'resolver', type: 'address', description: 'Resolver covering the longest suffix, or address(0)' }, { name: 'node', type: 'bytes32', description: 'Namehash of the full name' }, { name: 'offset', type: 'uint256', description: 'Byte offset into the DNS-encoded name where the resolver was found. 0 means an exact match; non-zero means the resolver was found at a parent suffix. Used by requireResolver to enforce that non-wildcard resolvers only serve exact matches.' }, ], }, { name: 'resolve', description: 'Forward-resolve a single record for a DNS-encoded name. For batch resolution, encode data as multicall(bytes[]).', params: [ { name: 'name', type: 'bytes', description: 'DNS-encoded name to resolve' }, { name: 'data', type: 'bytes', description: 'ABI-encoded resolver calldata' }, ], returns: [ { name: 'result', type: 'bytes', description: 'ABI-encoded response' }, { name: 'resolver', type: 'address', description: 'The resolver that was used' }, ], }, { name: 'resolveWithGateways', description: 'Same as resolve, but with custom CCIP-Read gateway URLs.', params: [ { name: 'name', type: 'bytes', description: 'DNS-encoded name to resolve' }, { name: 'data', type: 'bytes', description: 'ABI-encoded resolver calldata' }, { name: 'gateways', type: 'string[]', description: 'Custom CCIP-Read batch gateway URLs' }, ], returns: [ { name: 'result', type: 'bytes', description: 'ABI-encoded response' }, { name: 'resolver', type: 'address', description: 'The resolver that was used' }, ], }, { name: 'resolveWithResolver', description: 'Resolve using a specific resolver address, bypassing the findResolver lookup.', params: [ { name: 'resolver', type: 'address', description: 'Resolver address to use directly' }, { name: 'name', type: 'bytes', description: 'DNS-encoded name' }, { name: 'data', type: 'bytes', description: 'ABI-encoded resolver calldata' }, { name: 'gateways', type: 'string[]', description: 'CCIP-Read batch gateway URLs' }, ], returns: [ { name: 'result', type: 'bytes', description: 'ABI-encoded response' }, ], }, { name: 'reverse', description: 'Reverse resolution per ENSIP-19: look up the primary name for an address, then verify via forward resolution.', params: [ { name: 'lookupAddress', type: 'bytes', description: 'Byte-encoded address to look up' }, { name: 'coinType', type: 'uint256', description: 'Coin type of the address (e.g. 60 for Ethereum)' }, ], returns: [ { name: 'primary', type: 'string', description: 'Verified primary name, or empty if not set' }, { name: 'resolver', type: 'address', description: 'Forward resolver for the primary name' }, { name: 'reverseResolver', type: 'address', description: 'Reverse resolver that provided the name' }, ], }, { name: 'reverseWithGateways', description: 'Same as reverse, but with custom CCIP-Read gateway URLs.', params: [ { name: 'lookupAddress', type: 'bytes', description: 'Byte-encoded address to look up' }, { name: 'coinType', type: 'uint256', description: 'Coin type of the address' }, { name: 'gateways', type: 'string[]', description: 'Custom CCIP-Read batch gateway URLs' }, ], returns: [ { name: 'primary', type: 'string', description: 'Verified primary name, or empty if not set' }, { name: 'resolver', type: 'address', description: 'Forward resolver for the primary name' }, { name: 'reverseResolver', type: 'address', description: 'Reverse resolver that provided the name' }, ], }, { name: 'requireResolver', description: 'Same as findResolver, but reverts if no suitable resolver is found. Reverts with ResolverNotFound if: no resolver exists, or the resolver does not support IExtendedResolver and was found at a parent suffix (non-zero offset). Reverts with ResolverNotContract if the resolver was matched exactly (zero offset), does not support IExtendedResolver, and has no deployed code. Used internally by resolve() and reverse().', params: [ { name: 'name', type: 'bytes', description: 'DNS-encoded name to search' }, ], returns: [ { name: 'info', type: 'ResolverInfo', description: 'Struct with name, offset, node, resolver address, and whether it supports IExtendedResolver' }, ], }, { name: 'resolveWithNormalization', description: 'Like resolve, but first normalizes the name onchain via the supplied ENSIP-15 normalizer contract. Intended for future use, no normalizer contract is deployed yet. The variant resolveWithGatewaysAndNormalization additionally takes custom gateway URLs.', params: [ { name: 'name', type: 'bytes', description: 'DNS-encoded name to resolve' }, { name: 'data', type: 'bytes', description: 'ABI-encoded resolver calldata' }, { name: 'ensip15', type: 'IENSIP15', description: 'Normalizer contract implementing normalize(label)' }, ], returns: [ { name: 'result', type: 'bytes', description: 'ABI-encoded response' }, { name: 'resolver', type: 'address', description: 'The resolver that was used' }, ], }, { name: 'reverseWithNormalization', description: 'Like reverse, but verifies onchain that the returned primary name is normalized per the supplied ENSIP-15 normalizer contract. Intended for future use. The variant reverseWithGatewaysAndNormalization additionally takes custom gateway URLs.', params: [ { name: 'lookupAddress', type: 'bytes', description: 'Byte-encoded address to look up' }, { name: 'coinType', type: 'uint256', description: 'Coin type of the address' }, { name: 'ensip15', type: 'IENSIP15', description: 'Normalizer contract implementing normalize(label)' }, ], returns: [ { name: 'primary', type: 'string', description: 'Verified primary name, or empty if not set' }, { name: 'resolver', type: 'address', description: 'Forward resolver for the primary name' }, { name: 'reverseResolver', type: 'address', description: 'Reverse resolver that provided the name' }, ], }, { name: 'normalize', description: 'Normalize a DNS-encoded name label by label via the supplied ENSIP-15 normalizer contract.', params: [ { name: 'name', type: 'bytes', description: 'DNS-encoded name' }, { name: 'ensip15', type: 'IENSIP15', description: 'Normalizer contract implementing normalize(label)' }, ], returns: [ { name: 'wasNormalized', type: 'bool', description: 'True if the input was already normalized' }, { name: 'normalizedName', type: 'bytes', description: 'The normalized DNS-encoded name' }, ], }, { name: 'isENSv2', description: 'Marker distinguishing the v2 Universal Resolver from v1. Returns true.', returns: [ { name: 'ensv2', type: 'bool', description: 'Always true on UniversalResolverV2' }, ], }, ]} /> #### UniversalHelper Functions <ContractReference functions={[ { name: 'findExactOwner', description: 'Find the current owner of a name.', params: [ { name: 'name', type: 'bytes', description: 'DNS-encoded name' }, ], returns: [ { name: 'owner', type: 'address', description: 'Owner address, or address(0) if unowned, not found, or the registry does not implement IOwnedRegistry' }, ], }, { name: 'findNearestOwner', description: 'Find the owner of the closest owned ancestor of a name.', params: [ { name: 'name', type: 'bytes', description: 'DNS-encoded name' }, ], returns: [ { name: 'owner', type: 'address', description: 'Nearest owner, or address(0) if none found' }, { name: 'offset', type: 'uint256', description: 'Byte offset into the name such that findExactOwner(name[offset:]) returns the same owner' }, ], }, { name: 'findExactRegistry', description: "Find the registry at a name's position by walking down from root.", params: [ { name: 'name', type: 'bytes', description: 'DNS-encoded name' }, ], returns: [ { name: 'registry', type: 'IRegistry', description: 'Registry at that position, or address(0) if not found' }, ], }, { name: 'findNearestRegistry', description: 'Find the deepest registry along the path of a name.', params: [ { name: 'name', type: 'bytes', description: 'DNS-encoded name' }, ], returns: [ { name: 'registry', type: 'IRegistry', description: 'Nearest registry, or address(0) if not found' }, { name: 'offset', type: 'uint256', description: 'Byte offset into the name such that findExactRegistry(name[offset:]) returns the same registry' }, ], }, { name: 'findParentRegistry', description: "Find the parent registry for a name (the registry containing the name's entry).", params: [ { name: 'name', type: 'bytes', description: 'DNS-encoded name' }, ], returns: [ { name: 'parentRegistry', type: 'IRegistry', description: 'Parent registry, or address(0) if not found' }, ], }, { name: 'findRegistries', description: "Return all registries in a name's ancestry, innermost first.", params: [ { name: 'name', type: 'bytes', description: 'DNS-encoded name' }, ], returns: [ { name: 'registries', type: 'IRegistry[]', description: 'Array in label order, e.g. [<nick>, <eth>, <root>] for nick.eth' }, ], }, { name: 'findCanonicalName', description: "Reconstruct a registry's DNS-encoded name by walking up via getParent().", params: [ { name: 'registry', type: 'IRegistry', description: 'The registry to name' }, ], returns: [ { name: 'name', type: 'bytes', description: 'DNS-encoded name, or empty if not canonical' }, ], }, { name: 'findCanonicalRegistry', description: 'Find the registry for a name, verified canonical via bidirectional walk.', params: [ { name: 'name', type: 'bytes', description: 'DNS-encoded name' }, ], returns: [ { name: 'registry', type: 'IRegistry', description: 'Canonical registry, or address(0) if not found or not canonical' }, ], }, ]} /> #### Constants <ContractReference functions={[ { name: 'ROOT_REGISTRY', description: 'The ENSv2 root registry. All hierarchy traversal starts from this address. Set once at deployment (immutable). UniversalHelper exposes the same constant.', }, { name: 'batchGatewayProvider', description: 'Default gateway provider for CCIP-Read batching. Set once at deployment (immutable).', }, ]} /> #### Errors <ContractReference functions={[ { name: 'ResolverNotFound', description: 'No resolver found for the name.', params: [ { name: 'name', type: 'bytes', description: 'The DNS-encoded name that failed to resolve' }, ], }, { name: 'ResolverNotContract', description: 'Resolver address has no deployed code.', params: [ { name: 'name', type: 'bytes', description: 'The DNS-encoded name' }, { name: 'resolver', type: 'address', description: 'The resolver address that has no code' }, ], }, { name: 'UnsupportedResolverProfile', description: "Resolver doesn't support the requested function.", params: [ { name: 'selector', type: 'bytes4', description: 'The unsupported function selector' }, ], }, { name: 'ResolverError', description: 'Resolver reverted during resolution.', params: [ { name: 'errorData', type: 'bytes', description: 'The raw error data from the resolver' }, ], }, { name: 'ReverseAddressMismatch', description: "Forward resolution of the primary name doesn't match the original address.", params: [ { name: 'primary', type: 'string', description: 'The primary name that was looked up' }, { name: 'primaryAddress', type: 'bytes', description: 'The address the primary name resolved to' }, ], }, { name: 'NormalizationChangedName', description: 'resolveWithNormalization (or its gateway variant) was given a non-normalized name. The error carries the result for the normalized name instead.', params: [ { name: 'normalizedName', type: 'bytes', description: 'The normalized DNS-encoded name' }, { name: 'result', type: 'bytes', description: 'ABI-encoded response for the normalized name' }, { name: 'resolver', type: 'address', description: 'The resolver that was used' }, ], }, { name: 'PrimaryNameNotNormalized', description: 'reverseWithNormalization (or its gateway variant) found a primary name that is not normalized.', params: [ { name: 'primary', type: 'string', description: 'The non-normalized primary name' }, ], }, { name: 'HttpError', description: 'HTTP error from a CCIP-Read gateway.', params: [ { name: 'status', type: 'uint16', description: 'HTTP status code' }, { name: 'message', type: 'string', description: 'Error message from the gateway' }, ], }, ]} /> import { FrenCallout } from '../../components/ensv2/FrenCallout' ## Verifiable Factory ENSv2's default setup deploys per-account resolvers and per-name subname registries through a single shared factory, replacing the v1 Public Resolver with individual [Permissioned Resolver](/ensv2/permissioned-resolver) proxies per account. Each instance is a UUPS proxy with a deterministic CREATE2 address and an on-chain proof of provenance. The factory is maintained in a [separate repository](https://github.com/ensdomains/verifiable-factory). This page covers how the protocol uses it. The factory is the **default** deployment mechanism, not a protocol requirement. Custom resolver contracts are fully supported: `setResolver()` on the [Permissioned Registry](/ensv2/permissioned-registry) accepts any address. You can deploy your own resolver implementing `IExtendedResolver` (or the standard resolver profiles) without using the factory. ### Why a Factory ENSv2 chooses per-account resolver and per-name registry instances over a single shared contract (see [Overview](/ensv2/overview#whats-new-in-ensv2)). Each instance is an upgradeable proxy, so deployment is cheap and any single instance can be upgraded without touching the rest of the system. The factory makes every such deployment: * **Deterministic**: the address is known before deployment. * **Verifiable**: anyone can prove on-chain that an arbitrary address really came from this factory with a known proxy bytecode. * **Cheap**: each deployment writes only 77 bytes of proxy code. The proxy logic and the implementation are shared. ### Deterministic Deployment ```solidity function depl
프로젝트로 돌아가기