Skip to main content
This guide explains how to implement Gas on Receive functionality when building custom frontends with the Skip Go Client Library. Gas on Receive helps users automatically obtain native gas tokens on destination chains during cross-chain swaps.

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 the getRouteWithGasOnReceive 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 and executeRoute 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-in getRouteWithGasOnReceive function:

How getRouteWithGasOnReceive Works

The function automatically:
  1. Checks if the destination chain is supported (excludes Solana chains)
  2. Checks source chain support (excludes Ethereum mainnet and Sepolia testnet)
  3. Verifies the destination asset isn’t already a fee asset
  4. 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
  5. Creates a gas route to obtain native tokens
  6. Adjusts the main route amount accordingly
  7. Returns both routes, or the original route as mainRoute if gas route creation fails
Note: If gas route creation fails for any reason, the function returns the original route as 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 what getRouteWithGasOnReceive 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

  1. Use getRouteWithGasOnReceive: The automatic function handles edge cases and optimizations
  2. Auto-detection: Check gas balances and suggest Gas on Receive when needed
  3. User Control: Always allow users to toggle the feature on/off
  4. Clear Communication: Show exact amounts and costs transparently
  5. Graceful Degradation: Main swap should continue even if gas route fails
  6. Higher Slippage: Use 10% slippage for gas routes (vs 1% for main routes)
  7. Chain Support: Disable for Ethereum mainnet and Solana
  8. Amount Limits: Use recommended amounts (0.10forCosmos,0.10 for Cosmos, 2.00 for EVM L2s)

Advanced Configuration

Custom Gas Amounts

Dynamic Pricing

Comparison with Widget Implementation

Summary

The Skip Go Client Library provides flexible options for implementing Gas on Receive:
  1. Quick implementation with getRouteWithGasOnReceive for automatic route splitting
  2. Full control with manual balance checking and route creation
  3. Status tracking via callbacks in executeMultipleRoutes
  4. Graceful error handling where gas route failures don’t affect main swaps
Choose the approach that best fits your application’s needs. For most use cases, getRouteWithGasOnReceive provides the ideal balance of simplicity and functionality.