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
npmi@tanx-libs/tanx-connector
2. Create an Instance
import{Client}from'@tanx-libs/tanx-connector';// Create an instance with either testnet or mainnetconstclient=newClient();// orconstclient=newClient('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:
Set up an RPC provider URL pointing to an Ethereum node.
Use the ETH private key corresponding to the sender's Ethereum address.
Specify the network (testnet or mainnet), coin symbol, and amount.
Execute the deposit transaction.
1.2 Using Custom Provider and Signer
Alternatively, you can use a custom provider and signer:
Create a JSON-RPC provider instance.
Generate a signer with the private key and provider.
Execute the deposit transaction.
2. Cross-Chain Deposit
There are two protocols to make a deposit on the Cross-chain: one is EVM (Ethereum-supported chain) and the other is Starknet deposit.
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.
);
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',
);
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: '',
},
);
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: '',
},
);
const depositRes = await client.starknetDeposit(
'14', // Enter the amount you want to deposit.
'usdc', // Enter the coin symbol.
process.env.STARKNET_RPC_PROVIDER as string, // Replace your RPC URL based on your destination network.
starknetPublicKey as string, // Your starknet public address.
starknetPrivateKey as string, // Your starknet private key.
);
// Note: Please use starknet.js version 5.14.1.
import { Account, RpcProvider } from 'starknet'
// Replace your RPC URL based on your destination network.
const provider = new RpcProvider({ nodeUrl: rpcURL })
const account = new Account(
provider,
userStarknetPublicAddress,
userStarknetPrivateKey,
)
const depositRes = await client.starknetDepositWithStarknetSigner(
'14', // Enter the amount you want to deposit.
'usdc', // Enter the coin symbol.
starknetPublicKey as string, // Your starknet public address.
account, // The account created above.
provider, // The provider created above.
);
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', 'STARKNET', and 'MODE'.
page: 2, // This is an optional field
limit: 1, // This is an optional field
})