Skip to content
LogoLogo

accounts.verifyHash

Verifies a configurable account signature against the account's current configuration with the signature verifier precompile.

Returns false when the signature is for another account, or for a config that is not the account's current config. Throws when the signature is malformed or its approvals do not reach quorum.

verifyHash on a Tempo chain also verifies configurable account signatures, and returns false instead of throwing.

Usage

import { Account } from 'viem/tempo'
import { client } from './viem.config'
 
const owner = Account.fromSecp256k1(
  '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'
)
const account = Account.fromConfig({ address: 'infer', owners: [owner] })
 
const hash =
  '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef'
const signature = await account.sign({ hash })
 
const valid = await client.accounts.verifyHash({
  account: account.address,
  hash,
  signature,
})
true

Return Value

boolean

Whether the signature is valid for the account.

Parameters

account

  • Type: Address

Configurable account address the signature is expected to belong to.

await client.accounts.verifyHash({
  account: '0x...', 
  hash: '0x...',
  signature: '0x...',
})

hash

  • Type: Hex

Original message hash that was signed.

await client.accounts.verifyHash({
  account: '0x...',
  hash: '0x...', 
  signature: '0x...',
})

signature

  • Type: Hex

Configurable account signature envelope.

await client.accounts.verifyHash({
  account: '0x...',
  hash: '0x...',
  signature: '0x...', 
})

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.