Skip to main content

Function Signature

Description

Sends an unsigned Solana transaction to Dynamic’s gas sponsorship endpoint (/solana/sponsorTransaction), which replaces the fee payer with the sponsor’s address. The returned transaction has the sponsor as fee payer and should be passed to signTransaction() instead of the original. Gas sponsorship must be enabled for your environment in the Dynamic dashboard before calling this method.
For most use cases, pass sponsor: true to signTransaction() instead of calling sponsorTransaction() directly. Use this method when you need to inspect or modify the sponsored transaction before signing.

Parameters

Required Parameters

  • transaction (VersionedTransaction | Transaction) - The unsigned Solana transaction. Supports both legacy Transaction and VersionedTransaction.

Optional Parameters

  • traceContext (TraceContext) - Distributed tracing context for observability.

Returns

Promise<VersionedTransaction | Transaction> - The sponsored transaction with the gas sponsor set as fee payer. Returns the same transaction type that was passed in.

Example

Error Handling

The method throws when sponsorship is unavailable or not enabled:
Last modified on June 23, 2026