DeFi Daily News
Tuesday, June 17, 2025
Advertisement
  • Cryptocurrency
    • Bitcoin
    • Ethereum
    • Altcoins
    • DeFi-IRA
  • DeFi
    • NFT
    • Metaverse
    • Web 3
  • Finance
    • Business Finance
    • Personal Finance
  • Markets
    • Crypto Market
    • Stock Market
    • Analysis
  • Other News
    • World & US
    • Politics
    • Entertainment
    • Tech
    • Sports
    • Health
  • Videos
No Result
View All Result
DeFi Daily News
  • Cryptocurrency
    • Bitcoin
    • Ethereum
    • Altcoins
    • DeFi-IRA
  • DeFi
    • NFT
    • Metaverse
    • Web 3
  • Finance
    • Business Finance
    • Personal Finance
  • Markets
    • Crypto Market
    • Stock Market
    • Analysis
  • Other News
    • World & US
    • Politics
    • Entertainment
    • Tech
    • Sports
    • Health
  • Videos
No Result
View All Result
DeFi Daily News
No Result
View All Result
Home DeFi Web 3

Creating an ERC-20 Token on Base using the Interchain Token Service in 5 Easy Steps with Moralis for Developers | Enterprise-Grade Web3 APIs

David Olsson by David Olsson
July 18, 2024
in Web 3
0 0
0
Creating an ERC-20 Token on Base using the Interchain Token Service in 5 Easy Steps with Moralis for Developers | Enterprise-Grade Web3 APIs
0
SHARES
0
VIEWS
Share on FacebookShare on TwitterShare on Telegram
Listen to this article

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: ““,
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

“`javascript
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:

“`javascript
//…

// 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:

“`javascript
//…

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:

“`bash
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: Transaction Token: Token

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

“`bash
MORALIS_API_KEY= // Add you Moralis API key here
“`

Get your token balance

Add the following in the script.js file:

“`javascript
//…

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() :

“`javascript
//…

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:

“`bash
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:

For more trending news articles like this, visit DeFi Daily News

***Conclusion:***

Congratulations on successfully minting your multichain ERC-20 token on the Base network using Axelar’s Interchain Token Service (ITS) and utilizing the Moralis Token API to retrieve your token balances. You have now ventured into the exciting world of decentralized finance (DeFi) and added a new asset to the crypto ecosystem. Keep exploring, experimenting, and innovating in the ever-evolving blockchain space. Stay tuned to DeFi Daily News for more updates, trends, and insights into the world of decentralized finance. Happy minting and token trading!



Source link

Tags: APIsBaseCreatingDevelopersEASYEnterpriseGradeERC20InterchainMoralisServiceStepstokenWeb3
ShareTweetShare
Previous Post

This year’s summer rally has gotten healthier, says Bank of America’s Stephen Suttmeier

Next Post

“I Don’t Know How I’m Going To Pay This Stuff Off”

Next Post
“I Don’t Know How I’m Going To Pay This Stuff Off”

“I Don’t Know How I’m Going To Pay This Stuff Off”

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

No Result
View All Result
  • Trending
  • Comments
  • Latest
Exploring the Top Option for Streaming On-Chain Data – Moralis Web3 | Enterprise-Grade Web3 APIs as an Alternative to QuickAlerts

Exploring the Top Option for Streaming On-Chain Data – Moralis Web3 | Enterprise-Grade Web3 APIs as an Alternative to QuickAlerts

July 12, 2024
Revisiting Jennifer’s Body: A Review of the 2009 Horror Film

Revisiting Jennifer’s Body: A Review of the 2009 Horror Film

August 27, 2024
5 Crypto Experts Predict: Bitcoin is About To EXPLODE Just Like Gold!

5 Crypto Experts Predict: Bitcoin is About To EXPLODE Just Like Gold!

May 3, 2025
The Future of Blockchain: An Inside Look at Cardano

The Future of Blockchain: An Inside Look at Cardano

July 18, 2024
Proximus Group Partners with Infosys to Explore New Business Opportunities

Proximus Group Partners with Infosys to Explore New Business Opportunities

September 10, 2024
rewrite this title Hudson Pacific Properties: Beware The Perceived Discount (NYSE:HPP)

rewrite this title Hudson Pacific Properties: Beware The Perceived Discount (NYSE:HPP)

May 6, 2025
rewrite this title with good SEO Dogecoin Price Enters Historical Bounce Zone, But Will This Time Be Different? | Bitcoinist.com

rewrite this title with good SEO Dogecoin Price Enters Historical Bounce Zone, But Will This Time Be Different? | Bitcoinist.com

June 17, 2025
rewrite this title and make it good for SEOThe smallest country on the Southeast Asia 500 generated the most revenue 

rewrite this title and make it good for SEOThe smallest country on the Southeast Asia 500 generated the most revenue 

June 17, 2025
rewrite this title Anne Burrell's Final Instagram Post Before Her Unexpected Death Was Joyful

rewrite this title Anne Burrell's Final Instagram Post Before Her Unexpected Death Was Joyful

June 17, 2025
rewrite this title Analyst Says Ethereum Is Ready To Surge With Higher Lows Against Bitcoin, But There’s A Caveat | Bitcoinist.com

rewrite this title Analyst Says Ethereum Is Ready To Surge With Higher Lows Against Bitcoin, But There’s A Caveat | Bitcoinist.com

June 17, 2025
rewrite this title Senate Passes Landmark Stablecoin Bill in Major Boon for Crypto Industry – Decrypt

rewrite this title Senate Passes Landmark Stablecoin Bill in Major Boon for Crypto Industry – Decrypt

June 17, 2025
rewrite this title JPMorgan Unveils Its U.S. Dollar-backed JPMD Stablecoin on Ethereum’s Base

rewrite this title JPMorgan Unveils Its U.S. Dollar-backed JPMD Stablecoin on Ethereum’s Base

June 17, 2025
DeFi Daily

Stay updated with DeFi Daily, your trusted source for the latest news, insights, and analysis in finance and cryptocurrency. Explore breaking news, expert analysis, market data, and educational resources to navigate the world of decentralized finance.

  • About Us
  • Blogs
  • DeFi-IRA | Learn More.
  • Advertise with Us
  • Disclaimer
  • Privacy Policy
  • DMCA
  • Cookie Privacy Policy
  • Terms and Conditions
  • Contact us

Copyright © 2024 Defi Daily.
Defi Daily is not responsible for the content of external sites.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
No Result
View All Result
  • Cryptocurrency
    • Bitcoin
    • Ethereum
    • Altcoins
    • DeFi-IRA
  • DeFi
    • NFT
    • Metaverse
    • Web 3
  • Finance
    • Business Finance
    • Personal Finance
  • Markets
    • Crypto Market
    • Stock Market
    • Analysis
  • Other News
    • World & US
    • Politics
    • Entertainment
    • Tech
    • Sports
    • Health
  • Videos

Copyright © 2024 Defi Daily.
Defi Daily is not responsible for the content of external sites.