Skip to content
LogoLogo

Get Receive Policy

receivePolicy.get

Gets the receive policy configured for an account.

Usage

import {  } from './viem.config'
 
const  = await ..({
  : '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
})
 
.('Receive policy:', .)
Receive policy: true

Recipes

Apply a Default Policy Only Once

Gate onboarding on hasReceivePolicy so you only apply your default policy with receivePolicy.setSync to accounts that have none configured.

import {  } from './viem.config'
 
const {  } = await ..({
  : ..,
})
 
if (!)
  await ..({
    : 'self',
    : 'allow-all',
    : 'allow-all',
  })

Audit Who Can Recover Blocked Funds

Use the returned claimer to confirm blocked funds route to an account you control before tightening a policy across treasury accounts.

import {  } from './viem.config'
 
const  = '0x8ba1f109551bD432803012645Ac136ddd64DBA72'
 
const { ,  } = await ..({
  : '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
})
 
if ( &&  !== 'self' &&  !== )
  throw new (`Blocked funds are not recoverable by treasury: ${}`)

Return Value

type ReturnType = {
  /** Whether the account has a receive policy configured. */
  hasReceivePolicy: boolean
  /** TIP-403 policy restricting which senders are allowed. */
  senderPolicyId: 'reject-all' | 'allow-all' | bigint
  /** Type of the sender policy. */
  senderPolicyType: 'blacklist' | 'whitelist'
  /** TIP-403 policy restricting which tokens are allowed. */
  tokenPolicyId: 'reject-all' | 'allow-all' | bigint
  /** Type of the token policy. */
  tokenPolicyType: 'blacklist' | 'whitelist'
  /** Who can reclaim funds blocked by this policy. */
  claimer: 'sender' | 'self' | Address
  /** Raw recovery authority address. */
  recoveryAuthority: Address
}

The account receive policy configuration.

Parameters

account

  • Type: Account | Address

Account or address whose receive policy is read. Defaults to client.account.

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.