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
Name | Type | Description |
---|---|---|
to | address | The account that is receiving the tokens |
value | uint256 | The amount of tokens being created |
_burn
Burns value
tokens from from
.
Emits a {IButtonswapERC20Events-Transfer} event.
function _burn(address from, uint256 value) internal;
Parameters
Name | Type | Description |
---|---|---|
from | address | The account that is sending the tokens |
value | uint256 | The 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
Name | Type | Description |
---|---|---|
owner | address | The account whose tokens are being approved |
spender | address | The account that is granted permission to spend the tokens |
value | uint256 | The 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
Name | Type | Description |
---|---|---|
from | address | The account that is sending the tokens |
to | address | The account that is receiving the tokens |
value | uint256 | The amount of tokens being sent |
name
Returns the name of the token.
function name() external view virtual override returns (string memory _name);
Returns
Name | Type | Description |
---|---|---|
_name | string | The 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
Name | Type | Description |
---|---|---|
_symbol | string | The 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
Name | Type | Description |
---|---|---|
spender | address | The account that is granted permission to spend the tokens |
value | uint256 | The amount of tokens that can be spent |
Returns
Name | Type | Description |
---|---|---|
success | bool | Whether 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
Name | Type | Description |
---|---|---|
to | address | The account that is receiving the tokens |
value | uint256 | The amount of tokens being sent |
Returns
Name | Type | Description |
---|---|---|
success | bool | Whether 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
Name | Type | Description |
---|---|---|
from | address | The account that is sending the tokens |
to | address | The account that is receiving the tokens |
value | uint256 | The amount of tokens being sent |
Returns
Name | Type | Description |
---|---|---|
success | bool | Whether 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
ands
must be a validsecp256k1
signature fromowner
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
Name | Type | Description |
---|---|---|
owner | address | The account that owns the tokens |
spender | address | The account that can spend the tokens |
value | uint256 | The amount of owner 's tokens that spender can transfer |
deadline | uint256 | The future time after which the permit is no longer valid |
v | uint8 | Part of the signature |
r | bytes32 | Part of the signature |
s | bytes32 | Part of the signature |