> ## Documentation Index
> Fetch the complete documentation index at: https://www.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# delegatedSponsorTransaction

> Swap the fee payer for a Dynamic-funded sponsor on a delegated SVM transaction.

`delegatedSponsorTransaction` sends an unsigned Solana transaction to Dynamic's gas sponsorship endpoint and returns a `VersionedTransaction` with the sponsor as fee payer. Pass the result to [`delegatedSignTransaction`](/docs/node/reference/svm/delegated-sign-transaction) with an explicit `signerAddress` so the delegated wallet signs as the user, not as the new fee payer.

<Note>
  For most cases, pass `sponsor: true` to [`delegatedSignTransaction`](/docs/node/reference/svm/delegated-sign-transaction) instead of calling this method directly.
</Note>

## Function signature

```typescript theme={"system"}
delegatedSponsorTransaction(
  client: DelegatedSvmWalletClient,
  params: {
    transaction: VersionedTransaction | Transaction;
    userId: string;
    traceContext?: TraceContext;
  }
): Promise<VersionedTransaction>
```

## Parameters

| Parameter      | Type                                  | Description                                                                                                             |
| -------------- | ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `client`       | `DelegatedSvmWalletClient`            | The delegated client from [`createDelegatedSvmWalletClient()`](/docs/node/reference/svm/create-delegated-svm-wallet-client). |
| `transaction`  | `VersionedTransaction \| Transaction` | The unsigned transaction. Its fee payer should be the delegated wallet's address.                                       |
| `userId`       | `string`                              | UUID of the end user who owns the wallet.                                                                               |
| `traceContext` | `TraceContext` (optional)             | Distributed tracing context.                                                                                            |

## Returns

`Promise<VersionedTransaction>` — the sponsored transaction, always returned as a `VersionedTransaction`.

## Example

```typescript theme={"system"}
import {
  createDelegatedSvmWalletClient,
  delegatedSponsorTransaction,
  delegatedSignTransaction
} from '@dynamic-labs-wallet/node-svm';
import { Connection, Transaction, SystemProgram, PublicKey } from '@solana/web3.js';

const delegatedClient = createDelegatedSvmWalletClient({
  environmentId: process.env.DYNAMIC_ENVIRONMENT_ID,
  apiKey: process.env.DYNAMIC_SERVER_API_KEY,
});

const connection = new Connection(process.env.SOLANA_RPC_URL ?? 'https://api.mainnet-beta.solana.com');
const { blockhash } = await connection.getLatestBlockhash();

const endUser = { id: 'user-uuid' };
const recipientAddress = 'RecipientPublicKey';
// Replace with the decrypted delegation payload from your webhook handler
const credentials = {
  walletId: 'wallet-id',
  walletApiKey: 'wallet-api-key',
  keyShare: 'encrypted-key-share',
  publicKey: 'SenderPublicKey',
};

const sender = new PublicKey(credentials.publicKey);

const transaction = new Transaction().add(
  SystemProgram.transfer({
    fromPubkey: sender,
    toPubkey: new PublicKey(recipientAddress),
    lamports: 1000000,
  })
);

transaction.recentBlockhash = blockhash;
transaction.feePayer = sender;

const sponsoredTx = await delegatedSponsorTransaction(delegatedClient, {
  transaction,
  userId: endUser.id,
});

const signedTx = await delegatedSignTransaction(delegatedClient, {
  walletId: credentials.walletId,
  walletApiKey: credentials.walletApiKey,
  keyShare: credentials.keyShare,
  transaction: sponsoredTx,
  signerAddress: sender.toString(),
});
```

## Related

* [`delegatedSignTransaction`](/docs/node/reference/svm/delegated-sign-transaction) — sign the sponsored transaction
* [SVM Gas Sponsorship](/docs/node/wallets/server-wallets/gas-sponsorship-svm) — full guide
