ERC-20 token is a fungible digital asset on the Ethereum blockchain that follows a standard interface (with functions like totalSupply
, balanceOf
, transfer
, etc.). The standard enables tokens to be usable in wallets and exchanges. Developers test contracts before utilizing real ETH on a testnet – a sandbox blockchain network with free “play” Ether.
Sepolia testnet is now Ethereum’s primary testnet: it is actively maintained, stable, and uses Proof-of-Stake as mainnet. Sepolia gives developers confidence by allowing them to “interact with blockchain before risking real money”. Node providers like GetBlock are also useful for Ethereum development. GetBlock is a Blockchain-as-a-Service (BaaS) which provides instant API access to full nodes for Ethereum and many other chains.
In practice, GetBlock lets you obtain an already-configured RPC endpoint (an HTTP URL) to Sepolia without running your own node. For example, after signing up, you receive a URL like wss://go.getblock.io/1ecbe979e63f420fb1cea042893xxxxx
, which you can paste in your tools. This is extremely convenient for testing and deployment.
Setting Up the Development Environment
First, establish general dev environments. Ensure that you have Node.js and npm (nodejs.org) installed so that you can install JavaScript packages. You will also need a code editor (like VS Code), a wallet (like MetaMask) and some Sepolia ETH (use a faucet – e.g., GetBlock’s faucet). Two of the most popular contract development environments are Hardhat and Remix:
- Hardhat. A local development environment. It takes care of tasks like compiling and deploying contracts. Hardhat is a development environment for Ethereum software that helps you edit, compile, test, and deploy contracts. To begin with, open a terminal in the directory of your project and run:
npm init -y
npm install --save-dev hardhat
npx hardhat # follow prompts to create a basic project
This creates a Hardhat project where you can write contracts (in contracts/
) and scripts (in scripts/
).
- Remix IDE. A browser-based Solidity IDE. Remix never needs to be installed by you. You can write, compile, and deploy contracts with an embedded UI. Select the “Injected Web3” environment and link MetaMask to deploy on Sepolia. Remix is handy for quick evaluation or those who prefer a GUI.
You will also require the OpenZeppelin Contracts library for ERC-20 templates. OpenZeppelin provides audited smart contract code, such as a base ERC20 contract. Here is a basic ERC-20 example:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MyToken is ERC20 {
constructor(uint256 initialSupply) ERC20("MyToken", "MTK") {
_mint(msg.sender, initialSupply);
}
}
This contract inherits the standard ERC-20 implementation, sets the token name (“MyToken”) and symbol (“MTK”), and mints initialSupply
tokens to the deployer. You can customize the name, symbol, and initial supply as desired. Because all ERC-20 logic is inherited, you don’t need to write any of the standard functions yourself.
Writing the ERC-20 Contract in Solidity
Now let’s write the token contract. In your project’s contracts/
folder (or in Remix), create a file like MyToken.sol
. Use OpenZeppelin’s ERC20 as shown:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MyToken is ERC20 {
constructor() ERC20("MyToken", "MTK") {
// Mint 1,000,000 tokens to the deployer
_mint(msg.sender, 1000000 * (10 ** decimals()));
}
}
This does the following: the ERC20
constructor sets the token name to “MyToken” and symbol to “MTK”. The _mint
call in the constructor creates 1,000,000 tokens (adjusted by decimals()
, which defaults to 18) and assigns them to the deployer’s address. Because the contract inherits all ERC-20 functions from OpenZeppelin, you automatically get totalSupply()
, balanceOf()
, transfer()
, approve()
, etc. for free. In short, you only needed to write a few lines of code.
Using GetBlock to Connect to Sepolia
Before deploying, set up your network connection. GetBlock makes this easy. Create a free account on GetBlock.io and generate an endpoint for Ethereum Sepolia. GetBlock will give you a JSON-RPC URL like:
https://go.getblock.io/<YOUR_ACCESS_TOKEN>
This URL is your full node endpoint for Sepolia. For example, GetBlock’s documentation shows using this URL with chain ID 11155111 for Sepolia. In Hardhat, you would add a network entry in hardhat.config.js
using this URL. For example (using GetBlock’s shared config):
const { getblock } = require("./getblock.config.js");
module.exports = {
defaultNetwork: "sepolia",
networks: {
sepolia: {
url: getblock.shared.eth.sepolia.rpc[0].go()
// this will yield something like "https://go.getblock.io/ACCESS_TOKEN"
}
},
solidity: "0.8.0",
};
Alternatively, you can hardcode your URL and an account private key:
module.exports = {
solidity: "0.8.0",
networks: {
sepolia: {
url: "https://go.getblock.io/<YOUR_ACCESS_TOKEN>",
accounts: ["0xYOUR_PRIVATE_KEY"]
}
}
};
With this configuration, Hardhat knows how to broadcast transactions on Sepolia via GetBlock’s node. If you’re working with Remix, you can configure a custom network in MetaMask: enter “Network Name” as Ethereum Sepolia Testnet, Chain ID 11155111, and RPC URL as your GetBlock endpoint. Finally, you’ll need Sepolia test ETH to pay for gas. Send yourself ~0.1 SepoliaETH using a faucet (GetBlock’s faucet).
Deploying the Contract on Sepolia
With environment and contract ready, it is time for deployment. Two common approaches are:
- Hardhat script. Create a deployment script, e.g.
scripts/deploy.js
, within your project. Example with ethers.js (Hardhat comes withethers
built-in):
async function main() {
const [deployer] = await ethers.getSigners();
console.log("Deploying with account:", deployer.address);
const Token = await ethers.getContractFactory("MyToken");
// If your constructor requires an initial supply, pass it here.
const token = await Token.deploy();
console.log("Token deployed at address:", token.address);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
Save the file and run Hardhat to deploy on Sepolia:
npx hardhat run scripts/deploy.js --network sepolia
On success, Hardhat will print the deployed contract address. For example, a typical deploy script does:
const HelloWorld = await ethers.getContractFactory("HelloWorld");
const contract = await HelloWorld.deploy();
console.log("Contract deployed at:", contract.address);
For your instance, replace “HelloWorld
” with “MyToken
” (and include constructor args if any).
- Remix. Compile the contract in Remix, then go to the “Deploy & Run Transactions” tab. Select Injected Web3 as the environment (which is accessed through MetaMask). Ensure your MetaMask is on Sepolia network, then Deploy for
MyToken
contract. Confirm the transaction in MetaMask. Remix will show the deployed contract in “Deployed Contracts.”
Either method will deploy a transaction on Sepolia. You can just copy the address of the contract from the output.
Verification and Interacting with the Token
After deploying, inspect the contract and play around with it:
- Inspect on Sepolia Etherscan. Visit Sepolia Etherscan and search for your contract address. Use the “Verify and Publish” button to upload your Solidity source. The easiest route is through Etherscan’s UI: visit the Contract tab and click Verify and Publish. You will need the same version of the compiler and any arguments for the constructor (if you provided initial supply). Once confirmed, your source code and ABI are viewable by anyone on Etherscan. Another alternative is the Hardhat Etherscan plugin by setting your API key in
hardhat.config.js
, e.g.:
etherscan: {
apiKey: "YOUR_ETHERSCAN_API_KEY"
}
```. Then Hardhat can automatically verify contracts.
- Interact with the contract. You can now call ERC-20 functions. On Etherscan, the verified contract page shows a “Read Contract” and “Write Contract” interface. For example, call
name()
orsymbol()
to see your token’s name. In Remix or any web3 script you can do:
let token = await ethers.getContractAt("MyToken", "0xYourTokenAddress");
console.log(await token.name()); // e.g. "MyToken"
If you are using the UI of Remix, then click the contract that is deployed and click name function buttons, etc. If you click the name function in Remix, you will see your custom token name that you have defined.
You can also include the token in your MetaMask wallet. Take the address of the contract and in MetaMask choose Import tokens, paste the address, and MetaMask will automatically fill the token symbol and decimals for you. Now you’ll see your new token in your wallet’s assets (with your Sepolia balance).
By following these steps, you’ve deployed a live ERC-20 token onto Sepolia. You can send it, check balances, and pretty much treat it like a real token (using fake ETH for gas).
Transition from Testnet to Ethereum Mainnet
Once you finish on Sepolia, you can migrate your token to Ethereum mainnet. The process is the same with a few differences: you’ll be working with real ETH in your wallet (gas fees are real), and you ought to double check your code (consider audits). In hardhat.config.js
, add or modify a mainnet
network with a GetBlock mainnet endpoint. For example:
networks: {
mainnet: {
url: getblock.shared.eth.mainnet.rpc[0].go(), // GetBlock mainnet RPC
accounts: ["0xYOUR_PRIVATE_KEY"]
}
}
GetBlock also provides Ethereum mainnet nodes, so you can set up a mainnet RPC URL in your dashboard. You can get access to mainnet nodes and deploy the Solidity contract to Ethereum just as on testnet. Mainnet Chain ID is 1. And deploy with Hardhat:
npx hardhat run scripts/deploy.js --network mainnet
After deploying, check etherscan.io (mainnet) using the same “Verify & Publish” process (or Hardhat’s Etherscan plugin). Once verified, your token is live on Ethereum mainnet.
In short, the most critical steps were:
- Write your ERC-20 contract
- Compile it
- Configure Hardhat (or Remix) to use GetBlock’s Sepolia RPC
- Deploy the contract
- Verify
GetBlock’s service simplified node access: you did not need to run your own node or supply infrastructure – you simply plugged in an HTTP UR. All these steps and tools can be used by a beginner to deploy, develop, and maintain an ERC-20 token on Ethereum testnets and beyond.