Skip to content

Commit

Permalink
fix: unknown code block language "JavaScript" and add hardhat guide (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Olanetsoft authored Oct 22, 2024
1 parent 6a12357 commit 9029fac
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" });

Expand Down Expand Up @@ -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;
Expand All @@ -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() {
Expand All @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -323,15 +325,15 @@ 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.

### Estimate gas fees

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 });
Expand All @@ -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
Expand Down Expand Up @@ -413,7 +415,7 @@ async function deployRemoteTokenManager() {

Update `main()` to execute `deployRemoteTokenManager()` :

```JavaScript
```javascript
//...

async function main() {
Expand All @@ -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
```

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -498,7 +500,7 @@ async function transferMintAccessToTokenManagerOnFantom() {

Update `main()` to execute `transferMintAccessToTokenManagerOnFantom()` :

```JavaScript
```javascript
//...

async function main() {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -570,7 +572,7 @@ async function transferMintAccessToTokenManagerOnPolygon() {

Update `main()` to execute `transferMintAccessToTokenManagerOnPolygon()` :

```JavaScript
```javascript
//...

async function main() {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -650,7 +652,7 @@ async function transferTokens() {

Update the `main()` to execute `transferTokens()`:

```JavaScript
```javascript
//...

async function main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" });

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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() {
Expand All @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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 });
Expand All @@ -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
Expand Down Expand Up @@ -335,7 +335,7 @@ async function deployRemoteCanonicalInterchainToken() {

Update `main()` to execute `deployRemoteCanonicalInterchainToken()` :

```JavaScript
```javascript
//...

async function main() {
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -424,7 +424,7 @@ async function transferTokens() {

Update the `main()` to execute `transferTokens()`:

```JavaScript
```javascript
//...

async function main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" });

Expand Down Expand Up @@ -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;
Expand All @@ -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() {
Expand All @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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,
Expand All @@ -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 });
Expand All @@ -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
Expand Down Expand Up @@ -356,7 +356,7 @@ async function deployToRemoteChain() {

Update `main()` to execute `deployToRemoteChain()` :

```JavaScript
```javascript
//...

async function main() {
Expand All @@ -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
```

Expand All @@ -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() {
Expand Down Expand Up @@ -434,7 +434,7 @@ async function transferTokens() {

Update the `main()` to execute `transferTokens()`:

```JavaScript
```javascript
//...

async function main() {
Expand All @@ -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
```

Expand Down

0 comments on commit 9029fac

Please sign in to comment.