Withdrawal

TanX offers various SDKs in different languages to facilitate seamless withdrawal. This document outlines the withdrawal process through the JavaScript (JS) SDK. For additional SDK options, refer to the SDK Reference

Please visit tanX website and create an account using your wallet before proceeding with the below steps.

Withdrawal Process

1. Install the NPM Package

npm i @tanx-libs/tanx-connector

2. Create an Instance

import { Client } from '@tanx-libs/tanx-connector';

// Create an instance with either testnet or mainnet
const client = new Client();
// or
const client = new Client('testnet'); // default is mainnet

Withdrawal Options

Generally, we have two modes of withdrawal: Normal Withdrawal and Fast Withdrawal. For withdrawal methods that require a signer and provider, please refer to the deposit method mentioned above.

1. Normal Withdrawal

With Normal Withdrawal, your requested funds will be processed within a standard time frame (24 hours). This mode is suitable for users who are not in a rush to access their funds and are comfortable with the regular processing time.

Normal Withdrawal Process:

  1. Initiate Your Withdrawal Request: Call the initiateNormalWithdrawal function with the following parameters:

    const withdrawalRes = await client.initiateNormalWithdrawal(
      keyPair, // The keyPair created above
      0.0001, // Enter the amount you want to withdraw
      'usdc', // Enter the coin symbol
    )

  2. Wait for Confirmation: Wait for up to 24 hours.

  3. Check Pending Withdrawal Balance: Use the getPendingNormalWithdrawalAmountByCoin function with the required parameters to check if the withdrawn balance is pending:

     const pendingBalance = await client.getPendingNormalWithdrawalAmountByCoin(
      'eth', // Enter the coin symbol
      ethAddress, // User public ETH address
      signer, // The signer created above
    )

  4. Complete Withdrawal: If the pending balance is greater than 0, use the completeNormalWithdrawal function to withdraw the cumulative amount to your ETH wallet:

    const completeNWRes = await client.completeNormalWithdrawal(
      'eth', // Enter the coin symbol
      ethAddress, // User public ETH address
      signer, // The signer created above
    )

Get a List of Normal Withdrawals:

Retrieve a list of normal withdrawals with optional pagination:

const withdrawalsList = await client.listNormalWithdrawals({
  page: 2, // This field is optional
})

2. Fast Withdrawal

With Fast Withdrawal, your funds will be processed in an expedited timeframe, often within a few minutes. This mode is ideal for users who require immediate access to their funds and are comfortable with paying a fee.

const fastWithdrawalRes = await client.fastWithdrawal(
  keyPair, // The keyPair created above
  0.0001, // Enter the amount you want to deposit
  'usdc', // Enter the coin symbol
  'ETHEREUM', // Allowed networks include 'ETHEREUM', 'POLYGON', 'OPTIMISM', 'ARBITRUM', 'LINEA', 'SCROLL', 'STARKNET' and 'MODE'
)

Get a List of Fast Withdrawals:

Retrieve a list of fast withdrawals with optional pagination:

const withdrawalsList = await client.listFastWithdrawals({
  page: 2, // This field is optional
  network: 'ETHEREUM', // Allowed networks include 'ETHEREUM', 'POLYGON', 'OPTIMISM', 'ARBITRUM', 'LINEA', 'SCROLL', 'STARKNET' and 'MODE'
})

For additional information, please refer to the SDK Reference.

Last updated