bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 20쪽
itmap of roles to count' },
],
returns: [
{ name: 'counts', type: 'uint256', description: 'Packed per-role assignee counts' },
{ name: 'mask', type: 'uint256', description: 'Mask indicating which nybbles are relevant' },
],
},
{
name: 'hasRootRoles',
description: 'Check whether an account holds all specified roles on ROOT_RESOURCE only (does not check token-level roles).',
params: [
{ name: 'roleBitmap', type: 'uint256', description: 'Bitmap of roles to check' },
{ name: 'account', type: 'address', description: 'Account to check' },
],
returns: [
{ name: 'result', type: 'bool', description: 'True if account holds all specified roles on ROOT' },
],
},
{
name: 'uri',
description: 'ERC1155 metadata URI. Delegates to the renderer if set, otherwise returns the static URI.',
params: [
{ name: 'tokenId', type: 'uint256', description: 'Token ID' },
],
returns: [
{ name: '', type: 'string', description: 'Metadata URI' },
],
},
{
name: 'findOwner',
description: 'Get the current owner of a name by label. Returns address(0) if expired.',
params: [
{ name: 'label', type: 'string', description: 'The label to query' },
],
returns: [
{ name: 'owner', type: 'address', description: 'Owner address, or address(0)' },
],
},
{
name: 'findExpiry',
description: 'Get the expiry timestamp of a name by label.',
params: [
{ name: 'label', type: 'string', description: 'The label to query' },
],
returns: [
{ name: 'expiry', type: 'uint64', description: 'Expiry timestamp in seconds' },
],
},
{
name: 'findTokenId',
description: 'Get the current token ID of a name by label.',
params: [
{ name: 'label', type: 'string', description: 'The label to query' },
],
returns: [
{ name: 'tokenId', type: 'uint256', description: 'Current ERC1155 token ID' },
],
},
]}
/>
#### Events
<ContractReference
functions={[
{
name: 'RegistryCreated',
description: 'Emitted once in the constructor when the registry is deployed.',
params: [],
},
{
name: 'LabelRegistered',
description: 'Name registered with an owner.',
params: [
{ name: 'tokenId', type: 'uint256', indexed: true, description: 'Token ID of the registered name' },
{ name: 'labelHash', type: 'bytes32', indexed: true, description: 'Hash of the registered label' },
{ name: 'label', type: 'string', description: 'The registered label' },
{ name: 'owner', type: 'address', description: 'Owner of the name' },
{ name: 'expiry', type: 'uint64', description: 'Expiry timestamp' },
{ name: 'sender', type: 'address', indexed: true, description: 'Caller that triggered the registration' },
],
},
{
name: 'TokenResource',
description: 'Associates a token ID with its EAC resource ID. Emitted during registration.',
params: [
{ name: 'tokenId', type: 'uint256', indexed: true, description: 'Token ID of the name' },
{ name: 'resource', type: 'uint256', indexed: true, description: 'EAC resource ID for role checks' },
],
},
{
name: 'LabelReserved',
description: 'Name reserved without an owner.',
params: [
{ name: 'tokenId', type: 'uint256', indexed: true, description: 'Token ID of the reserved name' },
{ name: 'labelHash', type: 'bytes32', indexed: true, description: 'Hash of the reserved label' },
{ name: 'label', type: 'string', description: 'The reserved label' },
{ name: 'expiry', type: 'uint64', description: 'Expiry timestamp' },
{ name: 'sender', type: 'address', indexed: true, description: 'Caller that triggered the reservation' },
],
},
{
name: 'LabelUnregistered',
description: 'Name unregistered.',
params: [
{ name: 'tokenId', type: 'uint256', indexed: true, description: 'Token ID of the unregistered name' },
{ name: 'sender', type: 'address', indexed: true, description: 'Caller that triggered unregistration' },
],
},
{
name: 'ExpiryUpdated',
description: 'Expiry extended via renew().',
params: [
{ name: 'tokenId', type: 'uint256', indexed: true, description: 'Token ID of the name' },
{ name: 'newExpiry', type: 'uint64', indexed: true, description: 'New expiry timestamp' },
{ name: 'sender', type: 'address', indexed: true, description: 'Caller that triggered the renewal' },
],
},
{
name: 'SubregistryUpdated',
description: 'Subregistry changed.',
params: [
{ name: 'tokenId', type: 'uint256', indexed: true, description: 'Token ID of the name' },
{ name: 'subregistry', type: 'IRegistry', indexed: true, description: 'New subregistry address' },
{ name: 'sender', type: 'address', indexed: true, description: 'Caller that made the change' },
],
},
{
name: 'ResolverUpdated',
description: 'Resolver address changed.',
params: [
{ name: 'tokenId', type: 'uint256', indexed: true, description: 'Token ID of the name' },
{ name: 'resolver', type: 'address', indexed: true, description: 'New resolver address' },
{ name: 'sender', type: 'address', indexed: true, description: 'Caller that made the change' },
],
},
{
name: 'TokenRegenerated',
description: 'Token ID changed due to role update.',
params: [
{ name: 'oldTokenId', type: 'uint256', indexed: true, description: 'Previous token ID' },
{ name: 'newTokenId', type: 'uint256', indexed: true, description: 'New token ID' },
],
},
{
name: 'ParentUpdated',
description: 'Canonical parent reference changed.',
params: [
{ name: 'parent', type: 'IRegistry', indexed: true, description: 'New parent registry' },
{ name: 'label', type: 'string', description: 'Label within the parent' },
{ name: 'sender', type: 'address', indexed: true, description: 'Caller that made the change' },
],
},
{
name: 'URIUpdated',
description: 'Emitted when metadata URI or renderer is changed.',
params: [
{ name: 'uri', type: 'string', description: 'New metadata URI' },
{ name: 'renderer', type: 'address', description: 'New renderer address (or address(0))' },
{ name: 'sender', type: 'address', indexed: true, description: 'Account that called setURI' },
],
},
]}
/>
import { ContractReference } from '../../components/ensv2/ContractReference'
import { FrenCallout } from '../../components/ensv2/FrenCallout'
import { ResourceCalculator } from '../../components/ensv2/ResourceCalculator'
import { RoleBitmapComposer } from '../../components/ensv2/RoleBitmapComposer'
import { Card } from '../../components/ui/Card'
## Permissioned Resolver
In ENSv1, most names shared a single [Public Resolver](/resolvers/public) contract. In ENSv2, **each account gets its own resolver instance**, deployed as a UUPS-upgradeable proxy. All names owned by the same account share one resolver. Records are stored as numbered bundles that names link to, so several names can share one set of records, and permissions are managed per record type through fine-grained roles.
### What Changed from ENSv1
| Feature | ENSv1 Public Resolver | ENSv2 Permissioned Resolver |
| --------------- | --------------------------------- | --------------------------------------------------------------------------- |
| Deployment | Single shared contract by default | Per-account proxy instances by default |
| Record storage | One record set per name | Numbered records, shareable between names via [links](#records-and-linking) |
| Write interface | Node-based setters | Name-based setters |
| Permissions | Owner controls all records | Per-record-type roles via [EAC](/ensv2/enhanced-access-control) |
| Record clearing | `clearRecords()` by owner | Unlink the name and start a fresh record |
| Upgradeability | Not upgradeable | UUPS proxy pattern |
### Supported Record Types
The Permissioned Resolver supports the following record types:
| Record | Read profile | Setter | Standard |
| -------------------- | --------------------------------------- | ------------------------------------------- | ------------------------------------------------- |
| Address (ETH) | `addr(bytes32 node)` | `setAddress(bytes name, 60, addressBytes)` | [ENSIP-1](/ensip/1) |
| Address (multichain) | `addr(bytes32 node, uint256 coinType)` | `setAddress(bytes name, uint256, bytes)` | [ENSIP-9](/ensip/9) |
| Address (default) | fallback for EVM coin types | `setAddress(bytes name, 0x80000000, bytes)` | [ENSIP-19](/ensip/19) |
| Address existence | `hasAddr(bytes32 node, uint256)` | (none) | |
| Text | `text(bytes32 node, string key)` | `setText(bytes name, string, string)` | [ENSIP-5](/ensip/5) |
| Content hash | `contenthash(bytes32 node)` | `setContenthash(bytes name, bytes)` | [ENSIP-7](/ensip/7) |
| Name (reverse) | `name(bytes32 node)` | `setName(bytes name, string)` | [EIP-181](https://eips.ethereum.org/EIPS/eip-181) |
| ABI | `ABI(bytes32 node, uint256)` | `setABI(bytes name, uint256, bytes)` | [EIP-205](https://eips.ethereum.org/EIPS/eip-205) |
| Interface | `interfaceImplementer(bytes32, bytes4)` | `setInterface(bytes name, bytes4, address)` | [ENSIP-8](/ensip/8) |
| Data | `data(bytes32 node, string key)` | `setData(bytes name, string, bytes)` | [ENSIP-24](/ensip/24) |
<FrenCallout fren="bittu" variant="note">
Resolution starts at the [Universal Resolver](/ensv2/universal-resolver-v2),
which calls the resolver's `resolve(name, data)` function with the profile
calldata shown in the Read column as `data`. The node argument inside it is
ignored (the resolver derives the node from `name`), and the contract has no
standalone getters for record values.
</FrenCallout>
Setters take the DNS-encoded name (`bytes`), not a namehash.
### Records and Linking
The resolver stores values in **records**: numbered bundles holding all of a name's addresses, text records, content hash, and other values. A name is associated with a record through a link from its namehash to a record ID:
```mermaid
flowchart TB
subgraph resolver ["PermissionedResolver instance"]
direction LR
n1["alice.eth"] -->|"record ID 1"| r1["Record 1\n─────────\ncontenthash\nname\naddresses\ntexts\ndatas\nabis\ninterfaces"]
n2["wallet.eth"] -->|"record ID 1"| r1
n3["bob.eth"] -->|"record ID 2"| r2["Record 2"]
n4["unlinked name"] -.->|"fallback"| r0["Default record\n(linked to the root name 0x00)"]
end
```
In the diagram above, `alice.eth` and `wallet.eth` serve the same set of records because both names are linked to record 1. A write to a shared record changes the values served for every name linked to it. The records of `bob.eth` are not shared, since it is the only name linked to record 2. The unlinked name has no record of its own and falls back to the default record, which is the record linked to the root name `0x00`.
Records are created automatically: the first write to a name mints a new record (IDs start at 1), links the name to it, and emits `Linked(recordId, node, name)`. Every later write through that name mutates the same record.
#### Linking Names
Two functions manage the links, both requiring `ROLE_LINK` on `ROOT_RESOURCE` (see [EAC Integration](#eac-integration)):
* `linkToNode(sourceName, targetNode)` makes `sourceName` use the record that `targetNode` currently uses. This is the way to make two names resolve identically without duplicating values.
* `linkToRecord(sourceName, recordId)` links `sourceName` to a record by number. Passing `0` unlinks the name.
Both end in the same effect, setting the name's record ID. They differ only in how the record is identified: by example of another name, or directly by number. Linking is bundle-level: a name serves either all of a record's values or none of them.
Records are never deleted: unlinking a name leaves the record in place for any other names still linked to it.
#### The Default Record
A name with no record of its own serves the **default record**, the record linked to the root name `0x00` (namehash `bytes32(0)`). Writing records via the root name manages the defaults for every unlinked name on the resolver. The fallback is per name, not per value: once a name has its own record, missing values in it return empty results instead of the default record's values.
#### Use Cases
* **Multiple names, same records**: point `wallet.eth`, `brand.eth`, and `company.eth` at the same resolver, then link them to one record so they share one set of values
* **Name migration**: link a new name to the old name's record, then unlink the old name. The record moves without copying a single value
* **Shared defaults**: set records on the root name once and let all subnames serve them until they get records of their own
Note that record linking at the resolver level is different from [namespace aliasing](/ensv2/registry-hierarchy#namespace-aliasing) at the registry level. Record links share record bundles; registry aliasing shares entire namespaces.
### EAC Integration
All permissions are managed through [Enhanced Access Control](/ensv2/enhanced-access-control).
#### Roles
Each record type has its own role. A role is always held at a [resource](#resource-scheme): either `ROOT_RESOURCE`, which covers the whole resolver, or the resource of a setter argument such as a text key or coin type. The same role bit granted at different resources yields independent permissions, which is how a single `ROLE_SET_TEXT` bit can be restricted to one specific key.
There is no per-name scoping: a role holder can write the covered records on **every** name served by the resolver instance. For example, if the owner of `alice.eth` grants an account `ROLE_SET_TEXT` for the `description` text key, that account can modify the `description` record of every name served by the instance, including `alice.eth` itself.
| Role | Value | Scope | Purpose |
| ---------------------- | ---------- | -------------------- | ------------------------------------------------------------------------ |
| `ROLE_SET_ADDRESS` | `1 << 0` | root or coin type | Set address records |
| `ROLE_SET_TEXT` | `1 << 4` | root or text key | Set text records |
| `ROLE_SET_CONTENTHASH` | `1 << 8` | root | Set the content hash |
| `ROLE_SET_ABI` | `1 << 12` | root or content type | Set ABI records |
| `ROLE_SET_INTERFACE` | `1 << 16` | root or interface ID | Set interface records |
| `ROLE_SET_NAME` | `1 << 20` | root | Set the reverse name |
| `ROLE_SET_DATA` | `1 << 24` | root or data key | Set data records |
| `ROLE_LINK` | `1 << 28` | root | Link and unlink records |
| `ROLE_CAN_NAME` | `1 << 120` | root | Name this contract (see [Reverse Resolution](/ensv2/reverse-resolution)) |
| `ROLE_UPGRADE` | `1 << 124` | root | Authorize proxy upgrades |
Each role has a corresponding admin role at `role << 128` (e.g., `ROLE_SET_TEXT_ADMIN = (1 << 4) << 128`). In TypeScript, use `1n << 4n` for the bigint equivalent.
<FrenCallout fren="earl" variant="note" title="Initialization">
When deployed through the [Verifiable Factory](/ensv2/verifiable-factory),
`initialize(grants, calls)` defines the initial permissions: each `Grant` is
an account and a role bitmap, granted on `ROOT_RESOURCE` exactly as passed.
The `calls` array is executed as a multicall during initialization, with role
checks skipped, which allows setting initial records in the same transaction.
</FrenCallout>
#### Role Bitmap Composer
<FrenCallout fren="peanut" variant="tip" title="Interactive Widget">
Select roles to compose a bitmap value for use with `initialize` grants or
`grantRootRoles`.
</FrenCallout>
<Card>
<RoleBitmapComposer contract="resolver" />
</Card>
#### Granting and Revoking Roles
Resolver-wide permissions are managed with `grantRootRoles()` / `revokeRootRoles()` inherited from [EAC](/ensv2/enhanced-access-control). The generic `grantRoles()` is disabled on the Permissioned Resolver and always reverts with `EACCannotGrantRoles`.
Argument-scoped permissions (a single text key, coin type, content type, or interface ID) are granted with `grantSetterRoles(setter, account)`: `setter` is ABI-encoded calldata of the setter to authorize, from which the resolver derives the argument, its EAC resource, and the matching role. Only the function selector and the argument in the calldata matter; the name and value parts are ignored.
| Grant | Function |
| --------------------------- | ------------------------------------- |
| Any role, resolver-wide | `grantRootRoles(roleBitmap, account)` |
| One setter for one argument | `grantSetterRoles(setter, account)` |
To revoke an argument-scoped role, call `revokeRoles(resource, roleBitmap, account)` with the argument's [resource](#resource-scheme). Revoking a root-scoped role uses `revokeRootRoles(roleBitmap, account)`.
When checking permissions, the resolver allows a write if the account holds the setter's role either at the argument's resource or at `ROOT_RESOURCE`, so a root grant is a superset of any argument-scoped grant.
#### Resource Scheme
<FrenCallout fren="bittu" variant="tip" title="Developer tip">
This section explains how [EAC
resources](/ensv2/enhanced-access-control#resources) are computed internally.
You don't need this for normal use. `grantSetterRoles` handles resource
computation automatically.
</FrenCallout>
Unlike the registry's labelhash-based resources, resolver resources are derived from the **setter argument alone**. Names play no part in resource computation, and the [anyId polymorphism](/ensv2/mutable-token-ids#anyid-polymorphism) used in the registry does not apply here:
| Argument type | Resource computation |
| ------------------------------------- | ------------------------------------------ |
| Text or data key (`string`) | `keccak256(bytes(key))` |
| Coin type or content type (`uint256`) | `keccak256(abi.encode(value))` |
| Interface ID (`bytes4`) | `keccak256(abi.encodePacked(interfaceId))` |
When a resource that currently has no role holders receives a grant through `grantSetterRoles`, the resolver emits `ResourceArgument(resource, arg)`, which lets indexers map opaque resources back to their arguments. The event can re-fire for the same resource after all of its roles were revoked.
#### Resource Calculator
<FrenCallout fren="peanut" variant="tip" title="Interactive Widget">
Compute the EAC resource for any setter argument.
</FrenCallout>
<Card>
<ResourceCalculator />
</Card>
### Deploying a Permissioned Resolver
Each account deploys its own resolver instance through the [Verifiable Factory](/ensv2/verifiable-factory): a UUPS proxy with a deterministic address, pointing at the protocol-provided implementation contract from the [deployments table](/learn/deployments#sepolia-ensv2). The deploy call runs `initialize(grants, calls)`, which defines the initial permissions and can set initial records in the same transaction (see [Roles](#roles)). Afterwards, point a name at the new instance via `setResolver` on the [registry that holds the name](/ensv2/permissioned-registry).
See [Deploying a Resolver Proxy](/ensv2/verifiable-factory#deploying-a-resolver-proxy) for the full code example.
Because every instance is a proxy, the deployment is cheap and upgradeable: the root-only `ROLE_UPGRADE` controls who can upgrade an individual instance's implementation.
### Code Examples
The examples below assume you already have a `resolverAddress`, deployed as [described above](#deploying-a-permissioned-resolver).
#### Setting and Reading Records
Setters take the DNS-encoded name. Reading through viem's built-in ENS functions works unchanged, since resolution goes through the Universal Resolver:
```ts [Viem]
import { createPublicClient, createWalletClient, http, toHex } from 'viem'
import { mainnet } from 'viem/chains'
import { normalize, packetToBytes } from 'viem/ens'
const client = createPublicClient({ chain: mainnet, transport: http() })
const wallet = createWalletClient({ chain: mainnet, transport: http() })
const name = normalize('alice.eth')
const dnsName = toHex(packetToBytes(name))
// Set the ETH address (coin type 60, address as 20 bytes)
await wallet.writeContract({
address: resolverAddress,
abi: permissionedResolverAbi,
functionName: 'setAddress',
args: [dnsName, 60n, '0x1234...'],
})
// Set a text record
await wallet.writeContract({
address: resolverAddress,
abi: permissionedResolverAbi,
functionName: 'setText',
args: [dnsName, '프로젝트로 돌아가기