Documentation Index
Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
Use this file to discover all available pages before exploring further.
SVM Gas Sponsorship lets you sponsor Solana (SVM) transaction fees for embedded wallet users. Use the dedicated signAndSendSponsoredTransaction function to explicitly send sponsored transactions.
SVM Gas Sponsorship is available exclusively for V3 MPC embedded wallets.
Overview
When you call signAndSendSponsoredTransaction, the SDK:
- Sends the transaction to Dynamic’s backend for sponsorship
- Replaces the fee payer with Dynamic’s sponsored account
- Signs the sponsored transaction with the user’s wallet
- Broadcasts to the network with
skipPreflight: true by default
If sponsorship fails for any reason, a SponsorTransactionError is thrown — there is no silent fallback.
- Go to the Dynamic Dashboard
- Navigate to Settings > Embedded Wallets
- Ensure Solana (SOL) is enabled in your chain configurations
- Toggle on SVM Gas Sponsorship
Usage
Use signAndSendSponsoredTransaction to explicitly send a sponsored transaction:
import { signAndSendSponsoredTransaction } from '@dynamic-labs-sdk/solana';
const sendSponsoredTx = async (walletAccount, transaction) => {
const { signature } = await signAndSendSponsoredTransaction({
transaction,
walletAccount,
});
console.log('Sponsored transaction sent:', signature);
};
signAndSendTransaction sends transactions without sponsorship. Use it when you don’t need gas sponsorship:
import { signAndSendTransaction } from '@dynamic-labs-sdk/solana';
const sendTx = async (walletAccount, transaction) => {
const { signature } = await signAndSendTransaction({
transaction,
walletAccount,
});
console.log('Transaction sent:', signature);
};
Send Options
You can pass SendOptions to override defaults. Sponsored transactions use skipPreflight: true by default, but you can override this:
const { signature } = await signAndSendSponsoredTransaction({
transaction,
walletAccount,
options: { skipPreflight: false },
});
Error Handling
Sponsorship failures throw a SponsorTransactionError. This error is thrown when:
- The sponsorship API cannot sponsor the transaction
- The wallet provider does not support sponsored transactions (e.g. external wallets)
import {
signAndSendSponsoredTransaction,
SponsorTransactionError,
} from '@dynamic-labs-sdk/solana';
const sendTransaction = async (walletAccount, transaction) => {
try {
const { signature } = await signAndSendSponsoredTransaction({
transaction,
walletAccount,
});
return { success: true, signature };
} catch (error) {
if (error instanceof SponsorTransactionError) {
return {
success: false,
error: 'Gas sponsorship failed',
};
}
return { success: false, error: error.message };
}
};
React
Use signAndSendSponsoredTransaction inside a button handler, with useWalletAccounts from @dynamic-labs-sdk/react-hooks to reactively get the embedded wallet:
import { signAndSendSponsoredTransaction, isSolanaWalletAccount, SponsorTransactionError } from '@dynamic-labs-sdk/solana';
import { useWalletAccounts } from '@dynamic-labs-sdk/react-hooks';
import { useState } from 'react';
import { Transaction, SystemProgram, PublicKey } from '@solana/web3.js';
function SponsoredSendButton({ recipientAddress }) {
const walletAccounts = useWalletAccounts();
const walletAccount = walletAccounts.find(isSolanaWalletAccount);
const [signature, setSignature] = useState('');
const [error, setError] = useState('');
const handleSend = async () => {
if (!walletAccount) return;
setError('');
try {
const transaction = new Transaction().add(
SystemProgram.transfer({
fromPubkey: new PublicKey(walletAccount.address),
toPubkey: new PublicKey(recipientAddress),
lamports: 1_000_000,
}),
);
const { signature } = await signAndSendSponsoredTransaction({ transaction, walletAccount });
setSignature(signature);
} catch (err) {
if (err instanceof SponsorTransactionError) {
setError('Gas sponsorship failed');
}
}
};
return (
<div>
<button onClick={handleSend} disabled={!walletAccount}>Send (Sponsored)</button>
{signature && <p>Signature: {signature.slice(0, 20)}...</p>}
{error && <p style={{ color: 'red' }}>{error}</p>}
</div>
);
}
Limitations
| Limitation | Details |
|---|
| Wallet type | Embedded wallets only (V3 MPC) |
| Transaction size | Maximum 2KB base64-encoded |
| Already-signed | Transactions with signatures are not sponsored |
| Batching | Each transaction sponsored individually |