Skip to content
LogoLogo

Verify Access Key Hash

accessKey.verifyHash

Verifies that a keychain signature was produced by an active access key for the expected account.

Usage

import {  } from './viem.config'
 
const  = await ..({
  : '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
  : '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef',
  : '0x...',
})
 
.('Valid:', )
Valid: true

Recipes

Tier Endpoint Access by Signer Privilege

Use the default admin check for sensitive operations and admin: false for routine access key traffic, so one signature check enforces two permission tiers.

import {  } from './viem.config'
 
const  = '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb'
const  =
  '0x9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658'
const  = '0x...'
 
// Any active access key may read order history.
const  = await ..({
  ,
  : false,
  ,
  ,
})
 
// Only the root key or an admin key may change payout settings.
const  = await ..({
  ,
  ,
  ,
})

Return Value

type ReturnType = boolean

Whether the keychain signature is valid for the account.

Parameters

account

  • Type: Address

Account address the signature is expected to belong to.

admin

  • Type: boolean
  • Default: true

Whether to require the signer to be the account's root key or an active admin access key. Set to false to accept any active access key.

hash

  • Type: Hex

Original message hash that was signed.

signature

  • Type: Hex

Keychain signature envelope.

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.