# Gas Fee Sponsorship Execute swaps without holding SOL for transaction fees. When gasless mode is enabled, Vybe sponsors the transaction fee on behalf of the user—removing one of the biggest friction points for new users and token-only wallets. ## The Problem We Solve New users often face this frustrating flow: ``` User has: 100 USDC from an airdrop User wants: Swap to SOL Problem: Can't swap without SOL for gas Solution: Need to buy SOL first, but... how? ``` This creates a chicken-and-egg problem that kills conversion. Users who receive tokens from airdrops, transfers, or exchanges can't do anything without first acquiring SOL. **Gasless mode eliminates this friction entirely.** **Note:** Users still sign the transaction (Vybe never touches private keys). We simply pay the ~0.000005 SOL network fee so your users don't have to *** ## How It Works ``` Normal Swap: ┌─────────────────────────────────────────────────────┐ │ User Wallet │ │ - Pays ~0.000005 SOL transaction fee │ │ - Swaps tokens │ └─────────────────────────────────────────────────────┘ Gasless Swap: ┌─────────────────────────────────────────────────────┐ │ User Wallet │ │ - Signs transaction (proving ownership) │ │ - Swaps tokens │ │ │ │ Vybe Fee Payer │ │ - Pays the ~0.000005 SOL transaction fee │ └─────────────────────────────────────────────────────┘ ``` The transaction is identical—same instructions, same swap—just with Vybe as the fee payer instead of the user. *** ## Enable Gasless Mode Add `gasless: true` to your swap request: ```bash curl -X POST "https://api.vybenetwork.com/trading/swap" \ -H "X-API-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "wallet": "UserWalletAddress", "amount": 100, "inputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "outputMint": "So11111111111111111111111111111111111111112", "router": "vybe", "slippage": 1, "gasless": true }' ``` That's it. The returned transaction will have Vybe as the fee payer. *** ## Use Cases ### 1. Onboarding New Users New users from airdrops or transfers can swap immediately: ```javascript async function onboardingSwap(userWallet, tokenMint, amount) { // User has tokens but no SOL const response = await fetch('https://api.vybenetwork.com/trading/swap', { method: 'POST', headers: { 'X-API-Key': API_KEY, 'Content-Type': 'application/json' }, body: JSON.stringify({ wallet: userWallet, amount, inputMint: tokenMint, outputMint: 'So11111111111111111111111111111111111111112', // SOL gasless: true, // Vybe pays gas slippage: 2 }) }); return response.json(); } ``` ### 2. Token-Only Wallets Wallets funded only with tokens (from CEX withdrawal, bridge, etc.): ```javascript async function swapFromTokenOnlyWallet(wallet, inputToken, outputToken, amount) { // Check if user has SOL const solBalance = await connection.getBalance(new PublicKey(wallet)); const needsGasless = solBalance < 5000; // Less than 0.000005 SOL return fetch('https://api.vybenetwork.com/trading/swap', { method: 'POST', headers: { 'X-API-Key': API_KEY, 'Content-Type': 'application/json' }, body: JSON.stringify({ wallet, amount, inputMint: inputToken, outputMint: outputToken, gasless: needsGasless, slippage: 2 }) }).then(r => r.json()); } ``` ### 3. Smoother UX for All Users Remove the "insufficient SOL for gas" error from your app entirely: ```javascript async function smartSwap(params) { try { // Try normal swap first return await executeSwap({ ...params, gasless: false }); } catch (error) { // If insufficient SOL, retry with gasless if (error.message.includes('insufficient') && error.message.includes('SOL')) { return await executeSwap({ ...params, gasless: true }); } throw error; } } ``` *** ## Complete Gasless Flow ```javascript import { Connection, Transaction } from '@solana/web3.js'; async function executeGaslessSwap(wallet, inputMint, outputMint, amount) { // 1. Build gasless transaction const response = await fetch('https://api.vybenetwork.com/trading/swap', { method: 'POST', headers: { 'X-API-Key': API_KEY, 'Content-Type': 'application/json' }, body: JSON.stringify({ wallet: wallet.publicKey.toString(), amount, inputMint, outputMint, gasless: true, slippage: 2 }) }); const { transaction: txBase64 } = await response.json(); // 2. Deserialize const transaction = Transaction.from(Buffer.from(txBase64, 'base64')); // 3. User signs (partial signature - user only) transaction.partialSign(wallet); // 4. Submit to network // The transaction already has Vybe's signature for fee payment const connection = new Connection('https://api.mainnet-beta.solana.com'); const signature = await connection.sendRawTransaction(transaction.serialize()); // 5. Confirm await connection.confirmTransaction(signature, 'confirmed'); return signature; } ``` *** ## Security Model Gasless mode is secure by design: | Aspect | How It Works | | ------------------------- | ------------------------------------------------ | | **User sovereignty** | User still signs the transaction | | **Key security** | Vybe never sees private keys | | **Transaction integrity** | Same swap instructions, just different fee payer | | **No custody** | Tokens go directly user → DEX → user | The only difference is who pays the ~0.000005 SOL network fee. *** ## Availability & Limits | Aspect | Details | | --------------------- | ------------------------------ | | **Plans** | Pro and Enterprise plans | | **Transaction types** | Swaps only | | **Rate limits** | Same as your plan tier | | **Fee cost** | Vybe absorbs the ~0.000005 SOL | *** ## Implementation Patterns ### Always Gasless For maximum user friendliness: ```javascript const ALWAYS_GASLESS = true; async function swap(params) { return executeSwap({ ...params, gasless: ALWAYS_GASLESS }); } ``` ### Smart Gasless (Check Balance First) For cost optimization: ```javascript async function smartGaslessSwap(wallet, params) { const balance = await connection.getBalance(wallet); const needsGasless = balance < 10000; // ~0.00001 SOL threshold return executeSwap({ ...params, gasless: needsGasless }); } ``` ### User Choice Let users decide: ```javascript function SwapForm({ onSwap }) { const [gasless, setGasless] = useState(false); const { balance } = useWalletBalance(); const insufficientSol = balance < 10000; return (
{/* ... other fields ... */}
); } ``` *** ## Next Steps * [Build Transaction](./build-transaction.md) - Add gasless to your swaps * [Pricing](../get-started/pricing.md) - Plans with gasless access * [Quick Start](../get-started/quick-start.md) - Get started with the API