Documentation
Use Cases
Withdraw From Cex

Integrate Withdrawal Feature in your dApp

ℹ️

Estimated feature integration time: ~2 hours*

Prerequisites

The following steps are required. If you haven't done so already, please follow the steps in the prerequisites guide:

  • Contact us to get access to the SDK package and client ID. You can also try the MOCK mode without a client ID (https://github.com/cedelabs/sdk-examples (opens in a new tab)).
  • Install the SDK package.
  • Create an SDK instance with your client ID. Every user's CEX account should have an exchange instance.
  • Subscribe to events to connect SDK's cache with the storage and manage errors.

Withdraw from CEX

  1. Retrieve withdrawable token list from our Provider API and display to the user:
const tokens = await cedeSDK.api.getWithdrawableBalances({ exchangeInstanceId });
  1. When the user selects a token, you can retrieve available withdrawal chains for the token:
const tokenSymbol = "ETH";
 
const networks = await cedeSDK.api.getNetworks({
  exchangeInstanceId,
  tokenSymbol,
  opts: {
    toWithdraw: true,
  },
});
  1. When the user select a network, an amount and a destination address, you can prepare the withdrawal. This is necessary to ensure that the withdrawable amount is available and that it exceeds the minimum withdrawal requirement:
const network = "ethereum";
const amount = "1";
const address = "0x123456789";
 
const data = await cedeSDK.api.prepareWithdrawal({
  fromExchangeInstanceId: exchangeInstanceId,
  tokenSymbol,
  amount,
  network,
});
  1. When the user selects a chain, you can initiate a withdrawal:
const withdrawal = await cedeSDK.api.createWithdrawal({
  fromExchangeInstanceId,
  tokenSymbol,
  amount,
  address,
  network,
});
  1. Retreive withdrawal information by withdrawal ID:
const data = await cedeSDK.api.getWithdrawalById({
  exchangeInstanceId,
  tokenSymbol: withdrawal.from.transaction.tokenSymbol,
  withdrawalId: withdrawal.from.transaction.transactionId,
  timestamp: withdrawal.from.transaction.timestamp,
});

* The estimated integration time is for a project that already has UI components for a similar DeFi send feature.