Skip to main content

ButtonswapERC20

Inherits: IButtonswapERC20

State Variables​

decimals​

Returns the number of decimals used to get its user representation. For example, if decimals equals 2, a balance of 505 tokens should be displayed to a user as 5.05 (505 / 10 ** 2).

This information is only used for display purposes: it in no way affects any of the arithmetic of the contract.

uint8 public constant decimals = 18;

totalSupply​

Returns the amount of tokens in existence.

uint256 public totalSupply;

balanceOf​

Returns the amount of tokens owned by account.

mapping(address => uint256) public balanceOf;

allowance​

Returns the remaining number of tokens that spender will be allowed to spend on behalf of owner through {transferFrom}. This is zero by default. This value changes when {approve} or {transferFrom} are called.

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

DOMAIN_SEPARATOR​

Returns the domain separator used in the encoding of the signature for {permit}, as defined by EIP712.

bytes32 public immutable DOMAIN_SEPARATOR;

PERMIT_TYPEHASH​

Returns the typehash used in the encoding of the signature for {permit}, as defined by EIP712.

Value should equal 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9 but it is recommended to verify this by checking the public method on-chain.

bytes32 public constant PERMIT_TYPEHASH =
keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");

nonces​

Returns the current nonce for owner. This value must be included whenever a signature is generated for {permit}.

Every successful call to {permit} increases owner's nonce by one. This prevents a signature from being used multiple times.

mapping(address => uint256) public nonces;

Functions​

constructor​

constructor();

_mint​

Mints value tokens to to. Emits a {IButtonswapERC20Events-Transfer} event.

function _mint(address to, uint256 value) internal;

Parameters

NameTypeDescription
toaddressThe account that is receiving the tokens
valueuint256The amount of tokens being created

_burn​

Burns value tokens from from. Emits a {IButtonswapERC20Events-Transfer} event.

function _burn(address from, uint256 value) internal;

Parameters

NameTypeDescription
fromaddressThe account that is sending the tokens
valueuint256The amount of tokens being destroyed

_approve​

Sets value as the allowance of spender over the caller's tokens. Emits a {IButtonswapERC20Events-Approval} event.

function _approve(address owner, address spender, uint256 value) private;

Parameters

NameTypeDescription
owneraddressThe account whose tokens are being approved
spenderaddressThe account that is granted permission to spend the tokens
valueuint256The amount of tokens that can be spent

_transfer​

Moves value tokens from from to to. Emits a {IButtonswapERC20Events-Transfer} event.

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

Parameters

NameTypeDescription
fromaddressThe account that is sending the tokens
toaddressThe account that is receiving the tokens
valueuint256The amount of tokens being sent

name​

Returns the name of the token.

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

Returns

NameTypeDescription
_namestringThe token name

symbol​

Returns the symbol of the token, usually a shorter version of the name.

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

Returns

NameTypeDescription
_symbolstringThe token symbol

approve​

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

IMPORTANT: 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: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 Emits an {IButtonswapERC20Events-Approval} event.

function approve(address spender, uint256 value) external returns (bool success);

Parameters

NameTypeDescription
spenderaddressThe account that is granted permission to spend the tokens
valueuint256The amount of tokens that can be spent

Returns

NameTypeDescription
successboolWhether the operation succeeded

transfer​

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

Emits a {IButtonswapERC20Events-Transfer} event.

function transfer(address to, uint256 value) external returns (bool success);

Parameters

NameTypeDescription
toaddressThe account that is receiving the tokens
valueuint256The amount of tokens being sent

Returns

NameTypeDescription
successboolWhether the operation succeeded

transferFrom​

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

Emits a {IButtonswapERC20Events-Transfer} event.

function transferFrom(address from, address to, uint256 value) external returns (bool success);

Parameters

NameTypeDescription
fromaddressThe account that is sending the tokens
toaddressThe account that is receiving the tokens
valueuint256The amount of tokens being sent

Returns

NameTypeDescription
successboolWhether the operation succeeded

permit​

Sets value as the allowance of spender over owner's tokens, given owner's signed approval.

*IMPORTANT: The same issues {approve} has related to transaction ordering also apply here. Emits an {IButtonswapERC20Events-Approval} event. Requirements:

  • spender cannot be the zero address.
  • deadline must be a timestamp in the future.
  • v, r and s must be a valid secp256k1 signature from owner over the EIP712-formatted function arguments.
  • the signature must use owner's current nonce (see {nonces}). For more information on the signature format, see the relevant EIP section.*
function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
external;

Parameters

NameTypeDescription
owneraddressThe account that owns the tokens
spenderaddressThe account that can spend the tokens
valueuint256The amount of owner's tokens that spender can transfer
deadlineuint256The future time after which the permit is no longer valid
vuint8Part of the signature
rbytes32Part of the signature
sbytes32Part of the signature