Altszn.com
  • Home
  • Crypto
    • Altcoins
    • Bitcoin
    • Ethereum
    • Monero
    • XRP
    • Zcash
  • Web3
  • DeFi
  • NFTs
No Result
View All Result
Altszn.com
  • Home
  • Crypto
    • Altcoins
    • Bitcoin
    • Ethereum
    • Monero
    • XRP
    • Zcash
  • Web3
  • DeFi
  • NFTs
No Result
View All Result
Altszn.com
No Result
View All Result

How to Mint an ERC-20 Token on Base with the Interchain Token Service in 5 Steps – Moralis Web3

Altszn.com by Altszn.com
July 18, 2024
in Web3
0
How to Mint an ERC-20 Token on Base with the Interchain Token Service in 5 Steps – Moralis Web3
399
SHARES
2.3k
VIEWS
Share on FacebookShare on Twitter


This step-by-step guide will teach you how to mint a multichain ERC-20 token on the Base network using Axelar’s Interchain Token Service (ITS) and use the Moralis Token API to easily retrieve token balances.

Step 1: Prerequisites

You will need:

Step 2: Set up a new project and required ABIs

In this step, you will need to create a new project and set up the required ABIs to interact with ITS and mint your ERC-20 token on the Base network.

Open your terminal and navigate to any directory of your choice. Run the following commands to create and initiate a project:

mkdir mint-token && cd mint-token npm init -y

Install Hardhat and Moralis

Install Hardhat and Moralis with the following commands:

npm install --save-dev [email protected] [email protected] \\ [email protected] @nomicfoundation/[email protected] moralis

Set up project ABIs

Next, set up the ABI for the Interchain Token Factory as it will be needed during deployment. Create a new file called interchainTokenFactoryABI.json and add the Interchain Token Factory ABI.

Create an .env file

To make sure you’re not accidentally publishing your private key, create an .env file to store it in:

touch .env

Add your private key to .env

Export your private key and add it to the .env file you just created:

PRIVATE_KEY= // Add your account private key here

💡 If you will push this project on GitHub, create a .gitignore file and include .env.

Step 3: Set up the remote procedure call (RPC)

Next, you’ll need to set up the RPC. Navigate to the directory where you installed Hardhat and run the following command:

npx hardhat init

Select Create an empty hardhat.config.js with your keyboard and hit enter:

888    888                      888 888               888 888    888                      888 888               888 888    888                      888 888               888 8888888888  8888b.  888d888 .d88888 88888b.   8888b.  888888 888    888     "88b 888P"  d88" 888 888 "88b     "88b 888 888    888 .d888888 888    888  888 888  888 .d888888 888 888    888 888  888 888    Y88b 888 888  888 888  888 Y88b. 888    888 "Y888888 888     "Y88888 888  888 "Y888888  "Y888  👷 Welcome to Hardhat v2.18.1 👷‍  ? What do you want to do? …   Create a JavaScript project   Create a TypeScript project   Create a TypeScript project (with Viem) ❯ Create an empty hardhat.config.js   Quit

Next, update hardhat.config.js with the following code snippet:

/** @type import('hardhat/config').HardhatUserConfig */ require("@nomicfoundation/hardhat-toolbox"); require("dotenv").config({ path: ".env" });  const PRIVATE_KEY = process.env.PRIVATE_KEY;  /** @type import('hardhat/config').HardhatUserConfig */ module.exports = {   solidity: "0.8.19",   networks: {     base: {       url: "<https://base-sepolia-rpc.publicnode.com>",       chainId: 84532,       accounts: [PRIVATE_KEY],     },   }, };

Hardhat runs by locating the nearest hardhat.config.js from the current directory, typically found at the root of your project. Even an empty hardhat.config.js allows Hardhat to function, as your entire setup is housed in this file.

Step 4: Mint an ERC-20 token with ITS

Now that you’ve set up a Base Sepolia testnet RPC, you can mint a multichain ERC-20 token. For this tutorial, you will create a token using the following information:

  • Name: My New Token
  • Symbol: MNT
  • Decimals: 18

Create a new file named script.js. Import the necessary dependencies:

  • Ethers.js
  • Moralis
  • The contract ABI
  • The InterchainTokenFactory contract address
  • Your token information
