Saturday, May 17, 2025
No Result
View All Result
Blockchain 24hrs
  • Home
  • Bitcoin
  • Crypto Updates
    • General
    • Altcoins
    • Ethereum
    • Crypto Exchanges
  • Blockchain
  • NFT
  • DeFi
  • Metaverse
  • Web3
  • Blockchain Justice
  • Analysis
Crypto Marketcap
  • Home
  • Bitcoin
  • Crypto Updates
    • General
    • Altcoins
    • Ethereum
    • Crypto Exchanges
  • Blockchain
  • NFT
  • DeFi
  • Metaverse
  • Web3
  • Blockchain Justice
  • Analysis
No Result
View All Result
Blockchain 24hrs
No Result
View All Result

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

Home Web3
Share on FacebookShare on Twitter


This step-by-step information will train you how you can mint a multichain ERC-20 token on the Base community utilizing Axelar’s Interchain Token Service (ITS) and use the Moralis Token API to simply retrieve token balances.

Step 1: Stipulations

You’ll need:

Step 2: Arrange a brand new mission and required ABIs

On this step, you’ll need to create a brand new mission and arrange the required ABIs to work together with ITS and mint your ERC-20 token on the Base community.

Open your terminal and navigate to any listing of your alternative. Run the next instructions to create and provoke a mission:

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

Set up Hardhat and Moralis

Set up Hardhat and Moralis with the next instructions:

npm set up –save-dev [email protected] [email protected]
[email protected] @nomicfoundation/[email protected] moralis

Arrange mission ABIs

Subsequent, arrange the ABI for the Interchain Token Manufacturing facility as it is going to be wanted throughout deployment. Create a brand new file referred to as interchainTokenFactoryABI.json and add the Interchain Token Manufacturing facility ABI.

Create an .env file

To ensure you’re not by accident publishing your non-public key, create an .env file to retailer it in:

contact .env

Add your non-public key to .env

Export your non-public key and add it to the .env file you simply created:

PRIVATE_KEY= // Add your account non-public key right here

💡 If you’ll push this mission on GitHub, create a .gitignore file and embrace .env.

Step 3: Arrange the distant process name (RPC)

Subsequent, you’ll must arrange the RPC. Navigate to the listing the place you put in Hardhat and run the next command:

npx hardhat init

Choose Create an empty hardhat.config.js along 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 wish to do? …
Create a JavaScript mission
Create a TypeScript mission
Create a TypeScript mission (with Viem)
❯ Create an empty hardhat.config.js
Give up

Subsequent, replace hardhat.config.js with the next code snippet:

/** @kind import(‘hardhat/config’).HardhatUserConfig */
require(“@nomicfoundation/hardhat-toolbox”);
require(“dotenv”).config({ path: “.env” });

const PRIVATE_KEY = course of.env.PRIVATE_KEY;

