> ## Documentation Index
> Fetch the complete documentation index at: https://developers.paxoslabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# prepareDepositTxData

> Prepare transaction data for a standard deposit after approval

Prepares the transaction data for executing a deposit after the user has approved token spending. Use this for the approval flow or when allowance is already sufficient.

<Info>
  For most use cases, use the [unified deposit
  workflow](/v0.5.2/intro/products/earn/developers/api/deposit-workflow) which
  handles authorization automatically.
</Info>

## Import

```ts theme={null}
import { prepareDepositTxData } from '@paxoslabs/amplify-sdk'
```

## Usage

```ts theme={null}
// First discover the vault
const [vault] = await getVaultsByConfig({
  yieldType: YieldType.CORE,
  chainId: 1,
  depositAssetAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
})

const txData = await prepareDepositTxData({
  vaultName: vault.name,
  depositAsset: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
  depositAmount: '1000',
  to: '0x...',
  chainId: 1,
})
```

## Parameters

| Parameter         | Type      | Required | Description                                                             |
| ----------------- | --------- | -------- | ----------------------------------------------------------------------- |
| `vaultName`       | `string`  | Yes      | Account name from `AmplifyVault.name` (e.g. from `getVaultsByConfig()`) |
| `depositAsset`    | `Address` | Yes      | Token contract address to deposit                                       |
| `depositAmount`   | `string`  | Yes      | Amount to deposit as decimal string (e.g., `"100.50"`)                  |
| `to`              | `Address` | Yes      | Recipient address for account shares                                    |
| `chainId`         | `number`  | Yes      | Blockchain network ID                                                   |
| `slippage`        | `number`  | No       | Slippage tolerance in basis points (default: 50 = 0.5%)                 |
| `distributorCode` | `string`  | No       | Distributor code for fee attribution                                    |

```ts theme={null}
interface PrepareDepositTxDataParams {
  /** Vault name (from AmplifyVault.name) */
  vaultName: string
  /** Token contract address to deposit */
  depositAsset: Address
  /** Amount to deposit as decimal string (e.g., "100.25") */
  depositAmount: string
  /** Recipient address for vault shares */
  to: Address
  /** Blockchain network ID */
  chainId: number
  /** Slippage in basis points (default: 50 = 0.5%) */
  slippage?: number
  /** Distributor code for fee attribution */
  distributorCode?: string
}
```

## Return Type

Returns a discriminated union based on the account's configuration. Use `depositType` or the type guards `isStandardDeposit()` / `isKytDeposit()` to narrow.

<Tabs>
  <Tab title="Type Definition">
    ```ts theme={null}
    type DepositTxData = StandardDepositTxData | KytDepositTxData;

    interface StandardDepositTxData {
      depositType: "standard";
      abi: Abi;
      address: Address;
      functionName: "deposit";
      args: readonly [Address, bigint, bigint, Address, Hex];
      chainId: number;
    }

    interface KytDepositTxData {
      depositType: "kyt";
      abi: Abi;
      address: Address;
      functionName: "deposit";
      args: readonly [Address, bigint, bigint, Address, Hex, Attestation];
      chainId: number;
    }
    ```
  </Tab>

  <Tab title="Standard Example">
    ```ts theme={null}
    {
      depositType: "standard",
      abi: [...], // DistributorCodeDepositorV0 ABI
      address: "0x1234...5678",
      functionName: "deposit",
      args: [
        "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // depositAsset
        1000000000n,    // depositAmount (in base units)
        995000000n,     // minimumMint (with slippage applied)
        "0xUser...Addr", // to (recipient)
        "0x",           // distributorCode (hex-encoded)
      ],
      chainId: 1,
    }
    ```
  </Tab>

  <Tab title="KYT Example">
    ```ts theme={null}
    {
      depositType: "kyt",
      abi: [...], // DistributorCodeDepositorV1 ABI
      address: "0x1234...5678",
      functionName: "deposit",
      args: [
        "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // depositAsset
        1000000000n,    // depositAmount
        995000000n,     // minimumMint
        "0xUser...Addr", // to
        "0x",           // distributorCode
        { uuid: "", expiration: 0n, attester: "0x0...0", signature: "0x" },
      ],
      chainId: 1,
    }
    ```
  </Tab>
</Tabs>

