Build an FT post-condition
Create post-conditions for fungible token transfers to ensure exact amounts are transferred as expected
import { Pc } from '@stacks/transactions';// Create a post-condition for fungible token transfersconst postCondition = Pc.principal("ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM").willSendGte(500) // Amount in token's smallest unit.ft("ST1HTBVD3JG9C05J7HBJTHGR0GGW7KXW28M5JS8QE.token-ft", "my-token");// Use in transaction optionsconst txOptions = {// ... other transaction optionspostConditions: [postCondition],postConditionMode: PostConditionMode.Deny,};
Use cases
- Securing fungible token transfers with amount validation
- Protecting users from unexpected token transfers in DeFi protocols
- Ensuring token swaps happen with expected amounts
Key concepts
The Pc
builder for fungible tokens accepts:
.ft()
- Takes two parameters:- Contract address with asset name (e.g.,
"contract.asset-name"
) - Token name as defined in the contract
- Contract address with asset name (e.g.,