Skip to main content

MockERC20

Git Source

Inherits: IERC20

This is a mock contract of the ERC20 standard for testing purposes only, it SHOULD NOT be used in production.

Forked from: https://github.com/transmissions11/solmate/blob/0384dbaaa4fcb5715738a9254a7c0a4cb62cf458/src/tokens/ERC20.sol

State Variables

_name

string internal _name;

_symbol

string internal _symbol;

_decimals

uint8 internal _decimals;

_totalSupply

uint256 internal _totalSupply;

_balanceOf

mapping(address => uint256) internal _balanceOf;

_allowance

mapping(address => mapping(address => uint256)) internal _allowance;

INITIAL_CHAIN_ID

uint256 internal INITIAL_CHAIN_ID;

INITIAL_DOMAIN_SEPARATOR

bytes32 internal INITIAL_DOMAIN_SEPARATOR;

nonces

mapping(address => uint256) public nonces;

initialized

A bool to track whether the contract has been initialized.

bool private initialized;

Functions

name

function name() external view override returns (string memory);

symbol

function symbol() external view override returns (string memory);

decimals

function decimals() external view override returns (uint8);

totalSupply

function totalSupply() external view override returns (uint256);

balanceOf

function balanceOf(address owner) external view override returns (uint256);

allowance

function allowance(address owner, address spender) external view override returns (uint256);

initialize

To hide constructor warnings across solc versions due to different constructor visibility requirements and syntaxes, we add an initialization function that can be called only once.

function initialize(string memory name_, string memory symbol_, uint8 decimals_) public;

approve

function approve(address spender, uint256 amount) public virtual override returns (bool);

transfer

function transfer(address to, uint256 amount) public virtual override returns (bool);

transferFrom

function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool);

permit

function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
public
virtual;

DOMAIN_SEPARATOR

function DOMAIN_SEPARATOR() public view virtual returns (bytes32);

computeDomainSeparator

function computeDomainSeparator() internal view virtual returns (bytes32);

_mint

function _mint(address to, uint256 amount) internal virtual;

_burn

function _burn(address from, uint256 amount) internal virtual;

_add

function _add(uint256 a, uint256 b) internal pure returns (uint256);

_sub

function _sub(uint256 a, uint256 b) internal pure returns (uint256);

_viewChainId

function _viewChainId() private view returns (uint256 chainId);

_pureChainId

function _pureChainId() private pure returns (uint256 chainId);