bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 16쪽
. They are shared logic targets, not usable instances, so a registry/resolver list built purely from creation events contains these three extra addresses. Discovery via `ProxyDeployed` is unaffected.
#### TokenId vs Resource (Canonical ID)
* **tokenId**: the ERC1155 token ID. Changes when roles are modified (`TokenRegenerated`), because it embeds a version counter that increments on each change.
* **resource**: the EAC permission key for a name within a registry. Derived from the `labelHash` and `eacVersionId`. Stable across role modifications, but changes on re-registration (when `eacVersionId` increments).
Use the `TokenResource` event (emitted at registration) to establish the `tokenId → resource` mapping, and follow `TokenRegenerated` to move that mapping onto the new `tokenId` when roles change, since no new `TokenResource` is emitted then. The `resource` should be the primary key for domain lookups, as it stays stable across regenerations.
#### Name Construction
The indexer must track the registry hierarchy to construct full names:
1. **ETHRegistry** emits `LabelRegistered` with `label = "test"` → full name is `"test.eth"`
2. A `SubregistryUpdated` on `test.eth` points to a UserRegistry at address `0xABC`
3. That UserRegistry emits `LabelRegistered` with `label = "sub"` → full name is `"sub.test.eth"`
The indexer must map each registry address to its parent name to build the complete DNS name.
#### Shared Subregistries
Multiple parent names can point to the same subregistry via `setSubregistry()`. For example:
* `sub1.sub2.parent.eth` has subregistry at `0xABC`
* `linked.parent.eth` also has subregistry at `0xABC`
Children registered in `0xABC` appear under both parents. The token `wallet` in registry `0xABC` is simultaneously `wallet.sub1.sub2.parent.eth` and `wallet.linked.parent.eth` - they share the same tokenId.
#### Records and Linking
Record storage is a resolver-level concept, decoupled from names:
* Values live in numbered record bundles, and record events fire under `recordId`
* `Linked(recordId, node, name)` associates names with records, and one record can be linked from any number of names
* A name with no record link of its own resolves via the **default record**, the one linked to the root name (node `bytes32(0)`)
* `Linked` with `recordId = 0` unlinks a name
Two consequences for record indexing: a single `*Updated` event can change the effective records of many names at once (every name linked to that record, and every unlinked name if it is the default record), and resolving a name requires the join: node to recordId (latest `Linked`, falling back to the default record), then recordId to values. Indexed record rows are per-record, not per-name; apply the link mapping before treating them as what a name resolves to.
#### Registration Status
Names can be in one of three states (from `IPermissionedRegistry.Status`):
| Status | Value | Description |
| ------------ | ----- | ------------------------------------------------------------------------------------------------ |
| `AVAILABLE` | 0 | Name can be registered |
| `RESERVED` | 1 | Name is reserved (cannot be registered until expiry, unless caller has `ROLE_REGISTER_RESERVED`) |
| `REGISTERED` | 2 | Name is actively registered with an owner |
After expiry, names return to `AVAILABLE`. Re-registration creates both a new `tokenId` and a new `resource` (both version counters increment).
For `.eth` names, the [ETH Registrar](/ensv2/eth-registrar) adds a grace period on top of the registry status: `GRACE_PERIOD` is an immutable constructor parameter, and while it runs an expired name cannot be re-registered but can still be renewed. No event marks entering or leaving grace (or the premium window that follows), so `.eth` availability must be computed client-side from the expiry, the grace constant, and the current time. A plain "expired means available" check is wrong for `.eth` names in grace.
#### Event Processing Order
For a single registration via `ETHRegistrar.register()`, events fire in this order. The registrar calls `ETHRegistry.register()` first (which emits all the registry events) and only then emits its own event, so `NameRegistered` comes **last**, not first:
1. `IRegistryEvents.LabelRegistered` - registry-level event with registration details
2. `TransferSingle` (mint) - ERC1155 token creation
3. `TokenResource` - tokenId-to-resource mapping
4. `EACRolesChanged` - the owner's initial roles on the name (always fires on this path)
5. `SubregistryUpdated` - if a subregistry was provided
6. `ResolverUpdated` - if a resolver was provided
7. `IETHRegistrar.NameRegistered` - registrar-level event with pricing
For a direct `IStandardRegistry.register()` call (e.g., on a UserRegistry):
1. `IRegistryEvents.LabelRegistered`
2. `TransferSingle` (mint)
3. `TokenResource`
4. `EACRolesChanged` - if a nonzero role bitmap was passed
5. `SubregistryUpdated` - if a subregistry was provided
6. `ResolverUpdated` - if a resolver was provided
For a name [migrated from ENSv1](/ensv2/migration), the migration controllers call `register()` on the ETHRegistry directly, so only the registry sequence fires: there is no `CommitmentMade` and no registrar `NameRegistered`, and `LabelRegistered.sender` is the migration controller.
One more same-transaction caveat: re-registering an expired name whose token was never unregistered emits a burn `TransferSingle` for the old token ID **before** `LabelRegistered`, so a burn does not always mean unregistration or regeneration.
### Contract Address Summary
| Contract | Role | Events to Watch |
| ----------------------------------- | ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| PermissionedRegistry (ETHRegistry) | Manages `.eth` names | All `IRegistry` events, `TokenResource`, ERC1155 transfers, `EACRolesChanged` |
| PermissionedRegistry (RootRegistry) | Manages TLDs | Same as above |
| UserRegistry | Manages subnames (dynamically deployed) | Same as above |
| ETHRegistrar | User-facing `.eth` registration | `CommitmentMade`, `NameRegistered`, `NameRenewed` |
| PermissionedResolver | Stores resolver records (dynamically deployed) | `Linked`, `ResolverCreated`, `AddressUpdated`, `TextUpdated`, `DataUpdated`, `ContenthashUpdated`, `ABIUpdated`, `NameUpdated`, `InterfaceUpdated`, `ResourceArgument`, `EACRolesChanged` |
| VerifiableFactory | Deploys registry/resolver proxies | `ProxyDeployed` |
### Read Functions for State Verification
These view functions are useful for verifying indexed state or backfilling data:
<FrenCallout fren="kuzco" variant="warning" title="Watch out!">
Several of these views mask state once a name is expired (`block.timestamp >= expiry`): `getOwner()`, `getSubregistry()`, and `getResolver()` return zero, `ownerOf()` returns zero for expired or stale token IDs, and `getResource()` (and `getState().resource`) return the *next* resource, one version ahead of what `TokenResource` announced, without any storage write or event. A mismatch between indexed state and these functions for an expired name is expected behavior, not an indexing bug. `getExpiry()` and `getTokenId()` return raw, unmasked values.
</FrenCallout>
#### Registry State
```solidity
// Get full state of a name (status, expiry, owner, tokenId, resource)
function getState(uint256 anyId) external view returns (State memory);
// Get the subregistry for a label
function getSubregistry(string calldata label) external view returns (IRegistry);
// Get the resolver for a label
function getResolver(string calldata label) external view returns (address);
// Get the owner of a token
function ownerOf(uint256 tokenId) external view returns (address);
// Get the owner of a name by any of its IDs
function getOwner(uint256 anyId) external view returns (address);
// Get the stable resource ID
function getResource(uint256 anyId) external view returns (uint256);
// Get the current tokenId (may change after role modifications)
function getTokenId(uint256 anyId) external view returns (uint256);
// Get the expiry
function getExpiry(uint256 anyId) external view returns (uint64);
```
#### Registrar State
```solidity
// Check if a name is available for registration
function isAvailable(string memory label) external view returns (bool);
// Get the registration price
// (reverts NameNotAvailable if the name is not registerable)
function getRegisterPrice(
string memory label,
uint64 duration,
IERC20 paymentToken
) external view returns (uint256 base, uint256 premium);
// Get the renewal price, the total amount of paymentToken
// (reverts NameNotRenewable if the name is not renewable)
function getRenewPrice(
string memory label,
uint64 duration,
IERC20 paymentToken
) external view returns (uint256);
```
#### Resolver State
```solidity
// Read any record (ENSIP-10): data carries the ABI-encoded profile call,
// e.g. addr(node, coinType) or text(node, key)
function resolve(bytes calldata name, bytes calldata data) external view returns (bytes memory);
// Record linked to a node (0 = no link; the name falls back to the default record)
function getRecordId(bytes32 node) external view returns (uint256);
// Number of records created on this resolver
function getRecordCount() external view returns (uint256);
```
The resolver has no per-profile getters: all record reads go through `resolve()`. The name determines which record is read, and the node inside the profile calldata is ignored.
import { FrenCallout } from '../../components/ensv2/FrenCallout'
## Migration
ENSv2 provides a migration framework for transitioning ENSv1 `.eth` names to the new system. Migration is a two-phase process: **premigration** reserves all existing names in v2 automatically, then **migration** lets owners claim their names by transferring their v1 tokens to a migration controller.
<FrenCallout fren="kuzco" variant="warning" title="Watch out!">
Once ENSv2 is live, v1 `.eth` registrations and renewals are disabled. New registrations go through the v2 [ETH Registrar](/ensv2/eth-registrar). Migrated names are renewed via the ETH Registrar; unmigrated ([RESERVED](#key-definitions)) names are renewed via [`ETHRenewerV1`](#renewals), which syncs the expiry back to v1. Names in v1 will simply expire and can never be re-registered through v1.
</FrenCallout>
### What You Need to Do
#### .eth Name Owners
<FrenCallout fren="lili" variant="tip">
If you just own a `.eth` name and aren't a developer, you don't need to understand the technical details below. A frontend migration tool will be available when the time comes that handles everything for you.
</FrenCallout>
Premigration happens automatically. To migrate your name to v2:
1. Transfer your v1 token to the appropriate migration controller:
* **Unwrapped or unlocked**: `UnlockedMigrationController`
* **Locked**: `LockedMigrationController`
2. Specify the name's label plus the new v2 owner, resolver, and subregistry in the transfer data (the label must match the transferred token, otherwise migration reverts with `NameDataMismatch`)
3. The v2 owner can be a different address than the v1 owner (e.g., migrating to a smart account)
If your name is in the v1 grace period, use `ETHRenewerV1` to renew it first.
<FrenCallout fren="peanut" variant="note">
Migration is **not required** immediately. Unmigrated names continue to resolve through v1 via `ENSV1Resolver`. However, migrating gives you access to v2 features like [per-record permissions](/ensv2/permissioned-resolver#eac-integration), [record linking](/ensv2/permissioned-resolver#records-and-linking), and the new resolver.
</FrenCallout>
#### Subname Owners
If you own an emancipated subname (3LD+), your parent must migrate first. Once the parent has migrated, transfer your token to the parent's `WrapperRegistry`:
* **Locked subnames** (`CANNOT_UNWRAP` set): fuses are converted to v2 roles, a new WrapperRegistry is deployed as the subregistry
* **Detached subnames** (emancipated without `CANNOT_UNWRAP`): unwrapped to the [Graveyard](#graveyard) and registered with the standard role set (plus renewal roles if `CAN_EXTEND_EXPIRY` was set)
Non-emancipated 3LD+ subnames cannot be migrated through the migration controllers. They must be registered directly in v2 once their parent has a v2 registry.
#### What Happens to Records
* **Locked names with `CANNOT_SET_RESOLVER`**: the v1 resolver is preserved. If it's a known `PublicResolver`, it's replaced with `PublicResolverV2` (records may need to be copied separately).
* **All other names**: the v1 resolver is cleared during migration. The v2 resolver is set from the migration transfer data (or can be set up afterwards).
### Overview
```mermaid
flowchart TB
subgraph Phase 1: Premigration
batch["BatchRegistrar reserves all\nregistered/in-grace v1 names in v2"]
reserved["RESERVED in v2 ETH Registry\n(expiry = v1 + ~62 days, no owner)"]
batch --> reserved
end
subgraph Phase 2: Migration
transfer["Owner transfers v1 token\nto migration controller"]
registered["REGISTERED in v2 ETH Registry\n(owner, resolver, subregistry set)"]
graveyard["v1 token sent to Graveyard"]
transfer --> registered
transfer --> graveyard
end
reserved -.->|"owner initiates"| transfer
```
#### ENSv1 Token Types
Migration supports `.eth` 2LDs and emancipated subnames. The migration path depends on the token type:
| Type | Token Standard | Description |
| ------------- | --------------------- | ------------------------------------------------------------------ |
| **Unwrapped** | BaseRegistrar ERC-721 | 2LD only |
| **Unlocked** | NameWrapper ERC-1155 | Without `CANNOT_UNWRAP` (2LD only) |
| **Locked** | NameWrapper ERC-1155 | Emancipated + `CANNOT_UNWRAP` (2LD and 3LD+) |
| **Detached** | NameWrapper ERC-1155 | Emancipated, without `CANNOT_UNWRAP`, parent is Locked (3LD+ only) |
Both Locked and Detached are subtypes of **Emancipated** (`PARENT_CANNOT_CONTROL` set). The distinction determines the migration path: Locked names preserve their fuse restrictions as v2 roles, while Detached names are unwrapped and registered with the standard role set (see [Detached Names](#detached-names)).
#### Key Definitions
* **RESERVED**: a v2 registry slot with an expiry and resolver but no owner. Created during premigration.
* **REGISTERED**: a v2 registry slot with an owner. Created when a user migrates their v1 token.
* **Graveyard**: the contract that receives migrated v1 tokens and can clear stale v1 registry entries so they no longer resolve.
#### Time Constants
| Constant | Value | Description |
| ----------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GRACE_PERIOD_V1` | 90 days | Post-expiry window in ENSv1 where the owner can still renew |
| `GRACE_PERIOD_V2` | 28 days | Post-expiry window in ENSv2 where the owner can still renew via the [ETH Registrar](/ensv2/eth-registrar) |
| `BONUS_PERIOD` | \~62 days | `GRACE_PERIOD_V1 - GRACE_PERIOD_V2` (plus 1 second due to boundary handling). Added to v1 expiry during premigration so that the v2 reservation does not expire before v1's grace period ends |
### Premigration
Before users can migrate, every registered or in-grace v1 name is batch-reserved in the v2 ETH Registry by the `BatchRegistrar`. This happens automatically and does not require any user action.
For each name:
* **Status**: set to `RESERVED`
* **Expiry**: `expiryV1 + BONUS_PERIOD`
* **Resolver**: set to `ENSV1Resolver`, which performs wildcard fallback to the v1 ENS registry
* **Owner**: not set (RESERVED names have no owner)
After premigration, v1 `.eth` registrations and v1 renewals are disabled. Migrated (REGISTERED) names are renewed via the `ETHRegistrar`. Unmigrated (RESERVED) names are renewed via `ETHRenewerV1`, which syncs the expiry back to the v1 BaseRegistrar. Names continue to resolve through v1 during this phase because `ENSV1Resolver` mirrors v1 resolution.
### Migration Paths
Migration is initiated by the name owner transferring their v1 token to the appropriate controller. The controller promotes the pre-existing RESERVED slot to REGISTERED, setting the owner, resolver, subregistry, and role bitmap. The v1 token is forwarded to the Graveyard. Promoted names additionally carry the non-revokable `ROLE_WAS_RESERVED` marker role, which fresh registrations do not have.
The v2 owner specified during migration **does not need to match** the v1 owner. This allows migrating directly to a new wallet or smart account.
#### Unwrapped Names
Unwrapped 2LD names (BaseRegistrar ERC-721 tokens) are migrated via the `UnlockedMigrationController`.
1. Transfer the ERC-721 token via `safeTransferFrom` with an encoded data payload specifying: label, new owner, resolver, and subregistry
2. The controller reclaims the token on the BaseRegistrar, transfers v1 registry ownership to the Graveyard, and clears the v1 resolver
3. The ERC-721 token is sent to the Graveyard
4. The name is promoted from RESERVED to REGISTERED in the v2 ETH Registry with the provided parameters
5. The token is granted the same roles as a fresh `ETHRegistrar.register()` ([REGISTRATION\_ROLE\_BITMAP](/ensv2/eth-registrar#roles-granted-at-registration))
#### Unlocked Wrapped Names
Unlocked 2LD names (NameWrapper ERC-1155 tokens without `CANNOT_UNWRAP`) are also migrated via the `UnlockedMigrationController`.
1. Transfer the ERC-1155 token via `safeTransferFrom` (or batch via `safeBatchTransferFrom`) with an encoded data payload
2. The controller verifies the name is NOT locked (reverts `NameIsLocked` otherwise)
3. The token is unwrapped to the Graveyard and the v1 resolver is cleared
4. The name is promoted from RESERVED to REGISTERED with the provided parameters
5. Token roles are the same as `ETHRegistrar.register()`
<FrenCallout fren="peanut" variant="note">
Unlocked 3LD+ names cannot be migrated through this path. They must be registered directly in v2 once their parent has a v2 registry.
</FrenCallout>
#### Locked Names
Locked names (NameWrapper ERC-1155 tokens with `CANNOT_UNWRAP`) have irrevocable restrictions that must be preserved. The migration path depends on the name level:
* **2LD**: transfer to `LockedMigrationController`
* **3LD+**: transfer to the parent name's `WrapperRegistry` (the parent must have migrated first)
The migration flow:
1. Transfer the ERC-1155 token to the appropriate receiver
2. The receiver branches on the token type: locked tokens continue with the steps below, detached tokens follow their own path (see [Detached Names](#detached-names)), and anything else reverts (`NameNotLocked`)
3. If `CANNOT_APPROVE` is burned and `getApproved()` is non-null after transfer, migration reverts (`FrozenTokenApproval`). If `CANNOT_APPROVE` is not burned, any approval is automatically cleared during the transfer, so this cannot trigger.
4. ENSv1 [fuses](/wrapper/fuses) are converted to ENSv2 roles (see [Fuse-to-Role Conversion](#fuse-to-role-conversion))
5. A `WrapperRegistry` is always deployed as the subregistry, replicating the v1 fuse-based access control using v2's [EAC](/ensv2/enhanced-access-control) system
6. The v1 resolver is cleared and the v2 name gets the resolver from the transfer data, **unless** `CANNOT_SET_RESOLVER` is burned, in which case the transfer-data resolver is ignored and the existing v1 resolver is carried over to v2. If the carried-over resolver is a known `PublicResolver`, it is replaced with `PublicResolverV2`
7. The token is **not unwrapped** but is transferred to the Graveyard as an ERC-1155 token
8. The name is promoted from RESERVED to REGISTERED (for 2LD) or registered directly (for 3LD+) with the converted role프로젝트로 돌아가기