const hre = require("hardhat"); const crypto = require("crypto"); const Moralis = require("moralis").default; const ethers = hre.ethers;  const interchainTokenFactoryContractABI = require("./interchainTokenFactoryABI");  const interchainTokenFactoryContractAddress =   "0x83a93500d23Fbc3e82B410aD07A6a9F7A0670D66";    // Create a new token const name = "My New Tokenn"; const symbol = "MNT"; const decimals = 18;  // Intial token to be minted const initialSupply = ethers.utils.parseEther("1000");

Create a mintToken() function

Create a mintToken() function for minting a new token on the Base Sepolia testnet:

//...  // Mint a new ERC-20 multichain token to the Base Sepolia testnet try {     // Generate random salt     const salt = "0x" + crypto.randomBytes(32).toString("hex");      // Get a signer to sign the transaction     const [signer] = await ethers.getSigners();      // Create contract instances     const interchainTokenFactoryContract = await new ethers.Contract(       interchainTokenFactoryContractAddress,       interchainTokenFactoryContractABI,       signer     );      // Deploy the token     const deployTxData =       await interchainTokenFactoryContract.deployInterchainToken(         salt,         name,         symbol,         decimals,         initialSupply,         signer.address       );      console.log(       `     Transaction Hash: ${deployTxData.hash},     salt: ${salt},     `     );   } catch (e) {     console.error(e); }

Add a main() function

Add a main() function for executing script.js. It will handle any errors that may arise:

//...  async function main() {   const functionName = process.env.FUNCTION_NAME;   switch (functionName) {     case "mintToken":       await mintToken();       break;     default:       console.error(`Unknown function: ${functionName}`);       process.exitCode = 1;       return;   } }  main().catch((error) => {   console.error(error);   process.exitCode = 1; }); 

Run  script.js  to deploy your token to the Base Sepolia testnet

Run the script in your terminal to create and mint the token, specifying the Base Sepolia testnet:

FUNCTION_NAME=mintToken npx hardhat run script.js --network base

You should see something similar to the following on your console:

Transaction Hash: 0x7695f2dd6e29240fc792d37fd6b86f402f2b5338e088e0ad4a448685e0ad565b, salt: 0xef36cf55326c3fb9fb47c6d3828b8a4ea12fdfab31aae4bc3634bf7bbe04eb49,

Transaction: https://sepolia.basescan.org/tx/0x7695f2dd6e29240fc792d37fd6b86f402f2b5338e088e0ad4a448685e0ad565b Token: https://sepolia.basescan.org/token/0x274e53a526fa2543ce19f9c0334286b4724aa5e0

Step 5: Check the minted token balance with the Moralis API

Now that you have successfully minted your new token, it’s time to retrieve the balance.

Add the Moralis API key to .env

MORALIS_API_KEY= // Add you Moralis API key here

Get your token balance

Add the following in the script.js file:

//...  const MORALIS_API_KEY = process.env.MORALIS_API_KEY;  // Get user balance with the Moralis API async function getBalance() {   try {     console.log("Getting balance...");     await Moralis.start({       apiKey: MORALIS_API_KEY,     });      const response = await Moralis.EvmApi.token.getWalletTokenBalances({       chain: "84532", // Base Sepolia       address: "0x510e5EA32386B7C48C4DEEAC80e86859b5e2416C", // User address     });      console.log(response.raw);   } catch (e) {     console.error(e);   } }

Update main() to get the token balance

Update main() to execute getBalance() :

//...  async function main() {   const functionName = process.env.FUNCTION_NAME;   switch (functionName) {     //...     case "getBalance":       await getBalance();       break;     default:     //...   } }

Run the script in your terminal to retrieve your token:

FUNCTION_NAME=getBalance node script.js 

You should see something similar to the following on your console:

Getting balance... [   {     token_address: '0x274e53a526fa2543ce19f9c0334286b4724aa5e0',     symbol: 'MNT',     name: 'My New Tokenn',     logo: null,     thumbnail: null,     decimals: 18,     balance: '1000000000000000000000',     possible_spam: false,     verified_contract: false,     total_supply: '1000000000000000000000',     total_supply_formatted: '1000',     percentage_relative_to_total_supply: 100   } ]

Summary

The tutorial provides a step-by-step guide on minting a multichain ERC-20 token on the Base Sepolia network using Axelar’s Interchain Token Service (ITS). The process involves setting up prerequisites, creating a new project and ABIs, setting up a remote procedure call (RPC), minting the ERC-20 token with ITS, and checking the minted token balance with the Moralis API.

