source_idx
stringlengths
1
5
contract_name
stringlengths
1
48
func_name
stringlengths
0
52
masked_contract
stringlengths
105
184k
func_body
stringlengths
0
324k
func_requirement
stringlengths
1
28.3k
85466
EEYcoin
transferToContract
contract EEYcoin is ERC223 { using SafeMath for uint256; using SafeMath for uint; address public owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; mapping (address => bool) public blacklist; mapping (address ...
if (balanceOf(msg.sender) < _value) revert(); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); ContractReceiver receiver = ContractReceiver(_to); receiver.tokenFallback(msg.sender, _value, _data); Transfer(msg.sender, _to, _value, _data);...
function that is called when transaction target is a contract
85469
KurumiInu
setMinSwapTokensThreshold
contract KurumiInu is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "Kurumi Inu"; string private constant _symbol = "KURINU"; uint8 private constant _decimals = 9; mapping(address => uint256) private _rOwned; mapping(address => uint256) privat...
_swapTokensAtAmount = swapTokensAtAmount;
Set minimum tokens required to swap.
85469
KurumiInu
toggleSwap
contract KurumiInu is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "Kurumi Inu"; string private constant _symbol = "KURINU"; uint8 private constant _decimals = 9; mapping(address => uint256) private _rOwned; mapping(address => uint256) privat...
swapEnabled = _swapEnabled;
Set minimum tokens required to swap.
85469
KurumiInu
setMaxTxnAmount
contract KurumiInu is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "Kurumi Inu"; string private constant _symbol = "KURINU"; uint8 private constant _decimals = 9; mapping(address => uint256) private _rOwned; mapping(address => uint256) privat...
_maxTxAmount = maxTxAmount;
Set maximum transaction
85470
BasicToken
transfer
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) /* ...
balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true;
* * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred.
85470
BasicToken
balanceOf
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) /* ...
return balances[_owner];
* * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address.
85470
Ownable
Ownable
contract Ownable { address public owner; /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() {<FILL_FUNCTION_BODY>} /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() ...
owner = msg.sender;
* * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account.
85470
Ownable
transferOwnership
contract Ownable { address public owner; /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onl...
require(newOwner != address(0)); owner = newOwner;
* * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to.
85470
ReleasableToken
addLockAddressInternal
contract ReleasableToken is ERC20, Ownable { /* The finalizer contract that allows unlift the transfer limits on this token */ address public releaseAgent; /** A crowdsale contract can release us to the wild if ICO success. If false we are are in transfer lock up period.*/ bool public released = false; ...
if(addr == 0x0) revert(); lock_addresses[addr]= lock_time; AddLockAddress(addr, lock_time);
lock new team release time
85470
ReleasableToken
setReleaseAgent
contract ReleasableToken is ERC20, Ownable { /* The finalizer contract that allows unlift the transfer limits on this token */ address public releaseAgent; /** A crowdsale contract can release us to the wild if ICO success. If false we are are in transfer lock up period.*/ bool public released = false; ...
// We don't do interface check here as we might want to a normal wallet address to act as a release agent releaseAgent = addr;
* * Set the contract that can call release and make the token transferable. * * Design choice. Allow reset the release agent to fix fat finger mistakes.
85470
ReleasableToken
setTransferAgent
contract ReleasableToken is ERC20, Ownable { /* The finalizer contract that allows unlift the transfer limits on this token */ address public releaseAgent; /** A crowdsale contract can release us to the wild if ICO success. If false we are are in transfer lock up period.*/ bool public released = false; ...
transferAgents[addr] = state;
* * Owner can allow a particular address (a crowdsale contract) to transfer tokens despite the lock up period.
85470
ReleasableToken
releaseTokenTransfer
contract ReleasableToken is ERC20, Ownable { /* The finalizer contract that allows unlift the transfer limits on this token */ address public releaseAgent; /** A crowdsale contract can release us to the wild if ICO success. If false we are are in transfer lock up period.*/ bool public released = false; ...
released = true;
* * One way function to release the tokens to the wild. * * Can be called only from the release agent that is the final ICO contract. It is only called if the crowdsale has been success (first milestone reached).
85470
StandardToken
transferFrom
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to ...
var _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // require (_value <= _allowance); balances[_to] = balances[_to].add(_value); balances[_from] = balances[_from].sub(_value); allowed[_fro...
* * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amout of tokens to be transfered
85470
StandardToken
approve
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to ...
// To change the approve amount you first have to reduce the addresses` // allowance to zero by calling `approve(_spender, 0)` if it is not // already 0 to mitigate the race condition described here: // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 require((_value == 0...
* * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent.
85470
StandardToken
allowance
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to ...
return allowed[_owner][_spender];
* * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifing the amount of tokens still available for the spender.
85470
MintableToken
setMintAgent
contract MintableToken is StandardToken, Ownable { bool public mintingFinished = false; /** List of agents that are allowed to create new tokens */ mapping (address => bool) public mintAgents; event MintingAgentChanged(address addr, bool state ); event Mint(address indexed to, uint256 amount); ...
mintAgents[addr] = state; MintingAgentChanged(addr, state);
* * Owner can allow a crowdsale contract to mint new tokens.
85470
MintableToken
mint
contract MintableToken is StandardToken, Ownable { bool public mintingFinished = false; /** List of agents that are allowed to create new tokens */ mapping (address => bool) public mintAgents; event MintingAgentChanged(address addr, bool state ); event Mint(address indexed to, uint256 amount); ...
totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); return true;
* * @dev Function to mint tokens * @param _to The address that will recieve the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful.
85470
MintableToken
finishMinting
contract MintableToken is StandardToken, Ownable { bool public mintingFinished = false; /** List of agents that are allowed to create new tokens */ mapping (address => bool) public mintAgents; event MintingAgentChanged(address addr, bool state ); event Mint(address indexed to, uint256 amount); ...
mintingFinished = true; MintFinished(); return true;
* * @dev Function to stop minting new tokens. * @return True if the operation was successful.
85470
CrowdsaleToken
CrowdsaleToken
contract CrowdsaleToken is ReleasableToken, MintableToken { string public name; string public symbol; uint public decimals; /** * Construct the token. * * @param _name Token name * @param _symbol Token symbol - should be all caps * @param _initialSupply How many tokens we sta...
owner = msg.sender; name = _name; symbol = _symbol; totalSupply = _initialSupply; decimals = _decimals; balances[owner] = totalSupply; if(totalSupply > 0) { Mint(owner, totalSupply); } // No more new supply allowed after the token creation if(!_min...
* * Construct the token. * * @param _name Token name * @param _symbol Token symbol - should be all caps * @param _initialSupply How many tokens we start with * @param _decimals Number of decimal places * @param _mintable Are new tokens created over the crowdsale or do we distribute only the ...
85470
CrowdsaleToken
releaseTokenTransfer
contract CrowdsaleToken is ReleasableToken, MintableToken { string public name; string public symbol; uint public decimals; /** * Construct the token. * * @param _name Token name * @param _symbol Token symbol - should be all caps * @param _initialSupply How many tokens we sta...
mintingFinished = true; super.releaseTokenTransfer();
* * When token is released to be transferable, enforce no new tokens can be created.
85470
CrowdsaleToken
addLockAddress
contract CrowdsaleToken is ReleasableToken, MintableToken { string public name; string public symbol; uint public decimals; /** * Construct the token. * * @param _name Token name * @param _symbol Token symbol - should be all caps * @param _initialSupply How many tokens we sta...
super.addLockAddressInternal(addr, lock_time);
lock team address by crowdsale
85471
Initializable
isConstructor
contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private initializing; /** * @dev Modifier to use in the initializer function ...
// extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, making it an effective way to detect if a contract is // under constr...
/ @dev Returns true if and only if the function is running in the constructor
85471
ContextUpgradeSafe
__Context_init
contract ContextUpgradeSafe is Initializable { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. function __Context_init() internal initializer {<FILL_FUNCTION_BODY>} function __Context_init_unchained...
__Context_init_unchained();
Empty internal constructor, to prevent people from mistakenly deploying an instance of this contract, which should be used via inheritance.
85471
OwnableUpgradeSafe
__Ownable_init
contract OwnableUpgradeSafe is Initializable, ContextUpgradeSafe { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init(...
__Context_init_unchained(); __Ownable_init_unchained();
* * @dev Initializes the contract setting the deployer as the initial owner.
85471
OwnableUpgradeSafe
owner
contract OwnableUpgradeSafe is Initializable, ContextUpgradeSafe { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init(...
return _owner;
* * @dev Returns the address of the current owner.
85471
OwnableUpgradeSafe
renounceOwnership
contract OwnableUpgradeSafe is Initializable, ContextUpgradeSafe { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init(...
emit OwnershipTransferred(_owner, address(0)); _owner = address(0);
* * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the ...
85471
OwnableUpgradeSafe
transferOwnership
contract OwnableUpgradeSafe is Initializable, ContextUpgradeSafe { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init(...
require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner;
* * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner.
85471
ERC20UpgradeSafe
__ERC20_init
contract ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; strin...
__Context_init_unchained(); __ERC20_init_unchained(name, symbol);
* * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction.
85471
ERC20UpgradeSafe
name
contract ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; strin...
return _name;
* * @dev Returns the name of the token.
85471
ERC20UpgradeSafe
symbol
contract ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; strin...
return _symbol;
* * @dev Returns the symbol of the token, usually a shorter version of the * name.
85471
ERC20UpgradeSafe
decimals
contract ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; strin...
return _decimals;
* * @dev 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`). * * Tokens usually opt for a value of 18, imitating the relationship between * ...
85471
ERC20UpgradeSafe
totalSupply
contract ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; strin...
return _totalSupply;
* * @dev See {IERC20-totalSupply}.
85471
ERC20UpgradeSafe
balanceOf
contract ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; strin...
return _balances[account];
* * @dev See {IERC20-balanceOf}.
85471
ERC20UpgradeSafe
transfer
contract ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; strin...
_transfer(_msgSender(), recipient, amount); return true;
* * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`.
85471
ERC20UpgradeSafe
allowance
contract ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; strin...
return _allowances[owner][spender];
* * @dev See {IERC20-allowance}.
85471
ERC20UpgradeSafe
approve
contract ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; strin...
_approve(_msgSender(), spender, amount); return true;
* * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address.
85471
ERC20UpgradeSafe
transferFrom
contract ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; strin...
_transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true;
* * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must ha...
85471
ERC20UpgradeSafe
increaseAllowance
contract ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; strin...
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true;
* * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requi...
85471
ERC20UpgradeSafe
decreaseAllowance
contract ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; strin...
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true;
* * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requi...
85471
ERC20UpgradeSafe
_transfer
contract ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; strin...
require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds bal...
* * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `s...
85471
ERC20UpgradeSafe
_mint
contract ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; strin...
require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount);
* @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address.
85471
ERC20UpgradeSafe
_burn
contract ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; strin...
require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(acco...
* * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens.
85471
ERC20UpgradeSafe
_approve
contract ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; strin...
require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount);
* * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: ...
85471
ERC20UpgradeSafe
_setupDecimals
contract ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; strin...
_decimals = decimals_;
* * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does.
85471
ERC20UpgradeSafe
_beforeTokenTransfer
contract ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; strin...
* * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens ...
85471
DEFIBaseToken
rebase
contract DEFIBaseToken is ERC20UpgradeSafe, ERC677Token, OwnableUpgradeSafe { // PLEASE READ BEFORE CHANGING ANY ACCOUNTING OR MATH // Anytime there is division, there is a risk of numerical instability from rounding errors. In // order to minimize this risk, we adhere to the following guidelines: /...
require(msg.sender == monetaryPolicy, "only monetary policy"); require(!rebasesPaused, "rebases paused"); if (supplyDelta == 0) { emit LogRebase(epoch, _totalSupply); return _totalSupply; } if (supplyDelta < 0) { _totalSupply = _to...
* * @dev Notifies DEFIBaseToken contract about a new rebase cycle. * @param supplyDelta The number of new DEFIBASE tokens to add into circulation via expansion. * @return The total number of DEFIBASE after the supply adjustment.
85471
DEFIBaseToken
totalSupply
contract DEFIBaseToken is ERC20UpgradeSafe, ERC677Token, OwnableUpgradeSafe { // PLEASE READ BEFORE CHANGING ANY ACCOUNTING OR MATH // Anytime there is division, there is a risk of numerical instability from rounding errors. In // order to minimize this risk, we adhere to the following guidelines: /...
return _totalSupply;
* * @return The total number of DEFIBASE.
85471
DEFIBaseToken
balanceOf
contract DEFIBaseToken is ERC20UpgradeSafe, ERC677Token, OwnableUpgradeSafe { // PLEASE READ BEFORE CHANGING ANY ACCOUNTING OR MATH // Anytime there is division, there is a risk of numerical instability from rounding errors. In // order to minimize this risk, we adhere to the following guidelines: /...
return _shareBalances[who].div(_sharesPerDEFIBASE);
* * @param who The address to query. * @return The balance of the specified address.
85471
DEFIBaseToken
transfer
contract DEFIBaseToken is ERC20UpgradeSafe, ERC677Token, OwnableUpgradeSafe { // PLEASE READ BEFORE CHANGING ANY ACCOUNTING OR MATH // Anytime there is division, there is a risk of numerical instability from rounding errors. In // order to minimize this risk, we adhere to the following guidelines: /...
require(!transfersPaused || transferPauseExemptList[msg.sender], "paused"); uint256 shareValue = value.mul(_sharesPerDEFIBASE); _shareBalances[msg.sender] = _shareBalances[msg.sender].sub(shareValue); _shareBalances[to] = _shareBalances[to].add(shareValue); emit Transfer(...
* * @dev Transfer tokens to a specified address. * @param to The address to transfer to. * @param value The amount to be transferred. * @return True on success, false otherwise.
85471
DEFIBaseToken
allowance
contract DEFIBaseToken is ERC20UpgradeSafe, ERC677Token, OwnableUpgradeSafe { // PLEASE READ BEFORE CHANGING ANY ACCOUNTING OR MATH // Anytime there is division, there is a risk of numerical instability from rounding errors. In // order to minimize this risk, we adhere to the following guidelines: /...
return _allowedDEFIBASE[owner_][spender];
* * @dev Function to check the amount of tokens that an owner has allowed to a spender. * @param owner_ The address which owns the funds. * @param spender The address which will spend the funds. * @return The number of tokens still available for the spender.
85471
DEFIBaseToken
transferFrom
contract DEFIBaseToken is ERC20UpgradeSafe, ERC677Token, OwnableUpgradeSafe { // PLEASE READ BEFORE CHANGING ANY ACCOUNTING OR MATH // Anytime there is division, there is a risk of numerical instability from rounding errors. In // order to minimize this risk, we adhere to the following guidelines: /...
require(!transfersPaused || transferPauseExemptList[msg.sender], "paused"); _allowedDEFIBASE[from][msg.sender] = _allowedDEFIBASE[from][msg.sender].sub(value); uint256 shareValue = value.mul(_sharesPerDEFIBASE); _shareBalances[from] = _shareBalances[from].sub(shareValue); ...
* * @dev Transfer tokens from one address to another. * @param from The address you want to send tokens from. * @param to The address you want to transfer to. * @param value The amount of tokens to be transferred.
85471
DEFIBaseToken
approve
contract DEFIBaseToken is ERC20UpgradeSafe, ERC677Token, OwnableUpgradeSafe { // PLEASE READ BEFORE CHANGING ANY ACCOUNTING OR MATH // Anytime there is division, there is a risk of numerical instability from rounding errors. In // order to minimize this risk, we adhere to the following guidelines: /...
require(!transfersPaused || transferPauseExemptList[msg.sender], "paused"); _allowedDEFIBASE[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true;
* * @dev Approve the passed address to spend the specified amount of tokens on behalf of * msg.sender. This method is included for ERC20 compatibility. * increaseAllowance and decreaseAllowance should be used instead. * Changing an allowance with this method brings the risk that someone may tran...
85471
DEFIBaseToken
increaseAllowance
contract DEFIBaseToken is ERC20UpgradeSafe, ERC677Token, OwnableUpgradeSafe { // PLEASE READ BEFORE CHANGING ANY ACCOUNTING OR MATH // Anytime there is division, there is a risk of numerical instability from rounding errors. In // order to minimize this risk, we adhere to the following guidelines: /...
require(!transfersPaused || transferPauseExemptList[msg.sender], "paused"); _allowedDEFIBASE[msg.sender][spender] = _allowedDEFIBASE[msg.sender][spender].add(addedValue); emit Approval(msg.sender, spender, _allowedDEFIBASE[msg.sender][spender]); return true;
* * @dev Increase the amount of tokens that an owner has allowed to a spender. * This method should be used instead of approve() to avoid the double approval vulnerability * described above. * @param spender The address which will spend the funds. * @param addedValue The amount of tokens t...
85471
DEFIBaseToken
decreaseAllowance
contract DEFIBaseToken is ERC20UpgradeSafe, ERC677Token, OwnableUpgradeSafe { // PLEASE READ BEFORE CHANGING ANY ACCOUNTING OR MATH // Anytime there is division, there is a risk of numerical instability from rounding errors. In // order to minimize this risk, we adhere to the following guidelines: /...
require(!transfersPaused || transferPauseExemptList[msg.sender], "paused"); uint256 oldValue = _allowedDEFIBASE[msg.sender][spender]; if (subtractedValue >= oldValue) { _allowedDEFIBASE[msg.sender][spender] = 0; } else { _allowedDEFIBASE[msg.sender][spend...
* * @dev Decrease the amount of tokens that an owner has allowed to a spender. * * @param spender The address which will spend the funds. * @param subtractedValue The amount of tokens to decrease the allowance by.
85471
DEFIBaseTokenMonetaryPolicy
rebase
contract DEFIBaseTokenMonetaryPolicy is OwnableUpgradeSafe { using SafeMath for uint256; using SafeMathInt for int256; using UInt256Lib for uint256; event LogRebase( uint256 indexed epoch, uint256 exchangeRate, uint256 mcap, int256 requestedSupplyAdjustment, ...
require(msg.sender == orchestrator, "you are not the orchestrator"); require(inRebaseWindow(), "the rebase window is closed"); // This comparison also ensures there is no reentrancy. require(lastRebaseTimestampSec.add(minRebaseTimeIntervalSec) < now, "cannot rebase yet"); ...
* * @notice Initiates a new rebase operation, provided the minimum time period has elapsed. * * @dev The supply adjustment equals (_totalSupply * DeviationFromTargetRate) / rebaseLag * Where DeviationFromTargetRate is (TokenPriceOracleRate - targetPrice) / targetPrice * and targe...
85471
DEFIBaseTokenMonetaryPolicy
setMcapOracle
contract DEFIBaseTokenMonetaryPolicy is OwnableUpgradeSafe { using SafeMath for uint256; using SafeMathInt for int256; using UInt256Lib for uint256; event LogRebase( uint256 indexed epoch, uint256 exchangeRate, uint256 mcap, int256 requestedSupplyAdjustment, ...
mcapOracle = mcapOracle_;
* * @notice Sets the reference to the market cap oracle. * @param mcapOracle_ The address of the mcap oracle contract.
85471
DEFIBaseTokenMonetaryPolicy
setTokenPriceOracle
contract DEFIBaseTokenMonetaryPolicy is OwnableUpgradeSafe { using SafeMath for uint256; using SafeMathInt for int256; using UInt256Lib for uint256; event LogRebase( uint256 indexed epoch, uint256 exchangeRate, uint256 mcap, int256 requestedSupplyAdjustment, ...
tokenPriceOracle = tokenPriceOracle_;
* * @notice Sets the reference to the token price oracle. * @param tokenPriceOracle_ The address of the token price oracle contract.
85471
DEFIBaseTokenMonetaryPolicy
setOrchestrator
contract DEFIBaseTokenMonetaryPolicy is OwnableUpgradeSafe { using SafeMath for uint256; using SafeMathInt for int256; using UInt256Lib for uint256; event LogRebase( uint256 indexed epoch, uint256 exchangeRate, uint256 mcap, int256 requestedSupplyAdjustment, ...
orchestrator = orchestrator_;
* * @notice Sets the reference to the orchestrator. * @param orchestrator_ The address of the orchestrator contract.
85471
DEFIBaseTokenMonetaryPolicy
setDeviationThreshold
contract DEFIBaseTokenMonetaryPolicy is OwnableUpgradeSafe { using SafeMath for uint256; using SafeMathInt for int256; using UInt256Lib for uint256; event LogRebase( uint256 indexed epoch, uint256 exchangeRate, uint256 mcap, int256 requestedSupplyAdjustment, ...
deviationThreshold = deviationThreshold_;
* * @notice Sets the deviation threshold fraction. If the exchange rate given by the market * oracle is within this fractional distance from the targetRate, then no supply * modifications are made. DECIMALS fixed point number. * @param deviationThreshold_ The new exchange rate th...
85471
DEFIBaseTokenMonetaryPolicy
setRebaseLag
contract DEFIBaseTokenMonetaryPolicy is OwnableUpgradeSafe { using SafeMath for uint256; using SafeMathInt for int256; using UInt256Lib for uint256; event LogRebase( uint256 indexed epoch, uint256 exchangeRate, uint256 mcap, int256 requestedSupplyAdjustment, ...
require(rebaseLag_ > 0); rebaseLag = rebaseLag_;
* * @notice Sets the rebase lag parameter. It is used to dampen the applied supply adjustment by 1 / rebaseLag If the rebase lag R, equals 1, the smallest value for R, then the full supply correction is applied on each rebase cycle. If it is greater ...
85471
DEFIBaseTokenMonetaryPolicy
setRebaseTimingParameters
contract DEFIBaseTokenMonetaryPolicy is OwnableUpgradeSafe { using SafeMath for uint256; using SafeMathInt for int256; using UInt256Lib for uint256; event LogRebase( uint256 indexed epoch, uint256 exchangeRate, uint256 mcap, int256 requestedSupplyAdjustment, ...
require(minRebaseTimeIntervalSec_ > 0, "minRebaseTimeIntervalSec cannot be 0"); require(rebaseWindowOffsetSec_ < minRebaseTimeIntervalSec_, "rebaseWindowOffsetSec_ >= minRebaseTimeIntervalSec_"); minRebaseTimeIntervalSec = minRebaseTimeIntervalSec_; rebaseWindowOffsetSec = rebaseW...
* * @notice Sets the parameters which control the timing and frequency of * rebase operations. * a) the minimum time period that must elapse between rebase cycles. * b) the rebase window offset parameter. * c) the rebase window length parameter. * @par...
85471
DEFIBaseTokenMonetaryPolicy
initialize
contract DEFIBaseTokenMonetaryPolicy is OwnableUpgradeSafe { using SafeMath for uint256; using SafeMathInt for int256; using UInt256Lib for uint256; event LogRebase( uint256 indexed epoch, uint256 exchangeRate, uint256 mcap, int256 requestedSupplyAdjustment, ...
__Ownable_init(); deviationThreshold = 0; rebaseLag = 1; minRebaseTimeIntervalSec = 1 days; rebaseWindowOffsetSec = 79200; // 6PM UTC rebaseWindowLengthSec = 60 minutes; lastRebaseTimestampSec = 0; epoch = 0; DEFIBASE = DEFIBASE_; ...
* * @dev ZOS upgradable contract initialization method. * It is called at the time of contract creation to invoke parent class initializers and * initialize the contract's state variables.
85471
DEFIBaseTokenMonetaryPolicy
inRebaseWindow
contract DEFIBaseTokenMonetaryPolicy is OwnableUpgradeSafe { using SafeMath for uint256; using SafeMathInt for int256; using UInt256Lib for uint256; event LogRebase( uint256 indexed epoch, uint256 exchangeRate, uint256 mcap, int256 requestedSupplyAdjustment, ...
return ( now.mod(minRebaseTimeIntervalSec) >= rebaseWindowOffsetSec && now.mod(minRebaseTimeIntervalSec) < (rebaseWindowOffsetSec.add(rebaseWindowLengthSec)) );
* * @return If the latest block timestamp is within the rebase time window it, returns true. * Otherwise, returns false.
85471
DEFIBaseTokenMonetaryPolicy
computeSupplyDelta
contract DEFIBaseTokenMonetaryPolicy is OwnableUpgradeSafe { using SafeMath for uint256; using SafeMathInt for int256; using UInt256Lib for uint256; event LogRebase( uint256 indexed epoch, uint256 exchangeRate, uint256 mcap, int256 requestedSupplyAdjustment, ...
if (withinDeviationThreshold(price, mcap.div(100000000000))) { return 0; } // supplyDelta = totalSupply * (price - targetPrice) / targetPrice // 100,000,000,000:1 ratio int256 pricex = price.mul(100000000000).toInt256Safe(); int256 targetPricex...
* * @return Computes the total supply adjustment in response to the exchange rate * and the targetRate.
85471
DEFIBaseTokenMonetaryPolicy
withinDeviationThreshold
contract DEFIBaseTokenMonetaryPolicy is OwnableUpgradeSafe { using SafeMath for uint256; using SafeMathInt for int256; using UInt256Lib for uint256; event LogRebase( uint256 indexed epoch, uint256 exchangeRate, uint256 mcap, int256 requestedSupplyAdjustment, ...
if (deviationThreshold == 0) { return false; } uint256 absoluteDeviationThreshold = targetRate.mul(deviationThreshold).div(10 ** DECIMALS); return (rate >= targetRate && rate.sub(targetRate) < absoluteDeviationThreshold) || (rate < targetRate && targetR...
* * @param rate The current exchange rate, an 18 decimal fixed point number. * @param targetRate The target exchange rate, an 18 decimal fixed point number. * @return If the rate is within the deviation threshold from the target rate, returns true. * Otherwise, returns false.
85473
UpgradeabilityProxy
null
contract UpgradeabilityProxy is Proxy { /** * @dev Contract constructor. * @param _logic Address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be ...
assert(IMPLEMENTATION_SLOT == bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)); _setImplementation(_logic); if(_data.length > 0) { (bool success,) = _logic.delegatecall(_data); require(success); }
* * @dev Contract constructor. * @param _logic Address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidit...
85473
UpgradeabilityProxy
_implementation
contract UpgradeabilityProxy is Proxy { /** * @dev Contract constructor. * @param _logic Address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be ...
bytes32 slot = IMPLEMENTATION_SLOT; assembly { impl := sload(slot) }
* * @dev Returns the current implementation. * @return impl Address of the current implementation
85473
UpgradeabilityProxy
_upgradeTo
contract UpgradeabilityProxy is Proxy { /** * @dev Contract constructor. * @param _logic Address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be ...
_setImplementation(newImplementation); emit Upgraded(newImplementation);
* * @dev Upgrades the proxy to a new implementation. * @param newImplementation Address of the new implementation.
85473
UpgradeabilityProxy
_setImplementation
contract UpgradeabilityProxy is Proxy { /** * @dev Contract constructor. * @param _logic Address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be ...
require(Address.isContract(newImplementation), "Cannot set a proxy implementation to a non-contract address"); bytes32 slot = IMPLEMENTATION_SLOT; assembly { sstore(slot, newImplementation) }
* * @dev Sets the implementation address of the proxy. * @param newImplementation Address of the new implementation.
85473
AdminUpgradeabilityProxy
null
contract AdminUpgradeabilityProxy is UpgradeabilityProxy { /** * Contract constructor. * @param _logic address of the initial implementation. * @param _admin Address of the proxy administrator. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It ...
assert(ADMIN_SLOT == bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)); _setAdmin(_admin);
* * Contract constructor. * @param _logic address of the initial implementation. * @param _admin Address of the proxy administrator. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function ...
85473
AdminUpgradeabilityProxy
admin
contract AdminUpgradeabilityProxy is UpgradeabilityProxy { /** * Contract constructor. * @param _logic address of the initial implementation. * @param _admin Address of the proxy administrator. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It ...
return _admin();
* * @return The address of the proxy admin.
85473
AdminUpgradeabilityProxy
implementation
contract AdminUpgradeabilityProxy is UpgradeabilityProxy { /** * Contract constructor. * @param _logic address of the initial implementation. * @param _admin Address of the proxy administrator. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It ...
return _implementation();
* * @return The address of the implementation.
85473
AdminUpgradeabilityProxy
changeAdmin
contract AdminUpgradeabilityProxy is UpgradeabilityProxy { /** * Contract constructor. * @param _logic address of the initial implementation. * @param _admin Address of the proxy administrator. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It ...
require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin);
* * @dev Changes the admin of the proxy. * Only the current admin can call this function. * @param newAdmin Address to transfer proxy administration to.
85473
AdminUpgradeabilityProxy
upgradeTo
contract AdminUpgradeabilityProxy is UpgradeabilityProxy { /** * Contract constructor. * @param _logic address of the initial implementation. * @param _admin Address of the proxy administrator. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It ...
_upgradeTo(newImplementation);
* * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation.
85473
AdminUpgradeabilityProxy
upgradeToAndCall
contract AdminUpgradeabilityProxy is UpgradeabilityProxy { /** * Contract constructor. * @param _logic address of the initial implementation. * @param _admin Address of the proxy administrator. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It ...
_upgradeTo(newImplementation); (bool success,) = newImplementation.delegatecall(data); require(success);
* * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should i...
85473
AdminUpgradeabilityProxy
_admin
contract AdminUpgradeabilityProxy is UpgradeabilityProxy { /** * Contract constructor. * @param _logic address of the initial implementation. * @param _admin Address of the proxy administrator. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It ...
bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) }
* * @return adm The admin slot.
85473
AdminUpgradeabilityProxy
_setAdmin
contract AdminUpgradeabilityProxy is UpgradeabilityProxy { /** * Contract constructor. * @param _logic address of the initial implementation. * @param _admin Address of the proxy administrator. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It ...
bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) }
* * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin.
85473
AdminUpgradeabilityProxy
_willFallback
contract AdminUpgradeabilityProxy is UpgradeabilityProxy { /** * Contract constructor. * @param _logic address of the initial implementation. * @param _admin Address of the proxy administrator. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It ...
require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin"); super._willFallback();
* * @dev Only fall back when the sender is not the admin.
85474
ERC20
null
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {...
_name = name_; _symbol = symbol_;
* * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction.
85474
ERC20
name
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {...
return _name;
* * @dev Returns the name of the token.
85474
ERC20
symbol
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {...
return _symbol;
* * @dev Returns the symbol of the token, usually a shorter version of the * name.
85474
ERC20
decimals
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {...
return 18;
* * @dev 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`). * * Tokens usually opt for a value of 18, imitating the relationship between * ...
85474
ERC20
totalSupply
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {...
return _totalSupply;
* * @dev See {IERC20-totalSupply}.
85474
ERC20
balanceOf
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {...
return _balances[account];
* * @dev See {IERC20-balanceOf}.
85474
ERC20
transfer
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {...
_transfer(_msgSender(), recipient, amount); return true;
* * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`.
85474
ERC20
allowance
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {...
return _allowances[owner][spender];
* * @dev See {IERC20-allowance}.
85474
ERC20
approve
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {...
_approve(_msgSender(), spender, amount); return true;
* * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address.
85474
ERC20
transferFrom
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {...
_transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } ...
* * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender`...
85474
ERC20
increaseAllowance
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {...
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true;
* * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requi...
85474
ERC20
decreaseAllowance
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {...
uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true;
* * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requi...
85474
ERC20
_transfer
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {...
require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, ...
* * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `s...
85474
ERC20
_mint
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {...
require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, am...
* @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address.
85474
ERC20
_burn
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {...
require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balanc...
* * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens.
85474
ERC20
_approve
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {...
require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount);
* * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * ...
85474
ERC20
_beforeTokenTransfer
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {...
* * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens wil...
85474
ERC20
_afterTokenTransfer
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {...
* * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens hav...
85476
LafiteToken
LafiteToken
contract LafiteToken { string public name; string public symbol; uint8 public decimals = 8; // decimals 可以有的小数点个数,最小的代币单位。18 是建议的默认值 uint256 public totalSupply; // 用mapping保存每个地址对应的余额 mapping (address => uint256) public balanceOf; // 存储对账号的控制 mapping (address => mapping (addr...
totalSupply = initialSupply * 10 ** uint256(decimals); // 供应的份额,份额跟最小的代币单位有关,份额 = 币数 * 10 ** decimals。 balanceOf[msg.sender] = totalSupply; // 创建者拥有所有的代币 name = tokenName; // 代币名称 symbol = tokenSymbol; /...
* * 初始化构造
85476
LafiteToken
_transfer
contract LafiteToken { string public name; string public symbol; uint8 public decimals = 8; // decimals 可以有的小数点个数,最小的代币单位。18 是建议的默认值 uint256 public totalSupply; // 用mapping保存每个地址对应的余额 mapping (address => uint256) public balanceOf; // 存储对账号的控制 mapping (address => mapping (addr...
// 确保目标地址不为0x0,因为0x0地址代表销毁 require(_to != 0x0); // 检查发送者余额 require(balanceOf[_from] >= _value); // 确保转移为正数个 require(balanceOf[_to] + _value > balanceOf[_to]); // 以下用来检查交易, uint previousBalances = balanceOf[_from] + balanceOf[_to]; // S...
* * 代币交易转移的内部实现
85476
LafiteToken
transfer
contract LafiteToken { string public name; string public symbol; uint8 public decimals = 8; // decimals 可以有的小数点个数,最小的代币单位。18 是建议的默认值 uint256 public totalSupply; // 用mapping保存每个地址对应的余额 mapping (address => uint256) public balanceOf; // 存储对账号的控制 mapping (address => mapping (addr...
_transfer(msg.sender, _to, _value);
* * 代币交易转移 * 从自己(创建交易者)账号发送`_value`个代币到 `_to`账号 * * @param _to 接收者地址 * @param _value 转移数额
85476
LafiteToken
transferFrom
contract LafiteToken { string public name; string public symbol; uint8 public decimals = 8; // decimals 可以有的小数点个数,最小的代币单位。18 是建议的默认值 uint256 public totalSupply; // 用mapping保存每个地址对应的余额 mapping (address => uint256) public balanceOf; // 存储对账号的控制 mapping (address => mapping (addr...
require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true;
* * 账号之间代币交易转移 * @param _from 发送者地址 * @param _to 接收者地址 * @param _value 转移数额