Skip to main content

Introduction

SVM Gas Sponsorship is Dynamic’s built-in feature that automatically sponsors Solana (SVM) transaction fees for your users. When enabled, Dynamic handles all the complexity of fee sponsorship behind the scenes, allowing your users to transact without needing SOL for gas fees. When enabled, Dynamic automatically replaces the fee payer in Solana transactions with a sponsored account, so your users don’t need SOL for gas.
SVM Gas Sponsorship is available exclusively for V3 MPC embedded wallets. It works automatically once enabled - no code changes required.

How It Differs From Manual Approaches

FeatureSVM Gas SponsorshipManual Fee Payer
SetupToggle in dashboardServer-side wallet management
Code changesNone requiredAPI routes needed
Fee payer managementHandled by DynamicYou manage the wallet
Best forEmbedded walletsCustom implementations

Getting Started

Prerequisites

Before enabling SVM Gas Sponsorship, ensure you have:
  1. Solana enabled in your embedded wallet chain configurations
  2. V3 MPC wallets configured (Settings > Embedded Wallets > Wallet Version)
  3. A Live environment (sponsorship is available in both Sandbox and Live)

Enabling SVM Gas Sponsorship

  1. Go to the Dynamic Dashboard
  2. Navigate to Settings > Embedded Wallets
  3. Ensure Solana (SOL) is enabled in your chain configurations
  4. Toggle on SVM Gas Sponsorship
The SVM Gas Sponsorship toggle only appears when Solana is enabled in your chain configurations and you’re using V3 MPC wallets.

How It Works

Once enabled, gas sponsorship is applied automatically to all transactions from your users’ embedded wallets:
User initiates transaction

SDK detects embedded wallet + sponsorship enabled

Transaction serialized and sent to Dynamic backend

Dynamic replaces fee payer with sponsored account

Sponsored transaction returned to client

User signs the sponsored transaction

Transaction broadcast to Solana network

Technical Flow

When your application calls transaction methods on an embedded Solana wallet:
  1. Transaction Creation: Your app creates a standard Solana transaction
  2. Automatic Sponsorship: The SDK intercepts the transaction before signing
  3. Backend Processing: The transaction is sent to Dynamic’s backend
  4. Sponsorship Processing: Dynamic sponsors the transaction
  5. Fee Payer Replacement: The transaction’s fee payer is replaced with Dynamic’s sponsored account
  6. User Signing: The sponsored transaction is returned for the user to sign
  7. Broadcast: The fully signed transaction is sent to the Solana network
All of this happens transparently - your code simply calls the standard signing methods:
import { useDynamicContext } from "@dynamic-labs/sdk-react-core";
import { isSolanaWallet } from "@dynamic-labs/solana";
import { Transaction, PublicKey, SystemProgram, LAMPORTS_PER_SOL } from "@solana/web3.js";

function SendTransaction() {
  const { primaryWallet } = useDynamicContext();

  const sendSOL = async () => {
    if (!primaryWallet || !isSolanaWallet(primaryWallet)) return;

    const connection = await primaryWallet.getConnection();
    const signer = await primaryWallet.getSigner();

    // Create a standard transaction - sponsorship is handled automatically
    const transaction = new Transaction().add(
      SystemProgram.transfer({
        fromPubkey: new PublicKey(primaryWallet.address),
        toPubkey: new PublicKey("recipient_address_here"),
        lamports: 0.01 * LAMPORTS_PER_SOL,
      })
    );

    const { blockhash } = await connection.getLatestBlockhash();
    transaction.recentBlockhash = blockhash;
    transaction.feePayer = new PublicKey(primaryWallet.address);

    // Sign and send - gas sponsorship is applied automatically
    const { signature } = await signer.signAndSendTransaction(transaction);
    console.log("Transaction sent:", signature);
  };

  return <Button title="Send SOL (Gasless)" onPress={sendSOL} />;
}

Supported Transaction Types

SVM Gas Sponsorship supports both Solana transaction formats:
import {
  VersionedTransaction,
  TransactionMessage,
  SystemProgram,
  PublicKey
} from "@solana/web3.js";

const sendVersionedTransaction = async () => {
  if (!primaryWallet || !isSolanaWallet(primaryWallet)) return;

  const connection = await primaryWallet.getConnection();
  const signer = await primaryWallet.getSigner();

  const { blockhash } = await connection.getLatestBlockhash();

  const instructions = [
    SystemProgram.transfer({
      fromPubkey: new PublicKey(primaryWallet.address),
      toPubkey: new PublicKey("recipient_address_here"),
      lamports: 10000,
    }),
  ];

  const messageV0 = new TransactionMessage({
    payerKey: new PublicKey(primaryWallet.address),
    recentBlockhash: blockhash,
    instructions,
  }).compileToV0Message();

  const transaction = new VersionedTransaction(messageV0);

  // Sponsorship is applied automatically
  const { signature } = await signer.signAndSendTransaction(transaction);
  console.log("Versioned transaction sent:", signature);
};

