Documentation
Use Cases
Deposit To Cex

Integrate Deposit 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.

Deposit to CEX

  1. Retrieve depositable token list from our Provider API and display to the user:
const tokens = await cedeSDK.api.getDepositableTokens({ exchangeInstanceId });
  1. When the user selects a token, you can retrieve available deposit chains for the token:
const tokenSymbol = "ETH";
const networks = await cedeSDK.api.getNetworks({
  exchangeInstanceId,
  tokenSymbol,
  opts: {
    toDeposit: true,
  },
});
  1. When the user selects a chain, you can retrieve deposit address for the token and chain:
const network = "ethereum";
 
const depositAddress = await cedeSDK.api.getDepositAddress({
  exchangeInstanceId,
  tokenSymbol,
  network,
});
  1. When the user sends tokens to the deposit address, you register the callback to handle the deposit event:
const txHash = "0xf9e10c965a3b8d1edaa2c6ec5b83db7346aa50881cc4417e4e549c9535f87622";
const txStatusToTriggerOn = "ok"; // you can also trigger your callback on "pending"/"failed"/"cancelled" status.
 
cedeSDK.api.onDeposit({
  exchangeInstanceId,
  tokenSymbol,
  txHash,
  txStatus: txStatusToTriggerOn,
  callback: (transaction) => {
    console.log("Deposit event: ", transaction);
  },
});

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