Skip to content

taurushq-io/TERC-20

Repository files navigation

TERC-20

ERC-20 is the main standard to represent fungibles tokens on Ethereum and EVM blockchain. This ERC defines the functions, events and the behavior of a token implementing this interface.

One of the main libraries used to build ERC-20 is OpenZeppelin. This library provides already all functions which are part of the standard. Nevertheless, OpenZeppelin does not provide a deployable contract, but only an abstract contract which can be used to build other contracts though inheritance but cannot be deployed directly on the blockchain. You can find more information about their implementation in their documentation.

TERC-20 aims to provide a minimal deployable implementation for standalone deployment (immutable) and proxy deployment (upgradeable) which allows the issueur (and only him) to mint and burn tokens.

TERC-20 exists in two different version: standalone and proxy:

  • TERC20Standalone for an immutable deployment, without proxy.

See ./TERC20Standalone

  • TERC20Upgradeable for an upgradeable deployment, with a compatible proxy (Transparent or Beacon)

See ./TERC20Upgradeable

ERC

In addition to ERC-20, TERC-20 uses the following ERCs:

  • ERC-6093: Custom errors for ERC-20 tokens (through OpenZeppelin)
  • eip-3643: implements the following functions:
    • version()
    • mint(), burn()
    • batchMint, batchBurn()
  • TERC20Upgradeable only:
    • implements ERC-7201 to manage the storage location.

Common features

These ERC-20 tokens have the following characteristics:

Mint

  • A mint function only accessible with the MINTER role

  • Two mint batch functions only accessible with the MINTER role

Interface defined in ./TERC20ShareMint

Burn

  • A burn function only accessible with the BURNER role
  • Two burn in batch functions only accessible with the BURNER role

Interface defined in ./TERC20ShareBurn

ERC20

  • At deployment, the issuer can set the name, symbol and decimals.

  • Once deployed, it is no longer possible to modify these values except via an upgrade in the case of the proxy.

Access control

Access Control is managed with the OpenZeppelin library AccessControl which implements a role-based access control mechanism.

  • Default Admin Role

The most important role is the role DEFAULT_ADMIN_ROLE. This role manages all other roles.

This role is also its own admin: it has permission to grant and revoke this role.

warning: Extra precautions should be taken to secure accounts that have been granted it.

  • Supply management role

Two roles BURNER_ROLE and MINTER_ROLE allow their members to respectively mint or burn tokens.

Schema

TERC20.drawio

Schema

TERC20Standalone

Inheritance

surya_inheritance_TERC20Standalone.sol

Graph

surya_graph_TERC20Standalone.sol

TERC20 Upgradeable

Inheritance

surya_inheritance_TERC20Upgradeable.sol

Graph

surya_graph_TERC20Upgradeable.sol

Surya Description Report

TERC20Standalone

Contract Type Bases
β”” Function Name Visibility Mutability Modifiers
TERC20Standalone Implementation ERC20, AccessControl, TERC20Share
β”” Public ❗️ πŸ›‘ ERC20
β”” decimals Public ❗️ NO❗️
β”” version Public ❗️ NO❗️
β”” mint Public ❗️ πŸ›‘ onlyRole
β”” batchMint Public ❗️ πŸ›‘ onlyRole
β”” batchMintSameValue Public ❗️ πŸ›‘ onlyRole
β”” burn Public ❗️ πŸ›‘ onlyRole
β”” batchBurn Public ❗️ πŸ›‘ onlyRole
β”” batchBurnSameValue Public ❗️ πŸ›‘ onlyRole
β”” hasRole Public ❗️ NO❗️

TERC20Upgradeable

Contract Type Bases
β”” Function Name Visibility Mutability Modifiers
TERC20Upgradeable Implementation Initializable, ERC20Upgradeable, AccessControlUpgradeable, TERC20Share, TERC20UpgradeableBurn, TERC20UpgradeableMint
β”” Public ❗️ πŸ›‘ NO❗️
β”” initialize Public ❗️ πŸ›‘ initializer
β”” __TERC20Upgradeable_init_unchained Internal πŸ”’ πŸ›‘ onlyInitializing
β”” decimals Public ❗️ NO❗️
β”” version Public ❗️ NO❗️
β”” hasRole Public ❗️ NO❗️
β”” _getTERC20UpgradeableStorage Private πŸ”

