Skip to content
LogoLogo

Get Token Role Admin

token.getRoleAdmin

Gets the admin role for a specific role in a TIP-20 token. Learn more about token roles

Usage

import {  } from './viem.config'
 
const  = await ..({
  : 'issuer',
  : '0x20c0000000000000000000000000000000000001',
})
 
.('Admin role:', )
Admin role: 0x0000000000000000000000000000000000000000000000000000000000000000

Recipes

Verify Your Admin Key Can Grant a Role

Compare the returned hash against TokenRole.serialize to confirm the defaultAdmin role still governs issuer grants before calling token.grantRolesSync from your admin key.

import {  } from 'viem/tempo'
import {  } from './viem.config'
 
const  = '0x20c0000000000000000000000000000000000001'
 
const  = await ..({
  : 'issuer',
  ,
})
 
if ( === .('defaultAdmin'))
  await ..({
    : ['issuer'],
    : '0x8ba1f109551bD432803012645Ac136ddd64DBA72',
    ,
  })

Return Value

type ReturnType = Hex // Admin role hash

The admin role hash. The zero hash is the defaultAdmin role. Use TokenRole.serialize from viem/tempo to compare against a named role.

Parameters

role

  • Type: "defaultAdmin" | "pause" | "unpause" | "issuer" | "burnBlocked"

Role to get admin for.

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.