Check Transfer Policy Authorization
policy.isAuthorized
Checks if a user is authorized by a TIP-403 transfer policy.
Usage
import { } from './viem.config'
const = await ..({
: 1n,
: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
})
.('Authorized:', )
Authorized: trueimport { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Recipes
Screen a Recipient Before Sending a Payout
Combine policy.isAuthorized with token.transferSync to hold payouts that the token's transfer policy would revert.
import { } from './viem.config'
const = '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb'
const = await ..({
: 1n,
: ,
})
if ()
await ..({
: { : '1250' },
: ,
: '0x20c0000000000000000000000000000000000000',
})import { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Audit a Payout List for Blocked Recipients
Use one pass over your recipient list to surface accounts that fail compliance screening before a payroll run starts.
import { } from './viem.config'
const = [
'0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
'0x8ba1f109551bD432803012645Ac136ddd64DBA72',
] as
const = await .(
.(async () => ({
: await ..({ : 1n, }),
,
})),
)
const = .(() => !.)
.('Blocked:', .(() => .))
Blocked: ['0x8ba1f109551bD432803012645Ac136ddd64DBA72']import { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Return Value
type ReturnType = booleanWhether the user is authorized by the policy.
Parameters
policyId
- Type:
bigint
Policy ID.
user
- Type:
Address
User address to check.
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.