This project implements a simple ERC20 token using foundry for cyfrin updraft course Advanced Foundry. It includes the following components:
- Token Contract: Implements the ERC20 standard using OpenZeppelin's
ERC20
library. - Deployment Script: Deploys the token with an initial supply.
- Comprehensive Tests: Validates the functionality and robustness of the ERC20 token.
This project is a foundational implementation of an ERC20 token called Token
with the symbol TKN
. The token is initialized with a fixed supply upon deployment and adheres to the ERC20 standard.
- Basic ERC20 functionality:
transfer
,approve
,transferFrom
, andallowance
. - Comprehensive testing suite for both core functionality and edge cases.
- Modular design with a deployment script and test suite using Foundry.
To set up and run the project, follow these steps:
- Clone the Repository:
git clone https://github.com/KMean/foundry-erc20.git cd fouudry-erc20
- Install Dependencies: Ensure you have Foundry installed. If not, install it:
forge install
- Compile the Contracts:
forge build
The DeployToken script deploys the token with an initial supply of 1,000,000 tokens (adjustable in the script).
Run the deployment script:
forge script script/DeployToken.s.sol:DeployToken --rpc-url <RPC_URL> --private-key <PRIVATE_KEY> --broadcast
The project includes a comprehensive test suite written with Foundry's forge-std library. The tests cover:
- Deployment correctness.
- Transfers and allowances.
- Edge cases (e.g., transferring to a zero address, transferring zero tokens).
- Failure cases (e.g., insufficient balance, insufficient allowance).
To run the test suite:
forge test
This project leverages:
- OpenZeppelin Contracts for secure and modular ERC20 implementation.
- Foundry for testing and deployment.