Skip to content
LogoLogo

Sign Channel Voucher

channel.signVoucher

Signs a TIP-20 channel reserve voucher.

Usage

import {  } from './viem.config'
 
const  = await ..({
  : '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef',
  : 40000000n,
})
 
.('Signature:', )
Signature: 0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1b

Recipes

Meter Usage with a Running Cumulative Total

Sign a voucher for the new running total after each unit of usage; each voucher supersedes the last, so the payee only keeps the latest one.

import {  } from './viem.config'
 
const  = 10_000n
let  = 0n
 
async function () {
   += 
  const  = await ..({
    : '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef',
    ,
  })
  // Hand the voucher to the payee off-chain.
  return { ,  }
}

Sign with a Delegated Hot Key

Pass account to sign with the channel's authorized signer instead of the client account, as configured through channel.open's authorizedSigner option.

import {  } from 'viem/tempo'
import {  } from './viem.config'
 
const  = .('0x...')
 
const  = await ..({
  : ,
  : '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef',
  : 40_000000n,
})

Return Value

type ReturnType = Hex

The voucher signature.

Parameters

account

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

Account to sign with.

chainId

  • Type: number | bigint
  • Default: client.chain.id

The chain ID.

channel

  • Type: Channel | Hex

Channel ID or channel.

cumulativeAmount

  • Type: bigint

Total voucher amount signed for the channel.