bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 15쪽
ment can be used.',
},
{
name: 'MAX_COMMITMENT_AGE',
description: 'Maximum seconds before a commitment expires.',
},
{
name: 'MIN_REGISTER_DURATION',
description: 'Shortest allowed registration duration.',
},
{
name: 'MIN_RENEW_DURATION',
description: 'Shortest allowed renewal duration (1 second).',
},
{
name: 'GRACE_PERIOD',
description: 'Post-expiry window (in seconds) during which a name is renewable but not re-registerable.',
},
{
name: 'rentPriceOracle',
description: 'Current pricing oracle.',
},
]}
/>
#### Events
<ContractReference
functions={[
{
name: 'CommitmentMade',
description: 'Commitment submitted.',
params: [
{ name: 'commitment', type: 'bytes32', description: 'The commitment hash' },
],
},
{
name: 'NameRegistered',
description: 'Name registered.',
params: [
{ name: 'tokenId', type: 'uint256', indexed: true, description: 'Token ID of the registered name' },
{ name: 'label', type: 'string', description: 'The registered label' },
{ name: 'owner', type: 'address', description: 'Owner of the name' },
{ name: 'subregistry', type: 'IRegistry', description: 'Child registry set' },
{ name: 'resolver', type: 'address', description: 'Resolver set' },
{ name: 'duration', type: 'uint64', description: 'Registration duration' },
{ name: 'paymentToken', type: 'IERC20', description: 'Token used for payment' },
{ name: 'referrer', type: 'bytes32', indexed: true, description: 'Referral identifier' },
{ name: 'base', type: 'uint256', description: 'Base price paid' },
{ name: 'premium', type: 'uint256', description: 'Premium paid' },
],
},
{
name: 'NameRenewed',
description: 'Name renewed.',
params: [
{ name: 'tokenId', type: 'uint256', indexed: true, description: 'Token ID of the name' },
{ name: 'label', type: 'string', description: 'The renewed label' },
{ name: 'duration', type: 'uint64', description: 'Duration extended by' },
{ name: 'newExpiry', type: 'uint64', description: 'New expiry timestamp' },
{ name: 'paymentToken', type: 'IERC20', description: 'Token used for payment' },
{ name: 'referrer', type: 'bytes32', indexed: true, description: 'Referral identifier' },
{ name: 'amount', type: 'uint256', description: 'Amount of payment token paid' },
],
},
{
name: 'RentPriceOracleUpdated',
description: 'Pricing oracle updated.',
params: [
{ name: 'oracle', type: 'IRentPriceOracle', description: 'New pricing oracle' },
],
},
]}
/>
import { FrenCallout } from '../../components/ensv2/FrenCallout'
import { MonoDiagram } from '../../components/ensv2/MonoDiagram'
## Indexing ENSv2
This page describes the ENSv2 contract events and functions relevant to building an indexer. It covers the full lifecycle of names - registration, transfer, renewal, subname creation, resolver record changes, record linking, and role management.
### Contract Hierarchy
ENSv2 uses a hierarchical registry model. There is no single registry contract that holds all names. Instead:
<MonoDiagram content={`RootRegistry (PermissionedRegistry)\n└── ETHRegistry (PermissionedRegistry) — manages *.eth\n ├── name.eth (token in ETHRegistry)\n │ └── UserRegistry — manages *.name.eth\n │ ├── sub.name.eth (token in UserRegistry)\n │ │ └── UserRegistry — manages *.sub.name.eth\n │ │ └── ...\n │ └── ...\n └── ...`} />
Each registry is a [Permissioned Registry](/ensv2/permissioned-registry) (or UserRegistry for subnames), implementing `IRegistry`, `IStandardRegistry`, `IPermissionedRegistry`, and `IEnhancedAccessControl`. Tokens are [ERC1155Singleton](/ensv2/erc1155-singleton) (one token per name).
Resolvers are separate contracts ([Permissioned Resolver](/ensv2/permissioned-resolver)) deployed per-account as UUPS proxies. All names owned by the same account share one resolver. Names on the same resolver can also share records via [record links](/ensv2/permissioned-resolver#records-and-linking) (`linkToNode` / `linkToRecord`).
### Registry Events
These events are emitted by any registry contract (PermissionedRegistry / UserRegistry).
#### RegistryCreated
```solidity
event RegistryCreated();
```
Emitted once per registry: by `PermissionedRegistry` in the constructor, and by `UserRegistry`/`WrapperRegistry` on `initialize()`. Allows indexers to discover new registry deployments on-chain.
#### LabelRegistered
```solidity
event LabelRegistered(
uint256 indexed tokenId,
bytes32 indexed labelHash,
string label,
address owner,
uint64 expiry,
address indexed sender
);
```
**Emitted by:** `IRegistryEvents` (on PermissionedRegistry, UserRegistry)
**When:** a new name is registered via `register()`. The full name is constructed by appending the parent name (e.g., label `"test"` under ETHRegistry = `"test.eth"`). The registry contract address that emitted this event identifies which level of the hierarchy this name belongs to.
The `sender` parameter is the account that called `register()`. For normal `.eth` registrations this is the ETHRegistrar; for names [migrated from ENSv1](/ensv2/migration) it is a migration controller, since migration bypasses the registrar and calls `register()` on the ETHRegistry directly. Checking `sender` against the known migration controller addresses is how an indexer distinguishes migrated names from fresh registrations.
#### LabelReserved
```solidity
event LabelReserved(
uint256 indexed tokenId,
bytes32 indexed labelHash,
string label,
uint64 expiry,
address indexed sender
);
```
**Emitted by:** `IRegistryEvents` (on PermissionedRegistry)
**When:** a name is reserved via `register()` with `owner = address(0)` and `roleBitmap = 0`. No token is minted and no owner is set. A reserved name can be promoted to `REGISTERED` by calling `register()` again with a real owner, which requires `ROLE_REGISTER_RESERVED`.
#### LabelUnregistered
```solidity
event LabelUnregistered(uint256 indexed tokenId, address indexed sender);
```
**Emitted by:** `IRegistryEvents` (on PermissionedRegistry, UserRegistry)
**When:** a name is explicitly deleted via `unregister()`, which works on both `REGISTERED` and `RESERVED` names. The expiry is set to `block.timestamp`, and if a token exists it is burned. Unregistering a `RESERVED` name burns nothing, since no token was ever minted.
#### ExpiryUpdated
```solidity
event ExpiryUpdated(uint256 indexed tokenId, uint64 indexed newExpiry, address indexed sender);
```
**Emitted by:** `IRegistryEvents` (on PermissionedRegistry, UserRegistry)
**When:** a name's expiry is extended via `renew()` on the registry.
#### SubregistryUpdated
```solidity
event SubregistryUpdated(
uint256 indexed tokenId,
IRegistry indexed subregistry,
address indexed sender
);
```
**Emitted by:** `IRegistryEvents` (on PermissionedRegistry, UserRegistry)
**When:** a name's child registry is set or changed via `setSubregistry()`. This also fires during `register()` if a subregistry is provided. New subregistry addresses indicate dynamically deployed UserRegistry contracts for subnames.
#### ResolverUpdated
```solidity
event ResolverUpdated(uint256 indexed tokenId, address indexed resolver, address indexed sender);
```
**Emitted by:** `IRegistryEvents` (on PermissionedRegistry, UserRegistry)
**When:** a name's resolver is set or changed via `setResolver()`. Also fires during `register()` if a resolver is provided. New resolver addresses indicate dynamically deployed PermissionedResolver contracts.
#### TokenRegenerated
```solidity
event TokenRegenerated(uint256 indexed oldTokenId, uint256 indexed newTokenId);
```
**Emitted by:** `IRegistryEvents` (on PermissionedRegistry, UserRegistry)
**When:** a name's [EAC roles](/ensv2/enhanced-access-control) are modified via `grantRoles()` or `revokeRoles()`. The ERC1155 token ID changes (its version counter increments), while the underlying name (canonical ID / resource) remains the same. Always accompanied by ERC1155 `TransferSingle` events (burn old + mint new). See [Mutable Token IDs](/ensv2/mutable-token-ids) for details.
#### ParentUpdated
```solidity
event ParentUpdated(IRegistry indexed parent, string label, address indexed sender);
```
**Emitted by:** `IRegistryEvents` (on PermissionedRegistry, UserRegistry)
**When:** a registry's parent reference is set via `setParent()`. This establishes the upward link in the registry hierarchy, complementing `SubregistryUpdated` (which links parent → child) by establishing the child → parent direction.
`setParent()` is an optional, separately-permissioned call (`ROLE_SET_PARENT`), so this event is **not** emitted for every child registry and `getParent()` may return empty for registries where it was never called. Treat `SubregistryUpdated` (emitted by the parent) as the authoritative parent → child link, and use `ParentUpdated`/`getParent()` only as a supplementary child → parent hint when present.
#### TokenResource
```solidity
event TokenResource(uint256 indexed tokenId, uint256 indexed resource);
```
**Emitted by:** `IPermissionedRegistry`
**When:** a token is created during registration (`register()`). Maps a `tokenId` to its corresponding `resource`. It is **not** re-emitted on token regeneration: the `resource` is derived from the `labelHash` and `eacVersionId`, so it stays stable across role-change regenerations (which only bump the `tokenVersionId`), and you should carry it onto the new `tokenId` by following [`TokenRegenerated`](#tokenregenerated) rather than expecting a fresh `TokenResource`. The `resource` does change on re-registration (which increments `eacVersionId`), at which point the new `register()` emits a fresh `TokenResource`. See [Mutable Token IDs](/ensv2/mutable-token-ids#id-types) for details.
#### URIUpdated
```solidity
event URIUpdated(string uri, address renderer, address indexed sender);
```
**Emitted by:** `IRegistryEvents`
**When:** the registry's ERC1155 metadata configuration changes via `setURI(uri, renderer)` (requires `ROLE_SET_URI` on `ROOT_RESOURCE`). This is registry-wide token metadata, not per-name state.
### ERC1155 Transfer Events
These standard ERC1155 events are emitted by all registries (which extend ERC1155Singleton).
#### TransferSingle
```solidity
event TransferSingle(
address indexed operator,
address indexed from,
address indexed to,
uint256 id,
uint256 value
);
```
**When:**
* **Registration (mint):** `from = address(0)`, `to = owner` - a new name token is minted
* **Transfer:** `from = previousOwner`, `to = newOwner` - ownership changes via `safeTransferFrom()`
* **Unregistration (burn):** `from = owner`, `to = address(0)` - name token is burned
* **Token regeneration:** two events fire - burn old tokenId + mint new tokenId. Correlate with `TokenRegenerated` to avoid treating it as a separate domain.
#### TransferBatch
```solidity
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
```
**When:** batch transfers of multiple name tokens. Same semantics as `TransferSingle` but for multiple tokens at once.
### Registrar Events
These events are emitted by the [ETH Registrar](/ensv2/eth-registrar) contract, which is the user-facing entry point for `.eth` name registration (with commit-reveal and pricing).
#### CommitmentMade
```solidity
event CommitmentMade(bytes32 commitment);
```
**Emitted by:** `IETHRegistrar`
**When:** step 1 of the commit-reveal registration via `commit()`. The commitment hash can be matched to the subsequent registration.
#### NameRegistered (Registrar)
```solidity
event NameRegistered(
uint256 indexed tokenId,
string label,
address owner,
IRegistry subregistry,
address resolver,
uint64 duration,
IERC20 paymentToken,
bytes32 indexed referrer,
uint256 base,
uint256 premium
);
```
**Emitted by:** `IETHRegistrar`
**When:** step 2 of the commit-reveal registration via `register()`. This is distinct from the registry's `LabelRegistered` event. The registrar emits its own event with pricing information, and the underlying ETHRegistry also emits `LabelRegistered`.
<FrenCallout fren="bittu" variant="note">
Both events fire for the same registration. The registrar event has pricing data; the registry event has the canonical registration data.
</FrenCallout>
#### NameRenewed
```solidity
event NameRenewed(
uint256 indexed tokenId,
string label,
uint64 duration,
uint64 newExpiry,
IERC20 paymentToken,
bytes32 indexed referrer,
uint256 amount
);
```
**Emitted by:** `IETHRenewer`, implemented by both the ETH Registrar and `ETHRenewerV1` (which renews not-yet-migrated names during the [migration](/ensv2/migration) and emits this event from its own address)
**When:** a `.eth` name is renewed via `renew()` or `renewBatch()` (one event per name). The renewer also calls `renew()` on the ETHRegistry, which emits `ExpiryUpdated`.
### Resolver Events
These events are emitted by [Permissioned Resolver](/ensv2/permissioned-resolver) contracts. Record values live in numbered **record bundles**, so the record events are keyed by `recordId`, not by name. Which names a record serves is a separate event stream: `Linked` associates a `node` (namehash) with a `recordId`. An indexer therefore maintains two tables, record contents (from the `*Updated` events) and name-to-record links (from `Linked`), and joins them at query time.
#### Linked
```solidity
event Linked(uint256 indexed recordId, bytes32 indexed node, bytes name);
```
**When:** a name is associated with a record: on the first write to a name (the resolver auto-creates a record and links it) and on explicit `linkToNode` / `linkToRecord` calls. `name` is DNS-encoded and `node` is its namehash. `recordId = 0` means the name was unlinked. The record linked to the root name (node `bytes32(0)`) serves as the **default record** for names without a link of their own.
#### ResolverCreated
```solidity
event ResolverCreated();
```
**When:** the resolver proxy is initialized, marking a new resolver instance (see [Dynamic Contract Discovery](#dynamic-contract-discovery)).
#### AddressUpdated
```solidity
event AddressUpdated(uint256 indexed recordId, uint256 coinType, bytes addressBytes);
```
**When:** an address record is set via `setAddress(name, coinType, addressBytes)`. `coinType = 60` is ETH. Other coin types follow [SLIP-44](https://github.com/AdrianSimionov/slip-0044/blob/main/slip-0044.md) (e.g., 0 = BTC, 501 = SOL).
#### TextUpdated
```solidity
event TextUpdated(uint256 indexed recordId, string indexed keyHash, string key, string value);
```
**When:** a text record is set via `setText(name, key, value)`. `keyHash` is an indexed copy of `key` (the topic holds its keccak hash), so specific keys can be filtered without decoding the data. Common keys: `avatar`, `url`, `description`, `com.twitter`, `com.github`, `email`, etc.
#### DataUpdated
```solidity
event DataUpdated(uint256 indexed recordId, string indexed keyHash, string key, bytes value);
```
**When:** a raw data record is set via `setData(name, key, value)`, the byte-valued counterpart of text records.
#### ContenthashUpdated
```solidity
event ContenthashUpdated(uint256 indexed recordId, bytes hash);
```
**When:** a content hash is set via `setContenthash(name, hash)`. Supports IPFS, Arweave, Swarm, etc.
#### ABIUpdated
```solidity
event ABIUpdated(uint256 indexed recordId, uint256 indexed contentType);
```
**When:** an ABI record is set via `setABI(name, contentType, data)`. The data itself is not in the event.
#### NameUpdated
```solidity
event NameUpdated(uint256 indexed recordId, string primaryName);
```
**When:** a primary (reverse) name record is set via `setName(name, primaryName)`.
#### InterfaceUpdated
```solidity
event InterfaceUpdated(uint256 indexed recordId, bytes4 indexed interfaceId, address implementer);
```
**When:** an EIP-165 interface implementer is set via `setInterface(name, interfaceId, implementer)`.
#### ResourceArgument
```solidity
event ResourceArgument(uint256 indexed resource, bytes arg);
```
**When:** a role is granted on an argument-scoped [EAC resource](/ensv2/permissioned-resolver#eac-integration) that currently has no assignees. It publishes the preimage (`arg`, e.g. the text key or coin type) of the resource hash, letting indexers label resources. It can fire more than once for the same resource.
The resolver interface also declares `Cleared(uint256 indexed recordId)`, which the current implementation never emits.
### Role Events
#### EACRolesChanged
```solidity
event EACRolesChanged(
uint256 indexed resource,
address indexed account,
uint256 oldRoleBitmap,
uint256 newRoleBitmap
);
```
**Emitted by:** every contract inheriting [Enhanced Access Control](/ensv2/enhanced-access-control), which includes **both registries and resolvers**.
**When:** the roles of `account` on `resource` change. On registries this fires:
* at creation, for each initial root grant (in the `constructor`, or in `initialize()` for proxy-deployed registries)
* on every registration that passes a nonzero role bitmap, when the new owner's roles are granted (always the case for [ETH Registrar](/ensv2/eth-registrar) registrations)
* on `grantRoles()` / `revokeRoles()`, which also trigger [`TokenRegenerated`](#tokenregenerated)
* on `grantRootRoles()` / `revokeRootRoles()`, which never regenerate
* twice per token transfer, when all roles move from the old owner to the new owner (a revoke followed by a grant, no regeneration)
Only `grantRoles()` / `revokeRoles()` regenerate the token, so an `EACRolesChanged` cannot be assumed to pair with a `TokenRegenerated`. On resolvers the event fires via `initialize()`, `grantSetterRoles()`, and the inherited `revokeRoles()` / `grantRootRoles()` / `revokeRootRoles()` (plain `grantRoles()` is disabled on resolvers and always reverts).
<FrenCallout fren="kuzco" variant="warning" title="Watch out!">
Registries and resolvers use different resource ID spaces: a registry resource is derived from the labelhash and its EAC version counter, while a resolver resource is `keccak256(arg)` of the bare setter argument (the text key, coin type, content type, or interface ID), independent of any name. The same numeric `resource` value can therefore mean different things on different contracts. Always key role state by the emitting contract address together with the resource.
</FrenCallout>
### Key Concepts for Indexers
#### Dynamic Contract Discovery
An indexer cannot know all contract addresses at startup. The core pattern is:
1. Start by watching the **RootRegistry** and **ETHRegistry** (known addresses from deployment).
2. When a `SubregistryUpdated` event fires with a new subregistry address, add that address to the watch list.
3. When a `ResolverUpdated` event fires with a new resolver address, add that address to the watch list for resolver events.
This creates a self-expanding set of monitored contracts.
Link-time discovery has a blind spot: anything a registry or resolver emits **before** it is linked (its `RegistryCreated` or `ResolverCreated`, the initial `EACRolesChanged` root grant from `initialize()`, or records set before linking) predates the discovery point. Since registries and resolvers are deployed as proxies through the [Verifiable Factory](/ensv2/verifiable-factory), which emits `ProxyDeployed(sender, proxy, salt, implementation)`, watching the factory address discovers contracts at deployment time instead and closes that gap.
Note the log order inside a deployment transaction: `deployProxy()` calls `initialize()` on the new proxy **before** emitting `ProxyDeployed`. For a UserRegistry deployment the sequence is `Upgraded` → `RegistryCreated` → `EACRolesChanged` → `ProxyDeployed`. An indexer that discovers a contract from `ProxyDeployed` must therefore also process the earlier logs of that same transaction.
The implementation contracts behind the proxies (`UserRegistryImpl`, `WrapperRegistryImpl`, `PermissionedResolverImpl`) each also emitted one of these events, from their constructors at deployment프로젝트로 돌아가기