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

# Withdraw

> Withdraw funds from your Mini App Wallet to Lemon Wallet.

## Usage

```typescript theme={null}
const result = await withdraw({
  amount: '50',
  tokenName: 'USDC',
  chainId: ChainId.POLYGON,
});
```

## Parameters

```typescript theme={null}
type WithdrawInput {
  amount: string;
  tokenName: string;
  chainId: ChainId;
}
```

<ParamField body="amount" type="string" required>
  The amount to withdraw.
</ParamField>

<ParamField body="tokenName" type="string" required>
  The tokenName name (e.g., 'USDC', 'USDT', 'ETH').
</ParamField>

<ParamField body="chainId" type="ChainId" required>
  The chain id to use for the withdrawal.
</ParamField>

## Returns

<CodeGroup>
  ```typescript WithdrawResponse theme={null}
  type WithdrawResponse = {
    result: TransactionResult.SUCCESS | TransactionResult.PENDING;
    data: {
      txHash: string;
    };
  } | {
    result: TransactionResult.FAILED;
    error: MiniAppError;
  } | {
    result: TransactionResult.CANCELLED;
  }
  ```

  ```typescript SUCCESS icon="check" theme={null}
  {
    result: 'SUCCESS',
    data: {
      txHash: '0x1234567890123456789012345678901234567890'
    }
  }
  ```

  ```typescript FAILED icon="ban" theme={null}
  {
    result: 'FAILED',
    error: {
      message: 'Insufficient balance',
      code: 'INSUFFICIENT_BALANCE'
    }
  }
  ```

  ```typescript CANCELLED icon="user-minus" theme={null}
  {
    result: 'CANCELLED',
  }
  ```

  ```typescript PENDING icon="clock" theme={null}
  {
    result: 'PENDING',
    data: {
      txHash: '0x1234567890123456789012345678901234567890'
    }
  }
  ```
</CodeGroup>

<ResponseField name="result" type="TransactionResult">
  The result of the withdrawal attempt.

  * `SUCCESS`: The withdrawal was successful.
  * `FAILED`: The withdrawal failed.
  * `CANCELLED`: The withdrawal was cancelled by the user.
  * `PENDING`: The withdrawal is pending confirmation.
</ResponseField>

<ResponseField name="data" type="object">
  Contains the transaction hash of the withdrawal transaction. Only present when the result is `SUCCESS` or `PENDING`.

  * `txHash`: The transaction hash.
</ResponseField>

<ResponseField name="error" type="MiniAppError">
  Contains the error information when the withdrawal fails. Only present when the result is `FAILED`.

  * `message`: The error message.
  * `code`: The error code.
</ResponseField>

## Demo

<div className="w-screen px-0 relative left-1/2 right-1/2 -mx-[50vw]">
  <video autoPlay muted loop playsInline className="w-full aspect-video rounded-xl" src="https://mintcdn.com/lemoncash/V3w-aDpCopaji2Ja/assets/videos/demo-withdraw.mp4?fit=max&auto=format&n=V3w-aDpCopaji2Ja&q=85&s=45e9da6090cc8dcfe8456676189df374" data-path="assets/videos/demo-withdraw.mp4" />
</div>

## Related Functions

<CardGroup cols={2}>
  <Card title="Deposit" icon="arrow-down-right" href="/functions/deposit">
    Deposit funds to your Mini App Wallet.
  </Card>

  <Card title="Call Smart Contract" icon="code" href="/functions/call-smart-contract">
    Interact with smart contracts on the blockchain.
  </Card>
</CardGroup>
