Skip to main content

Usage

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

Parameters

type WithdrawInput {
  amount: string;
  tokenName: string;
  chainId: ChainId;
}
amount
string
required
The amount to withdraw.
tokenName
string
required
The tokenName name (e.g., ‘USDC’, ‘USDT’, ‘ETH’).
chainId
ChainId
required
The chain id to use for the withdrawal.

Returns

type WithdrawResponse = {
  result: TransactionResult.SUCCESS | TransactionResult.PENDING;
  data: {
    txHash: string;
  };
} | {
  result: TransactionResult.FAILED;
  error: MiniAppError;
} | {
  result: TransactionResult.CANCELLED;
}
result
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.
data
object
Contains the transaction hash of the withdrawal transaction. Only present when the result is SUCCESS or PENDING.
  • txHash: The transaction hash.
error
MiniAppError
Contains the error information when the withdrawal fails. Only present when the result is FAILED.
  • message: The error message.
  • code: The error code.

Demo