TERC20UpgradeableMint

Contract Type Bases
β”” Function Name Visibility Mutability Modifiers
TERC20UpgradeableMint Implementation ERC20Upgradeable, AccessControlUpgradeable, TERC20ShareMint
β”” mint Public ❗️ πŸ›‘ onlyRole
β”” batchMint Public ❗️ πŸ›‘ onlyRole
β”” batchMintSameValue Public ❗️ πŸ›‘ onlyRole

TERC20UpgradeableBurn

Contract Type Bases
β”” Function Name Visibility Mutability Modifiers
TERC20UpgradeableBurn Implementation ERC20Upgradeable, AccessControlUpgradeable, TERC20ShareBurn
β”” burn Public ❗️ πŸ›‘ onlyRole
β”” batchBurn Public ❗️ πŸ›‘ onlyRole
β”” batchBurnSameValue Public ❗️ πŸ›‘ onlyRole

Legend

Symbol Meaning
πŸ›‘ Function can modify state
πŸ’΅ Function is payable

Dependencies

The toolchain includes the following components, where the versions are the latest ones that we tested:

  • Foundry / forge 1.0.0-stable
  • Solidity 0.8.28 (via solc-js)
  • OpenZeppelin Contracts (submodule) v5.2.0
  • OpenZeppelin Contracts upgradeable (submodule) v5.2.0

Security and Audit

Vulnerability disclosure

Please see SECURITY.md.

Audit

Report made by SecFault Security

See our comment here report file

Audit tools

Slither

Report file

See crytic/slither

slither .  --checklist --filter-paths "openzeppelin-contracts|test|forge-std" > slither-report.md

Mythril

Report file

myth analyze src/TERC20Standalone.sol --solc-json solc_setting.json

See Consensys/mythril

Cyfrin Aderyn

Report file

aderyn

See Cyfrin/aderyn

Tools

Surya

See ./doc/script and Consensys/surya

Prettier

npx prettier --write --plugin=prettier-plugin-solidity 'src/**/*.sol'
npx prettier --write --plugin=prettier-plugin-solidity 'test/**/*.sol'

Foundry

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.

Usage

Explain how it works.

Toolchain installation

The contracts are developed and tested with Foundry, a smart contract development toolchain.

To install the Foundry suite, please refer to the official instructions in the Foundry book.

Initialization

You must first initialize the submodules, with

forge install

See also the command's documentation.

Later you can update all the submodules with:

forge update

See also the command's documentation.

Compilation

The official documentation is available in the Foundry website

 forge build

Testing

You can run the tests with

forge test

To run a specific test, use

forge test --match-contract <contract name> --match-test <function name>

See also the test framework's official documentation, and that of the test commands.

Coverage

coverage

  • Perform a code coverage
forge coverage
  • Generate LCOV report
forge coverage --report lcov
  • Generate index.html
forge coverage --ffi --report lcov && genhtml lcov.info --branch-coverage --output-dir coverage 

See Solidity Coverage in VS Code with Foundry & Foundry forge coverage

Documentation

https://book.getfoundry.sh/

FAQ

Can we put the smart contract in a pause state ?

No, it is not possible to put the contract in a pause state. However, to desactivate the contract, it is possible to burn all tokens and renounce the control on the smart contract.

If you are interested by this feature, CMTAT could be more suitable.

Is the contracts compatible with ERC-2771 (gasless / MetaTx transaction)/

No, TERC-20 does not implement this ERC. If you are interested by this feature, CMTAT could be more suitable.

Can we change the symbol, name or decimals after deployment ?

In standalone deployment (immutable), all these information can not be changed.

With a proxy deployment, it is still possible to change it by deploying a new implementation which allows to set these information, but it requires extra work.

if you want the possibility to update these information, CMTAT could be more suitable since it allows more flexibility.

Intellectual property

The original code is copyright (c) Taurus 2025, and is released under MIT license.