Documentation for agents: an index at /llms.txt, every docs page in one file at /llms-full.txt, and Markdown for any docs page by adding .md to its URL.

Skip to Content
ensforgeSDK

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.

ReadBatchablestable
Since v1.0.0View source

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 with root: true); "resolver" reads root roles on the name's PermissionedResolver.
  • Root roles apply to every name, so roles includes them; rootRoles shows them alone.
  • contract reads 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

OptionTypeDefaultDescription
account (required)stringAccount whose roles to read.
target (required)"registry" | "resolver"Registry or PermissionedResolver roles.
namestringENS name whose registry or resolver to use. Normalized automatically.
contractstringRegistry or resolver address, instead of the name's.
rootbooleanRead 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.

FieldTypeDescription
contractAddress
resourcebigintEAC resource read; 0n is the root.
rolesbigint
rootRolesbigint
namesreadonly Role.Name[]
adminreadonly Role.Name[]Admin roles: the account may grant and revoke these roles.

Errors

It can also fail with the errors every read can (Errors.CommonError: ConfigError, ContractRevertError, InternalError, NetworkError).

See How errors work.

Examples

Reading an account's roles on a name
const { names } = await ens.role.get({ name: "alice.eth", account, target: "registry" })

See also

Was this page helpful?