> ## 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.

# executeEarnTransaction

> Executes an Earn signing payload's Solana transaction sequence with an SVM wallet

## Function Signature

```typescript theme={"system"}
executeEarnTransaction(params: {
  signingPayload: EarnSigningPayload;
  walletMetadata: WalletMetadata;
  password?: string;
  externalServerKeyShares?: ServerKeyShare[];
  sponsored?: boolean;
  rpcUrl?: string;
  chainId?: string;
  context?: SignMessageContext;
  onStepChange?: (step: EarnExecutionStep) => void;
  onTransactionStepChange?: (step: EarnTransactionStepProgress) => void;
}): Promise<EarnTransactionResult>
```

## Description

Executes an [Earn](https://www.dynamic.xyz/docs/earn/overview.md) signing payload returned by the `client.earn.prepare*` methods. Solana payloads carry an ordered `transactions` sequence, so the method signs and sends each transaction one at a time, because a later transaction can depend on the state an earlier one wrote. Each step's transaction was built against a fixed blockhash and carries an `expiryBlockHeight`, so execute promptly after preparing.

For a single call that prepares and executes, use [`depositToEarnVault`](https://www.dynamic.xyz/docs/node/reference/svm/deposit-to-earn-vault), [`withdrawFromEarnVault`](https://www.dynamic.xyz/docs/node/reference/svm/withdraw-from-earn-vault), or [`claimEarnRewards`](https://www.dynamic.xyz/docs/node/reference/svm/claim-earn-rewards).

## Parameters

### Required Parameters

* **`signingPayload`** (`EarnSigningPayload`): The payload from [`prepareDeposit`](https://www.dynamic.xyz/docs/node/reference/earn/prepare-deposit), [`prepareWithdrawal`](https://www.dynamic.xyz/docs/node/reference/earn/prepare-withdrawal), or [`prepareClaimRewards`](https://www.dynamic.xyz/docs/node/reference/earn/prepare-claim-rewards).
* **`walletMetadata`** ([`WalletMetadata`](https://www.dynamic.xyz/docs/node/reference/types/wallet-metadata)): Non-sensitive wallet metadata persisted from `createWalletAccount()` / `importPrivateKey()`. Its `chainName` must be `'SVM'`.

### Optional Parameters

* **`password`** (`string`): Required if the wallet was created with `backUpToDynamic: true`. Used for backup decryption when `externalServerKeyShares` is not provided.
* **`externalServerKeyShares`** ([`ServerKeyShare[]`](https://www.dynamic.xyz/docs/node/reference/types/server-key-share)): Caller-supplied plaintext shares.
* **`sponsored`** (`boolean`): When `true`, sponsors every transaction in the sequence through Dynamic gas sponsorship. Vault transactions are built with the owner as fee payer, unlike the browser SDK which sponsors automatically. See [SVM Gas Sponsorship](https://www.dynamic.xyz/docs/node/wallets/server-wallets/gas-sponsorship-svm.md).
* **`rpcUrl`** (`string`): Solana RPC endpoint. Defaults to the public cluster for the payload's `chainId` (101 mainnet, 103 devnet).
* **`chainId`** (`string`): The Solana chain identifier.
* **`context`** (`SignMessageContext`): Signing context forwarded to the transaction signer.
* **`onStepChange`** (`(step: EarnExecutionStep) => void`): Reports `transaction` once per transaction in the sequence.
* **`onTransactionStepChange`** (`(step: EarnTransactionStepProgress) => void`): Invoked as each transaction is about to be signed, with its `ordinal`, the `total`, and an optional `label`.

## Returns

* **`Promise<EarnTransactionResult>`**: An object with `transactionHash`, the signature of the last transaction in the sequence.

## Example

```typescript theme={"system"}
import { authenticatedSvmClient } from './client';

const svmClient = await authenticatedSvmClient();

const signingPayload = await svmClient.earn.prepareDeposit({
  vaultId: 'kamino-usdc-steakhouse',
  ownerAddress: walletMetadata.accountAddress,
  amount: '12.5',
});

const { transactionHash } = await svmClient.executeEarnTransaction({
  signingPayload,
  walletMetadata,
  externalServerKeyShares,
  password: 'user-password',
  onTransactionStepChange: ({ ordinal, total }) =>
    console.log(`Sent transaction ${ordinal + 1} of ${total}`),
});
```

## Error Handling

Throws when `walletMetadata.chainName` is not `'SVM'` or when the payload carries no `transactions` sequence. When a step fails after earlier transactions confirmed, the method throws an `EarnSolanaStepError` whose `ordinal` reports which step failed, so the action may be partially applied. Its `code` is one of `yield_step_expired`, `yield_step_failed`, `yield_step_send_failed`, or `yield_step_confirmation_unknown`.

## See Also

* [Earn](https://www.dynamic.xyz/docs/node/earn.md)
* [depositToEarnVault](https://www.dynamic.xyz/docs/node/reference/svm/deposit-to-earn-vault.md)
* [withdrawFromEarnVault](https://www.dynamic.xyz/docs/node/reference/svm/withdraw-from-earn-vault.md)
* [claimEarnRewards](https://www.dynamic.xyz/docs/node/reference/svm/claim-earn-rewards.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.