Contract Call Examples
Production-ready examples for common DeFi, NFT, and gaming use cases
Real-world examples of contract calls using OneBalance APIs. Each example shows the complete flow from preparing quotes to execution with actual API payloads.
Overview
These examples demonstrate the three-step flow for contract calls:
- Prepare - Generate user operation and typed data
- Sign - Sign the typed data (handled by your wallet/signer)
- Execute - Submit the signed quote for execution
For interactive testing, use the API Reference playground or copy the cURL commands directly.
DeFi Examples
Uniswap V3 Swap
Swap USDC for WETH on Base using Uniswap V3 router.
After signing the typed data from the prepare response, execute the quote:
Aave V3 Supply
Supply USDC to Aave V3 on Base to earn yield.
NFT Examples
Mint NFT Collection
Mint 2 NFTs from a collection on Base with ETH payment.
Gaming Examples
In-Game Purchase
Purchase game item #1 using USDC as payment token.
Basic Account Examples
Basic accounts use a simpler structure with just signer and account addresses.
Token Transfer with Basic Account
Transfer USDC tokens using a basic account configuration.
Multi-Step Operations
Batch Token Transfers
Send tokens to multiple recipients in a single transaction.
Integration Helpers
TypeScript Helper Functions
Utility functions to simplify contract call integration.
Production Best Practices
Validation
Always validate addresses, amounts, and parameters before preparing quotes. Use checksummed addresses.
Error Handling
Implement proper error handling for failed preparations, rejections, and execution failures.
Gas Estimation
OneBalance handles gas estimation, but monitor network congestion and adjust timeouts accordingly.
Testing
Test all operations with small amounts on testnet before production deployment.
Next Steps: Learn about troubleshooting common issues or explore advanced patterns for complex use cases.