Skip to content
LogoLogo

Get Blocked Balance

receivePolicy.getBlockedBalance

Gets the blocked balance for an encoded receipt.

Usage

import {  } from './viem.config'
 
const  = await ..({
  : '0x1234',
})
 
.('Blocked balance:', )
Blocked balance: 1000000n

Recipes

Skip Receipts That Were Already Resolved

A receipt's balance drops to zero once claimed or burned, so check it before receivePolicy.claimSync when replaying stored receipts.

import {  } from './viem.config'
 
// Claim receipts indexed from `TransferBlocked` events.
const  = ['0x1234', '0x5678'] as 
 
for (const  of ) {
  const  = await ..({  })
  if ( === 0n) continue
  await ..({
    ,
    : ..,
  })
}

Inspect a Blocked Payment for Support

Pair the held balance with ReceivePolicyReceipt.decode to show support staff who sent a blocked payment, in which token, and when.

import {  } from 'viem/tempo'
import {  } from './viem.config'
 
const  = '0x1234'
 
const  = await ..({  })
const { , ,  } = .()
 
.(`${} base units of ${} from ${}, held since ${}`)

Return Value

type ReturnType = bigint

The blocked balance for the encoded receipt.

Parameters

receipt

  • Type: Hex

The encoded claim receipt.

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.