role.get
Reads the ENSv2 roles an account holds on a name, or at the root of a registry or resolver. Options, result, errors and examples for role.get.
Reads the ENSv2 roles an account holds on a name, or at the root of a registry or resolver.
When to use
Use to inspect EnhancedAccessControl roles directly; permission.get answers
the higher-level question of what the account may do.
Details
target: "registry"reads roles on the name in the registry holding it (or the root withroot: true);"resolver"reads root roles on the name's PermissionedResolver.- Root roles apply to every name, so
rolesincludes them;rootRolesshows them alone. contractreads another registry or resolver than the name's.
Signature
function get(client: Like, options: get.Options): Promise<get.ReturnType>Call it as ens.role.get(options) on a client, or Actions.role.get(client, options).
role.get.request(options) builds a deferred read for Actions.batch. See Look up many at once.
Parameters
| Option | Type | Default | Description |
|---|---|---|---|
account (required) | string | Account whose roles to read. | |
target (required) | "registry" | "resolver" | Registry or PermissionedResolver roles. | |
name | string | ENS name whose registry or resolver to use. Normalized automatically. | |
contract | string | Registry or resolver address, instead of the name's. | |
root | boolean | Read root roles instead of the name's. |
Also takes the read options.
Returns
Resolves to get.ReturnType. The roles held, as a bitmap and as role names.
| Field | Type | Description |
|---|---|---|
contract | Address | |
resource | bigint | EAC resource read; 0n is the root. |
roles | bigint | |
rootRoles | bigint | |
names | readonly Role.Name[] | |
admin | readonly Role.Name[] | Admin roles: the account may grant and revoke these roles. |
Errors
| Error | Codes | When |
|---|---|---|
InvalidInputError | INVALID_NAME, INVALID_ADDRESS, INVALID_RECORD_VALUE | invalid input or targets. |
NotFoundError | RESOLVER_NOT_FOUND | the name has no resolver. |
UnsupportedError | UNSUPPORTED_PROTOCOL | ENSv1 names. |
NetworkError | RPC_REQUEST_FAILED, RPC_TIMEOUT, RATE_LIMITED | the RPC request fails. |
It can also fail with the errors every read can (Errors.CommonError: ConfigError, ContractRevertError, InternalError, NetworkError).
See How errors work.
Examples
const { names } = await ens.role.get({ name: "alice.eth", account, target: "registry" })See also
role.grantto grant roles
Was this page helpful?