/** @kind 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 finding the closest hardhat.config.js from the present listing, usually discovered on the root of your mission. Even an empty hardhat.config.js permits Hardhat to perform, as your whole setup is housed on this file.

Step 4: Mint an ERC-20 token with ITS

Now that you just’ve arrange a Base Sepolia testnet RPC, you possibly can mint a multichain ERC-20 token. For this tutorial, you’ll create a token utilizing the next info:


Title: My New Token



Image: MNT



Decimals: 18

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


Ethers.js



Moralis



The contract ABI



The InterchainTokenFactory contract handle



Your token info

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 brand new token
const title = “My New Tokenn”;
const image = “MNT”;
const decimals = 18;

// Intial token to be minted
const initialSupply = ethers.utils.parseEther(“1000”);

Create a mintToken() perform

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

//…

// Mint a brand new ERC-20 multichain token to the Base Sepolia testnet
strive {
// Generate random salt
const salt = “0x” + crypto.randomBytes(32).toString(“hex”);

// Get a signer to signal the transaction
const [signer] = await ethers.getSigners();

// Create contract cases
const interchainTokenFactoryContract = await new ethers.Contract(
interchainTokenFactoryContractAddress,
interchainTokenFactoryContractABI,
signer
);

// Deploy the token
const deployTxData =
await interchainTokenFactoryContract.deployInterchainToken(
salt,
title,
image,
decimals,
initialSupply,
signer.handle
);

console.log(
`
Transaction Hash: ${deployTxData.hash},
salt: ${salt},
`
);
} catch (e) {
console.error(e);
}

Add a predominant() perform

Add a predominant() perform for executing script.js. It should deal with any errors which will come up:

//…

async perform predominant() {
const functionName = course of.env.FUNCTION_NAME;
swap (functionName) {
case “mintToken”:
await mintToken();
break;
default:
console.error(`Unknown perform: ${functionName}`);
course of.exitCode = 1;
return;
}
}

predominant().catch((error) => {
console.error(error);
course of.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 must see one thing much like the next in your console:

Transaction Hash: 0x7695f2dd6e29240fc792d37fd6b86f402f2b5338e088e0ad4a448685e0ad565b,
salt: 0xef36cf55326c3fb9fb47c6d3828b8a4ea12fdfab31aae4bc3634bf7bbe04eb49,

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

Step 5: Verify the minted token steadiness with the Moralis API

Now that you’ve efficiently minted your new token, it’s time to retrieve the steadiness.

Add the Moralis API key to .env

MORALIS_API_KEY= // Add you Moralis API key right here

Get your token steadiness

Add the next within the script.js file:

//…

const MORALIS_API_KEY = course of.env.MORALIS_API_KEY;

// Get person steadiness with the Moralis API
async perform getBalance() {
strive {
console.log(“Getting steadiness…”);
await Moralis.begin({
apiKey: MORALIS_API_KEY,
});

const response = await Moralis.EvmApi.token.getWalletTokenBalances({
chain: “84532”, // Base Sepolia
handle: “0x510e5EA32386B7C48C4DEEAC80e86859b5e2416C”, // Consumer handle
});

console.log(response.uncooked);
} catch (e) {
console.error(e);
}
}

Replace predominant() to get the token steadiness

Replace predominant() to execute getBalance() :

//…

async perform predominant() {
const functionName = course of.env.FUNCTION_NAME;
swap (functionName) {
//…
case “getBalance”:
await getBalance();
break;
default:
//…
}
}

Run the script in your terminal to retrieve your token:

FUNCTION_NAME=getBalance node script.js 

You must see one thing much like the next in your console:

Getting steadiness…
[
{
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
}
]

Abstract

The tutorial offers a step-by-step information on minting a multichain ERC-20 token on the Base Sepolia community utilizing Axelar’s Interchain Token Service (ITS). The method includes establishing stipulations, creating a brand new mission and ABIs, establishing a distant process name (RPC), minting the ERC-20 token with ITS, and checking the minted token steadiness with the Moralis API.

References

Now that you understand how to mint a multichain token, take a look at the next:



Source link

Tags: BaseERC20InterchainMintMoralisServiceStepstokenWeb3
Previous Post

Dogwifhat, Popcat, Bonk brace for key competitor: Poodlana

Next Post

July 2024 Newsletter for All Things BitPay & Crypto

Related Posts

‘Fortnite’ Fixes AI-Powered Darth Vader After It Starts Saying Slurs
Web3

‘Fortnite’ Fixes AI-Powered Darth Vader After It Starts Saying Slurs

May 16, 2025
Bitcoin and Ethereum Waver as Investors Take Profits on Recent Rally
Web3

Bitcoin and Ethereum Waver as Investors Take Profits on Recent Rally

May 15, 2025
Brian Armstrong Makes ‘Open Call’ For Ex-DOGE Staff to Join Coinbase
Web3

Brian Armstrong Makes ‘Open Call’ For Ex-DOGE Staff to Join Coinbase

May 14, 2025
Truth Social Denies Meme Coin Plans as Trump Token Slips
Web3

Truth Social Denies Meme Coin Plans as Trump Token Slips

May 13, 2025
US Futures Rise, Crypto Retreats as White House Signals Progress in China Talks
Web3

US Futures Rise, Crypto Retreats as White House Signals Progress in China Talks

May 12, 2025
Yat Siu on building web3’s most influential unicorn 
Web3

Yat Siu on building web3’s most influential unicorn 

May 12, 2025
Next Post
July 2024 Newsletter for All Things BitPay & Crypto

July 2024 Newsletter for All Things BitPay & Crypto

TON Foundation to Launch Bitcoin Bridge on The Open Network

TON Foundation to Launch Bitcoin Bridge on The Open Network

Facebook Twitter Instagram Youtube RSS
Blockchain 24hrs

Blockchain 24hrs delivers the latest cryptocurrency and blockchain technology news, expert analysis, and market trends. Stay informed with round-the-clock updates and insights from the world of digital currencies.

CATEGORIES

  • Altcoins
  • Analysis
  • Bitcoin
  • Blockchain
  • Blockchain Justice
  • Crypto Exchanges
  • Crypto Updates
  • DeFi
  • Ethereum
  • Metaverse
  • NFT
  • Regulations
  • Web3

SITEMAP

  • About Us
  • Advertise With Us
  • Disclaimer
  • Privacy Policy
  • DMCA
  • Cookie Privacy Policy
  • Terms and Conditions
  • Contact Us

Copyright © 2024 Blockchain 24hrs.
Blockchain 24hrs is not responsible for the content of external sites.

  • bitcoinBitcoin(BTC)$103,234.00-0.71%
  • ethereumEthereum(ETH)$2,478.62-3.97%
  • tetherTether(USDT)$1.00-0.01%
  • rippleXRP(XRP)$2.34-2.70%
  • binancecoinBNB(BNB)$641.77-1.24%
  • solanaSolana(SOL)$166.48-2.49%
  • usd-coinUSDC(USDC)$1.000.00%
  • dogecoinDogecoin(DOGE)$0.215325-4.91%
  • cardanoCardano(ADA)$0.74-3.90%
  • tronTRON(TRX)$0.271722-0.20%
No Result
View All Result
  • Home
  • Bitcoin
  • Crypto Updates
    • General
    • Altcoins
    • Ethereum
    • Crypto Exchanges
  • Blockchain
  • NFT
  • DeFi
  • Metaverse
  • Web3
  • Blockchain Justice
  • Analysis
Crypto Marketcap

Copyright © 2024 Blockchain 24hrs.
Blockchain 24hrs is not responsible for the content of external sites.