6. Advanced Topics & FAQ
This section covers advanced integration techniques, best practices, troubleshooting tips, and frequently asked questions about Kaia's Gas Abstraction (GA) feature. It is designed for developers who want to optimize their implementation and ensure a smooth user experience.
6.1 Best Practices
| Topic | Recommendation | Notes |
|---|---|---|
| Slippage | Start with 0.5 % (50 bps) for getAmountIn() unless the token is highly volatile. | The SDK does not hard-code a value; 0.5 % is the de-facto default shown in Kaia’s reference code. |
| Allowance | Cache the ERC-20 allowance and skip ApproveTx when allowance > 0, avoiding an extra signature & gas. | KIP-247 allows a 2-tx bundle (Lend + Swap) when approval already exists, so re-using allowance is completely safe. |
| Batch submit | Use kaia_sendRawTransactions (array payload) to push ApproveTx + SwapTx together, preventing pool race conditions. | Single-tx calls (eth_sendRawTransaction) work, but if the second tx reaches the node first it will fail the nonce/static-rule checks. |
| Security | a) Hard-code the canonical GaslessSwapRouter (GSR) address from Kaia docs. b) Verify support before building a swap, e.g. await router.dexAddress(token) inside a try/catch or by checking the list returned from getSupportedTokens(). | Prevents phishing contracts or unsupported tokens from hijacking the GA flow. |
| Gas estimation without KAIA | Use eth_estimateGas with state override to give the sender a temporary balance in the call, e.g. eth_estimateGas(txObj, 'latest', { [from]: { balance: '0x…' } }). | Bypasses “insufficient balance” errors when the account truly has 0 KAIA. |