Skip to content
LogoLogo

channel.verifyVoucher

Verifies a TIP-20 channel reserve voucher signature.

Returns whether signature is a valid voucher for cumulativeAmount from the channel's voucher signer: its authorizedSigner when set, else the payer. It does not check cumulativeAmount against the channel's deposit or settled amount, so a valid voucher can still fail to settle. Use channel.getStates to read the deposit and settled amount.

Usage

import { parseUnits } from 'viem'
import { client, channel } from './viem.config'
 
const valid = await client.channel.verifyVoucher({
  channel,
  cumulativeAmount: parseUnits('40', 6),
  signature: '0x...',
})
true

Standalone Action

import { parseUnits } from 'viem'
import { Actions } from 'viem/tempo'
import { client, channel } from './viem.config'
 
const valid = await Actions.channel.verifyVoucher(client, {
  channel,
  cumulativeAmount: parseUnits('40', 6),
  signature: '0x...',
})
true

Return Value

boolean

Whether the signature is a valid voucher for the channel and amount.

Parameters

channel

  • Type: Channel.from.Value

Channel descriptor. The precompile computes the channel ID from it, so a channel ID alone is not enough.

const channel = Channel.from({ 
  expiringNonceHash: '0x...', 
  payee: '0x...', 
  payer: client.account.address, 
  salt: '0x...', 
  token: '0x...', 
}) 
 
await client.channel.verifyVoucher({
  channel, 
  cumulativeAmount: parseUnits('40', 6),
  signature: '0x...',
})

cumulativeAmount

  • Type: bigint

Total voucher amount signed for the channel.

await client.channel.verifyVoucher({
  channel,
  cumulativeAmount: parseUnits('40', 6), 
  signature: '0x...',
})

signature

  • Type: Hex

Voucher signature, from channel.signVoucher.

await client.channel.verifyVoucher({
  channel,
  cumulativeAmount: parseUnits('40', 6),
  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.

Errors

ErrorDescription
ChannelNotFoundErrorThe channel does not exist.