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

# prepareWithdrawal

> Prepare withdrawal transaction data via the unified withdrawal wrapper

Prepare transaction data for submitting a withdrawal order through the unified withdrawal wrapper.

`prepareWithdrawal()` is the recommended execution helper for most integrations.

<Warning>
  `prepareWithdrawal()` does not check or enforce allowance. Run
  [prepareWithdrawalAuthorization](/v0.4.2/intro/products/earn/developers/api/prepareWithdrawalAuthorization) first if
  you need approval routing.
</Warning>

## Import

```typescript theme={null}
import { prepareWithdrawal } from "@paxoslabs/amplify-sdk";
```

## Usage

```typescript theme={null}
const txData = await prepareWithdrawal({
  yieldType: "CORE",
  wantAsset: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
  withdrawAmount: "1.0", // Vault shares to offer
  userAddress: "0x1234...",
  chainId: 1,
});

const hash = await walletClient.writeContract(txData);
```

## Parameters

| Parameter        | Type        | Required | Description                               |
| ---------------- | ----------- | -------- | ----------------------------------------- |
| `yieldType`      | `YieldType` | Yes      | Yield strategy (CORE, TREASURY, FRONTIER) |
| `wantAsset`      | `Address`   | Yes      | Token address user wants to receive       |
| `withdrawAmount` | `string`    | Yes      | Vault shares to withdraw (decimal string) |
| `userAddress`    | `Address`   | Yes      | User wallet address                       |
| `chainId`        | `ChainId`   | Yes      | Chain ID                                  |

## Return Type

Returns `PrepareWithdrawalResult` (alias of `WithdrawOrderTxData`), ready for `writeContract`.

## Recommended Flow

<Steps>
  <Step title="Check Authorization">
    ```typescript theme={null}
    const auth = await prepareWithdrawalAuthorization({
      yieldType: "CORE",
      wantAsset: USDC_ADDRESS,
      withdrawAmount: "1.0",
      userAddress,
      chainId: 1,
    });

    if (isWithdrawApprovalAuth(auth)) {
      await walletClient.writeContract(auth.txData);
    }
    ```
  </Step>

  <Step title="Prepare Withdrawal Tx">
    ```typescript theme={null}
    const withdrawTx = await prepareWithdrawal({
      yieldType: "CORE",
      wantAsset: USDC_ADDRESS,
      withdrawAmount: "1.0",
      userAddress,
      chainId: 1,
    });
    ```
  </Step>

  <Step title="Submit Transaction">
    ```typescript theme={null}
    await walletClient.writeContract(withdrawTx);
    ```
  </Step>
</Steps>

## Related

* [prepareWithdrawalAuthorization](/v0.4.2/intro/products/earn/developers/api/prepareWithdrawalAuthorization) - Authorization routing
* [prepareWithdrawOrderTxData](/v0.4.2/intro/products/earn/developers/api/prepareWithdrawOrderTxData) - Low-level withdraw order builder
* [prepareApproveWithdrawOrderTxData](/v0.4.2/intro/products/earn/developers/api/prepareApproveWithdrawOrderTxData) - Manual vault share approval