<Info>
  KYT routing is automatic — the SDK checks `vault.enterpriseConfig.predicatePolicyId` and returns the correct variant. Most consumers can ignore `depositType` and pass the result directly to `writeContract`.
</Info>

## Examples

<Tabs>
  <Tab title="Privy">
    ```tsx theme={null}
    import { encodeFunctionData } from "viem";
    import { usePrivy } from "@privy-io/react-auth";
    import {
      getVaultsByConfig,
      prepareDepositTxData,
      YieldType,
    } from "@paxoslabs/amplify-sdk";

    const { sendTransaction } = usePrivy();

    const USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";

    // Discover vault
    const [vault] = await getVaultsByConfig({
      yieldType: YieldType.CORE,
      chainId: 1,
      depositAssetAddress: USDC,
    });

    // After approval is confirmed...
    const txData = await prepareDepositTxData({
      vaultName: vault.name,
      depositAsset: USDC,
      depositAmount: "1000",
      to: userAddress,
      chainId: 1,
    });

    await sendTransaction({
      chainId: txData.chainId,
      to: txData.address,
      data: encodeFunctionData({
        abi: txData.abi,
        functionName: txData.functionName,
        args: txData.args,
      }),
    });
    ```
  </Tab>

  <Tab title="Wagmi">
    ```tsx theme={null}
    import { useWriteContract } from "wagmi";
    import {
      getVaultsByConfig,
      prepareDepositTxData,
      YieldType,
    } from "@paxoslabs/amplify-sdk";

    const { writeContractAsync } = useWriteContract();
    const USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";

    // Discover vault
    const [vault] = await getVaultsByConfig({
      yieldType: YieldType.CORE,
      chainId: chainId,
      depositAssetAddress: USDC,
    });

    // After approval is confirmed...
    const txData = await prepareDepositTxData({
      vaultName: vault.name,
      depositAsset: USDC,
      depositAmount: "1000",
      to: address,
      chainId: chainId,
    });

    await writeContractAsync({
      ...txData,
      account: address,
    });
    ```
  </Tab>

  <Tab title="Viem">
    ```ts theme={null}
    import { createWalletClient, custom } from "viem";
    import { mainnet } from "viem/chains";
    import {
      getVaultsByConfig,
      prepareDepositTxData,
      YieldType,
    } from "@paxoslabs/amplify-sdk";

    const client = createWalletClient({
      account,
      chain: mainnet,
      transport: custom(window.ethereum),
    });

    const USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";

    const [vault] = await getVaultsByConfig({
      yieldType: YieldType.CORE,
      chainId: mainnet.id,
      depositAssetAddress: USDC,
    });

    const txData = await prepareDepositTxData({
      vaultName: vault.name,
      depositAsset: USDC,
      depositAmount: "1000",
      to: account,
      chainId: mainnet.id,
    });

    await client.writeContract({
      ...txData,
      account,
    });
    ```
  </Tab>
</Tabs>

## Slippage Configuration

The default slippage is 50 basis points (0.5%). Adjust for volatile conditions:

```ts theme={null}
// 1% slippage for higher tolerance
const txData = await prepareDepositTxData({
  ...params,
  slippage: 100,
})

// 0.1% slippage for tighter tolerance
const txData = await prepareDepositTxData({
  ...params,
  slippage: 10,
})
```

## Error Handling

| Error Message Pattern        | Description                    | Resolution                                           |
| ---------------------------- | ------------------------------ | ---------------------------------------------------- |
| `"SDK not initialized"`      | SDK not initialized            | Call `initAmplifySDK()` first                        |
| `"Vault not found"`          | No account matches `vaultName` | Verify account name via `getVaultsByConfig()`        |
| `"Asset metadata not found"` | Token not in asset cache       | Verify token is supported via `getSupportedAssets()` |

## Related

* [Deposit Workflow](/v0.5.2/intro/products/earn/developers/api/deposit-workflow) - Unified deposit API
* [getVaultsByConfig](/v0.5.2/intro/products/earn/developers/api/getVaultsByConfig) - Discover account names
* [prepareDepositWithPermitTxData](/v0.5.2/intro/products/earn/developers/api/prepareDepositWithPermitTxData) - Permit-based deposits
* [Deposits Guide](/v0.5.2/intro/products/earn/developers/guides/deposits) - Complete examples