References

Now that you know how to mint a multichain token, check out the following:



Read More: moralis.io

Tags: BaseERC20interchainMintMoralisServicestepsTokenweb 3.0Web3
ADVERTISEMENT

Recent

Top crypto gainers today: Flare, Monero, Zcash break out – What’s fueling the rally?

Top crypto gainers today: Flare, Monero, Zcash break out – What’s fueling the rally?

June 3, 2025
SEC flags legal issues with Ethereum, Solana ETFs – Delay ahead?

SEC flags legal issues with Ethereum, Solana ETFs – Delay ahead?

June 2, 2025
The Dark Times Are Here. Where Is Bitcoin?

The Dark Times Are Here. Where Is Bitcoin?

June 2, 2025

Categories

  • Bitcoin (4,485)
  • Blockchain (10,699)
  • Crypto (8,639)
  • Dark Web (435)
  • DeFi (8,061)
  • Ethereum (4,512)
  • Metaverse (6,720)
  • Monero (242)
  • NFT (1,049)
  • Solana (4,888)
  • Web3 (19,721)
  • Zcash (459)

Category

Select Category

    Advertise

    Advertise your site, company or product to millions of web3, NFT and cryptocurrency enthusiasts. Learn more

    Useful Links

    Advertise
    DMCA
    Contact Us
    Privacy Policy
    Shipping & Returns
    Terms of Use

    Resources

    Exchanges
    Changelly
    Web3 Jobs

    Recent News

    Top crypto gainers today: Flare, Monero, Zcash break out – What’s fueling the rally?

    Top crypto gainers today: Flare, Monero, Zcash break out – What’s fueling the rally?

    June 3, 2025
    SEC flags legal issues with Ethereum, Solana ETFs – Delay ahead?

    SEC flags legal issues with Ethereum, Solana ETFs – Delay ahead?

    June 2, 2025

    © 2022 Altszn.com. All Rights Reserved.

    No Result
    View All Result
    • Home
      • Home – Layout 1
      • Home – Layout 2
      • Home – Layout 3

    © Altszn.com. All Rights Reserved.

    • bitcoinBitcoin (BTC) $ 106,309.00
    • ethereumEthereum (ETH) $ 2,622.10
    • tetherTether (USDT) $ 1.00
    • xrpXRP (XRP) $ 2.21
    • bnbBNB (BNB) $ 669.52
    • solanaSolana (SOL) $ 158.83
    • usd-coinUSDC (USDC) $ 0.999778
    • dogecoinDogecoin (DOGE) $ 0.196505
    • tronTRON (TRX) $ 0.268787
    • cardanoCardano (ADA) $ 0.697092
    • staked-etherLido Staked Ether (STETH) $ 2,619.69
    • wrapped-bitcoinWrapped Bitcoin (WBTC) $ 106,205.00
    • hyperliquidHyperliquid (HYPE) $ 36.38
    • suiSui (SUI) $ 3.35
    • wrapped-stethWrapped stETH (WSTETH) $ 3,154.70
    • chainlinkChainlink (LINK) $ 14.14
    • avalanche-2Avalanche (AVAX) $ 21.35
    • stellarStellar (XLM) $ 0.272485
    • bitcoin-cashBitcoin Cash (BCH) $ 403.12
    • the-open-networkToncoin (TON) $ 3.22
    • leo-tokenLEO Token (LEO) $ 8.52
    • shiba-inuShiba Inu (SHIB) $ 0.000013
    • hedera-hashgraphHedera (HBAR) $ 0.172244
    • wethWETH (WETH) $ 2,622.99
    • usdsUSDS (USDS) $ 0.999825
    • litecoinLitecoin (LTC) $ 90.13
    • wrapped-eethWrapped eETH (WEETH) $ 2,803.01
    • moneroMonero (XMR) $ 358.34
    • polkadotPolkadot (DOT) $ 4.18
    • binance-bridged-usdt-bnb-smart-chainBinance Bridged USDT (BNB Smart Chain) (BSC-USD) $ 1.00
    • ethena-usdeEthena USDe (USDE) $ 1.00
    • bitget-tokenBitget Token (BGB) $ 4.79
    • pepePepe (PEPE) $ 0.000012
    • pi-networkPi Network (PI) $ 0.649724
    • coinbase-wrapped-btcCoinbase Wrapped BTC (CBBTC) $ 106,285.00
    • whitebitWhiteBIT Coin (WBT) $ 31.50
    • aaveAave (AAVE) $ 256.88
    • uniswapUniswap (UNI) $ 6.46
    • bittensorBittensor (TAO) $ 404.34
    • daiDai (DAI) $ 0.999995
    • ethena-staked-usdeEthena Staked USDe (SUSDE) $ 1.18
    • aptosAptos (APT) $ 4.92
    • nearNEAR Protocol (NEAR) $ 2.54
    • crypto-com-chainCronos (CRO) $ 0.103518
    • okbOKB (OKB) $ 50.19
    • jito-staked-solJito Staked SOL (JITOSOL) $ 191.63
    • blackrock-usd-institutional-digital-liquidity-fundBlackRock USD Institutional Digital Liquidity Fund (BUIDL) $ 1.00
    • internet-computerInternet Computer (ICP) $ 5.20
    • ondo-financeOndo (ONDO) $ 0.857706
    • ethereum-classicEthereum Classic (ETC) $ 17.62
    • bitcoinBitcoin (BTC) $ 106,309.00
    • ethereumEthereum (ETH) $ 2,622.10
    • tetherTether (USDT) $ 1.00
    • xrpXRP (XRP) $ 2.21
    • bnbBNB (BNB) $ 669.52
    • solanaSolana (SOL) $ 158.83
    • usd-coinUSDC (USDC) $ 0.999778
    • dogecoinDogecoin (DOGE) $ 0.196505
    • tronTRON (TRX) $ 0.268787
    • cardanoCardano (ADA) $ 0.697092
    • staked-etherLido Staked Ether (STETH) $ 2,619.69
    • wrapped-bitcoinWrapped Bitcoin (WBTC) $ 106,205.00
    • hyperliquidHyperliquid (HYPE) $ 36.38
    • suiSui (SUI) $ 3.35
    • wrapped-stethWrapped stETH (WSTETH) $ 3,154.70
    • chainlinkChainlink (LINK) $ 14.14
    • avalanche-2Avalanche (AVAX) $ 21.35
    • stellarStellar (XLM) $ 0.272485
    • bitcoin-cashBitcoin Cash (BCH) $ 403.12
    • the-open-networkToncoin (TON) $ 3.22
    • leo-tokenLEO Token (LEO) $ 8.52
    • shiba-inuShiba Inu (SHIB) $ 0.000013
    • hedera-hashgraphHedera (HBAR) $ 0.172244
    • wethWETH (WETH) $ 2,622.99
    • usdsUSDS (USDS) $ 0.999825
    • litecoinLitecoin (LTC) $ 90.13
    • wrapped-eethWrapped eETH (WEETH) $ 2,803.01
    • moneroMonero (XMR) $ 358.34
    • polkadotPolkadot (DOT) $ 4.18
    • binance-bridged-usdt-bnb-smart-chainBinance Bridged USDT (BNB Smart Chain) (BSC-USD) $ 1.00
    • ethena-usdeEthena USDe (USDE) $ 1.00
    • bitget-tokenBitget Token (BGB) $ 4.79
    • pepePepe (PEPE) $ 0.000012
    • pi-networkPi Network (PI) $ 0.649724
    • coinbase-wrapped-btcCoinbase Wrapped BTC (CBBTC) $ 106,285.00
    • whitebitWhiteBIT Coin (WBT) $ 31.50
    • aaveAave (AAVE) $ 256.88
    • uniswapUniswap (UNI) $ 6.46
    • bittensorBittensor (TAO) $ 404.34
    • daiDai (DAI) $ 0.999995
    • ethena-staked-usdeEthena Staked USDe (SUSDE) $ 1.18
    • aptosAptos (APT) $ 4.92
    • nearNEAR Protocol (NEAR) $ 2.54
    • crypto-com-chainCronos (CRO) $ 0.103518
    • okbOKB (OKB) $ 50.19
    • jito-staked-solJito Staked SOL (JITOSOL) $ 191.63
    • blackrock-usd-institutional-digital-liquidity-fundBlackRock USD Institutional Digital Liquidity Fund (BUIDL) $ 1.00
    • internet-computerInternet Computer (ICP) $ 5.20
    • ondo-financeOndo (ONDO) $ 0.857706
    • ethereum-classicEthereum Classic (ETC) $ 17.62