Overview
Gas on Receive prevents users from getting “stuck” with assets they can’t use by automatically providing a small amount of native gas tokens on the destination chain. The client library provides thegetRouteWithGasOnReceive
function that handles all the complexity for you, or you can implement custom logic if you need specific behavior.
Prerequisites
- Skip Go Client Library v1.5.0 or higher
- Understanding of the basic
route
andexecuteRoute
functions - Access to user wallet signers for multiple chains
Supported Chains
- Destination: Cosmos chains and EVM L2s (Solana not supported)
- Source: Most chains except Ethereum mainnet and Sepolia testnet
Quick Start: Using getRouteWithGasOnReceive
The simplest way to implement Gas on Receive is using the built-ingetRouteWithGasOnReceive
function:
How getRouteWithGasOnReceive Works
The function automatically:- Checks if the destination chain is supported (excludes Solana chains)
- Checks source chain support (excludes Ethereum mainnet and Sepolia testnet)
- Verifies the destination asset isn’t already a fee asset
- Calculates appropriate gas amounts:
- Cosmos chains: Average gas price × 3 (or $0.10 USD fallback if gas price unavailable)
- EVM L2 chains: $2.00 USD worth of native tokens
- Creates a gas route to obtain native tokens
- Adjusts the main route amount accordingly
- Returns both routes, or the original route as mainRoute if gas route creation fails
mainRoute
with gasRoute
as undefined, allowing your swap to proceed without gas-on-receive.
Custom Implementation Guide
If you need to customize the Gas on Receive behavior beyond whatgetRouteWithGasOnReceive
provides:
Step 1: Check Destination Gas Balance
Before initiating a swap, check if the user has sufficient gas on the destination chain:Step 2: Calculate Gas Amount Needed
Step 3: Create Routes with Custom Logic
Step 4: Execute Routes
Complete Implementation Example
Here’s a full example combining all the concepts:UI Considerations
When implementing Gas on Receive in your UI:Display Gas Information
Show Status During Execution
Error Handling
Handle various failure scenarios gracefully:Best Practices
- Use getRouteWithGasOnReceive: The automatic function handles edge cases and optimizations
- Auto-detection: Check gas balances and suggest Gas on Receive when needed
- User Control: Always allow users to toggle the feature on/off
- Clear Communication: Show exact amounts and costs transparently
- Graceful Degradation: Main swap should continue even if gas route fails
- Higher Slippage: Use 10% slippage for gas routes (vs 1% for main routes)
- Chain Support: Disable for Ethereum mainnet and Solana
- Amount Limits: Use recommended amounts (2.00 for EVM L2s)
Advanced Configuration
Custom Gas Amounts
Dynamic Pricing
Comparison with Widget Implementation
Feature | Widget (Automatic) | Client Library (Manual) |
---|---|---|
Gas balance detection | Automatic | Manual or use getRouteWithGasOnReceive |
Route creation | Automatic | Use getRouteWithGasOnReceive or manual |
Amount calculation | Built-in defaults | Built-in with getRouteWithGasOnReceive |
UI components | Provided | Build your own |
Error handling | Automatic | Manual implementation |
Status tracking | Built-in | Via callbacks |
Summary
The Skip Go Client Library provides flexible options for implementing Gas on Receive:- Quick implementation with
getRouteWithGasOnReceive
for automatic route splitting - Full control with manual balance checking and route creation
- Status tracking via callbacks in
executeMultipleRoutes
- Graceful error handling where gas route failures don’t affect main swaps
getRouteWithGasOnReceive
provides the ideal balance of simplicity and functionality.