Allowances & Approvals
How OneBalance automatically handles token approvals for secure, gas-efficient transactions
Learn how OneBalance automatically handles token approvals for DeFi operations while maintaining security best practices.
Important: Never manually call approve()
functions when using OneBalance. The platform automatically manages all required approvals as part of the contract call preparation process.
How Approval Management Works
When you specify allowanceRequirements
, OneBalance automatically:
- Checks existing allowances - Verifies current approval amounts
- Adds approval transactions - Only when needed, for exact amounts
- Executes your operations - Runs your contract calls
- Removes excess approvals - Cleans up remaining allowances for security
This prevents front-running attacks and ensures optimal gas usage.
OneBalance bundles approvals, your calls, and approval cleanup into a single user operation for atomic execution.
Basic Example
Here’s how to properly handle approvals for a DEX swap:
What NOT to Do
Common Mistake: Including approval calls manually will cause transaction failures.
Common Patterns
DEX Swaps
Lending Protocols
Multiple Token Operations
NFT Purchases
Special Cases
Native Tokens (ETH, MATIC, etc.)
Native tokens don’t require approvals - they’re sent directly:
Existing Allowances
OneBalance optimizes gas by checking existing allowances:
Sufficient Allowance
If current allowance ≥ required amount
, no approval transaction is added
Insufficient Allowance
Only approves the exact amount needed, not unlimited approvals
Security Features
OneBalance’s approval management includes several security measures:
- Exact Amount Approvals - Never approves more than needed
- Automatic Cleanup - Removes remaining allowances after execution
- Front-running Protection - Atomic bundling prevents manipulation
- Approval Validation - Verifies spender addresses match your calls
Best Practices
Use allowanceRequirements
Always specify token approvals in the allowanceRequirements
array, never in calls
Specify Exact Amounts
Use precise amounts to minimize approval exposure
Verify Spender Addresses
Double-check that spender addresses match your contract calls
Test with Small Amounts
Start with small transactions to verify your integration
TypeScript Interface
Troubleshooting
- Transaction fails with ‘Approval not found’ - Make sure you’re using
allowanceRequirements
instead of manual approval calls. - Gas costs seem high - OneBalance only adds approvals when needed. High gas might indicate multiple tokens or complex operations.
- Spender address mismatch - Verify that the spender in
allowanceRequirements
matches the contract address in yourcalls
. - Amount calculation errors - Ensure you’re using the correct decimals for the token (e.g., 6 for USDC, 18 for most ERC20s).
Need help? Check the troubleshooting guide for common issues and solutions.