Legacy Transactions

Legacy transactions are also supported, though versioned transactions are recommended for new implementations.

Configuration

Environment-Level Settings

SVM Gas Sponsorship is configured per environment (Sandbox or Live). Each environment maintains its own sponsorship settings:
  • Sandbox: Use for development and testing
  • Live: Use for production

Checking Sponsorship Status

You can programmatically check if gas sponsorship is enabled:
import { useDynamicContext } from "@dynamic-labs/sdk-react-core";

function CheckSponsorship() {
  const { sdkHasLoaded, projectSettings } = useDynamicContext();

  if (!sdkHasLoaded) return <Text>Loading...</Text>;

  const sponsorshipEnabled =
    projectSettings?.sdk?.embeddedWallets?.svmGasSponsorshipEnabled;

  return (
    <Text>
      SVM Gas Sponsorship: {sponsorshipEnabled ? "Enabled" : "Disabled"}
    </Text>
  );
}

Limitations

Wallet Requirements

  • Embedded wallets only: Sponsorship only works with Dynamic’s MPC embedded wallets
  • V3 wallets required: Must be using V3 MPC wallet configuration
  • Not for external wallets: External wallets (Phantom, Solflare, etc.) are not supported

Transaction Constraints

  • Transaction size: Maximum 2KB for the base64-encoded transaction
  • Already-signed transactions: Transactions that are already signed will not be sponsored
  • Single transaction: Each transaction is sponsored individually (no batching)

Sponsorship Policies

Dynamic may enforce sponsorship policies that could reject certain transactions. If a transaction cannot be sponsored, the SDK will fall back to using the original transaction, which requires the user to have SOL for gas fees.
When sponsorship fails, the transaction will proceed without sponsorship. Ensure your UX handles cases where users may need SOL for gas fees as a fallback.

Security Considerations

Transaction Integrity

  • Transactions are validated on Dynamic’s backend before sponsorship
  • Base64 encoding is verified to prevent injection attacks
  • Transactions are parsed and validated as legitimate Solana transactions
  • The sponsored transaction only modifies the fee payer - your transaction logic remains unchanged

Authentication

All sponsorship requests require:
  • Valid JWT token from an authenticated SDK user
  • Correct environment ID
  • Active embedded wallet session

Rate Limiting

Sponsorship requests are subject to rate limiting based on your Dynamic plan. Monitor your usage in the dashboard to ensure adequate capacity for your application’s needs.

Troubleshooting

Sponsorship Not Working

  1. Check wallet type: Verify you’re using a V3 MPC embedded wallet
  2. Check settings: Ensure SVM Gas Sponsorship is enabled in the dashboard
  3. Check Solana configuration: Confirm Solana is enabled in chain configurations
  4. Check authentication: Ensure the user is properly authenticated

Transaction Failures

If transactions fail after sponsorship:
  1. Insufficient SOL for value transfer: Users still need SOL for the actual transfer amount (not fees)
  2. Invalid instructions: Ensure your transaction instructions are valid
  3. Network congestion: Retry during lower congestion periods

Fallback Behavior

When sponsorship fails, check the console for error messages. Common reasons include:
  • Feature not enabled for the environment
  • Transaction already has signatures
  • Transaction exceeds size limits
  • Backend configuration issues

Best Practices

User Experience

  1. Don’t assume sponsorship: Build your UI to handle cases where sponsorship might not be available
  2. Show transaction status: Provide feedback during the sponsorship and signing process
  3. Handle errors gracefully: Inform users if they need SOL as a fallback

Development

  1. Test in Sandbox first: Verify sponsorship works in your Sandbox environment before going live
  2. Monitor usage: Keep an eye on sponsorship usage in your dashboard
  3. Use versioned transactions: They’re more efficient and recommended for new development

API Reference

For advanced use cases, you can interact with the sponsorship API directly:
POST /sdk/{environmentId}/solana/sponsorTransaction
Request:
{
  "transaction": "base64_encoded_unsigned_transaction"
}
Response:
{
  "transaction": "base64_encoded_sponsored_transaction"
}
Direct API usage is typically not needed - the SDK handles sponsorship automatically. Use this only for custom implementations.

Next Steps