Skip to main content

IButtonswapERC20

Inherits: IButtonswapERC20Errors, IButtonswapERC20Events

Functions

name

Returns the name of the token.

function name() external view 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 returns (string memory _symbol);

Returns

NameTypeDescription
_symbolstringThe token symbol

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.

function decimals() external pure returns (uint8 decimals);

Returns

NameTypeDescription
decimalsuint8The number of decimals

totalSupply

Returns the amount of tokens in existence.

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

Returns

NameTypeDescription
totalSupplyuint256The amount of tokens in existence

balanceOf

Returns the amount of tokens owned by account.

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

Parameters

NameTypeDescription
owneraddressThe account the balance is being checked for

Returns

NameTypeDescription
balanceuint256The amount of tokens owned by owner

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.

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

Parameters

NameTypeDescription
owneraddressThe account that owns the tokens
spenderaddressThe account that can spend the tokens

Returns

NameTypeDescription
allowanceuint256The amount of tokens owned by owner that the spender can transfer

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);

Parameters

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

Returns

NameTypeDescription
<none>boolsuccess Whether the operation succeeded

DOMAIN_SEPARATOR

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

function DOMAIN_SEPARATOR() external view returns (bytes32 DOMAIN_SEPARATOR);

Returns

NameTypeDescription
DOMAIN_SEPARATORbytes32The DOMAIN_SEPARATOR value

PERMIT_TYPEHASH

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

function PERMIT_TYPEHASH() external pure returns (bytes32 PERMIT_TYPEHASH);

Returns

NameTypeDescription
PERMIT_TYPEHASHbytes32The PERMIT_TYPEHASH value

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.

function nonces(address owner) external view returns (uint256 nonce);

Parameters

NameTypeDescription
owneraddressThe account to get the nonce for

Returns

NameTypeDescription
nonceuint256The current nonce for the given owner

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