Get Transfer Policy Data
policy.getData
Gets TIP-403 transfer policy data.
Usage
import { } from './viem.config'
const = await ..({
: 1n,
})
.('Policy data:', )
Policy data: { admin: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb', type: 'whitelist' }import { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Recipes
Verify a Policy Before Attaching It to a Token
Use policy.getData to confirm a policy's type and admin before token.changeTransferPolicySync puts it in front of live transfers.
import { } from './viem.config'
const { , } = await ..({ : 1n })
if ( !== 'whitelist' || !== ..)
throw new ('Unexpected policy configuration.')
await ..({
: 1n,
: '0x20c0000000000000000000000000000000000000',
})import { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Route Membership Updates by Policy Type
Use the returned type to choose between policy.modifyWhitelistSync and policy.modifyBlacklistSync when your tooling manages policies of both kinds.
import { } from './viem.config'
const = '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb'
const { } = await ..({ : 1n })
if ( === 'whitelist')
await ..({ , : true, : 1n })
else
await ..({ , : 1n, : false })import { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Return Value
type ReturnType = {
/** Admin address. */
admin: Address
/** Policy type. */
type: 'blacklist' | 'whitelist'
}The policy admin address and policy type.
Parameters
policyId
- Type:
bigint
Policy ID.
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.