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

# prepareDeposit

> Builds the unsigned transaction that deposits into an Earn vault

## Function Signature

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

## Description

Builds the unsigned transaction that deposits `amount` into an [Earn](https://www.dynamic.xyz/docs/earn/overview.md) vault. On EVM the payload also carries an `evmApproval` when the vault's ERC-20 allowance is short. On Solana the payload carries an ordered `transactions` sequence instead of a single transaction. Shares are credited to `receiverAddress` when given, otherwise to `ownerAddress`.

The method only builds the payload. Execute it with [`executeEarnTransaction`](https://www.dynamic.xyz/docs/node/reference/evm/execute-earn-transaction), or use `depositToEarnVault` 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 funding the deposit.
* **`amount`** (`string`): How much of the vault's underlying asset to deposit, 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 vault shares. Defaults to `ownerAddress`. For a Solana vault, omit it or set it to `ownerAddress`: Solana vaults always credit shares to the depositor'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.prepareDeposit({
  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 or address is invalid.

## See Also

* [Earn](https://www.dynamic.xyz/docs/node/earn.md)
* [depositToEarnVault](https://www.dynamic.xyz/docs/node/reference/evm/deposit-to-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.