# Deposit

TanX offers various [SDKs](/tech/api-documentation/sdk-reference.md) 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](/tech/api-documentation/sdk-reference.md)

{% hint style="info" %}
Please visit [tanX website](https://tanx.fi) and create an account using your wallet before proceeding with the below steps.
{% endhint %}

## Deposit Process

### 1. Install the NPM Package

```bash
npm i @tanx-libs/tanx-connector
```

### 2. Create an Instance

```javascript
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.

```javascript
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.

```javascript
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**

There are two protocols to make a deposit on the Cross-chain: one is EVM (Ethereum-supported chain) and the other is Starknet deposit.

#### **2.1 EVM Cross-Chain Deposit**

{% hint style="info" %}
Supported EVM cross-chain networks - 'POLYGON' | 'OPTIMISM' | 'ARBITRUM' | 'LINEA' | 'SCROLL' | 'MODE'
{% endhint %}

**2.1.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.

```javascript
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.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. Specify the **network** (testnet or mainnet), **coin symbol**, and **amount**.
4. Execute the deposit transaction.

```javascript
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: '',
  },
);
```

#### **2.2 Starknet Cross-Chain Deposit**

{% hint style="info" %}
Currently, Starknet deposits are only supported on the tanX mainnet.
{% endhint %}

**2.2.1 Using Starknet Private Key and RPC URL**

To initiate a cross-chain deposit:

1. Set up an **RPC provider URL** pointing to an **Starknet**.
2. Use the **Starknet private key** corresponding to the sender's starknet address.
3. Specify the **coin symbol**, and **amount**.
4. Submit the transaction to execute the starknet deposit.

```javascript
 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.
 );
```

\
**2.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 **coin symbol**, and **amount**.
4. Execute the deposit transaction.

```javascript
// 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.
);
```

### **List Deposits**

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

```javascript
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
})
```

\
\
For additional information, please refer to the [SDK Reference](/tech/api-documentation/sdk-reference.md).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tanx.fi/tech/api-documentation/account/deposit.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
