From 9029fac047b87c2aba0454473b8adaac5ca18dcb Mon Sep 17 00:00:00 2001 From: Idris Olubisi Date: Tue, 22 Oct 2024 14:17:25 +0100 Subject: [PATCH] fix: unknown code block language "JavaScript" and add hardhat guide (#1227) --- ...multiple-chains-into-interchain-tokens.mdx | 36 ++++++++++--------- ...grammatically-create-a-canonical-token.mdx | 22 ++++++------ .../programmatically-create-a-token.mdx | 28 +++++++-------- 3 files changed, 44 insertions(+), 42 deletions(-) diff --git a/src/content/docs/dev/send-tokens/interchain-tokens/developer-guides/link-custom-tokens-deployed-across-multiple-chains-into-interchain-tokens.mdx b/src/content/docs/dev/send-tokens/interchain-tokens/developer-guides/link-custom-tokens-deployed-across-multiple-chains-into-interchain-tokens.mdx index 6f1af3d85..4d2fe9599 100644 --- a/src/content/docs/dev/send-tokens/interchain-tokens/developer-guides/link-custom-tokens-deployed-across-multiple-chains-into-interchain-tokens.mdx +++ b/src/content/docs/dev/send-tokens/interchain-tokens/developer-guides/link-custom-tokens-deployed-across-multiple-chains-into-interchain-tokens.mdx @@ -72,6 +72,8 @@ contract SimpleCustomToken is ERC20, ERC20Burnable, AccessControl, ERC20Permit { } ``` +To learn how to deploy your own ERC-20 token using Hardhat step by step, check out this [Hardhat guide](https://hardhat.org/tutorial). + ## Set up your development environment ### Create and initialize a project @@ -128,7 +130,7 @@ PRIVATE_KEY= // Add your account private key here Then, create a file with the name `hardhat.config.js` and add the following code snippet: -```JavaScript +```javascript require("@nomicfoundation/hardhat-toolbox"); require("dotenv").config({ path: ".env" }); @@ -166,7 +168,7 @@ Create a new file named `customInterchainToken.js` and import the required depen - The address of the [`InterchainTokenService`](https://github.com/axelarnetwork/interchain-token-service/blob/main/contracts/InterchainTokenService.sol) contract - The address of your token deployed on Fantom and Polygon testnet -```JavaScript +```javascript const hre = require("hardhat"); const crypto = require("crypto"); const ethers = hre.ethers; @@ -193,7 +195,7 @@ const polygonCustomTokenAddress = "0x7884ac325fa7aedB8A4d7bBD92671e8699f49108"; Next, create a `getSigner()` function in `customInterchainToken.js`. This will obtain a signer for a secure transaction: -```JavaScript +```javascript //... async function getSigner() { @@ -206,7 +208,7 @@ async function getSigner() { Then, create a `getContractInstance()` function in `customInterchainToken.js`. This will get the contract instance based on the contract’s address, ABI, and signer: -```JavaScript +```javascript //... async function getContractInstance(contractAddress, contractABI, signer) { @@ -218,7 +220,7 @@ async function getContractInstance(contractAddress, contractABI, signer) { Create a `deployTokenManager()` function for the Fantom testnet. This will deploy a token manager with your custom token address: -```JavaScript +```javascript //... // Deploy token manager : Fantom @@ -276,7 +278,7 @@ async function deployTokenManager() { Add a `main()` function to execute the `customInterchainToken.js` script and handle any errors that may arise: -```JavaScript +```javascript //... async function main() { @@ -323,7 +325,7 @@ Copy the token ID, Expected Token Manager, and salt value and store them somewhe Check the [Fantom testnet scanner](https://testnet.ftmscan.com/) to see if you have successfully [deployed a token manager](https://testnet.ftmscan.com/tx/0x026ee7992de2108ecb83f37119ec84ebed371ff724d38e8fd055cbecde5b77e6). -## Remotely deploy a token manager on the Polygon testnet +## Deploy a remote token manager on the Polygon testnet You’ve just successfully deployed a token manager to Fantom, which you are using as your local chain. Now, deploy a token manager remotely to Polygon, which will act as the remote chain in this tutorial. Remember that you can specify any two chains as your local and remote chains. @@ -331,7 +333,7 @@ You’ve just successfully deployed a token manager to Fantom, which you are usi In `customInterchainToken.js`, call `estimateGasFee()` from the [AxelarJS SDK](https://www.notion.so/bd238d757a144a069501f0b481488ef3?pvs=21) to estimate the actual cost of deploying your remote Canonical Interchain Token on a remote chain: -```JavaScript +```javascript //... const api = new AxelarQueryAPI({ environment: Environment.TESTNET }); @@ -356,7 +358,7 @@ async function gasEstimator() { Create a `deployRemoteTokenManager()` function. This will deploy the remote Token Manager on the Polygon testnet. Make sure to change the salts to the value you saved from a previous step. -```JavaScript +```javascript //... // Deploy remote token manager : Polygon @@ -413,7 +415,7 @@ async function deployRemoteTokenManager() { Update `main()` to execute `deployRemoteTokenManager()` : -```JavaScript +```javascript //... async function main() { @@ -435,7 +437,7 @@ async function main() { Run the script in your terminal to deploy a token manager remotely, once again specifying the `fantom` testnet (the source chain where all transactions are taking place): -```JavaScript +```javascript FUNCTION_NAME=deployRemoteTokenManager npx hardhat run customInterchainToken.js --network fantom ``` @@ -468,7 +470,7 @@ You must transfer mint access to the Token Manager address on both chains before Create a `transferMintAccessToTokenManagerOnFantom()` function that will perform the mint access transfer on the Fantom testnet. -```JavaScript +```javascript //... // Transfer mint access on all chains to the Expected Token Manager : Fantom @@ -498,7 +500,7 @@ async function transferMintAccessToTokenManagerOnFantom() { Update `main()` to execute `transferMintAccessToTokenManagerOnFantom()` : -```JavaScript +```javascript //... async function main() { @@ -538,7 +540,7 @@ Check the [Fantom testnet scanner](https://testnet.ftmscan.com/) to see if you h Create a `transferMintAccessToTokenManagerOnPolygon()` function that will perform the mint access transfer on the Fantom testnet. -```JavaScript +```javascript //... // Transfer mint access on all chains to the Expected Token Manager Address : Polygon @@ -570,7 +572,7 @@ async function transferMintAccessToTokenManagerOnPolygon() { Update `main()` to execute `transferMintAccessToTokenManagerOnPolygon()` : -```JavaScript +```javascript //... async function main() { @@ -614,7 +616,7 @@ Now that you have deployed a `TokenManager` on both Fantom and Polygon testnet, In `customInterchainToken.js`, create a `transferTokens()` function that will facilitate remote token transfers between chains. Change the token ID to the `tokenId` that you [saved from an earlier step](### Store the token ID, Expected Token Manager, and salt value), and change the address in `transfer` to your own wallet address: -```JavaScript +```javascript //... // Transfer tokens : Fantom -> Polygon @@ -650,7 +652,7 @@ async function transferTokens() { Update the `main()` to execute `transferTokens()`: -```JavaScript +```javascript //... async function main() { diff --git a/src/content/docs/dev/send-tokens/interchain-tokens/developer-guides/programmatically-create-a-canonical-token.mdx b/src/content/docs/dev/send-tokens/interchain-tokens/developer-guides/programmatically-create-a-canonical-token.mdx index 652ac957f..c62caac02 100644 --- a/src/content/docs/dev/send-tokens/interchain-tokens/developer-guides/programmatically-create-a-canonical-token.mdx +++ b/src/content/docs/dev/send-tokens/interchain-tokens/developer-guides/programmatically-create-a-canonical-token.mdx @@ -84,7 +84,7 @@ If you will push this project on GitHub, create a `.gitignore` file and include Then, create a file with the name `hardhat.config.js` and add the following code snippet: -```JavaScript +```javascript require("@nomicfoundation/hardhat-toolbox"); require("dotenv").config({ path: ".env" }); @@ -117,7 +117,7 @@ Create a new file named `canonicalInterchainToken.js` and import the required de - The address of the [`InterchainTokenService`](https://github.com/axelarnetwork/interchain-token-service/blob/main/contracts/InterchainTokenService.sol) contract - The address of the [`InterchainTokenFactory`](https://github.com/axelarnetwork/interchain-token-service/blob/main/contracts/InterchainTokenFactory.sol) contract -```JavaScript +```javascript const hre = require("hardhat"); const crypto = require("crypto"); const { @@ -146,7 +146,7 @@ const customTokenAddress = "0x0EF6280417A1BF22c8fF05b54D7A7928a173E605"; // your Next, create a `getSigner()` function in `canonicalInterchainToken.js`. This will obtain a signer for a secure transaction: -```JavaScript +```javascript //... async function getSigner() { @@ -159,7 +159,7 @@ async function getSigner() { Then, create a `getContractInstance()` function in `canonicalInterchainToken.js` . This will get the contract instance based on the contract’s address, ABI, and signer: -```JavaScript +```javascript //... async function getContractInstance(contractAddress, contractABI, signer) { @@ -171,7 +171,7 @@ async function getContractInstance(contractAddress, contractABI, signer) { Now you’re ready to register your token as a Canonical Interchain Token! Create a `registerCanonicalInterchainToken()` function for the Fantom testnet. This will register a Canonical Interchain Token with your custom token address: -```JavaScript +```javascript // Register Canonical Interchain Token to the Fantom chain. async function registerCanonicalInterchainToken() { // Get a signer to sign the transaction @@ -218,7 +218,7 @@ async function registerCanonicalInterchainToken() { Add a `main()` function to execute the `canonicalInterchainToken.js` script. It will handle any errors that may arise: -```JavaScript +```javascript //... async function main() { @@ -272,7 +272,7 @@ You’ve just successfully a Canonical Interchain Token to Fantom, which you are In `canonicalInterchainToken.js`, call `estimateGasFee()` from the [AxelarJS SDK](https://www.notion.so/bd238d757a144a069501f0b481488ef3?pvs=21) to estimate the actual cost of deploying your remote Canonical Interchain Token on a remote chain: -```JavaScript +```javascript //... const api = new AxelarQueryAPI({ environment: Environment.TESTNET }); @@ -297,7 +297,7 @@ async function gasEstimator() { Create a `deployRemoteCanonicalInterchainToken()` function that will perform token remote canonical deployment on the Polygon Mumbai testnet. -```JavaScript +```javascript //... // deployRemoteCanonicalInterchainToken: On Polygon @@ -335,7 +335,7 @@ async function deployRemoteCanonicalInterchainToken() { Update `main()` to execute `deployRemoteCanonicalInterchainToken()` : -```JavaScript +```javascript //... async function main() { @@ -379,7 +379,7 @@ Now that you have registered and deployed a Canonical Interchain Token both loca In `canonicalInterchainToken.js`, create a `transferTokens()` function that will facilitate remote token transfers between chains. Change the token ID to the `tokenId` that you [saved from an earlier step](#store-the-token-id), and change the address in `transfer` to your own wallet address: -```JavaScript +```javascript //... // Transfer token between chains. @@ -424,7 +424,7 @@ async function transferTokens() { Update the `main()` to execute `transferTokens()`: -```JavaScript +```javascript //... async function main() { diff --git a/src/content/docs/dev/send-tokens/interchain-tokens/developer-guides/programmatically-create-a-token.mdx b/src/content/docs/dev/send-tokens/interchain-tokens/developer-guides/programmatically-create-a-token.mdx index 0e1601bd0..5dfc6dcff 100644 --- a/src/content/docs/dev/send-tokens/interchain-tokens/developer-guides/programmatically-create-a-token.mdx +++ b/src/content/docs/dev/send-tokens/interchain-tokens/developer-guides/programmatically-create-a-token.mdx @@ -79,7 +79,7 @@ PRIVATE_KEY= // Add your account private key here Then, create a file with the name `hardhat.config.js` and add the following code snippet: -```JavaScript +```javascript require("@nomicfoundation/hardhat-toolbox"); require("dotenv").config({ path: ".env" }); @@ -112,7 +112,7 @@ Create a new file named `newInterchainToken.js` and import the required dependen - The address of the Interchain Token Service contract - The address of the Interchain Token Factory contract -```JavaScript +```javascript const hre = require("hardhat"); const crypto = require("crypto"); const ethers = hre.ethers; @@ -137,7 +137,7 @@ const interchainTokenFactoryContractAddress = Next, create a `getSigner()` function in `newInterchainToken.js`. This will obtain a signer for a secure transaction: -```JavaScript +```javascript //... async function getSigner() { @@ -150,7 +150,7 @@ async function getSigner() { Then, create a `getContractInstance()` function in `newInterchainToken.js` . This will get the contract instance based on the contract’s address, ABI, and signer: -```JavaScript +```javascript //... async function getContractInstance(contractAddress, contractABI, signer) { @@ -162,7 +162,7 @@ async function getContractInstance(contractAddress, contractABI, signer) { Now you’re ready to register and deploy your token! Create a `registerAndDeploy()` function for the Fantom testnet. This will create a new token called “New Interchain Token” with the symbol “NIT”: -```JavaScript +```javascript // Register and deploy a new interchain token to the Fantom testnet async function registerAndDeploy() { // Generate random salt @@ -232,7 +232,7 @@ async function registerAndDeploy() { Add a `main()` function for executing the `newInterchainToken.js` script. It will handle any errors that may arise: -```JavaScript +```javascript //... async function main() { @@ -264,7 +264,7 @@ FUNCTION_NAME=registerAndDeploy npx hardhat run newInterchainToken.js --network You should see something similar to the following on your console: -```JavaScript +```javascript Deployed Token ID: 0x4427c3aab191db9cfc696291f93c6c33e93b5384ea5b25497e457316b50c45e9, Token Address: 0xc028ebdF906a890be73C594b6a14858D0552544A, Transaction Hash: 0x7b1b6321b5027851a15048fb9743d2b894f19d745441c1daf87d0c5054ed5309, @@ -290,7 +290,7 @@ You’ve just successfully deployed an Interchain Token to Fantom, which you are In `newInterchainToken.js`, call `estimateGasFee()` from the [AxelarJS SDK](https://www.notion.so/bd238d757a144a069501f0b481488ef3?pvs=21) to estimate the actual cost of deploying your token on a remote chain: -```JavaScript +```javascript //... const api = new AxelarQueryAPI({ environment: Environment.TESTNET }); @@ -315,7 +315,7 @@ async function gasEstimator() { Create a `deployToRemoteChain()` function that will perform token remote deployment on the Polygon Mumbai testnet. Make sure to replace the `salt` value with the salt returned to your terminal from when you ran `registerAndDeploy()`: -```JavaScript +```javascript //... // Deploy to remote chain: Polygon @@ -356,7 +356,7 @@ async function deployToRemoteChain() { Update `main()` to execute `deployToRemoteChain()` : -```JavaScript +```javascript //... async function main() { @@ -378,7 +378,7 @@ async function main() { Run the script in your terminal to register and deploy the token, once again specifying the `fantom` testnet (the source chain where all transactions are taking place): -```JavaScript +```javascript FUNCTION_NAME=deployToRemoteChain npx hardhat run newInterchainToken.js --network fantom ``` @@ -400,7 +400,7 @@ Now that you have deployed your token both locally to Fantom and remotely to Pol In `newInterchainToken.js`, create a `transferTokens()` function that will facilitate remote token transfers between chains. Change the address in `interchainToken` to the new token address from the FTM scan that you saved from an earlier step, and change the address in `transfer` to your own wallet address: -```JavaScript +```javascript //... async function transferTokens() { @@ -434,7 +434,7 @@ async function transferTokens() { Update the `main()` to execute `transferTokens()`: -```JavaScript +```javascript //... async function main() { @@ -456,7 +456,7 @@ async function main() { Run the script in your terminal, specifying the `fantom` testnet: -```JavaScript +```javascript FUNCTION_NAME=transferTokens npx hardhat run newInterchainToken.js --network fantom ```