Skip to main content

Function Signature

Description

Signs a Solana transaction on behalf of a user who has granted delegation permission. This function supports both legacy Transaction and VersionedTransaction types from @solana/web3.js. The function returns the signed transaction object with the signature added, ready to be sent to the Solana network. For gasless transactions where a separate fee payer covers gas, set transaction.feePayer to the fee payer’s public key and pass signerAddress to identify the actual signer. Pass sponsor: true and userId to use Dynamic-funded gas sponsorship instead of a separate fee payer. The SDK sends the transaction to the sponsorship endpoint, swaps the fee payer for a sponsor, and signs as the user.

Parameters

Required Parameters

  • client (DelegatedSvmWalletClient) - The delegated client instance created with createDelegatedSvmWalletClient()
  • walletId (string) - The wallet ID from the delegation webhook
  • walletApiKey (string) - The wallet-specific API key from the delegation webhook
  • keyShare (ServerKeyShare | ServerKeyShare[]) - The server key share(s) from the delegation webhook
  • transaction (VersionedTransaction | Transaction) - The Solana transaction to sign

Optional Parameters

  • shareSetId (string) - The shareSetId from the wallet.delegation.created webhook payload. If omitted, the server resolves the correct share set by walletId and share-set type.
  • signerAddress (string) - The address that should sign the transaction. If not provided, defaults to the first signer (VersionedTransaction) or fee payer (Transaction). Use this for gasless transactions where a separate fee payer pays the fees.
  • derivationPath (Uint32Array) - Custom derivation path for the signing key.
  • chainId (string) - Chain ID for the signing context.
  • context (SignMessageContext) - Additional context for the signing operation.
  • sponsor (boolean) - When true, Dynamic funds the transaction fee. Defaults to false.
  • userId (string) - Required when sponsor is true. UUID of the end user who owns the wallet.
  • traceContext (TraceContext) - Distributed tracing context for observability.

Returns

Promise<VersionedTransaction | Transaction> - The signed transaction with the signature added

Example

Basic Transaction Signing

Gasless Transaction with Separate Fee Payer

When a separate wallet pays the gas fees, set feePayer to the sponsor and pass signerAddress so the delegated wallet signs only the instruction:

Dynamic Sponsorship

Pass sponsor: true and the wallet owner’s userId to have Dynamic fund the transaction fee. signerAddress is required so the delegated wallet signs as the user, not as the sponsor fee payer.

Complete Transaction Flow

Versioned Transaction

Type Definitions

Error Handling

The function throws an error if:
  • Any required parameter is missing or invalid
  • The transaction is malformed
  • The delegation credentials are expired or revoked
  • The MPC signing operation fails
  • Network communication with Dynamic services fails

Security Considerations

  • Transaction Validation: Always validate transaction contents before signing
  • Recipient Verification: Verify recipient addresses to prevent sending to wrong addresses
  • Amount Validation: Implement checks for transaction amounts to prevent accidental large transfers
  • Audit Logging: Log all transaction signing operations for security auditing
  • Credential Storage: Never log or expose wallet API keys or key shares
  • Rate Limiting: Implement rate limiting to prevent abuse

Common Use Cases

Automated Payments

Batch Transactions

Last modified on August 18, 2026