ERC-20 Token Project on Solidity Sepolia using Hardhat Ethereum
This project consists of creating and deploying an ERC-20 token on the Sepolia test network using Hardhat and Ethereum.
The goal was to gain a deeper understanding of how smart contracts are developed, tested, and deployed on a blockchain environment.
I chose Ethereum because it is one of the most widely used and mature blockchains.
- It has a large developer community.
- It provides strong support for smart contract standards, especially ERC-20, which ensures compatibility with wallets (like MetaMask) and decentralized applications.
- Learning Ethereum allows me to apply the same principles later on other EVM-compatible blockchains.
I used Hardhat, a development framework for Ethereum, for two main reasons:
-
Local Blockchain Simulation
Hardhat provides a local blockchain environment, allowing me to test and deploy contracts without relying on external networks.
This gave me a low-level understanding of how transactions and deployments are handled. -
Deployment and Scripting
Hardhat makes it easy to compile, deploy, and interact with contracts across different networks (local, testnet as Sepolia, mainnet).
I wrote a deployment script to automate the process and ensure reproducibility.
I used Solidity as the programming language to implement my ERC-20 token contract.
- Purpose: Solidity is the main language for writing smart contracts on Ethereum and EVM-compatible blockchains.
- Syntax: It is inspired by JavaScript and C++, which makes it approachable for developers with prior programming experience.
- Token Standard: Using Solidity allowed me to directly implement the ERC-20 standard, ensuring compatibility with existing tools, wallets, and exchanges.
- Transparency: Since Solidity contracts are compiled into bytecode deployed on the blockchain, anyone can verify and audit the code once it is published (e.g., on Etherscan).
Example (simplified ERC-20 contract in Solidity):
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
constructor(uint256 initialSupply) {
totalSupply = initialSupply * (10 ** 18);
//msg.sender is the address of the wallet creating the request
balances[msg.sender] = totalSupply;
emit Transfer(address(0), owner, totalSupply);
}To deploy my contract on Sepolia, I needed access to a blockchain node. Running my own full node locally would be resource-intensive, so I used Alchemy, a blockchain development platform that provides reliable and scalable node infrastructure.
- Node Hosting: Alchemy acted as my remote Ethereum node, allowing Hardhat to connect to the Sepolia testnet.
- API Access: I used my Alchemy API key to configure Hardhat’s network settings.
- Stability: By using Alchemy, I ensured that my deployment was faster and more stable compared to running my own node.
This setup allowed me to bridge the gap between local testing (Hardhat) and public deployment (Sepolia).
Since deploying directly on the Ethereum mainnet is costly and requires real Ether, I used Sepolia, which is one of Ethereum’s official test networks.
- I obtained test ETH from a Sepolia faucet to cover deployment costs.
- I deployed my contract to Sepolia and used Sepolia Etherscan to verify and validate the contract.
- I chose single file importation for my contract, which simplified verification since all dependencies were bundled in one file.
- Write the smart contract (ERC-20 implementation).
- Compile and test the contract locally with Hardhat.
- Deploy to Sepolia using Hardhat scripts.
- Verify the contract on Sepolia Etherscan using the single file contract source.
- Interact with the token through Etherscan or MetaMask.
Through this project, I learned:
- How to set up a local blockchain environment with Hardhat.
- How to write and deploy an ERC-20 token contract.
- How to use Sepolia as a test environment before mainnet deployment.
- How to verify and interact with a contract via Etherscan.
This project gave me a hands-on understanding of the complete lifecycle of a smart contract, from local development to public deployment on a blockchain test network.