Project Overview – Custom ERC20 Token Implementations This project contains two Solidity smart contracts showcasing different approaches to implementing ERC-20-like tokens on Ethereum and EVM-compatible blockchains.
🎯 Purpose : The goal of this repository is to demonstrate:
1. Manual ERC-20-like Implementation — building token logic from scratch without importing external libraries.
2. Standard ERC-20 Implementation using OpenZeppelin’s battle-tested library for security and compatibility.
This dual approach gives developers a hands-on understanding of:
• How the ERC-20 standard works internally.
• The benefits of using audited libraries like OpenZeppelin.
• Security considerations when working with token balances and transfer logic.
A simple ERC20-like token smart contract written in Solidity without using the official ERC20 standard interface. This project demonstrates how token balances, transfers, and metadata (name, decimals, total supply) can be implemented manually.
ManualToken.sol is a lightweight token implementation for educational purposes.
It stores balances in a mapping and provides functions for reading token metadata and transferring tokens.
OurToken.sol is a simple but secure implementation of the ERC-20 token standard, built on top of OpenZeppelin’s audited contract library. The contract defines a fungible token named “OurToken” with symbol “OT” and mints the specified initial supply to the deploying address.
Token Metadata
• `name()` → Returns `"Manual Token"`.
• `totalSupply()` → Returns 100 tokens (`100 ether` = 100 × 10¹⁸ units).
• `decimals()` → Returns 18 decimals.
Balance Tracking
• `balanceOf(address)` → Returns the token balance of any address.
Token Transfers
• `transfer(address _to, uint256 _amount)` → Moves tokens from the sender to the recipient.
• Ensures the sum of both balances remains consistent after transfer (basic integrity check).
Limitations:
• No minting/burning.
• No approvals/allowances.
• No initial distribution logic — balances must be manually set.
• Potential underflow if sender does not have enough balance (needs `require` check).
A fully ERC-20 compliant token built on OpenZeppelin’s ERC20 contract.
Key Details:
Meta
• Name: `"OurToken"`
• Symbol: `"OT"`
• Decimals: `18` (default for ERC-20)
Constructor:
• Accepts an `initialSupply` parameter at deployment.
• Automatically mints the full amount to the deployer’s address.
Benefits:
• Inherits all ERC-20 functions (`transfer`, `approve`, `transferFrom`, `allowance`, `balanceOf`, `totalSupply`, etc.).
• Uses Solidity 0.8.x’s automatic overflow/underflow protection.
• Security and interoperability ensured by OpenZeppelin’s audit track record.
🔍 Purpose: Production-ready ERC-20 template for real-world deployments.
.
├── src
│ └── ManualToken.sol
| |__ OurToken.sol
|
├── lib
|
|__ script
| |__ DeployOurToken.s.sol
|
|__test
| |__OurToken.t.sol
|
└── foundry.toml
|
|__ Makefile
• ManualToken.sol should NOT be used in production without proper checks, events, and ERC-20 compliance.
• OurToken.sol is built on a secure base, but always audit before deployment.
• Initial supplies and role management should be carefully planned to avoid centralization pitfalls.
Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust. Foundry consists of:
- Forge: Ethereum testing framework (like Truffle, Hardhat and DappTools).
- Cast: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
- Anvil: Local Ethereum node, akin to Ganache, Hardhat Network.
- Chisel: Fast, utilitarian, and verbose solidity REPL.
$ forge build$ forge test$ forge fmt$ forge snapshot$ anvil$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>$ cast <subcommand>$ forge --help
$ anvil --help
$ cast --help