Skip to content

Commit

Permalink
fix: update interchain token developer guides to use sepolia (#1276)
Browse files Browse the repository at this point in the history
  • Loading branch information
Olanetsoft authored Dec 19, 2024
1 parent 278ed4e commit 2ff1a29
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ async function deployTokenManager() {
const interchainTokenServiceContract = await getContractInstance(
interchainTokenServiceContractAddress,
interchainTokenServiceContractABI,
signer
signer,
);

// Generate a random salt
Expand All @@ -241,7 +241,7 @@ async function deployTokenManager() {
// Create params
const params = ethers.utils.defaultAbiCoder.encode(
["bytes", "address"],
[signer.address, fantomCustomTokenAddress]
[signer.address, fantomCustomTokenAddress],
);

// Deploy the token manager
Expand All @@ -250,13 +250,13 @@ async function deployTokenManager() {
"",
MINT_BURN,
params,
ethers.utils.parseEther("0.01")
ethers.utils.parseEther("0.01"),
);

// Get the tokenId
const tokenId = await interchainTokenServiceContract.interchainTokenId(
signer.address,
salt
salt,
);

// Get the token manager address
Expand All @@ -269,7 +269,7 @@ async function deployTokenManager() {
Transaction Hash: ${deployTxData.hash},
Token ID: ${tokenId},
Expected token manager address: ${expectedTokenManagerAddress},
`
`,
);
}
```
Expand Down Expand Up @@ -345,7 +345,7 @@ async function gasEstimator() {
EvmChain.POLYGON,
GasToken.FTM,
700000,
1.1
1.1,
);

return gas;
Expand All @@ -370,13 +370,13 @@ async function deployRemoteTokenManager() {
const interchainTokenServiceContract = await getContractInstance(
interchainTokenServiceContractAddress,
interchainTokenServiceContractABI,
signer
signer,
);

// Create params
const param = ethers.utils.defaultAbiCoder.encode(
["bytes", "address"],
[signer.address, polygonCustomTokenAddress]
[signer.address, polygonCustomTokenAddress],
);

const gasAmount = await gasEstimator();
Expand All @@ -388,13 +388,13 @@ async function deployRemoteTokenManager() {
MINT_BURN,
param,
ethers.utils.parseEther("0.01"),
{ value: gasAmount }
{ value: gasAmount },
);

// Get the tokenId
const tokenId = await interchainTokenServiceContract.interchainTokenId(
signer.address,
"0x7f5fe989334ad23b77e8da841f672394d021ae83ff0a24afb461ba19d72e3553" // change salt
"0x7f5fe989334ad23b77e8da841f672394d021ae83ff0a24afb461ba19d72e3553", // change salt
);

// Get the token manager address
Expand All @@ -406,7 +406,7 @@ async function deployRemoteTokenManager() {
Transaction Hash: ${deployTxData.hash},
Token ID: ${tokenId},
Expected token manager address: ${expectedTokenManagerAddress},
`
`,
);
}
```
Expand Down Expand Up @@ -481,15 +481,15 @@ async function transferMintAccessToTokenManagerOnFantom() {
const tokenContract = await getContractInstance(
fantomCustomTokenAddress,
customTokenABI,
signer
signer,
);

// Get the minter role
const getMinterRole = await tokenContract.MINTER_ROLE();

const grantRoleTxn = await tokenContract.grantRole(
getMinterRole,
"0xad8Cf8FF7BBe82269844bBcbA60bAa8f02781f13"
"0xad8Cf8FF7BBe82269844bBcbA60bAa8f02781f13",
);

console.log("grantRoleTxn: ", grantRoleTxn.hash);
Expand Down Expand Up @@ -551,15 +551,15 @@ async function transferMintAccessToTokenManagerOnPolygon() {
const tokenContract = await getContractInstance(
polygonCustomTokenAddress,
customTokenABI,
signer
signer,
);

// Get the minter role
const getMinterRole = await tokenContract.MINTER_ROLE();

const grantRoleTxn = await tokenContract.grantRole(
getMinterRole,
"0xad8Cf8FF7BBe82269844bBcbA60bAa8f02781f13"
"0xad8Cf8FF7BBe82269844bBcbA60bAa8f02781f13",
);

console.log("grantRoleTxn: ", grantRoleTxn.hash);
Expand Down Expand Up @@ -627,7 +627,7 @@ async function transferTokens() {
const interchainTokenServiceContract = await getContractInstance(
interchainTokenServiceContractAddress,
interchainTokenServiceContractABI,
signer
signer,
);
const gasAmount = await gasEstimator();
const transfer = await interchainTokenServiceContract.interchainTransfer(
Expand All @@ -640,7 +640,7 @@ async function transferTokens() {
{
// Transaction options should be passed here as an object
value: gasAmount,
}
},
);

console.log("Transfer Transaction Hash:", transfer.hash);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ In this tutorial, you will learn how to:
You will need:

- A basic understanding of [Solidity](https://www.tutorialspoint.com/solidity/index.htm) and [JavaScript](https://www.w3schools.com/js/)
- A [wallet](https://metamask.io/) with FTM and MATIC funds for testing. If you don’t have these funds, you can get FTM from the [Fantom faucet](https://faucet.fantom.network/) and MATIC from the Mumbai faucets ([1](https://faucet.polygon.technology/), [2](https://faucet.quicknode.com/polygon/mumbai)).
- A [wallet](https://metamask.io/) with FTM and MATIC funds for testing. If you don’t have these funds, you can get FTM from the [Fantom faucet](https://faucet.fantom.network/) and MATIC from the Amoy faucets ([1](https://faucet.polygon.technology/), [2](https://faucet.quicknode.com/polygon/amoy)).

## Deploy an ERC-20 token on the Fantom testnet

Expand Down Expand Up @@ -181,24 +181,24 @@ async function registerCanonicalInterchainToken() {
const interchainTokenFactoryContract = await getContractInstance(
interchainTokenFactoryContractAddress,
interchainTokenFactoryContractABI,
signer
signer,
);
const interchainTokenServiceContract = await getContractInstance(
interchainTokenServiceContractAddress,
interchainTokenServiceContractABI,
signer
signer,
);

// Register a new Canonical Interchain Token
const deployTxData =
await interchainTokenFactoryContract.registerCanonicalInterchainToken(
customTokenAddress // Your token address
customTokenAddress, // Your token address
);

// Retrieve the token ID of the newly registered token
const tokenId =
await interchainTokenFactoryContract.canonicalInterchainTokenId(
customTokenAddress
customTokenAddress,
);

const expectedTokenManagerAddress =
Expand All @@ -209,7 +209,7 @@ async function registerCanonicalInterchainToken() {
Transaction Hash: ${deployTxData.hash},
Token ID: ${tokenId},
Expected Token Manager Address: ${expectedTokenManagerAddress},
`
`,
);
}
```
Expand Down Expand Up @@ -284,7 +284,7 @@ async function gasEstimator() {
EvmChain.POLYGON,
GasToken.FTM,
700000,
1.1
1.1,
);

return gas;
Expand All @@ -295,7 +295,7 @@ async function gasEstimator() {

### Perform remote token deployment

Create a `deployRemoteCanonicalInterchainToken()` function that will perform token remote canonical deployment on the Polygon Mumbai testnet.
Create a `deployRemoteCanonicalInterchainToken()` function that will perform token remote canonical deployment on the Polygon Amoy testnet.

```javascript
//...
Expand All @@ -309,7 +309,7 @@ async function deployRemoteCanonicalInterchainToken() {
const interchainTokenFactoryContract = await getContractInstance(
interchainTokenFactoryContractAddress,
interchainTokenFactoryContractABI,
signer
signer,
);

// Estimate gas fees
Expand All @@ -322,7 +322,7 @@ async function deployRemoteCanonicalInterchainToken() {
customTokenAddress, // Your token address
"Polygon",
gasAmount,
{ value: gasAmount }
{ value: gasAmount },
);

console.log(`Transaction Hash: ${txn.hash}`);
Expand Down Expand Up @@ -369,7 +369,7 @@ Transaction Hash: 0xb963f5ce3402e1787ead0c8f421be79ac06e5b78305b1dbce184806e099d

### Check the transaction on the Axelar testnet scanner

Check the [Axelarscan testnet scanner](https://testnet.axelarscan.io/) to see if you have successfully deployed the remote Canonical Interchain Token “MAT” on the Polygon Mumbai testnet. It should look something like [this](https://testnet.axelarscan.io/gmp/0xb963f5ce3402e1787ead0c8f421be79ac06e5b78305b1dbce184806e099d54fd). Make sure that Axelar shows a successful transaction before continuing on to the next step.
Check the [Axelarscan testnet scanner](https://testnet.axelarscan.io/) to see if you have successfully deployed the remote Canonical Interchain Token “MAT” on the Polygon Amoy testnet. It should look something like [this](https://testnet.axelarscan.io/gmp/0xb963f5ce3402e1787ead0c8f421be79ac06e5b78305b1dbce184806e099d54fd). Make sure that Axelar shows a successful transaction before continuing on to the next step.

## Transfer your token between chains

Expand All @@ -389,18 +389,18 @@ async function transferTokens() {
const interchainTokenServiceContract = await getContractInstance(
interchainTokenServiceContractAddress,
interchainTokenServiceContractABI,
signer
signer,
);

const customTokenContract = await getContractInstance(
customTokenAddress,
customTokenContractABI,
signer
signer,
); // Approve ITS to spend tokens

await customTokenContract.approve(
interchainTokenServiceContractAddress,
ethers.utils.parseEther("50")
ethers.utils.parseEther("50"),
);

const gasAmount = await gasEstimator();
Expand All @@ -413,7 +413,7 @@ async function transferTokens() {
ethers.utils.parseEther("50"), // Amount to transfer
"0x00",
gasAmount, // gasValue
{ value: gasAmount }
{ value: gasAmount },
);

console.log("Transfer Transaction Hash:", transfer.hash);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ In this tutorial, you will learn how to:
You will need:

- A basic understanding of [Solidity](https://www.tutorialspoint.com/solidity/index.htm) and [JavaScript](https://www.w3schools.com/js/)
- A [MetaMask wallet](https://metamask.io/) with FTM and MATIC funds for testing. If you don’t have these funds, you can get FTM from the [Fantom faucet](https://faucet.fantom.network/) and MATIC from the Mumbai faucets ([1](https://faucet.polygon.technology/), [2](https://faucet.quicknode.com/polygon/mumbai)).
- A [MetaMask wallet](https://metamask.io/) with FTM and MATIC funds for testing. If you don’t have these funds, you can get FTM from the [Fantom faucet](https://faucet.fantom.network/) and MATIC from the Amoy faucets ([1](https://faucet.polygon.technology/), [2](https://faucet.quicknode.com/polygon/amoy)).

## **Set up your development environment**

Expand Down Expand Up @@ -183,18 +183,18 @@ async function registerAndDeploy() {
const interchainTokenFactoryContract = await getContractInstance(
interchainTokenFactoryContractAddress,
interchainTokenFactoryContractABI,
signer
signer,
);
const interchainTokenServiceContract = await getContractInstance(
interchainTokenServiceContractAddress,
interchainTokenServiceContractABI,
signer
signer,
);

// Generate a unique token ID using the signer's address and salt
const tokenId = await interchainTokenFactoryContract.interchainTokenId(
signer.address,
salt
salt,
);

// Retrieve new token address
Expand All @@ -213,7 +213,7 @@ async function registerAndDeploy() {
symbol,
decimals,
initialSupply,
signer.address
signer.address,
);

console.log(
Expand All @@ -223,7 +223,7 @@ async function registerAndDeploy() {
Transaction Hash: ${deployTxData.hash},
salt: ${salt},
Expected Token Manager Address: ${expectedTokenManagerAddress},
`
`,
);
}
```
Expand Down Expand Up @@ -302,7 +302,7 @@ async function gasEstimator() {
EvmChain.POLYGON,
GasToken.FTM,
700000,
1.1
1.1,
);

return gas;
Expand All @@ -313,7 +313,7 @@ async function gasEstimator() {

### Perform remote token deployment

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()`:
Create a `deployToRemoteChain()` function that will perform token remote deployment on the Polygon Amoy testnet. Make sure to replace the `salt` value with the salt returned to your terminal from when you ran `registerAndDeploy()`:

```javascript
//...
Expand All @@ -326,7 +326,7 @@ async function deployToRemoteChain() {
const interchainTokenFactoryContract = await getContractInstance(
interchainTokenFactoryContractAddress,
interchainTokenFactoryContractABI,
signer
signer,
);

// Estimate gas fees
Expand All @@ -343,7 +343,7 @@ async function deployToRemoteChain() {
signer.address,
"Polygon",
gasAmount,
{ value: gasAmount }
{ value: gasAmount },
);

console.log(`Transaction Hash: ${txn.hash}`);
Expand Down Expand Up @@ -390,7 +390,7 @@ Transaction Hash: 0xca901048c74c3757fcea5d309cd53ef6e21816c841e85145ac8586fa71a9

### Check the transaction on the Axelar testnet scanner

Check the [Axelarscan testnet scanner](https://testnet.axelarscan.io/) to see if you have successfully created and remotely deployed NIT on the Polygon Mumbai testnet. It should look something like [this](https://testnet.axelarscan.io/gmp/0xca901048c74c3757fcea5d309cd53ef6e21816c841e85145ac8586fa71a9cc48). Make sure that Axelar shows a successful transaction before continuing on to the next step.
Check the [Axelarscan testnet scanner](https://testnet.axelarscan.io/) to see if you have successfully created and remotely deployed NIT on the Polygon Amoy testnet. It should look something like [this](https://testnet.axelarscan.io/gmp/0xca901048c74c3757fcea5d309cd53ef6e21816c841e85145ac8586fa71a9cc48). Make sure that Axelar shows a successful transaction before continuing on to the next step.

## Transfer your token between chains

Expand All @@ -410,7 +410,7 @@ async function transferTokens() {
const interchainToken = await getContractInstance(
"0xc028ebdF906a890be73C594b6a14858D0552544A", // Update with new token address
interchainTokenContractABI, // Interchain Token contract ABI
signer
signer,
);

// Calculate gas amount
Expand All @@ -422,7 +422,7 @@ async function transferTokens() {
"0x510e5EA32386B7C48C4DEEAC80e86859b5e2416C", // Update with your own wallet address
ethers.utils.parseEther("25"), // Transfer 25 tokens
"0x", // Empty data payload
{ value: gasAmount } // Transaction options
{ value: gasAmount }, // Transaction options
);
console.log("Transfer Transaction Hash:", transfer.hash);
}
Expand Down Expand Up @@ -470,7 +470,7 @@ If you see this, it means that your interchain transfer has been successful!

### Check the transaction on the Axelar testnet scanner

Check the [Axelarscan testnet scanner](https://testnet.axelarscan.io/) to see if you have successfully transferred NIT from the Fantom testnet to the Polygon testnet. It should look something like [this](https://mumbai.polygonscan.com/token/0xc028ebdf906a890be73c594b6a14858d0552544a).
Check the [Axelarscan testnet scanner](https://testnet.axelarscan.io/) to see if you have successfully transferred NIT from the Fantom testnet to the Polygon testnet. It should look something like [this](https://testnet.axelarscan.io/gmp/0x205554f5e39e29b21f3110ebf813579a3826465746c37a151ed18c992004c6b5).

### Import the new token into your wallet

Expand Down

0 comments on commit 2ff1a29

Please sign in to comment.