Skip to main content

CloneERC20

Git Source

Inherits: Clone, IERC20

Authors: Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC20.sol), Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)

Modern and gas efficient ERC20 implementation.

Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.

State Variables​

totalSupply​

Returns the amount of tokens in existence.

uint256 public totalSupply;

Returns

NameTypeDescription
<none>uint256

balanceOf​

Returns the amount of tokens owned by account.

mapping(address => uint256) public balanceOf;

Parameters

NameTypeDescription
<none>address

Returns

NameTypeDescription
<none>uint256

allowance​

Returns the remaining number of tokens that spender is allowed to spend on behalf of owner

mapping(address => mapping(address => uint256)) public allowance;

Parameters

NameTypeDescription
<none>address
<none>address

Returns

NameTypeDescription
<none>uint256

Functions​

name​

Returns the name of the token.

function name() external pure returns (string memory);

Returns

NameTypeDescription
<none>string

symbol​

Returns the symbol of the token.

function symbol() external pure returns (string memory);

Returns

NameTypeDescription
<none>string

decimals​

Returns the decimals places of the token.

function decimals() external pure returns (uint8);

Returns

NameTypeDescription
<none>uint8

approve​

Sets amount as the allowance of spender over the caller's tokens.

Be aware of front-running risks: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729

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

Parameters

NameTypeDescription
spenderaddress
amountuint256

Returns

NameTypeDescription
<none>bool

increaseAllowance​

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

Parameters

NameTypeDescription
spenderaddress
amountuint256

Returns

NameTypeDescription
<none>bool

decreaseAllowance​

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

Parameters

NameTypeDescription
spenderaddress
amountuint256

Returns

NameTypeDescription
<none>bool

transfer​

Moves amount tokens from the caller's account to to.

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

Parameters

NameTypeDescription
toaddress
amountuint256

Returns

NameTypeDescription
<none>bool

transferFrom​

Moves amount tokens from from to to using the allowance mechanism. amount is then deducted from the caller's allowance.

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

Parameters

NameTypeDescription
fromaddress
toaddress
amountuint256

Returns

NameTypeDescription
<none>bool

_mint​

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

Parameters

NameTypeDescription
toaddress
amountuint256

_burn​

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

Parameters

NameTypeDescription
fromaddress
amountuint256