> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://v3.viem.sh/api/mcp` to find what you need.

# Check Token Role \[token.hasRole]

Checks if an account has a specific role for a TIP-20 token. [Learn more about token roles](https://docs.tempo.xyz/protocol/tip403/spec)

## Usage

:::code-group
```ts twoslash [example.ts]
import { client } from './viem.config'

const hasRole = await client.token.hasRole({
  account: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
  role: 'issuer',
  token: '0x20c0000000000000000000000000000000000001',
})

console.log('Has issuer role:', hasRole)
// @log: Has issuer role: true
```

```ts twoslash [viem.config.ts] filename="viem.config.ts"
// [!include ~/snippets/tempo/viem.config.ts:setup]
```
:::

## Recipes

### Skip Redundant Role Grants When Provisioning

Combine `hasRole` with [`token.grantRolesSync`](/tempo/actions/token.grantRoles) to keep operator provisioning idempotent: grant the issuer role only when the operator does not already hold it.

:::code-group
```ts twoslash [example.ts]
import { client } from './viem.config'

const operator = '0x8ba1f109551bD432803012645Ac136ddd64DBA72'
const token = '0x20c0000000000000000000000000000000000001'

const hasRole = await client.token.hasRole({
  account: operator,
  role: 'issuer',
  token,
})

if (!hasRole) // [!code focus]
  await client.token.grantRolesSync({ // [!code focus]
    roles: ['issuer'],
    to: operator,
    token,
  })
```

```ts twoslash [viem.config.ts] filename="viem.config.ts"
// [!include ~/snippets/tempo/viem.config.ts:setup]
```
:::

### Verify Pause Authority Before an Incident Response

Omit `account` to check the Client's own account, for example verifying an incident-response key holds the `pause` role before it halts transfers with [`token.pauseSync`](/tempo/actions/token.pause).

:::code-group
```ts twoslash [example.ts]
import { client } from './viem.config'

const token = '0x20c0000000000000000000000000000000000001'

const canPause = await client.token.hasRole({ // [!code focus]
  role: 'pause', // [!code focus]
  token, // [!code focus]
}) // [!code focus]

if (!canPause)
  throw new Error('incident key is missing the pause role')

await client.token.pauseSync({ token })
```

```ts twoslash [viem.config.ts] filename="viem.config.ts"
// [!include ~/snippets/tempo/viem.config.ts:setup]
```
:::

## Return Value

```ts
type ReturnType = boolean // Whether the account has the role
```

## Parameters

### account

* **Type:** `Account | Address`
* **Default:** `client.account`

Account (or address) to check.

### role

* **Type:** `"defaultAdmin" | "pause" | "unpause" | "issuer" | "burnBlocked"`

Role to check.

### token

* **Type:** `Address | bigint`

Token to operate on: a TIP-20 token id or a contract address.

### blockNumber (optional)

* **Type:** `bigint`

Block number to read the state from.

### blockOverrides (optional)

* **Type:** `BlockOverrides`

Block overrides to apply to the state.

### blockTag (optional)

* **Type:** `BlockTag`

Block tag to read the state from.

### stateOverride (optional)

* **Type:** `StateOverride`

State override to apply.
