# role.get

> For the complete documentation index, see [llms.txt](https://ensforge.com/llms.txt).

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.

Source: https://ensforge.com/docs/reference/sdk/role/get

<ApiMeta kind="Read" stability="stable" since="1.0.0" source="packages/sdk/src/actions/role/get/index.ts#L57" batchable />

Reads the ENSv2 roles an account holds on a name, or at the root of a registry or resolver.

## When to use [#when-to-use]

Use to inspect EnhancedAccessControl roles directly; [`permission.get`](/docs/reference/sdk/permission/get) answers
the higher-level question of what the account may do.

## Details [#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 [#signature]

```ts
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](/docs/sdk/look-up-many-at-once).

## Parameters [#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](/docs/reference/sdk/client#read-options).

## Returns [#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 [#errors]

| Error | Codes | When |
| --- | --- | --- |
| [`InvalidInputError`](/docs/reference/errors/invalid-input-error) | [`INVALID_NAME`](/docs/reference/errors/INVALID_NAME), [`INVALID_ADDRESS`](/docs/reference/errors/INVALID_ADDRESS), [`INVALID_RECORD_VALUE`](/docs/reference/errors/INVALID_RECORD_VALUE) | invalid input or targets. |
| [`NotFoundError`](/docs/reference/errors/not-found-error) | [`RESOLVER_NOT_FOUND`](/docs/reference/errors/RESOLVER_NOT_FOUND) | the name has no resolver. |
| [`UnsupportedError`](/docs/reference/errors/unsupported-error) | [`UNSUPPORTED_PROTOCOL`](/docs/reference/errors/UNSUPPORTED_PROTOCOL) | ENSv1 names. |
| [`NetworkError`](/docs/reference/errors/network-error) | [`RPC_REQUEST_FAILED`](/docs/reference/errors/RPC_REQUEST_FAILED), [`RPC_TIMEOUT`](/docs/reference/errors/RPC_TIMEOUT), [`RATE_LIMITED`](/docs/reference/errors/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](/docs/sdk/errors-explained).

## Examples [#examples]

<Tabs groupId="api" items={["Client","Standalone","Effect"]} persist>
<Tab>
```ts title="Reading an account's roles on a name"
const { names } = await ens.role.get({ name: "alice.eth", account, target: "registry" })
```
</Tab>

<Tab>
```ts title="Root roles on a resolver with a standalone call"
import { Actions } from "@ensforge/sdk"

const roles = await Actions.role.get(publicClient, { name: "alice.eth", account, target: "resolver", root: true })
```
</Tab>

<Tab>
```ts title="Reading in an Effect program"
import { Actions } from "@ensforge/sdk/effect"

const roles = yield* Actions.role.get(ens, { name: "alice.eth", account, target: "registry" })
```
</Tab>
</Tabs>

## See also [#see-also]

- [`role.grant`](/docs/reference/sdk/role/grant) to grant roles