Token Minter
Deploying an ERC-20 Token on the KiteAI Testnet
Overview
This guide provides a comprehensive walkthrough for deploying an ERC-20 token on the KiteAI Testnet. It covers two primary methods:
Remix IDE: A beginner-friendly, browser-based approach.
Foundry: A command-line toolchain suitable for advanced users.
Before diving into the deployment steps, it's essential to understand the KiteAI network and the significance of deploying on this platform.
Understanding the KiteAI Network
What is KiteAI?
KiteAI is an EVM-compatible L1 blockchain designed to empower decentralized AI economies using, powered by Proof of AI (PoAI). This innovative consensus mechanism that ensures fair attribution and transparent rewards for contributors across agents, models, and data.
Key Features:
Chain ID: 2368 (0x940)
Native Currency: KITE
Block Gas Limit: 400,000,000
Testnet Faucet: https://faucet.gokite.ai/
Network Addition: Chainlist - KiteAI Testnet
Why Deploy on KiteAI?
Deploying on the KiteAI network allows developers to:
Test and validate smart contracts in an AI-enhanced environment.
Participate in a forward-thinking ecosystem that combines blockchain and AI technologies.
What You Will Do
Create an ERC-20 token smart contract using OpenZeppelin's standard implementation.
Deploy the contract to the KiteAI Testnet using:
Remix IDE (beginner-friendly)
Foundry (advanced CLI tool)
What You Will Need
A Web3 wallet (e.g., MetaMask)
Test Kite tokens (claim from faucet.gokite.ai)
Access to the KiteAI Testnet via MetaMask. (via Chainlist)
Basic knowledge of Solidity and smart contract development.
Understanding ERC-20 Token?
An ERC-20 token is a standardized smart contract on Ethereum and EVM-compatible blockchains that defines a set of rules for fungible tokens. These rules include how tokens are transferred, how users can access data about a token, and the total supply of tokens.
Key Functions:
totalSupply(): Returns the total token supply.
balanceOf(address): Returns the account balance of another account with address address.
transfer(address, uint256): Transfers amount of tokens to address recipient.
approve(address, uint256): Allows spender to withdraw from your account multiple times, up to the amount.
transferFrom(address, address, uint256): Transfers amount tokens from address sender to address recipient.
allowance(address, address): Returns the amount which spender is still allowed to withdraw from the owner.
Method 1: Deploying via Remix IDE
Step 1: Add KiteAI Testnet to MetaMask
Visit Chainlist - KiteAI Testnet.
Connect your MetaMask wallet.
Add the KiteAI Testnet to your networks.
Step 2: Obtain Test Kite Tokens
Visit the KiteAI Faucet.
Connect your MetaMask wallet.
Request 0.5 Kite tokens.
Step 3: Write the Smart Contract
Open Remix IDE.
Create a new file named ”MyToken.sol”.
Paste the following code:
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract MyToken is ERC20 { constructor(uint256 initialSupply) ERC20("MyToken", "MTK") { _mint(msg.sender, initialSupply); } }
This contract uses OpenZeppelin's ERC-20 implementation to create a token named "MyToken" with the symbol "MTK".
Step 4: Compile the Contract
Navigate to the "Solidity Compiler" tab in Remix.
Ensure the compiler version is set to 0.8.20 or higher.
Click "Compile MyToken.sol".
Step 5: Deploy the Contract
Go to the "Deploy & Run Transactions" tab.
Set the environment to "Injected Provider - MetaMask".
Ensure MetaMask is connected to the KiteAI Testnet.
Enter the initial supply (e.g., 1000000 for 1 million tokens).
Click "Deploy".
Confirm the transaction in MetaMask.
Once deployed, your ERC-20 token will be live on the KiteAI Testnet.
Method 2: Deploying via Foundry
Step 1: Install Foundry
If you haven't installed Foundry:
curl -L https://foundry.paradigm.xyz | bash foundryup
Step 2: Initialize the Project
forge init MyTokenProject cd MyTokenProject
Step 3: Install OpenZeppelin Contracts
forge install OpenZeppelin/openzeppelin-contracts
Step 4: Configure Remappings
In foundry.toml, add:
[profile.default] remappings = ["@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/"]
Step 5: Write the Smart Contract
Create a new file at src/MyToken.sol:
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract MyToken is ERC20 { constructor(uint256 initialSupply) ERC20("MyToken", "MTK") { _mint(msg.sender, initialSupply); } }
Step 6: Create Deployment Script
Create a new file at script/Deploy.s.sol:
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "forge-std/Script.sol"; import "../src/MyToken.sol"; contract DeployScript is Script { function run() external { vm.startBroadcast(); new MyToken(1000000 * 10 ** 18); vm.stopBroadcast(); } }
Step 7: Set Environment Variables
Create a .env file in the root directory:
PRIVATE_KEY=your_private_key RPC_URL=https://rpc-testnet.gokite.ai
Replace your_private_key with your wallet's private key that holds Kite tokens.
Step 8: Build and Deploy
source .env forge build forge script script/Deploy.s.sol:DeployScript --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast
After deployment, Foundry will provide the contract address and transaction details.
Conclusion
Deploying an ERC-20 token on the KiteAI Testnet is straightforward using either Remix IDE or Foundry. By following this guide, developers can:
Understand the KiteAI network and its unique features.
Write and deploy ERC-20 tokens efficiently.
Choose the deployment method that best suits their experience level.
For further exploration, consider integrating additional functionalities into your token, such as minting, burning, or pausing transfers, using OpenZeppelin's extensive library of smart contract modules.
Last updated