Skip to content

Latest commit

 

History

History
392 lines (305 loc) · 12.4 KB

ERC20.md

File metadata and controls

392 lines (305 loc) · 12.4 KB

Standard ERC20 token

  • (ERC20.sol)

View Source: contracts/token/ERC20/ERC20.sol

↗ Extends: IERC20 ↘ Derived Contracts: ERC20Burnable, ERC20DetailedMock, ERC20Mintable, ERC20Mock, ERC20Pausable, ERC20WithMetadataMock, SimpleToken

ERC20

Implementation of the basic standard token. https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md Originally based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol

Contract Members

Constants & Variables

mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowed;
uint256 private _totalSupply;

Functions

totalSupply

⤾ overrides IERC20.totalSupply

Total number of tokens in existence

function totalSupply() public
returns(uint256)

Arguments

Name Type Description

balanceOf

⤾ overrides IERC20.balanceOf

Gets the balance of the specified address.

function balanceOf(address owner) public
returns(uint256)

Returns

An uint256 representing the amount owned by the passed address.

Arguments

Name Type Description
owner address The address to query the balance of.

allowance

⤾ overrides IERC20.allowance

Function to check the amount of tokens that an owner allowed to a spender.

function allowance(address owner, address spender) public
returns(uint256)

Returns

A uint256 specifying the amount of tokens still available for the spender.

Arguments

Name Type Description
owner address address The address which owns the funds.
spender address address The address which will spend the funds.

transfer

⤾ overrides IERC20.transfer

⤿ Overridden Implementation(s): ERC20Pausable.transfer

Transfer token for a specified address

function transfer(address to, uint256 value) public undefined
returns(bool)

Arguments

Name Type Description
to address The address to transfer to.
value uint256 The amount to be transferred.

approve

⤾ overrides IERC20.approve

⤿ Overridden Implementation(s): ERC20Pausable.approve

Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: ethereum/EIPs#20 (comment)

function approve(address spender, uint256 value) public undefined
returns(bool)

Arguments

Name Type Description
spender address The address which will spend the funds.
value uint256 The amount of tokens to be spent.

transferFrom

⤾ overrides IERC20.transferFrom

⤿ Overridden Implementation(s): ERC20Pausable.transferFrom

Transfer tokens from one address to another

function transferFrom(address from, address to, uint256 value) public undefined
returns(bool)

Arguments

Name Type Description
from address address The address which you want to send tokens from
to address address The address which you want to transfer to
value uint256 uint256 the amount of tokens to be transferred

increaseAllowance

⤿ Overridden Implementation(s): ERC20Pausable.increaseAllowance

Increase the amount of tokens that an owner allowed to a spender. approve should be called when allowed_[_spender] == 0. To increment allowed value is better to use this function to avoid 2 calls (and wait until the first transaction is mined) From MonolithDAO Token.sol

function increaseAllowance(address spender, uint256 addedValue) public undefined
returns(bool)

Arguments

Name Type Description
spender address The address which will spend the funds.
addedValue uint256 The amount of tokens to increase the allowance by.

decreaseAllowance

⤿ Overridden Implementation(s): ERC20Pausable.decreaseAllowance

Decrease the amount of tokens that an owner allowed to a spender. approve should be called when allowed_[_spender] == 0. To decrement allowed value is better to use this function to avoid 2 calls (and wait until the first transaction is mined) From MonolithDAO Token.sol

function decreaseAllowance(address spender, uint256 subtractedValue) public undefined
returns(bool)

Arguments

Name Type Description
spender address The address which will spend the funds.
subtractedValue uint256 The amount of tokens to decrease the allowance by.

_transfer

Transfer token for a specified addresses

function _transfer(address from, address to, uint256 value) internal undefined

Arguments

Name Type Description
from address The address to transfer from.
to address The address to transfer to.
value uint256 The amount to be transferred.

_mint

⤿ Overridden Implementation(s): ERC20Capped._mint

Internal function that mints an amount of the token and assigns it to an account. This encapsulates the modification of balances such that the proper events are emitted.

function _mint(address account, uint256 value) internal undefined

Arguments

Name Type Description
account address The account that will receive the created tokens.
value uint256 The amount that will be created.

_burn

Internal function that burns an amount of the token of a given account.

function _burn(address account, uint256 value) internal undefined

Arguments

Name Type Description
account address The account whose tokens will be burnt.
value uint256 The amount that will be burnt.

_burnFrom

Internal function that burns an amount of the token of a given account, deducting from the sender's allowance for said account. Uses the internal burn function.

function _burnFrom(address account, uint256 value) internal undefined

Arguments

Name Type Description
account address The account whose tokens will be burnt.
value uint256 The amount that will be burnt.

Contracts