Project · Beginner · about 12 hours

An ERC-20 token with a full test suite

Build an ERC-20 token on OpenZeppelin, add capped minting and pausing with access control, and cover it with unit, fuzz and invariant tests in Foundry.

Skills:Blockchain fundamentals, Smart contracts and Solidity, Automated testing

Part of: Blockchain Developer

Data and licences

Brief

Tokens are the hello world of smart contracts, and they are also where careless code loses money. Build one the professional way: small, on audited libraries, and thoroughly tested. Use a local Anvil chain and, when you deploy publicly, a testnet such as Sepolia with free test ether from a faucet. Never use real funds or a wallet that holds any, and never paste a private key into code or a website.

What to build

  1. Create a Foundry project and install OpenZeppelin Contracts

  2. Write a token with a fixed maximum supply, a minter role, a pauser role and an admin that can grant and revoke roles

  3. Write unit tests for transfers, approvals, minting, pausing and every revert

  4. Write fuzz tests for transfers and an invariant test that total supply equals the sum of all balances and never exceeds the cap

  5. Write a forge script that deploys to Anvil, and document the roles and how to transfer admin safely

Deliverables

  • Repository with src/, test/, script/ and README.md

How it is graded

Reviewers run forge test, read your invariants, and try to mint above the cap or pause without the role.

Stretch

Add EIP-2612 permit support and tests for signature expiry and replay.

Deliverables

  • An ERC-20 contract built on OpenZeppelin with a supply cap, role-based minting and pausing
  • Unit tests for every function and revert path
  • Fuzz and invariant tests such as total supply equals the sum of balances and never exceeds the cap
  • A deployment script for a local chain and a README

How a reviewer grades it

CriterionWeightWhat good looks like
Contract uses audited building blocks correctly with least-privilege roles25%
Unit tests cover all paths including reverts and events30%
Invariant and fuzz tests express real properties and pass30%
Deployment and documentation15%