Deposit

TanX offers various SDKs in different languages to facilitate seamless deposits to its platform. This document outlines the deposit 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.

Deposit 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

Deposit Options

Two primary deposit methods are supported:

1. Ethereum Deposit

1.1. Using ETH Private Key and RPC URL

To deposit using an Ethereum private key and RPC URL, follow these steps:

  1. Set up an RPC provider URL pointing to an Ethereum node.

  2. Use the ETH private key corresponding to the sender's Ethereum address.

  3. Specify the network (testnet or mainnet), coin symbol, and amount.

  4. Execute the deposit transaction.

const res = await client.depositFromEthereumNetwork(
  process.env.RPC_PROVIDER as string, // Replace with your RPC URL.
  privateKey, // Your ETH private key.
  'testnet', // Network: 'testnet' or 'mainnet'.
  'eth', // Coin symbol.
  0.00001, // Amount to deposit.
);

1.2. Using Custom Provider and Signer

Alternatively, you can use a custom provider and signer:

  1. Create a JSON-RPC provider instance.

  2. Generate a signer with the private key and provider.

  3. Execute the deposit transaction.

import { Wallet, ethers } from 'ethers';

const provider = new ethers.providers.JsonRpcProvider(process.env.RPC_PROVIDER);
const signer = new Wallet(privateKey, provider);

const depositRes = await client.depositFromEthereumNetworkWithStarkKey(
  signer,
  provider,
  `0x${stark_public_key}`,
  0.0000001,
  'eth',
);

2. Cross-Chain Deposit

Supported EVM cross-chain networks - 'POLYGON' | 'OPTIMISM' | 'ARBITRUM' | 'LINEA' | 'SCROLL' | 'MODE'

2.1. Using ETH Private Key and RPC URL

To initiate a cross-chain deposit:

  1. Set up an RPC provider URL pointing to an Ethereum node.

  2. Use the ETH private key corresponding to the sender's Ethereum address.

  3. Specify the target network (e.g., 'POLYGON', 'OPTIMISM', etc.), the coin symbol, and the amount to deposit.

  4. Submit the transaction to execute the cross-chain deposit.

const depositRes = await client.crossChainDeposit(
  process.env.RPC_PROVIDER as string, // Replace with your RPC URL.
  privateKey, // Your ETH private key.
  'usdt', // Coin symbol.
  1, // Amount to deposit.
  'SCROLL', // Network to deposit into.
  // Optional: Gas limit and gas price.
  {
    gasLimit: '',
    gasPrice: '',
  },
);

2.2. Using Custom Provider and Signer

Alternatively, you can use a custom provider and signer:

  1. Create a JSON-RPC provider instance.

  2. Generate a signer with the private key and provider.

  3. Specify the network (testnet or mainnet), coin symbol, and amount.

  4. Execute the deposit transaction.

const provider = new ethers.providers.JsonRpcProvider(process.env.RPC_PROVIDER);
const signer = new Wallet(privateKey, provider);

const depositPolygonRes = await client.crossChainDepositWithSigner(
  signer,
  provider,
  'usdc', // Coin symbol.
  0.00001, // Amount to deposit.
  'SCROLL', // Network to deposit into.
  // Optional: Gas limit and gas price.
  {
    gasLimit: '',
    gasPrice: '',
  },
);

List Deposits

To retrieve the deposit history, you can utilise the following code snippet:

const depositsList = await client.listDeposits({
  network: 'ETHEREUM', // Specify the network for which you want to list the deposit history. Allowed networks include 'ETHEREUM', 'POLYGON', 'OPTIMISM', 'ARBITRUM', 'LINEA', 'SCROLL', and 'MODE'.
  page: 2, // This is an optional field
  limit: 1, // This is an optional field
})

For additional information, please refer to the SDK Reference.

Last updated