-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Removed Docs for deprecated info (SendToken) (#1261)
- Loading branch information
1 parent
c19eb13
commit 55c996a
Showing
4 changed files
with
197 additions
and
169 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/content/docs/dev/send-tokens/deprecated/deposit-address.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Callout } from "/src/components/callout"; | ||
|
||
|
||
# Transfer assets using a deposit address (Deprecated) | ||
|
||
<Callout type="warning"> | ||
Note: Transfering assets via `deposit addresses` are deprecated. For gateway tokens it is recommended to use `callContractWithToken()` and for other tokens it is recommended to use the `Interchain Token Service`. | ||
</Callout> | ||
|
||
A [deposit address](/dev/axelarjs-sdk/token-transfer-dep-addr/) is a temporary one-time address created and monitored by Axelar’s Relayer Services. Deposit addresses generally function for up to 24 hours. | ||
|
||
Use a deposit address if: | ||
|
||
- You need functionality not offered by the `sendToken()` method, such as Cosmos-to-X. | ||
- You want to allow token transfers from wallets that do not interact with Axelar, such as when withdrawing funds from a centralized exchange. | ||
|
||
To transfer assets using a deposit address, install the AxelarJS SDK and initiate an `AxelarAssetTransfer`. |
158 changes: 158 additions & 0 deletions
158
src/content/docs/dev/send-tokens/deprecated/send-tokens.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
import { Callout } from "/src/components/callout"; | ||
|
||
|
||
# Send Tokens Cross-Chain (Deprecated) | ||
|
||
<Callout type="warning"> | ||
Note: Transfering assets via `sendToken()` is deprecated. For gateway tokens it is recommended to use `callContractWithToken()` and for other tokens it is recommended to use the `Interchain Token Service`**.** | ||
</Callout> | ||
|
||
|
||
## Call `sendToken()` on an EVM source chain | ||
|
||
To send a token from an EVM source chain: | ||
|
||
### 1. Find the source chain’s Gateway contract address | ||
|
||
Locate the source chain’s Gateway contract address on either the [mainnet](/dev/reference/mainnet-contract-addresses/) or the [testnet](/dev/reference/testnet-contract-addresses/). | ||
|
||
EVM chains use Axelar Gateway smart contracts to send tokens. These are application-layer smart contracts that send and receive payloads as well as monitor transaction state. | ||
|
||
All Gateway contracts implement the [`IAxelarGateway`](https://github.com/axelarnetwork/axelar-cgp-solidity/blob/main/contracts/interfaces/IAxelarGateway.sol/) interface, which has a public method called `sendToken()` that transfers tokens between chains: | ||
|
||
```solidity | ||
function sendToken( | ||
string memory destinationChain, | ||
string memory destinationAddress, | ||
string memory symbol, | ||
uint256 amount | ||
) external; | ||
``` | ||
|
||
### 2. Call the source chain’s `approve()` method | ||
|
||
Transferring tokens through a Gateway is similar to doing a typical ERC-20 token transfer. You’ll need to call the source chain’s `approve()` method (inherited from the [ERC-20 interface](https://ethereum.org/en/developers/docs/standards/tokens/erc-20/) to allow the Gateway to transfer a specific token in a specific amount. | ||
|
||
```solidity | ||
function approve(address spender, uint256 amount) external returns (bool); | ||
``` | ||
|
||
`spender` is the source chain’s Gateway contract address on either the mainnet or the testnet. | ||
|
||
### 3. Call `sendToken()` on the source chain’s Gateway contract | ||
|
||
Call `sendToken()` on the source chain’s Gateway contract to transfer the tokens. For example: | ||
|
||
```solidity | ||
sendToken( | ||
"avalanche", // destination chain name | ||
"0xF16DfB26e1FEc993E085092563ECFAEaDa7eD7fD", // some destination wallet address (should be your own) | ||
"axlUSDC", // asset symbol, can be differ by chain, see above | ||
100000000 // amount (in atomic units) | ||
) | ||
``` | ||
|
||
Once you call `sendToken()`, watch for the tokens to appear at the address on the destination chain. | ||
|
||
## Call `sendToken()` on a Cosmos-based source chain | ||
|
||
For Cosmos-based source chains, `sendToken()` is a simple IBC transfer of any asset supported on the Axelar network. The message is sent to the address `axelar1dv4u5k73pzqrxlzujxg3qp8kvc3pje7jtdvu72npnt5zhq05ejcsn5qme5`, which is the designated address on the Axelar network for receiving [GMP](/dev/general-message-passing/overview/) messages, and includes a `memo` field with the following payload: | ||
|
||
```typescript | ||
{ | ||
destination_chain, | ||
destination_address, | ||
payload: null, | ||
type: 3, // corresponds to the `sendToken` command on Axelar | ||
} | ||
``` | ||
|
||
## Use the AxelarJS SDK to call `sendToken()` | ||
|
||
The AxelarJS SDK allows any frontend application to call `sendToken()` with one line of JS code. | ||
|
||
### EVM chain example | ||
|
||
```typescript | ||
import { | ||
AxelarAssetTransfer, | ||
CHAINS, | ||
Environment, | ||
SendTokenParams, | ||
} from "@axelar-network/axelarjs-sdk"; | ||
import { ethers, Wallet } from "ethers"; | ||
|
||
const api = new AxelarAssetTransfer({ environment: Environment.TESTNET }); | ||
|
||
const getSigner = () => { | ||
const privateKey = PRIVATE_KEY; | ||
return new Wallet(privateKey); | ||
}; | ||
|
||
async function test() { | ||
const provider = new ethers.providers.JsonRpcProvider( | ||
"https://api.avax-test.network/ext/bc/C/rpc", | ||
); | ||
const signer = getSigner().connect(provider); | ||
const requestOptions: SendTokenParams = { | ||
fromChain: CHAINS.TESTNET.AVALANCHE, | ||
toChain: CHAINS.TESTNET.OSMOSIS, | ||
destinationAddress: "osmo1x3z2vepjd7fhe30epncxjrk0lehq7xdqe8ltsn", | ||
asset: { symbol: "aUSDC" }, | ||
amountInAtomicUnits: "5000000", | ||
options: { | ||
evmOptions: { | ||
signer, | ||
provider, | ||
txOptions: null as any, | ||
approveSendForMe: true, | ||
}, | ||
}, | ||
}; | ||
return api.sendToken(requestOptions); | ||
} | ||
``` | ||
|
||
### Cosmos-based chain example | ||
|
||
```typescript | ||
import { | ||
AxelarAssetTransfer, | ||
CHAINS, | ||
Environment, | ||
SendTokenParams, | ||
} from "@axelar-network/axelarjs-sdk"; | ||
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; | ||
|
||
const api = new AxelarAssetTransfer({ environment: Environment.TESTNET }); | ||
|
||
const getSigner = async () => { | ||
const mnemonic = MNEMONIC; | ||
return DirectSecp256k1HdWallet.fromMnemonic(mnemonic, { prefix: "osmo" }); | ||
}; | ||
|
||
async function test() { | ||
const offlineSigner = await getSigner(); | ||
const requestOptions: SendTokenParams = { | ||
fromChain: CHAINS.TESTNET.OSMOSIS, | ||
toChain: CHAINS.TESTNET.AVALANCHE, | ||
destinationAddress: "0xB8Cd93C83A974649D76B1c19f311f639e62272BC", | ||
asset: { | ||
denom: | ||
"ibc/6F34E1BD664C36CE49ACC28E60D62559A5F96C4F9A6CCE4FC5A67B2852E24CFE", | ||
}, //aUSDC | ||
amountInAtomicUnits: "1000000", | ||
options: { | ||
cosmosOptions: { | ||
cosmosDirectSigner: offlineSigner, | ||
rpcUrl: "https://rpc.osmotest5.osmosis.zone", | ||
fee: { | ||
gas: "250000", | ||
amount: [{ denom: "uosmo", amount: "30000" }], | ||
}, | ||
}, | ||
}, | ||
}; | ||
return api.sendToken(requestOptions); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,171 +1,10 @@ | ||
# Send Tokens Cross-Chain | ||
# Overview | ||
Axelar offers cross-chain ERC20 token transfer in two main forms. Gateway tokens and Interchain Token Service based tokens. For general users looking to integrate their own tokens it is recommmended to use ITS. For Dapps looking to make use of more widely recognized assets such as `axlUSDC` or `axlETH`, Gateway tokens serve as a simple solution. | ||
|
||
There are three ways you can use Axelar to transfer ERC-20 tokens across different blockchains: | ||
## Gateway Tokens | ||
Gateway tokens are a collection of well known ERC20 tokens that have been wrapped by the Interop Labs team to provide easy cross-chain liquidity between blockchains. The full list of available Gateway tokens can be found [here](/resources/contract-addresses/mainnet/#assets). | ||
More on how to use/send Gateway tokens can be found [here](/dev/general-message-passing/gmp-tokens-with-messages/) | ||
|
||
1. Call `sendToken()` to send a token on any Axelar-supported source chain to a recipient on any Axelar-supported destination chain. This can be done from [EVM chains](/dev/send-tokens/introduction#call-sendtoken-on-an-evm-source-chain), [Cosmos-based chains](/dev/send-tokens/introduction#call-sendtoken-on-a-cosmos-based-source-chain), or the [AxelarJS SDK](/dev/send-tokens/introduction#use-the-axelarjs-sdk-to-call-sendtoken). | ||
1. [Transfer assets using a deposit address](/dev/send-tokens/introduction#transfer-assets-using-a-deposit-address) generated with the AxelarJS SDK. | ||
1. [Build your own Interchain Token](/dev/send-tokens/introduction#build-an-interchain-token) if your token is not [natively supported](/dev/reference/mainnet-contract-addresses#assets). | ||
|
||
## Call `sendToken()` on an EVM source chain | ||
|
||
To send a token from an EVM source chain: | ||
|
||
### 1. Find the source chain’s Gateway contract address | ||
|
||
Locate the source chain’s Gateway contract address on either the [mainnet](/dev/reference/mainnet-contract-addresses) or the [testnet](/dev/reference/testnet-contract-addresses). | ||
|
||
EVM chains use Axelar Gateway smart contracts to send tokens. These are application-layer smart contracts that send and receive payloads as well as monitor transaction state. | ||
|
||
All Gateway contracts implement the [`IAxelarGateway`](https://github.com/axelarnetwork/axelar-cgp-solidity/blob/main/contracts/interfaces/IAxelarGateway.sol) interface, which has a public method called `sendToken()` that transfers tokens between chains: | ||
|
||
```solidity | ||
function sendToken( | ||
string memory destinationChain, | ||
string memory destinationAddress, | ||
string memory symbol, | ||
uint256 amount | ||
) external; | ||
``` | ||
|
||
### 2. Call the source chain’s `approve()` method | ||
|
||
Transferring tokens through a Gateway is similar to doing a typical ERC-20 token transfer. You’ll need to call the source chain’s `approve()` method (inherited from the [ERC-20 interface](https://ethereum.org/en/developers/docs/standards/tokens/erc-20/)) to allow the Gateway to transfer a specific token in a specific amount. | ||
|
||
```solidity | ||
function approve(address spender, uint256 amount) external returns (bool); | ||
``` | ||
|
||
`spender` is the source chain’s Gateway contract address on either the mainnet or the testnet. | ||
|
||
### 3. Call `sendToken()` on the source chain’s Gateway contract | ||
|
||
Call `sendToken()` on the source chain’s Gateway contract to transfer the tokens. For example: | ||
|
||
```solidity | ||
sendToken( | ||
"avalanche", // destination chain name | ||
"0xF16DfB26e1FEc993E085092563ECFAEaDa7eD7fD", // some destination wallet address (should be your own) | ||
"axlUSDC", // asset symbol, can be differ by chain, see above | ||
100000000 // amount (in atomic units) | ||
) | ||
``` | ||
|
||
Once you call `sendToken()`, watch for the tokens to appear at the address on the destination chain. | ||
|
||
## Call `sendToken()` on a Cosmos-based source chain | ||
|
||
For Cosmos-based source chains, `sendToken()` is a simple IBC transfer of any asset supported on the Axelar network. The message is sent to the address `axelar1dv4u5k73pzqrxlzujxg3qp8kvc3pje7jtdvu72npnt5zhq05ejcsn5qme5`, which is the designated address on the Axelar network for receiving [GMP](/dev/general-message-passing/overview) messages, and includes a `memo` field with the following payload: | ||
|
||
```typescript | ||
{ | ||
destination_chain, | ||
destination_address, | ||
payload: null, | ||
type: 3, // corresponds to the `sendToken` command on Axelar | ||
} | ||
``` | ||
|
||
## Use the AxelarJS SDK to call `sendToken()` | ||
|
||
The AxelarJS SDK allows any frontend application to call `sendToken()` with one line of JS code. | ||
|
||
### EVM chain example | ||
|
||
```typescript | ||
import { | ||
AxelarAssetTransfer, | ||
CHAINS, | ||
Environment, | ||
SendTokenParams, | ||
} from "@axelar-network/axelarjs-sdk"; | ||
import { ethers, Wallet } from "ethers"; | ||
|
||
const api = new AxelarAssetTransfer({ environment: Environment.TESTNET }); | ||
|
||
const getSigner = () => { | ||
const privateKey = PRIVATE_KEY; | ||
return new Wallet(privateKey); | ||
}; | ||
|
||
async function test() { | ||
const provider = new ethers.providers.JsonRpcProvider( | ||
"https://api.avax-test.network/ext/bc/C/rpc", | ||
); | ||
const signer = getSigner().connect(provider); | ||
const requestOptions: SendTokenParams = { | ||
fromChain: CHAINS.TESTNET.AVALANCHE, | ||
toChain: CHAINS.TESTNET.OSMOSIS, | ||
destinationAddress: "osmo1x3z2vepjd7fhe30epncxjrk0lehq7xdqe8ltsn", | ||
asset: { symbol: "aUSDC" }, | ||
amountInAtomicUnits: "5000000", | ||
options: { | ||
evmOptions: { | ||
signer, | ||
provider, | ||
txOptions: null as any, | ||
approveSendForMe: true, | ||
}, | ||
}, | ||
}; | ||
return api.sendToken(requestOptions); | ||
} | ||
``` | ||
|
||
### Cosmos-based chain example | ||
|
||
```typescript | ||
import { | ||
AxelarAssetTransfer, | ||
CHAINS, | ||
Environment, | ||
SendTokenParams, | ||
} from "@axelar-network/axelarjs-sdk"; | ||
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; | ||
|
||
const api = new AxelarAssetTransfer({ environment: Environment.TESTNET }); | ||
|
||
const getSigner = async () => { | ||
const mnemonic = MNEMONIC; | ||
return DirectSecp256k1HdWallet.fromMnemonic(mnemonic, { prefix: "osmo" }); | ||
}; | ||
|
||
async function test() { | ||
const offlineSigner = await getSigner(); | ||
const requestOptions: SendTokenParams = { | ||
fromChain: CHAINS.TESTNET.OSMOSIS, | ||
toChain: CHAINS.TESTNET.AVALANCHE, | ||
destinationAddress: "0xB8Cd93C83A974649D76B1c19f311f639e62272BC", | ||
asset: { | ||
denom: | ||
"ibc/6F34E1BD664C36CE49ACC28E60D62559A5F96C4F9A6CCE4FC5A67B2852E24CFE", | ||
}, //aUSDC | ||
amountInAtomicUnits: "1000000", | ||
options: { | ||
cosmosOptions: { | ||
cosmosDirectSigner: offlineSigner, | ||
rpcUrl: "https://rpc.osmotest5.osmosis.zone", | ||
fee: { | ||
gas: "250000", | ||
amount: [{ denom: "uosmo", amount: "30000" }], | ||
}, | ||
}, | ||
}, | ||
}; | ||
return api.sendToken(requestOptions); | ||
} | ||
``` | ||
|
||
## Transfer assets using a deposit address | ||
|
||
A [deposit address](/dev/axelarjs-sdk/token-transfer-dep-addr) is a temporary one-time address created and monitored by Axelar’s Relayer Services. Deposit addresses generally function for up to 24 hours. | ||
|
||
Use a deposit address if: | ||
|
||
- You need functionality not offered by the `sendToken()` method, such as Cosmos-to-X. | ||
- You want to allow token transfers from wallets that do not interact with Axelar, such as when withdrawing funds from a centralized exchange. | ||
|
||
To transfer assets using a deposit address, install the AxelarJS SDK and initiate an `AxelarAssetTransfer`. | ||
|
||
## Build an Interchain Token | ||
|
||
[Interchain Tokens](/dev/send-tokens/interchain-tokens/intro) are ERC-20 tokens that are available on multiple blockchains. With Axelar’s [Interchain Token Service (ITS)](https://axelar.network/interchaintokens), you can either create new Interchain Tokens from scratch or update tokens that already exist on an Ethereum blockchain. If your token is not supported by Axelar, you can turn it into an Interchain Token to make cross-chain transfers. | ||
## Interchain Token Service Tokens (ITS) | ||
Axelar also offers the ability to make use of ITS. This is a permisionless service where any user (both technical and non technical!) can integrate existing tokens to provide cross-chain functionality for those tokens. Users can also create fresh new ERC20s with cross-chain functionality out of the box. | ||
More details on ITS can be found [here](/dev/send-tokens/interchain-tokens/intro/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters