Get a deposit address
A deposit address is a temporary special address created and monitored by Axelar's Relayer Services on behalf of the requester. It is similar to how centralized exchanges generate a monitored, one-time deposit address that facilitates your token transfers. Deposit addresses generally function for up to 24 hours.
Deposit address workflow
- The user generates a deposit address on a specific source chain.
- The user sends tokens to the deposit address on the source chain.
-
Examples:
- withdrawal from a centralized exchange
- transaction from your favorite wallet software.
IMPORTANT NOTE: When making your deposit, please ensure that the amount is greater than the cross-chain relayer gas fee
- A table of fees is listed here: mainnet | testnet.
- Alternatively, they can be programmatically queried in the SDK's AxelarQueryAPI.
- Axelar relayers observe the deposit transaction on the source chain and complete it on the destination chain, assuming the amount exceeds the requisite fee.
- Watch your tokens arrive on the destination chain.
1. Prerequisite
To help you write clean code, you can use the Environment
and CHAINS
constants.
Most methods in the sdk require you to work with chain ids instead of chain names. Chain ids are unique per Environment and are specific to Axelar. For instance, Ethereum will have a chain id of ethereum
on mainnet but ethereum-2
on testnet. In the same way Osmosis will be osmosis
on mainnet but osmosis-4
on tesnet. However some chains will have no difference between the chain names and chain ids.
To find the chain ids we support you can check the resources section. You can find the testnet chain information here and mainnet chain information there
2. Install the AxelarJs SDK
The AxelarJS SDK is an npm
dependency that helps to make requests to the Axelar network. The SDK is essentially a wrapper around various API endpoints. One of the endpoints allows you to generate a deposit address. Alternately, you can create a deposit address using the CLI instead of the SDK.
npm i @axelar-network/axelarjs-sdk
# or
yarn add @axelar-network/axelarjs-sdk
3. Import & instantiate the AxelarAssetTransfer
import { AxelarAssetTransfer, Environment } from "@axelar-network/axelarjs-sdk";
const axelarAssetTransfer = new AxelarAssetTransfer({
environment: Environment.TESTNET,
});
4. Get an estimate of the transfer fees (optional)
If you plan on using the transfer assets functionality, it is paramount to take the relayer fees into account. Any deposits into a deposit address that are not in excess of this calculate fee will not get processed until that deposit address is topped up to encompass the fee.
The following query retrieves the fee charged by the relayer for a transfer.
import {
AxelarQueryAPI,
CHAINS,
Environment,
} from "@axelar-network/axelarjs-sdk";
async function main() {
const axelarQuery = new AxelarQueryAPI({
environment: Environment.TESTNET,
});
const fee = await axelarQuery.getTransferFee(
CHAINS.TESTNET.OSMOSIS,
CHAINS.TESTNET.AVALANCHE,
"uausdc",
1000000
);
// returns { fee: { denom: 'uausdc', amount: '150000' } }
}
main();
You can look up asset denominations on our resources page.
5. Generate a deposit address
When making your deposit, please ensure that the amount is greater than the cross-chain relayer gas fee. The relayer gas fee can be calculated with
getTransferFee
function above.
The AxelarAssetTransfer
class exposes the getDepositAddress
function. With this function, you can create a deposit address. Here is the function signature 👇
interface GetDepositAddressParams {
fromChain: string; // See note (3) below
toChain: string; // See note (3) below
destinationAddress: string; // See note (1) below
asset: string; // denom of asset. See note (2) below