Skip to content
LogoLogo

Check Access Key Admin

accessKey.isAdmin

Checks whether an access key is an admin key for an account.

Usage

import {  } from './viem.config'
 
const  = await ..({
  : '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
  : '0x8ba1f109551bD432803012645Ac136ddd64DBA72',
})
 
.('Is admin:', )
Is admin: true

Recipes

Verify an Admin Key Before Delegated Management

Confirm the operator's key still has admin rights before signing key management like accessKey.revoke with it.

import {  } from 'viem/utils'
import {  } from 'viem/tempo'
import {  } from './viem.config'
 
const  = .('0x...')
 
// Admin key held by your ops service, authorized with `admin: true`.
const  = .(.(), {
  : ,
})
 
const  = await ..({ :  })
if (!) throw new ('admin key was revoked')
 
const {  } = await ..({
  : ,
  : '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
})

Audit the Account's Admin Keys

Check each known key so you can keep the number of active admin keys small.

import {  } from './viem.config'
 
const  = [
  '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
  '0x8ba1f109551bD432803012645Ac136ddd64DBA72',
] as 
 
const  = []
for (const  of ) {
  if (await ..({  }))
    .()
}
 
.('Admin keys:', )
Admin keys: ['0x8ba1f109551bD432803012645Ac136ddd64DBA72']

Return Value

type ReturnType = boolean

Whether the access key is an admin key.

Parameters

accessKey

  • Type: Address | AccessKeyAccount

Access key to check. Pass an access key address or an access key account.

account

  • Type: Account | Address
  • Default: client.account

Account (or address) that owns the key.

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.