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

# prepareWithdrawal

> Builds the unsigned transaction that withdraws from an Earn vault

## Function Signature

```typescript theme={"system"}
client.earn.prepareWithdrawal(params: {
  vaultId: string;
  ownerAddress: string;
  amount: string;
  receiverAddress?: string;
  traceContext?: TraceContext;
}): Promise<EarnSigningPayload>
```

## Description

Builds the unsigned transaction that withdraws `amount` from an [Earn](https://www.dynamic.xyz/docs/earn/overview.md) vault. Withdrawals redeem shares the wallet already holds, so they never carry an approval. The underlying asset is sent to `receiverAddress` when given, otherwise to `ownerAddress`.

The method only builds the payload. Execute it with `executeEarnTransaction`, or use `withdrawFromEarnVault` to prepare and execute in one call.

Available as `client.earn` on `DynamicEvmWalletClient` and `DynamicSvmWalletClient`.

## Parameters

### Required Parameters

* **`vaultId`** (`string`): The vault identifier from [`listVaults`](https://www.dynamic.xyz/docs/node/reference/earn/list-vaults).
* **`ownerAddress`** (`string`): The wallet address that owns the position.
* **`amount`** (`string`): How much of the vault's underlying asset to withdraw, in the asset's human-readable units (`'12.5'` USDC, not `'12500000'`). Needs a leading zero (`'0.01'`, not `'.01'`).

### Optional Parameters

* **`receiverAddress`** (`string`): The address that receives the withdrawn asset. Defaults to `ownerAddress`. For a Solana vault, omit it or set it to `ownerAddress`: Solana vaults always return tokens to the owner's own accounts.
* **`traceContext`** (`TraceContext`): Trace context forwarded to the Dynamic API.

## Returns

* **`Promise<EarnSigningPayload>`**: The unsigned signing payload to execute.

## Example

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

const evmClient = await authenticatedEvmClient();

const signingPayload = await evmClient.earn.prepareWithdrawal({
  vaultId: 'steakhouse-prime-usdc',
  ownerAddress: walletMetadata.accountAddress,
  amount: '12.5',
});

const { transactionHash } = await evmClient.executeEarnTransaction({
  signingPayload,
  walletMetadata,
  externalServerKeyShares,
  password: 'user-password',
  rpcUrl: 'https://mainnet.base.org',
});
```

## Error Handling

Fails with an HTTP 403 error when Earn is not enabled for your environment, or an HTTP 400 error when the amount exceeds the position or is otherwise invalid.

## See Also

* [Earn](https://www.dynamic.xyz/docs/node/earn.md)
* [withdrawFromEarnVault](https://www.dynamic.xyz/docs/node/reference/evm/withdraw-from-earn-vault.md)
* [executeEarnTransaction](https://www.dynamic.xyz/docs/node/reference/evm/execute-earn-transaction.md)


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