diff --git a/src/layouts/navigation.ts b/src/layouts/navigation.ts index e8031c34d..64bb8b81c 100644 --- a/src/layouts/navigation.ts +++ b/src/layouts/navigation.ts @@ -14,8 +14,21 @@ export const getNavigation = (section) => { { title: "Overview", href: "/dev/send-tokens/overview" }, { title: "Interchain Tokens", - href: "/dev/send-tokens/interchain-tokens", - }, + children: [ + { + title: "Introduction", + href: "/dev/send-tokens/interchain-tokens/intro", + }, + { + title: "Create Token", + href: "/dev/send-tokens/interchain-tokens/create-token", + }, + { + title: "Upgrade Token", + href: "/dev/send-tokens/interchain-tokens/upgrade-tokens", + }, + ], + } ], }, { diff --git a/src/pages/dev/reference/pricing.mdx b/src/pages/dev/reference/pricing.mdx index 0c44fedbd..65c664858 100644 --- a/src/pages/dev/reference/pricing.mdx +++ b/src/pages/dev/reference/pricing.mdx @@ -78,4 +78,4 @@ For GMP Express transactions, the total refund will then be: **Gas estimated to transfer the refund is usually a bit higher than the actual gas used. ## Interchain Tokens -Under the hood, creating an [Interchain Token](/dev/send-tokens/interchain-tokens) uses `callContract`, so users are responsible for the gas on the source chain to register the token, plus the addition of a `callContract` to each destination chain where the token is being registered. +Under the hood, creating an [Interchain Token](/dev/send-tokens/interchain-tokens/intro) uses `callContract`, so users are responsible for the gas on the source chain to register the token, plus the addition of a `callContract` to each destination chain where the token is being registered. diff --git a/src/pages/dev/send-tokens/interchain-tokens.mdx b/src/pages/dev/send-tokens/interchain-tokens.mdx deleted file mode 100644 index 54a112610..000000000 --- a/src/pages/dev/send-tokens/interchain-tokens.mdx +++ /dev/null @@ -1,161 +0,0 @@ -import { Callout } from "/src/components/callout" - -# Interchain Tokens -Interchain Tokens have received a major update as of July 2023 with many new features! Read on to learn about all of the new capabilities and check out the [Interchain Portal](https://testnet.interchain.axelar.dev). - -Axelar has [several ways](overview) to send [supported native tokens](/resources/testnet#assets), but what if you want to have your own [ERC-20](https://ethereum.org/developers/docs/standards/tokens/erc-20/) token available on multiple chains? Axelar can help with Interchain Tokens! - -Interchain Tokens are created and managed by our new Interchain Token Service, which allows you to send tokens cross-chain, build your own asset bridges, build asset transfers into your interchain dApp, and take on many other use cases. - -Depending on whether or not you have an existing ERC-20 token, there are two main paths available to you. - -- [I want to create a new Interchain Token](#create-a-new-interchain-token) - - a. [I want to register and create a new Interchain Token using the Interchain Token Portal](#create-a-new-interchain-token) - - b. [I want to create a new custom Interchain Token(s)](#create-a-new-interchain-token) - -- [I want to upgrade an existing token(s)](#making-existing-tokens-interchain) - - a. [I want to make a token on one chain into an Interchain Token](#making-existing-tokens-interchain) - - b. [I want to link deployed tokens on multiple chains into Interchain Tokens](#making-existing-tokens-interchain) - - -## Create a new Interchain Token - -### Register and create a new Interchain Token(s) using the Interchain Token Portal - -The simplest type of Interchain Token is to create a brand new [standardized](../reference/glossary/#standardized) ERC-20 that is available on multiple chains. [Here is a step-by-step tutorial for creating an Interchain Token using the Interchain Token Portal in 4 steps](https://axelar.network/blog/how-to-create-an-interchain-token-with-axelar-in-4-steps). - -- Visit the [Interchain Portal](https://testnet.interchain.axelar.dev) -- Connect your wallet to the portal -- Select a source network where you have funds available -- Choose the option to deploy a new ERC-20 token -- Specify the initial supply for your new token - - You can also choose the advanced option to enable later minting of additional tokens -- Select any additional chains where you want your new token to be available - - -**Congratulations!** You now have an ERC-20 token available on multiple chains. You can interact with your token on any chain identically, as they are all ERC-20 tokens. You can send, transfer, approve, and use all of the methods you are used to. - -Additionally, each of these tokens is a [Standardized Interchain Token](https://github.com/axelarnetwork/interchain-token-service/blob/main/contracts/interchain-token/InterchainTokenStandard.sol) and has an `interchainTransfer` method allowing you to transfer it between blockchains. - -Here is an example of using `interchainTransfer`. - -```solidity -function interchainTransfer( - string calldata destinationChain, - bytes calldata recipient, - uint256 amount, - bytes calldata metadata -) external payable; -``` - -### Create a new custom Interchain Tokens - -If you want more features than the [standardized](../reference/glossary/#standardized) token provides, you can create a [custom](../reference/glossary/#custom) token. You may want a customized token to customize minting policies, ensure ownership or control of the token by a DAO, create rate limits, or build any other custom logic into your token. - -- Build your [ERC-20 token](https://docs.alchemy.com/docs/how-to-create-an-erc-20-token-4-steps) and deploy it on multiple chains - -- Deploy a [Mint/Burn](../reference/glossary/#mintburn) [Token Manager](../reference/glossary/#token-manager) contract for each chain by calling `deployCustomTokenManager` (or `deployRemoteCustomTokenManager` for remote chains) on the Interchain Token Service - -- Set the [distributor](../reference/glossary/#distributor) on your token contract as the new Token Manager contract on each chain. This will give the Token Manager permission to mint and burn tokens on your behalf. - -Tokens can move between chains seamlessly as the Token Manager contracts will mint and burn tokens as needed. - -Here is an example of deploying your own Token Manager - -```solidity -function deployTokenManager(bytes32 salt) external { - bytes memory params = service.getParamsMintBurn(address(this).toBytes(), tokenAddress); - bytes32 tokenId = service.deployCustomTokenManager(salt, TokenManagerType.MINT_BURN, params); - address tokenManager = service.getTokenManagerAddress(tokenId); - CustomERC20(tokenAddress).setDistributor(tokenManager); -} -``` - -## Making existing tokens Interchain -If you already have an ERC-20 token on one or more blockchains, you can turn it into an Interchain Token by deploying [Token Managers](../reference/glossary/#token-manager). Token Managers can be either [Lock/Release](../reference/glossary/#lockrelease) or [Mint/Burn](../reference/glossary/#mintburn). For Mint/Burn Token Managers, you'll need to give the Token Manager permission to mint and burn tokens on your behalf as tokens move between chains. - -To clarify this powerful system, we'll look at two processes for turning existing tokens into Interchain Tokens. - -### Canonical Tokens (Simple Wrappers) -Suppose you have an ERC-20 token on a single chain, and you'd like a wrapped & bridgeable version to be available on other chains. You can register your ERC-20 as a [Canonical Token](../reference/glossary/#canonical) with the Interchain Token Service. Each token can only be registered a single time as a canonical chain. - -Want to try this out? [Use Remix to create your own ERC-20](https://remix.ethereum.org/axelarnetwork/axelar-docs/blob/main/public/samples/interchain-token-simple.sol) and register your token on the [Interchain Token Portal](https://testnet.interchain.axelar.dev). - -You can also do this directly via the Interchain Token Service Smart Contract. Follow these steps to register your token as a canonical token: - -1. First,[`registerCanonicalToken`](https://github.com/axelarnetwork/interchain-token-service/blob/main/contracts/interchain-token-service/InterchainTokenService.sol#L309) on the Interchain Token Service. This will deploy a [Lock/Release](../reference/glossary/#lockrelease) Token Manager on the source chain. - -Here is an example of registering a canonical token. - -```solidity -/** -* @notice Used to register canonical tokens. Caller does not matter. -* @param tokenAddress the token to be bridged. -* @return tokenId the tokenId that was used for this canonical token. -*/ -function registerCanonicalToken( - address tokenAddress -) external payable notPaused returns (bytes32 tokenId); -``` -2. [`deployRemoteCanonicalToken`](https://github.com/axelarnetwork/interchain-token-service/blob/main/contracts/interchain-token-service/InterchainTokenService.sol#L325) on the Interchain Token Service for each destination chain. This will create an ERC-20 on each destination chain and [Mint/Burn](../reference/glossary/#mintburn) Token Manager. - -Here is an example of deploying a remote canonical token. - -```solidity -/** - * @notice Used to deploy remote TokenManagers and standardized tokens for a canonical token. This needs to be - * called from the chain that registered the canonical token, and anyone can call it. - * @param tokenId the tokenId of the canonical token. - * @param destinationChain the name of the chain to deploy the TokenManager and standardized token to. - * @param gasValue the amount of native tokens to be used to pay for gas for the remote deployment. - * At least the amount specified needs to be passed to the call - * @dev `gasValue` exists because this function can be part of a `multicall` involving multiple functions that could make remote contract calls. - */ -function deployRemoteCanonicalToken( - bytes32 tokenId, - string calldata destinationChain, - uint256 gasValue -) public payable notPaused -``` - -When tokens are moved from the origin chain to another chain, the token will be locked on the origin chain and minted on the destination chain. If you moved tokens directly from one non-origin chain to another, the token would be burned on the source chain and minted on the destination chain. - -### Link deployed tokens on multiple chains into Interchain Tokens -If you require custom functionality on multiple chains, you must first deploy your [custom](../reference/glossary/#custom) token on multiple chains or already have a version of your token on multiple chains. - -To turn these deployed tokens into linked Interchain Tokens, register a Token Manager for each one. You can optionally have any of these custom tokens extend [`IInterchainToken`](https://github.com/axelarnetwork/interchain-token-service/blob/main/contracts/interfaces/IInterchainToken.sol) to offer [`interchainTransfer`](https://github.com/axelarnetwork/interchain-token-service/blob/main/contracts/interfaces/IInterchainToken.sol#L20) and [`interchainTransferFrom`](https://github.com/axelarnetwork/interchain-token-service/blob/main/contracts/interfaces/IInterchainToken.sol#L37) methods directly on your token. - -You could decide to make all of these Token Managers [Mint/Burn](../reference/glossary/#mintburn), or you could specify at most one (likely your primary/origin chain) to be [Lock/Release](../reference/glossary/#lockrelease) depending on your needs. - -To register a Custom Token via the Interchain Token Service, call the `deployCustomTokenManager` method. - -```solidity -/** -* @notice Used to deploy custom TokenManagers with the specified salt. Different callers would result in different tokenIds. -* @param salt the salt to be used. -* @param tokenManagerType the type of TokenManager to be deployed. -* @param params the params that will be used to initialize the TokenManager. -*/ -function deployCustomTokenManager( - bytes32 salt, - TokenManagerType tokenManagerType, - bytes memory params -) public payable notPaused returns (bytes32 tokenId) -``` - - -## Other Use cases -The Interchain Token Service is a powerful tool for moving tokens between blockchains, providing you with all the functionality and power you need to make your token interactive wherever it needs to be. Here are some other possibilities for Interchain Tokens. - -One of the features of the TokenManager that can be configured is that of the [Operator](../reference/glossary/#operator). The Operator can manage the flow rates of tokens between chains by calling `setFlowLimit` on the Interchain Token Service. - -Additionally, Interchain Tokens can be made executable, which means that they can be sent alongside a standard GMP message. For an example of this, see the example [InterchainTokenExecutable.sol](https://github.com/axelarnetwork/interchain-token-service/blob/example/example-flows-for-stephen/contracts/examples/InterchainTokenExecutable.sol). - - ->**Note**: If you want to build your token with the `IInterchainToken` feature yourself, make sure your token implements the [`IInterchainToken`](https://github.com/axelarnetwork/interchain-token-service/blob/main/contracts/interfaces/IInterchainToken.sol) interface so you can offer [`interchainTransfer`](https://github.com/axelarnetwork/interchain-token-service/blob/main/contracts/interfaces/IInterchainToken.sol#L20) and [`interchainTransferFrom`](https://github.com/axelarnetwork/interchain-token-service/blob/main/contracts/interfaces/IInterchainToken.sol#L37) methods directly on your token. -You can try our [sample custom token](https://remix.ethereum.org/axelarnetwork/axelar-docs/blob/main/public/samples/interchain-token-iinterchaintoken.sol) as a starting point. This token self-registers with the Interchain Token Service and can be deployed to multiple chains. -Once you have designed your token, you can deploy it to multiple chains using a tool such as the [Constant Address Deployer](https://docs.axelar.dev/dev/general-message-passing/solidity-utilities#constant-address-deployer) to give it the same address everywhere. diff --git a/src/pages/dev/send-tokens/interchain-tokens/create-token.mdx b/src/pages/dev/send-tokens/interchain-tokens/create-token.mdx new file mode 100644 index 000000000..bcbd0ac8f --- /dev/null +++ b/src/pages/dev/send-tokens/interchain-tokens/create-token.mdx @@ -0,0 +1,91 @@ +# Create a new Interchain Token + +Interchain Tokens are ERC-20 tokens that are available on [multiple blockchains](https://docs.axelar.dev/resources/testnet). They are created using the [Interchain Token Service](https://github.com/axelarnetwork/interchain-token-service/blob/main/contracts/InterchainTokenService.sol) and can be used to transfer value between blockchains. + +The Interchain Token Service is deployed to `0xB5FB4BE02232B1bBA4dC8f81dc24C26980dE9e3C` while the Interchain Token Factory is deployed to `0x83a93500d23Fbc3e82B410aD07A6a9F7A0670D66` + +Let's explore two methods to create new Interchain Token(s). + +## Create a new Interchain Token using the Interchain Token Portal + +The simplest type of Interchain Token is to create a brand new [Interchain Token](https://github.com/axelarnetwork/interchain-token-service/blob/main/contracts/InterchainTokenService.sol) available on multiple chains. For a detailed guide on how to create an Interchain Token using the Interchain Token Portal, refer to the [four-step tutorial](https://axelar.network/blog/how-to-create-an-interchain-token-with-axelar-in-4-steps). + +- Visit the [Interchain Portal](https://testnet.interchain.axelar.dev) +- Connect your wallet to the portal +- Select a source network where you have funds available +- Choose the option to deploy a new Interchain token +- Add the required details for your new token + - Name + - Symbol + - Decimals + - Amount to mint +- You can also click the advanced option where you can add an account as `Token Minter` and `Salt` value. Otherwise, it gets prefilled with the deployer(connected account) address and a random, uniquely generated salt value +- Select additional chains for your token's availability and optionally add the token amount to mint on each selected chain + +Congratulations! Your Interchain Token is now accessible on multiple blockchain networks. This allows for seamless interaction with your token on any of these networks, utilizing familiar methods like send, transfer, and approve, just as with any standard ERC-20 token. + +Furthermore, your token follows the [Interchain Token Standard](https://github.com/axelarnetwork/interchain-token-service/blob/main/contracts/interfaces/IInterchainTokenStandard.sol). This means that users can call the `interchainTransfer` method on the token itself to transfer between blockchains. + +Here is an example of the `interchainTransfer` method. + +```solidity +/** + * @notice Initiates an interchain transfer of a specified token to a destination chain. + * @dev The function retrieves the TokenManager associated with the tokenId. + * @param tokenId The unique identifier of the token to be transferred. + * @param destinationChain The destination chain to send the tokens to. + * @param destinationAddress The address on the destination chain to send the tokens to. + * @param amount The amount of tokens to be transferred. + * @param metadata Optional metadata for the call for additional effects (such as calling a destination contract). + */ +function interchainTransfer( + bytes32 tokenId, + string calldata destinationChain, + bytes calldata destinationAddress, + uint256 amount, + bytes calldata metadata, + uint256 gasValue +) external payable +``` + +## Create a custom Interchain Token + +If you want more features than the Interchain Token provides, you can create a [custom token](../../reference/glossary/#custom-token). You may want a customized token to customize specific minting policies, ownership structures, rate limits, or other bespoke functionalities. + +To create a custom Interchain Token: + +- Build your [ERC-20](https://docs.alchemy.com/docs/how-to-create-an-erc-20-token-4-steps) token and deploy it on multiple chains +- Deploy a [Mint/Burn](../../reference/glossary/#mintburn) - [Token Manager](../../reference/glossary/#token-manager) for existing tokens on all chains using [`deployTokenManager`](https://github.com/axelarnetwork/interchain-token-service/blob/9edc4318ac1c17231e65886eea72c0f55469d7e5/contracts/InterchainTokenService.sol#L276) on Interchain Token Service. The `deployTokenManager` method requires parameters like `salt`, `destinationChain`, `tokenManagerType`, `params`, and `gasValue` +- Make sure the Interchain Token Service can call the mint/burn on the token and repeat the step above for other chains where the token exists using the same deployer address and salt + +Here is an example of deploying a token manager: + +```solidity +/** + * @notice Used to deploy TokenManagers. + * @dev At least the `gasValue` amount of native token must be passed to the function call. `gasValue` exists because this function can be + * part of a multicall involving multiple functions that could make remote contract calls. + * @param salt The salt to be used during deployment. + * @param destinationChain The name of the chain to deploy the TokenManager and standardized token to. + * @param tokenManagerType The type of TokenManager to be deployed. + * @param params The params that will be used to initialize the TokenManager. + * @param gasValue The amount of native tokens to be used to pay for gas for the remote deployment. + * @return tokenId The tokenId corresponding to the deployed TokenManager. + */ +function deployTokenManager( + bytes32 salt, + string calldata destinationChain, + TokenManagerType tokenManagerType, + bytes calldata params, + uint256 gasValue +) external payable +``` + +You can directly transfer tokens between chains via the Interchain Token Service by calling the [`interchainTransfer`](https://github.com/axelarnetwork/interchain-token-service/blob/v1.0.0/contracts/interfaces/IInterchainTokenService.sol#L202). + +Tokens can move between chains seamlessly as the Token Manager contracts will mint and burn tokens as needed. If the `minter` parameter is empty bytes when deploying a new Interchain Token, use a Mint/Burn `TokenManager`. Otherwise, use a Lock/Unlock `TokenManager`. Use the `transferMintership` on the token to change the token minter to another address. + +>**Note**: If you want to build your token with the `IInterchainToken` feature yourself, make sure your token implements the [`IInterchainTokenStandard`](https://github.com/axelarnetwork/interchain-token-service/blob/v1.0.0/contracts/interfaces/IInterchainTokenStandard.sol) interface so you can offer [`interchainTransfer`](https://github.com/axelarnetwork/interchain-token-service/blob/9edc4318ac1c17231e65886eea72c0f55469d7e5/contracts/interfaces/IInterchainTokenStandard.sol#L19) and [`interchainTransferFrom`](https://github.com/axelarnetwork/interchain-token-service/blob/9edc4318ac1c17231e65886eea72c0f55469d7e5/contracts/interfaces/IInterchainTokenStandard.sol#L36) methods directly on your token. + +You can try our [sample custom token](https://remix.ethereum.org/axelarnetwork/axelar-docs/blob/main/public/samples/interchain-token-iinterchaintoken.sol) as a starting point. This token self-registers with the Interchain Token Service and can be deployed to multiple chains. +Once you have designed your token, you can deploy it to multiple chains using a tool such as the [Constant Address Deployer](https://docs.axelar.dev/dev/general-message-passing/solidity-utilities#constant-address-deployer) to give it the same address everywhere. diff --git a/src/pages/dev/send-tokens/interchain-tokens/intro.astro b/src/pages/dev/send-tokens/interchain-tokens/intro.astro new file mode 100644 index 000000000..6b6d7af30 --- /dev/null +++ b/src/pages/dev/send-tokens/interchain-tokens/intro.astro @@ -0,0 +1,111 @@ +--- +import Section from "../../../../layouts/Section.astro"; +import { Callout } from "../../../../../src/components/callout" + +const title = "What are Interchain Tokens?"; + +const cards = [ + { + title: "Create a new token", + description: + "Register and create new Interchain Token(s) using the Interchain Token Portal, or create custom Interchain Tokens.", + url: "/dev/send-tokens/interchain-tokens/create-token", + icon: ``, + }, + { + title: "Upgrade an existing token", + description: + "Upgrade existing tokens as Canonical Tokens (Simple Wrappers) or link tokens deployed on multiple chains into Interchain Tokens.", + url: "/dev/send-tokens/interchain-tokens/upgrade-tokens", + icon: ``, + }, +]; +--- + +
+ Interchain Tokens have received a major update as of November 2023 deployed with many new features! Read on to learn about all of the new capabilities and check out the Interchain Portal + + Axelar has several ways to send supported native tokens, but what if you want to have your own ERC-20 token available on multiple chains? Axelar can help with Interchain Tokens! +

+ Interchain Tokens are created and managed by our new Interchain Token Service, which allows you to send tokens cross-chain, build your own asset bridges, build asset transfers into your interchain dApp, and take on many other use cases. +

+ Depending on whether or not you have an existing ERC-20 token, there are two main paths available to you. + + + +
+ { + cards.map((card) => ( + +
+ {card.title} +
+
{card.description}
+ + Get Started{" "} + + + + +
+ )) + } +
+ +
diff --git a/src/pages/dev/send-tokens/interchain-tokens/upgrade-tokens.mdx b/src/pages/dev/send-tokens/interchain-tokens/upgrade-tokens.mdx new file mode 100644 index 000000000..f3691f67d --- /dev/null +++ b/src/pages/dev/send-tokens/interchain-tokens/upgrade-tokens.mdx @@ -0,0 +1,95 @@ +# Upgrade existing tokens into Interchain Token(s) + +If you already have an ERC-20 token on one or more blockchains, you can turn it into an Interchain Token by deploying [Token Managers](../../reference/glossary/#token-manager). Token Managers can be either [Lock/Release](../../reference/glossary/#lockunlock) or [Mint/Burn](../../reference/glossary/#mintburn). Canonical tokens are registered under the local chain's Lock/Release token manager and mint/burn on remote chains. They can be deployed to remote chains by anyone and don't depend on a deployer address/salt. + +The Interchain Token Service is deployed to `0xB5FB4BE02232B1bBA4dC8f81dc24C26980dE9e3C` while the Interchain Token Factory is deployed to `0x83a93500d23Fbc3e82B410aD07A6a9F7A0670D66`. You can find the list of the deployed contract addresses to all the networks supported by Axelar [here](https://github.com/axelarnetwork/axelar-contract-deployments/blob/main/axelar-chains-config/info/testnet.json). + +Now, let's explore how to transform existing tokens into Interchain Tokens. + +## Canonical Tokens (Simple wrappers) + +If you own an ERC-20 token on a single chain and want a wrapped, bridgeable version on other chains, register it as a [Canonical Token](../../reference/glossary/#canonical-interchain-token) with the [Interchain Token Service](https://github.com/axelarnetwork/interchain-token-service/blob/v1.0.0/contracts/InterchainTokenService.sol) using the [Interchain Token Factory contract](https://github.com/axelarnetwork/interchain-token-service/blob/v1.0.0/contracts/InterchainTokenFactory.sol). Each token can only be registered a single time as a canonical chain. + +Want to try this out? [Use Remix to create your own ERC-20](https://remix.ethereum.org/axelarnetwork/axelar-docs/blob/main/public/samples/interchain-token-simple.sol) and register your token on the [Interchain Token Portal](https://testnet.interchain.axelar.dev). + +You can also do this directly via the `InterchainTokenService.sol` using `InterchainTokenFactory.sol` to register canonical tokens and deploy remote canonical tokens. + +Follow these steps to register your token as a canonical token: + +- Retrieve the `tokenId` by calling the [`canonicalInterchainTokenId`](https://github.com/axelarnetwork/interchain-token-service/blob/9edc4318ac1c17231e65886eea72c0f55469d7e5/contracts/InterchainTokenFactory.sol#L93) with your token address + +- Register your token as a canonical token using the [`registerCanonicalInterchainToken`](https://github.com/axelarnetwork/interchain-token-service/blob/9edc4318ac1c17231e65886eea72c0f55469d7e5/contracts/InterchainTokenFactory.sol#L240) method on the `InterchainTokenFactory.sol`. This will deploy a [Lock/Release](../../reference/glossary/#lockunlock) - [Token Manager](../../reference/glossary/#token-manager) on the source chain + +Here is an example of registering a canonical token: + +```solidity +/** + * @notice Registers a canonical token as an interchain token and deploys its token manager. + * @param tokenAddress The address of the canonical token. + * @return tokenId The tokenId corresponding to the registered canonical token. + */ +function registerCanonicalInterchainToken(address tokenAddress) external payable returns (bytes32 tokenId) +``` +- Deploy a remote canonical interchain token for a pre-existing token on remote chains using the [`deployRemoteCanonicalInterchainToken`](https://github.com/axelarnetwork/interchain-token-service/blob/9edc4318ac1c17231e65886eea72c0f55469d7e5/contracts/InterchainTokenFactory.sol#L257) method on the `InterchainTokenFactory` for each destination chain. This will create the token on each destination chain and its registered under [Mint/Burn](../../reference/glossary/#mintburn) - [Token Manager](../../reference/glossary/#token-manager). They can be deployed to remote chains by anyone and don't depend on a deployer address/salt. + +Here is an example of deploying a remote canonical token: + +```solidity +/** + * @notice Deploys a canonical interchain token on a remote chain. + * @param originalChain The name of the chain where the token originally exists. + * @param originalTokenAddress The address of the original token on the original chain. + * @param destinationChain The name of the chain where the token will be deployed. + * @param gasValue The gas amount to be sent for deployment. + * @return tokenId The tokenId corresponding to the deployed InterchainToken. + */ +function deployRemoteCanonicalInterchainToken( + string calldata originalChain, + address originalTokenAddress, + string calldata destinationChain, + uint256 gasValue +) external payable returns (bytes32 tokenId) +``` + +If pre-mint is needed, you must make ERC20 approval to the Interchain Token Factory contract. When tokens are moved from the origin chain to another chain, the token will be locked on the origin chain and minted on the destination chain. If you moved tokens directly from one non-origin chain to another, the token would be burned on the source chain and minted on the destination chain. + + +## Link deployed tokens on multiple chains into Interchain Token(s) + +For custom functionality on multiple chains: + +- Deploy your [custom](../../reference/glossary/#custom-token) token on multiple chains or have existing versions on multiple chains +- Retrieve the `tokenId` by calling the [`interchainTokenId`](https://github.com/axelarnetwork/interchain-token-service/blob/9edc4318ac1c17231e65886eea72c0f55469d7e5/contracts/InterchainTokenService.sol#L218) on Interchain Token Service with your address (deployer) and salt +- Deploy a [Mint/Burn](../../reference/glossary/#mintburn) - [Token Manager](../../reference/glossary/#token-manager) for existing tokens on all chains using [`deployTokenManager`](https://github.com/axelarnetwork/interchain-token-service/blob/9edc4318ac1c17231e65886eea72c0f55469d7e5/contracts/InterchainTokenService.sol#L276) on Interchain Token Service. The `deployTokenManager` method requires parameters like `salt`, `destinationChain`, `tokenManagerType`, `params`, and `gasValue`. + +You can optionally have any of these custom tokens extend [`IInterchainTokenStandard`](https://github.com/axelarnetwork/interchain-token-service/blob/main/contracts/interfaces/IInterchainTokenStandard.sol) to offer [`interchainTransfer`](https://github.com/axelarnetwork/interchain-token-service/blob/a2dfcb2490497e627b66be789d944ec3260c5eea/contracts/interfaces/IInterchainTokenStandard.sol#L20) and [`interchainTransferFrom`](https://github.com/axelarnetwork/interchain-token-service/blob/a2dfcb2490497e627b66be789d944ec3260c5eea/contracts/interfaces/IInterchainTokenStandard.sol#L37) methods directly on your token. + +> You could decide to make all of these Token Managers [Mint/Burn](../../reference/glossary/#mintburn), or you could specify at most one (likely your primary/origin chain) to be [Lock/Release](../../reference/glossary/#lockunlock) as indicated in the [`ITokenManagerType.sol`](https://github.com/axelarnetwork/interchain-token-service/blob/main/contracts/interfaces/ITokenManagerType.sol) depending on your needs. + +Here is an example of deploying a token manager: + +```solidity +/** + * @notice Used to deploy TokenManagers. + * @dev At least the `gasValue` amount of native token must be passed to the function call. `gasValue` exists because this function can be + * part of a multicall involving multiple functions that could make remote contract calls. + * @param salt The salt to be used during deployment. + * @param destinationChain The name of the chain to deploy the TokenManager and standardized token to. + * @param tokenManagerType The type of TokenManager to be deployed. + * @param params The params that will be used to initialize the TokenManager. + * @param gasValue The amount of native tokens to be used to pay for gas for the remote deployment. + * @return tokenId The tokenId corresponding to the deployed TokenManager. + */ +function deployTokenManager( + bytes32 salt, + string calldata destinationChain, + TokenManagerType tokenManagerType, + bytes calldata params, + uint256 gasValue +) external payable +``` + +>**Note**: If you want to build your token with the `IInterchainToken` feature yourself, make sure your token implements the [`IInterchainTokenStandard`](https://github.com/axelarnetwork/interchain-token-service/blob/main/contracts/interfaces/IInterchainTokenStandard.sol) interface so you can offer [`interchainTransfer`](https://github.com/axelarnetwork/interchain-token-service/blob/a2dfcb2490497e627b66be789d944ec3260c5eea/contracts/interfaces/IInterchainTokenStandard.sol#L20) and [`interchainTransferFrom`](https://github.com/axelarnetwork/interchain-token-service/blob/a2dfcb2490497e627b66be789d944ec3260c5eea/contracts/interfaces/IInterchainTokenStandard.sol#L37) methods directly on your token. + +You can try our [sample custom token](https://remix.ethereum.org/axelarnetwork/axelar-docs/blob/main/public/samples/interchain-token-iinterchaintoken.sol) as a starting point. This token self-registers with the Interchain Token Service and can be deployed to multiple chains. +Once you have designed your token, you can deploy it to multiple chains using a tool such as the [Constant Address Deployer](https://docs.axelar.dev/dev/general-message-passing/solidity-utilities#constant-address-deployer) to give it the same address everywhere. \ No newline at end of file diff --git a/src/pages/dev/send-tokens/overview.mdx b/src/pages/dev/send-tokens/overview.mdx index 60ff1a510..2746a26ad 100644 --- a/src/pages/dev/send-tokens/overview.mdx +++ b/src/pages/dev/send-tokens/overview.mdx @@ -4,7 +4,7 @@ There are three ways to transfer tokens cross-chain with Axelar: 1. Call `sendToken` from any source chain. 1. Get a deposit address using the [AxelarJS SDK](../axelarjs-sdk/token-transfer-dep-addr). -1. For tokens not [natively supported](/dev/reference/mainnet-contract-addresses#assets), build your own [Interchain Token](interchain-tokens). +1. For tokens not [natively supported](/dev/reference/mainnet-contract-addresses#assets), build your own [Interchain Token](interchain-tokens/intro). ## Call `sendToken` diff --git a/vercel.json b/vercel.json index fdd3991e5..1e15c74fc 100644 --- a/vercel.json +++ b/vercel.json @@ -311,6 +311,11 @@ "source": "/cli-docs/:version/:path*", "destination": "https://github.com/axelarnetwork/axelar-core/blob/main/docs/cli/:path*.md", "permanent": true + }, + { + "source": "/dev/send-tokens/interchain-tokens", + "destination": "/dev/send-tokens/interchain-tokens/intro", + "permanent": true } ] } \ No newline at end of file