Skip to content
LogoLogo

Watch Transfer Policy Blacklist

policy.watchBlacklistUpdated

Watches BlacklistUpdated events on the TIP-403 registry.

Usage

import {  } from './viem.config'
 
const  = ..()
 
.(() => {
  for (const  of ) .(.)
{ policyId: 1n, updater: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', account: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb', restricted: true }
})
 
// Later, tear down the watcher.
.()

Also callable standalone: Actions.policy.watchBlacklistUpdated(client, options), with Actions imported from 'viem/tempo'.

Recipes

Maintain an Audit Trail of Sanctions Actions

Pass args.policyId to record every designation and removal on your policy, keyed by transaction hash, for compliance reporting.

import {  } from './viem.config'
 
const  = ..({
  : { : 1n },
})
 
.(() => {
  for (const  of ) {
    .({
      : ..,
      : .. ? 'designated' : 'removed',
      : .,
    })
  }
{ account: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb', action: 'designated', reference: '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef' }
})

Suspend Deposits When One of Your Addresses Is Blocked

Pass args.account to monitor your own deposit addresses across every policy, and stop routing customer funds through an address that gets blocked.

import {  } from './viem.config'
 
const  = ..({
  : {
    : [
      '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
      '0x8ba1f109551bD432803012645Ac136ddd64DBA72',
    ],
  },
})
 
.(() => {
  for (const  of )
    if (..) .('Suspend deposits to:', ..)
Suspend deposits to: 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb
})

Return Value

Returns a watcher handle. Watching starts when the first listener (or async iterator) attaches, and stops when off is called.

type ReturnType = {
  /** Registers a log listener. Starts the watcher on first registration. Returns an unregister function. */
  onLogs: (fn: (logs: readonly Log[]) => void) => () => void
  /** Registers an error listener. Returns an unregister function. */
  onError: (fn: (error: Error) => void) => () => void
  /** Tears down the watcher: removes listeners, ends iterators, stops the poll or subscription. */
  off: () => void
  /** Async-iterates emitted log batches (latest-only stream). */
  [Symbol.asyncIterator]: () => AsyncIterableIterator<{ logs: readonly Log[] }>
}

Each log is decoded, with the event arguments on args:

type Log = {
  /** Decoded `BlacklistUpdated` event arguments. */
  args: {
    policyId: bigint
    updater: Address
    account: Address
    restricted: boolean
  }
  /** Name of the emitted event. */
  eventName: 'BlacklistUpdated'
  // ...standard log fields (address, blockHash, blockNumber, logIndex, transactionHash, ...)
}

Parameters

args

  • Type: object
type Args = {
  policyId?: bigint | bigint[] | null
  updater?: Address | Address[] | null
  account?: Address | Address[] | null
}

Indexed argument values to filter logs by.

batch

  • Type: boolean
  • Default: true

Whether to batch the logs found within a poll interval into a single emission. When false, each log is emitted on its own.

fromBlock

  • Type: bigint

Block number from which to start watching for logs.

poll

  • Type: boolean

Whether to poll for new logs instead of using a subscription. Defaults to true when the transport cannot subscribe or fromBlock is provided.

pollingInterval

  • Type: number
  • Default: client.pollingInterval

Polling frequency (in ms).