contract_name
stringlengths
1
61
file_path
stringlengths
5
50.4k
contract_address
stringlengths
42
42
language
stringclasses
1 value
class_name
stringlengths
1
61
class_code
stringlengths
4
330k
class_documentation
stringlengths
0
29.1k
class_documentation_type
stringclasses
6 values
func_name
stringlengths
0
62
func_code
stringlengths
1
303k
func_documentation
stringlengths
2
14.9k
func_documentation_type
stringclasses
4 values
compiler_version
stringlengths
15
42
license_type
stringclasses
14 values
swarm_source
stringlengths
0
71
meta
dict
__index_level_0__
int64
0
60.4k
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
ERC20
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} and {symbol}. * * The defaut 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. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @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 * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); 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 have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); 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. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); 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. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @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: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { 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, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, 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. */ function _mint(address account, uint256 amount) internal virtual { 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); } /** * @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. */ function _burn(address account, uint256 amount) internal virtual { 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"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), 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: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { 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 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 will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
decimals
function decimals() public view virtual override returns (uint8) { 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 * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 1741, 1839 ] }
56,161
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
ERC20
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} and {symbol}. * * The defaut 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. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @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 * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); 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 have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); 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. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); 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. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @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: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { 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, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, 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. */ function _mint(address account, uint256 amount) internal virtual { 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); } /** * @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. */ function _burn(address account, uint256 amount) internal virtual { 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"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), 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: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { 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 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 will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
totalSupply
function totalSupply() public view virtual override returns (uint256) { return _totalSupply; }
/** * @dev See {IERC20-totalSupply}. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 1899, 2012 ] }
56,162
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
ERC20
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} and {symbol}. * * The defaut 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. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @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 * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); 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 have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); 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. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); 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. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @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: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { 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, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, 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. */ function _mint(address account, uint256 amount) internal virtual { 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); } /** * @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. */ function _burn(address account, uint256 amount) internal virtual { 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"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), 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: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { 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 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 will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
balanceOf
function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; }
/** * @dev See {IERC20-balanceOf}. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 2070, 2202 ] }
56,163
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
ERC20
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} and {symbol}. * * The defaut 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. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @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 * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); 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 have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); 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. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); 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. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @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: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { 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, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, 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. */ function _mint(address account, uint256 amount) internal virtual { 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); } /** * @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. */ function _burn(address account, uint256 amount) internal virtual { 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"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), 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: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { 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 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 will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
transfer
function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _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`. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 2410, 2590 ] }
56,164
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
ERC20
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} and {symbol}. * * The defaut 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. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @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 * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); 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 have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); 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. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); 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. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @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: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { 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, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, 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. */ function _mint(address account, uint256 amount) internal virtual { 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); } /** * @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. */ function _burn(address account, uint256 amount) internal virtual { 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"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), 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: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { 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 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 will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
allowance
function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; }
/** * @dev See {IERC20-allowance}. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 2648, 2804 ] }
56,165
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
ERC20
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} and {symbol}. * * The defaut 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. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @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 * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); 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 have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); 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. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); 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. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @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: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { 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, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, 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. */ function _mint(address account, uint256 amount) internal virtual { 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); } /** * @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. */ function _burn(address account, uint256 amount) internal virtual { 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"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), 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: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { 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 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 will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
approve
function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; }
/** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 2946, 3120 ] }
56,166
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
ERC20
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} and {symbol}. * * The defaut 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. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @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 * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); 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 have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); 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. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); 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. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @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: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { 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, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, 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. */ function _mint(address account, uint256 amount) internal virtual { 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); } /** * @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. */ function _burn(address account, uint256 amount) internal virtual { 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"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), 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: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { 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 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 will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
transferFrom
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); 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 have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 3597, 4024 ] }
56,167
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
ERC20
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} and {symbol}. * * The defaut 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. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @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 * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); 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 have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); 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. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); 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. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @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: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { 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, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, 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. */ function _mint(address account, uint256 amount) internal virtual { 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); } /** * @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. */ function _burn(address account, uint256 amount) internal virtual { 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"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), 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: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { 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 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 will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
increaseAllowance
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _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. * * Requirements: * * - `spender` cannot be the zero address. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 4428, 4648 ] }
56,168
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
ERC20
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} and {symbol}. * * The defaut 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. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @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 * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); 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 have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); 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. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); 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. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @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: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { 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, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, 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. */ function _mint(address account, uint256 amount) internal virtual { 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); } /** * @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. */ function _burn(address account, uint256 amount) internal virtual { 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"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), 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: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { 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 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 will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
decreaseAllowance
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _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. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 5146, 5528 ] }
56,169
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
ERC20
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} and {symbol}. * * The defaut 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. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @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 * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); 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 have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); 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. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); 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. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @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: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { 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, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, 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. */ function _mint(address account, uint256 amount) internal virtual { 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); } /** * @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. */ function _burn(address account, uint256 amount) internal virtual { 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"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), 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: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { 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 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 will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_transfer
function _transfer(address sender, address recipient, uint256 amount) internal virtual { 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, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); }
/** * @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: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 6013, 6622 ] }
56,170
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
ERC20
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} and {symbol}. * * The defaut 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. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @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 * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); 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 have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); 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. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); 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. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @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: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { 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, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, 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. */ function _mint(address account, uint256 amount) internal virtual { 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); } /** * @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. */ function _burn(address account, uint256 amount) internal virtual { 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"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), 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: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { 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 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 will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_mint
function _mint(address account, uint256 amount) internal virtual { 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); }
/** @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. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 6899, 7242 ] }
56,171
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
ERC20
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} and {symbol}. * * The defaut 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. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @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 * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); 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 have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); 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. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); 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. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @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: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { 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, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, 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. */ function _mint(address account, uint256 amount) internal virtual { 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); } /** * @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. */ function _burn(address account, uint256 amount) internal virtual { 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"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), 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: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { 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 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 will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_burn
function _burn(address account, uint256 amount) internal virtual { 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"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); }
/** * @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. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 7570, 8069 ] }
56,172
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
ERC20
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} and {symbol}. * * The defaut 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. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @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 * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); 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 have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); 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. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); 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. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @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: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { 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, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, 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. */ function _mint(address account, uint256 amount) internal virtual { 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); } /** * @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. */ function _burn(address account, uint256 amount) internal virtual { 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"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), 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: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { 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 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 will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_approve
function _approve(address owner, address spender, uint256 amount) internal virtual { 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: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 8502, 8853 ] }
56,173
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
ERC20
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} and {symbol}. * * The defaut 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. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @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 * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); 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 have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); 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. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); 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. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @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: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { 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, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, 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. */ function _mint(address account, uint256 amount) internal virtual { 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); } /** * @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. */ function _burn(address account, uint256 amount) internal virtual { 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"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), 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: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { 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 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 will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_beforeTokenTransfer
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
/** * @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 will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 9451, 9548 ] }
56,174
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
ERC20Burnable
abstract contract ERC20Burnable is Context, ERC20 { /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { uint256 currentAllowance = allowance(account, _msgSender()); require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance"); _approve(account, _msgSender(), currentAllowance - amount); _burn(account, amount); } }
/** * @dev Extension of {ERC20} that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */
NatSpecMultiLine
burn
function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); }
/** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 161, 257 ] }
56,175
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
ERC20Burnable
abstract contract ERC20Burnable is Context, ERC20 { /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { uint256 currentAllowance = allowance(account, _msgSender()); require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance"); _approve(account, _msgSender(), currentAllowance - amount); _burn(account, amount); } }
/** * @dev Extension of {ERC20} that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */
NatSpecMultiLine
burnFrom
function burnFrom(address account, uint256 amount) public virtual { uint256 currentAllowance = allowance(account, _msgSender()); require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance"); _approve(account, _msgSender(), currentAllowance - amount); _burn(account, amount); }
/** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 571, 908 ] }
56,176
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
Pausable
abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor () { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
/** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */
NatSpecMultiLine
paused
function paused() public view virtual returns (bool) { return _paused; }
/** * @dev Returns true if the contract is paused, and false otherwise. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 531, 622 ] }
56,177
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
Pausable
abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor () { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
/** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */
NatSpecMultiLine
_pause
function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); }
/** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 1331, 1454 ] }
56,178
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
Pausable
abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor () { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
/** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */
NatSpecMultiLine
_unpause
function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); }
/** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 1590, 1715 ] }
56,179
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
ERC20Pausable
abstract contract ERC20Pausable is ERC20, Pausable { /** * @dev See {ERC20-_beforeTokenTransfer}. * * Requirements: * * - the contract must not be paused. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { super._beforeTokenTransfer(from, to, amount); require(!paused(), "ERC20Pausable: token transfer while paused"); } }
/** * @dev ERC20 token with pausable token transfers, minting and burning. * * Useful for scenarios such as preventing trades until the end of an evaluation * period, or having an emergency switch for freezing all token transfers in the * event of a large bug. */
NatSpecMultiLine
_beforeTokenTransfer
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { super._beforeTokenTransfer(from, to, amount); require(!paused(), "ERC20Pausable: token transfer while paused"); }
/** * @dev See {ERC20-_beforeTokenTransfer}. * * Requirements: * * - the contract must not be paused. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 200, 443 ] }
56,180
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
Strings
library Strings { bytes16 private constant alphabet = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = alphabet[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
/** * @dev String operations. */
NatSpecMultiLine
toString
function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); }
/** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 180, 908 ] }
56,181
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
Strings
library Strings { bytes16 private constant alphabet = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = alphabet[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
/** * @dev String operations. */
NatSpecMultiLine
toHexString
function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); }
/** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 1013, 1358 ] }
56,182
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
Strings
library Strings { bytes16 private constant alphabet = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = alphabet[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
/** * @dev String operations. */
NatSpecMultiLine
toHexString
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = alphabet[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); }
/** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 1481, 1933 ] }
56,183
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
IERC165
interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
/** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */
NatSpecMultiLine
supportsInterface
function supportsInterface(bytes4 interfaceId) external view returns (bool);
/** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 374, 455 ] }
56,184
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
ERC165
abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
/** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */
NatSpecMultiLine
supportsInterface
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; }
/** * @dev See {IERC165-supportsInterface}. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 103, 265 ] }
56,185
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
AccessControl
abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping (address => bool) members; bytes32 adminRole; } mapping (bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ */ function _checkRole(bytes32 role, address account) internal view { if(!hasRole(role, account)) { revert(string(abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ))); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, getRoleAdmin(role), adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
/** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */
NatSpecMultiLine
supportsInterface
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); }
/** * @dev See {IERC165-supportsInterface}. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 1953, 2175 ] }
56,186
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
AccessControl
abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping (address => bool) members; bytes32 adminRole; } mapping (bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ */ function _checkRole(bytes32 role, address account) internal view { if(!hasRole(role, account)) { revert(string(abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ))); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, getRoleAdmin(role), adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
/** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */
NatSpecMultiLine
hasRole
function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; }
/** * @dev Returns `true` if `account` has been granted `role`. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 2262, 2406 ] }
56,187
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
AccessControl
abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping (address => bool) members; bytes32 adminRole; } mapping (bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ */ function _checkRole(bytes32 role, address account) internal view { if(!hasRole(role, account)) { revert(string(abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ))); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, getRoleAdmin(role), adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
/** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */
NatSpecMultiLine
_checkRole
function _checkRole(bytes32 role, address account) internal view { if(!hasRole(role, account)) { revert(string(abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ))); } }
/** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 2691, 3080 ] }
56,188
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
AccessControl
abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping (address => bool) members; bytes32 adminRole; } mapping (bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ */ function _checkRole(bytes32 role, address account) internal view { if(!hasRole(role, account)) { revert(string(abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ))); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, getRoleAdmin(role), adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
/** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */
NatSpecMultiLine
getRoleAdmin
function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; }
/** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 3264, 3392 ] }
56,189
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
AccessControl
abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping (address => bool) members; bytes32 adminRole; } mapping (bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ */ function _checkRole(bytes32 role, address account) internal view { if(!hasRole(role, account)) { revert(string(abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ))); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, getRoleAdmin(role), adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
/** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */
NatSpecMultiLine
grantRole
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); }
/** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 3649, 3801 ] }
56,190
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
AccessControl
abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping (address => bool) members; bytes32 adminRole; } mapping (bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ */ function _checkRole(bytes32 role, address account) internal view { if(!hasRole(role, account)) { revert(string(abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ))); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, getRoleAdmin(role), adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
/** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */
NatSpecMultiLine
revokeRole
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); }
/** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 4041, 4195 ] }
56,191
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
AccessControl
abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping (address => bool) members; bytes32 adminRole; } mapping (bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ */ function _checkRole(bytes32 role, address account) internal view { if(!hasRole(role, account)) { revert(string(abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ))); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, getRoleAdmin(role), adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
/** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */
NatSpecMultiLine
renounceRole
function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); }
/** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 4697, 4920 ] }
56,192
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
AccessControl
abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping (address => bool) members; bytes32 adminRole; } mapping (bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ */ function _checkRole(bytes32 role, address account) internal view { if(!hasRole(role, account)) { revert(string(abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ))); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, getRoleAdmin(role), adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
/** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */
NatSpecMultiLine
_setupRole
function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); }
/** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 5498, 5615 ] }
56,193
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
AccessControl
abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping (address => bool) members; bytes32 adminRole; } mapping (bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ */ function _checkRole(bytes32 role, address account) internal view { if(!hasRole(role, account)) { revert(string(abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ))); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, getRoleAdmin(role), adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
/** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */
NatSpecMultiLine
_setRoleAdmin
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, getRoleAdmin(role), adminRole); _roles[role].adminRole = adminRole; }
/** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 5742, 5942 ] }
56,194
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
EnumerableSet
library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
/** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */
NatSpecMultiLine
_add
function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } }
/** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 908, 1327 ] }
56,195
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
EnumerableSet
library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
/** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */
NatSpecMultiLine
_remove
function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } }
/** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 1498, 3056 ] }
56,196
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
EnumerableSet
library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
/** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */
NatSpecMultiLine
_contains
function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; }
/** * @dev Returns true if the value is in the set. O(1). */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 3137, 3271 ] }
56,197
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
EnumerableSet
library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
/** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */
NatSpecMultiLine
_length
function _length(Set storage set) private view returns (uint256) { return set._values.length; }
/** * @dev Returns the number of values on the set. O(1). */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 3352, 3466 ] }
56,198
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
EnumerableSet
library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
/** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */
NatSpecMultiLine
_at
function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; }
/** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 3805, 4014 ] }
56,199
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
EnumerableSet
library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
/** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */
NatSpecMultiLine
add
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); }
/** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 4263, 4393 ] }
56,200
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
EnumerableSet
library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
/** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */
NatSpecMultiLine
remove
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); }
/** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 4564, 4700 ] }
56,201
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
EnumerableSet
library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
/** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */
NatSpecMultiLine
contains
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); }
/** * @dev Returns true if the value is in the set. O(1). */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 4781, 4926 ] }
56,202
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
EnumerableSet
library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
/** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */
NatSpecMultiLine
length
function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); }
/** * @dev Returns the number of values in the set. O(1). */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 5007, 5129 ] }
56,203
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
EnumerableSet
library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
/** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */
NatSpecMultiLine
at
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); }
/** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 5468, 5604 ] }
56,204
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
EnumerableSet
library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
/** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */
NatSpecMultiLine
add
function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); }
/** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 5853, 6010 ] }
56,205
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
EnumerableSet
library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
/** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */
NatSpecMultiLine
remove
function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); }
/** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 6181, 6344 ] }
56,206
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
EnumerableSet
library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
/** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */
NatSpecMultiLine
contains
function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); }
/** * @dev Returns true if the value is in the set. O(1). */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 6425, 6597 ] }
56,207
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
EnumerableSet
library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
/** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */
NatSpecMultiLine
length
function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); }
/** * @dev Returns the number of values in the set. O(1). */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 6678, 6800 ] }
56,208
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
EnumerableSet
library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
/** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */
NatSpecMultiLine
at
function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); }
/** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 7139, 7302 ] }
56,209
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
EnumerableSet
library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
/** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */
NatSpecMultiLine
add
function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); }
/** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 7547, 7683 ] }
56,210
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
EnumerableSet
library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
/** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */
NatSpecMultiLine
remove
function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); }
/** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 7854, 7996 ] }
56,211
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
EnumerableSet
library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
/** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */
NatSpecMultiLine
contains
function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); }
/** * @dev Returns true if the value is in the set. O(1). */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 8077, 8228 ] }
56,212
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
EnumerableSet
library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
/** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */
NatSpecMultiLine
length
function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); }
/** * @dev Returns the number of values on the set. O(1). */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 8309, 8428 ] }
56,213
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
EnumerableSet
library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
/** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */
NatSpecMultiLine
at
function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); }
/** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 8767, 8909 ] }
56,214
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
AccessControlEnumerable
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl { using EnumerableSet for EnumerableSet.AddressSet; mapping (bytes32 => EnumerableSet.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view override returns (address) { return _roleMembers[role].at(index); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view override returns (uint256) { return _roleMembers[role].length(); } /** * @dev Overload {grantRole} to track enumerable memberships */ function grantRole(bytes32 role, address account) public virtual override { super.grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {revokeRole} to track enumerable memberships */ function revokeRole(bytes32 role, address account) public virtual override { super.revokeRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {renounceRole} to track enumerable memberships */ function renounceRole(bytes32 role, address account) public virtual override { super.renounceRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {_setupRole} to track enumerable memberships */ function _setupRole(bytes32 role, address account) internal virtual override { super._setupRole(role, account); _roleMembers[role].add(account); } }
/** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */
NatSpecMultiLine
supportsInterface
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId); }
/** * @dev See {IERC165-supportsInterface}. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 284, 516 ] }
56,215
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
AccessControlEnumerable
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl { using EnumerableSet for EnumerableSet.AddressSet; mapping (bytes32 => EnumerableSet.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view override returns (address) { return _roleMembers[role].at(index); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view override returns (uint256) { return _roleMembers[role].length(); } /** * @dev Overload {grantRole} to track enumerable memberships */ function grantRole(bytes32 role, address account) public virtual override { super.grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {revokeRole} to track enumerable memberships */ function revokeRole(bytes32 role, address account) public virtual override { super.revokeRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {renounceRole} to track enumerable memberships */ function renounceRole(bytes32 role, address account) public virtual override { super.renounceRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {_setupRole} to track enumerable memberships */ function _setupRole(bytes32 role, address account) internal virtual override { super._setupRole(role, account); _roleMembers[role].add(account); } }
/** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */
NatSpecMultiLine
getRoleMember
function getRoleMember(bytes32 role, uint256 index) public view override returns (address) { return _roleMembers[role].at(index); }
/** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 1110, 1260 ] }
56,216
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
AccessControlEnumerable
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl { using EnumerableSet for EnumerableSet.AddressSet; mapping (bytes32 => EnumerableSet.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view override returns (address) { return _roleMembers[role].at(index); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view override returns (uint256) { return _roleMembers[role].length(); } /** * @dev Overload {grantRole} to track enumerable memberships */ function grantRole(bytes32 role, address account) public virtual override { super.grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {revokeRole} to track enumerable memberships */ function revokeRole(bytes32 role, address account) public virtual override { super.revokeRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {renounceRole} to track enumerable memberships */ function renounceRole(bytes32 role, address account) public virtual override { super.renounceRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {_setupRole} to track enumerable memberships */ function _setupRole(bytes32 role, address account) internal virtual override { super._setupRole(role, account); _roleMembers[role].add(account); } }
/** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */
NatSpecMultiLine
getRoleMemberCount
function getRoleMemberCount(bytes32 role) public view override returns (uint256) { return _roleMembers[role].length(); }
/** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 1429, 1568 ] }
56,217
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
AccessControlEnumerable
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl { using EnumerableSet for EnumerableSet.AddressSet; mapping (bytes32 => EnumerableSet.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view override returns (address) { return _roleMembers[role].at(index); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view override returns (uint256) { return _roleMembers[role].length(); } /** * @dev Overload {grantRole} to track enumerable memberships */ function grantRole(bytes32 role, address account) public virtual override { super.grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {revokeRole} to track enumerable memberships */ function revokeRole(bytes32 role, address account) public virtual override { super.revokeRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {renounceRole} to track enumerable memberships */ function renounceRole(bytes32 role, address account) public virtual override { super.renounceRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {_setupRole} to track enumerable memberships */ function _setupRole(bytes32 role, address account) internal virtual override { super._setupRole(role, account); _roleMembers[role].add(account); } }
/** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */
NatSpecMultiLine
grantRole
function grantRole(bytes32 role, address account) public virtual override { super.grantRole(role, account); _roleMembers[role].add(account); }
/** * @dev Overload {grantRole} to track enumerable memberships */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 1655, 1825 ] }
56,218
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
AccessControlEnumerable
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl { using EnumerableSet for EnumerableSet.AddressSet; mapping (bytes32 => EnumerableSet.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view override returns (address) { return _roleMembers[role].at(index); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view override returns (uint256) { return _roleMembers[role].length(); } /** * @dev Overload {grantRole} to track enumerable memberships */ function grantRole(bytes32 role, address account) public virtual override { super.grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {revokeRole} to track enumerable memberships */ function revokeRole(bytes32 role, address account) public virtual override { super.revokeRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {renounceRole} to track enumerable memberships */ function renounceRole(bytes32 role, address account) public virtual override { super.renounceRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {_setupRole} to track enumerable memberships */ function _setupRole(bytes32 role, address account) internal virtual override { super._setupRole(role, account); _roleMembers[role].add(account); } }
/** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */
NatSpecMultiLine
revokeRole
function revokeRole(bytes32 role, address account) public virtual override { super.revokeRole(role, account); _roleMembers[role].remove(account); }
/** * @dev Overload {revokeRole} to track enumerable memberships */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 1913, 2088 ] }
56,219
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
AccessControlEnumerable
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl { using EnumerableSet for EnumerableSet.AddressSet; mapping (bytes32 => EnumerableSet.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view override returns (address) { return _roleMembers[role].at(index); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view override returns (uint256) { return _roleMembers[role].length(); } /** * @dev Overload {grantRole} to track enumerable memberships */ function grantRole(bytes32 role, address account) public virtual override { super.grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {revokeRole} to track enumerable memberships */ function revokeRole(bytes32 role, address account) public virtual override { super.revokeRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {renounceRole} to track enumerable memberships */ function renounceRole(bytes32 role, address account) public virtual override { super.renounceRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {_setupRole} to track enumerable memberships */ function _setupRole(bytes32 role, address account) internal virtual override { super._setupRole(role, account); _roleMembers[role].add(account); } }
/** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */
NatSpecMultiLine
renounceRole
function renounceRole(bytes32 role, address account) public virtual override { super.renounceRole(role, account); _roleMembers[role].remove(account); }
/** * @dev Overload {renounceRole} to track enumerable memberships */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 2178, 2357 ] }
56,220
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
AccessControlEnumerable
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl { using EnumerableSet for EnumerableSet.AddressSet; mapping (bytes32 => EnumerableSet.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view override returns (address) { return _roleMembers[role].at(index); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view override returns (uint256) { return _roleMembers[role].length(); } /** * @dev Overload {grantRole} to track enumerable memberships */ function grantRole(bytes32 role, address account) public virtual override { super.grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {revokeRole} to track enumerable memberships */ function revokeRole(bytes32 role, address account) public virtual override { super.revokeRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {renounceRole} to track enumerable memberships */ function renounceRole(bytes32 role, address account) public virtual override { super.renounceRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {_setupRole} to track enumerable memberships */ function _setupRole(bytes32 role, address account) internal virtual override { super._setupRole(role, account); _roleMembers[role].add(account); } }
/** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */
NatSpecMultiLine
_setupRole
function _setupRole(bytes32 role, address account) internal virtual override { super._setupRole(role, account); _roleMembers[role].add(account); }
/** * @dev Overload {_setupRole} to track enumerable memberships */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 2445, 2619 ] }
56,221
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
ThroneERC20
contract ThroneERC20 is Context, AccessControlEnumerable, ERC20Burnable, ERC20Pausable { bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE"); bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE"); bytes32 public constant DELEGATE_ROLE = keccak256("DELEGATE_ROLE"); /** * @dev Grants `OWNER_ROLE` account that deploys the contract. * Sets up `OWNER_ROLE` as an admin for other roles. * * See {ERC20-constructor}. */ constructor(string memory name, string memory symbol) ERC20(name, symbol) { _setupRole(OWNER_ROLE, _msgSender()); _setupRole(ADMIN_ROLE, _msgSender()); _setupRole(DELEGATE_ROLE, _msgSender()); _setRoleAdmin(OWNER_ROLE, OWNER_ROLE); _setRoleAdmin(ADMIN_ROLE, OWNER_ROLE); _setRoleAdmin(DELEGATE_ROLE, ADMIN_ROLE); } /** * @dev Creates `amount` new tokens for `to`. * * See {ERC20-_mint}. * * Requirements: * * - the caller must have the `DELEGATE_ROLE`. */ function mint(address to, uint256 amount) external virtual { require(hasRole(DELEGATE_ROLE, _msgSender()), "ThroneERC20: must have delegate role to mint"); _mint(to, amount); } /** * @dev Pauses all token transfers. * * See {ERC20Pausable} and {Pausable-_pause}. * * Requirements: * * - the caller must have the `ADMIN_ROLE`. */ function pause() external virtual { require(hasRole(ADMIN_ROLE, _msgSender()), "ThroneERC20: must have admin role to pause"); _pause(); } /** * @dev Unpauses all token transfers. * * See {ERC20Pausable} and {Pausable-_unpause}. * * Requirements: * * - the caller must have the `ADMIN_ROLE`. */ function unpause() external virtual { require(hasRole(ADMIN_ROLE, _msgSender()), "ThroneERC20: must have admin role to unpause"); _unpause(); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20, ERC20Pausable) { super._beforeTokenTransfer(from, to, amount); } /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public override { require(hasRole(OWNER_ROLE, _msgSender()), "ThroneERC20: must have owner role to unpause"); super.burn(amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public override { require(hasRole(OWNER_ROLE, _msgSender()), "ThroneERC20: must have owner role to unpause"); super.burnFrom(account, amount); } }
mint
function mint(address to, uint256 amount) external virtual { require(hasRole(DELEGATE_ROLE, _msgSender()), "ThroneERC20: must have delegate role to mint"); _mint(to, amount); }
/** * @dev Creates `amount` new tokens for `to`. * * See {ERC20-_mint}. * * Requirements: * * - the caller must have the `DELEGATE_ROLE`. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 1061, 1265 ] }
56,222
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
ThroneERC20
contract ThroneERC20 is Context, AccessControlEnumerable, ERC20Burnable, ERC20Pausable { bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE"); bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE"); bytes32 public constant DELEGATE_ROLE = keccak256("DELEGATE_ROLE"); /** * @dev Grants `OWNER_ROLE` account that deploys the contract. * Sets up `OWNER_ROLE` as an admin for other roles. * * See {ERC20-constructor}. */ constructor(string memory name, string memory symbol) ERC20(name, symbol) { _setupRole(OWNER_ROLE, _msgSender()); _setupRole(ADMIN_ROLE, _msgSender()); _setupRole(DELEGATE_ROLE, _msgSender()); _setRoleAdmin(OWNER_ROLE, OWNER_ROLE); _setRoleAdmin(ADMIN_ROLE, OWNER_ROLE); _setRoleAdmin(DELEGATE_ROLE, ADMIN_ROLE); } /** * @dev Creates `amount` new tokens for `to`. * * See {ERC20-_mint}. * * Requirements: * * - the caller must have the `DELEGATE_ROLE`. */ function mint(address to, uint256 amount) external virtual { require(hasRole(DELEGATE_ROLE, _msgSender()), "ThroneERC20: must have delegate role to mint"); _mint(to, amount); } /** * @dev Pauses all token transfers. * * See {ERC20Pausable} and {Pausable-_pause}. * * Requirements: * * - the caller must have the `ADMIN_ROLE`. */ function pause() external virtual { require(hasRole(ADMIN_ROLE, _msgSender()), "ThroneERC20: must have admin role to pause"); _pause(); } /** * @dev Unpauses all token transfers. * * See {ERC20Pausable} and {Pausable-_unpause}. * * Requirements: * * - the caller must have the `ADMIN_ROLE`. */ function unpause() external virtual { require(hasRole(ADMIN_ROLE, _msgSender()), "ThroneERC20: must have admin role to unpause"); _unpause(); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20, ERC20Pausable) { super._beforeTokenTransfer(from, to, amount); } /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public override { require(hasRole(OWNER_ROLE, _msgSender()), "ThroneERC20: must have owner role to unpause"); super.burn(amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public override { require(hasRole(OWNER_ROLE, _msgSender()), "ThroneERC20: must have owner role to unpause"); super.burnFrom(account, amount); } }
pause
function pause() external virtual { require(hasRole(ADMIN_ROLE, _msgSender()), "ThroneERC20: must have admin role to pause"); _pause(); }
/** * @dev Pauses all token transfers. * * See {ERC20Pausable} and {Pausable-_pause}. * * Requirements: * * - the caller must have the `ADMIN_ROLE`. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 1473, 1638 ] }
56,223
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
ThroneERC20
contract ThroneERC20 is Context, AccessControlEnumerable, ERC20Burnable, ERC20Pausable { bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE"); bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE"); bytes32 public constant DELEGATE_ROLE = keccak256("DELEGATE_ROLE"); /** * @dev Grants `OWNER_ROLE` account that deploys the contract. * Sets up `OWNER_ROLE` as an admin for other roles. * * See {ERC20-constructor}. */ constructor(string memory name, string memory symbol) ERC20(name, symbol) { _setupRole(OWNER_ROLE, _msgSender()); _setupRole(ADMIN_ROLE, _msgSender()); _setupRole(DELEGATE_ROLE, _msgSender()); _setRoleAdmin(OWNER_ROLE, OWNER_ROLE); _setRoleAdmin(ADMIN_ROLE, OWNER_ROLE); _setRoleAdmin(DELEGATE_ROLE, ADMIN_ROLE); } /** * @dev Creates `amount` new tokens for `to`. * * See {ERC20-_mint}. * * Requirements: * * - the caller must have the `DELEGATE_ROLE`. */ function mint(address to, uint256 amount) external virtual { require(hasRole(DELEGATE_ROLE, _msgSender()), "ThroneERC20: must have delegate role to mint"); _mint(to, amount); } /** * @dev Pauses all token transfers. * * See {ERC20Pausable} and {Pausable-_pause}. * * Requirements: * * - the caller must have the `ADMIN_ROLE`. */ function pause() external virtual { require(hasRole(ADMIN_ROLE, _msgSender()), "ThroneERC20: must have admin role to pause"); _pause(); } /** * @dev Unpauses all token transfers. * * See {ERC20Pausable} and {Pausable-_unpause}. * * Requirements: * * - the caller must have the `ADMIN_ROLE`. */ function unpause() external virtual { require(hasRole(ADMIN_ROLE, _msgSender()), "ThroneERC20: must have admin role to unpause"); _unpause(); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20, ERC20Pausable) { super._beforeTokenTransfer(from, to, amount); } /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public override { require(hasRole(OWNER_ROLE, _msgSender()), "ThroneERC20: must have owner role to unpause"); super.burn(amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public override { require(hasRole(OWNER_ROLE, _msgSender()), "ThroneERC20: must have owner role to unpause"); super.burnFrom(account, amount); } }
unpause
function unpause() external virtual { require(hasRole(ADMIN_ROLE, _msgSender()), "ThroneERC20: must have admin role to unpause"); _unpause(); }
/** * @dev Unpauses all token transfers. * * See {ERC20Pausable} and {Pausable-_unpause}. * * Requirements: * * - the caller must have the `ADMIN_ROLE`. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 1850, 2021 ] }
56,224
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
ThroneERC20
contract ThroneERC20 is Context, AccessControlEnumerable, ERC20Burnable, ERC20Pausable { bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE"); bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE"); bytes32 public constant DELEGATE_ROLE = keccak256("DELEGATE_ROLE"); /** * @dev Grants `OWNER_ROLE` account that deploys the contract. * Sets up `OWNER_ROLE` as an admin for other roles. * * See {ERC20-constructor}. */ constructor(string memory name, string memory symbol) ERC20(name, symbol) { _setupRole(OWNER_ROLE, _msgSender()); _setupRole(ADMIN_ROLE, _msgSender()); _setupRole(DELEGATE_ROLE, _msgSender()); _setRoleAdmin(OWNER_ROLE, OWNER_ROLE); _setRoleAdmin(ADMIN_ROLE, OWNER_ROLE); _setRoleAdmin(DELEGATE_ROLE, ADMIN_ROLE); } /** * @dev Creates `amount` new tokens for `to`. * * See {ERC20-_mint}. * * Requirements: * * - the caller must have the `DELEGATE_ROLE`. */ function mint(address to, uint256 amount) external virtual { require(hasRole(DELEGATE_ROLE, _msgSender()), "ThroneERC20: must have delegate role to mint"); _mint(to, amount); } /** * @dev Pauses all token transfers. * * See {ERC20Pausable} and {Pausable-_pause}. * * Requirements: * * - the caller must have the `ADMIN_ROLE`. */ function pause() external virtual { require(hasRole(ADMIN_ROLE, _msgSender()), "ThroneERC20: must have admin role to pause"); _pause(); } /** * @dev Unpauses all token transfers. * * See {ERC20Pausable} and {Pausable-_unpause}. * * Requirements: * * - the caller must have the `ADMIN_ROLE`. */ function unpause() external virtual { require(hasRole(ADMIN_ROLE, _msgSender()), "ThroneERC20: must have admin role to unpause"); _unpause(); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20, ERC20Pausable) { super._beforeTokenTransfer(from, to, amount); } /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public override { require(hasRole(OWNER_ROLE, _msgSender()), "ThroneERC20: must have owner role to unpause"); super.burn(amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public override { require(hasRole(OWNER_ROLE, _msgSender()), "ThroneERC20: must have owner role to unpause"); super.burnFrom(account, amount); } }
burn
function burn(uint256 amount) public override { require(hasRole(OWNER_ROLE, _msgSender()), "ThroneERC20: must have owner role to unpause"); super.burn(amount); }
/** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 2323, 2512 ] }
56,225
ThroneERC20
ThroneERC20.sol
0x2e95cea14dd384429eb3c4331b776c4cfbb6fcd9
Solidity
ThroneERC20
contract ThroneERC20 is Context, AccessControlEnumerable, ERC20Burnable, ERC20Pausable { bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE"); bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE"); bytes32 public constant DELEGATE_ROLE = keccak256("DELEGATE_ROLE"); /** * @dev Grants `OWNER_ROLE` account that deploys the contract. * Sets up `OWNER_ROLE` as an admin for other roles. * * See {ERC20-constructor}. */ constructor(string memory name, string memory symbol) ERC20(name, symbol) { _setupRole(OWNER_ROLE, _msgSender()); _setupRole(ADMIN_ROLE, _msgSender()); _setupRole(DELEGATE_ROLE, _msgSender()); _setRoleAdmin(OWNER_ROLE, OWNER_ROLE); _setRoleAdmin(ADMIN_ROLE, OWNER_ROLE); _setRoleAdmin(DELEGATE_ROLE, ADMIN_ROLE); } /** * @dev Creates `amount` new tokens for `to`. * * See {ERC20-_mint}. * * Requirements: * * - the caller must have the `DELEGATE_ROLE`. */ function mint(address to, uint256 amount) external virtual { require(hasRole(DELEGATE_ROLE, _msgSender()), "ThroneERC20: must have delegate role to mint"); _mint(to, amount); } /** * @dev Pauses all token transfers. * * See {ERC20Pausable} and {Pausable-_pause}. * * Requirements: * * - the caller must have the `ADMIN_ROLE`. */ function pause() external virtual { require(hasRole(ADMIN_ROLE, _msgSender()), "ThroneERC20: must have admin role to pause"); _pause(); } /** * @dev Unpauses all token transfers. * * See {ERC20Pausable} and {Pausable-_unpause}. * * Requirements: * * - the caller must have the `ADMIN_ROLE`. */ function unpause() external virtual { require(hasRole(ADMIN_ROLE, _msgSender()), "ThroneERC20: must have admin role to unpause"); _unpause(); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20, ERC20Pausable) { super._beforeTokenTransfer(from, to, amount); } /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public override { require(hasRole(OWNER_ROLE, _msgSender()), "ThroneERC20: must have owner role to unpause"); super.burn(amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public override { require(hasRole(OWNER_ROLE, _msgSender()), "ThroneERC20: must have owner role to unpause"); super.burnFrom(account, amount); } }
burnFrom
function burnFrom(address account, uint256 amount) public override { require(hasRole(OWNER_ROLE, _msgSender()), "ThroneERC20: must have owner role to unpause"); super.burnFrom(account, amount); }
/** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://b57468dd69bef025aa37774f30167907745b8d7d825492841bbe8f363cab7160
{ "func_code_index": [ 2826, 3049 ] }
56,226
enltetoken
enltetoken.sol
0x031ac79c8e01adbd6f305578107e5424f10dfbef
Solidity
enltetoken
contract enltetoken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "ENLTE"; name = "ENLTE"; decimals = 8; _totalSupply = 1000000000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
totalSupply
function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; }
// ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://911335bf0d9378167c76e71057d638c7817c3dc87432f96ddfc688989b7d3f0b
{ "func_code_index": [ 907, 1028 ] }
56,227
enltetoken
enltetoken.sol
0x031ac79c8e01adbd6f305578107e5424f10dfbef
Solidity
enltetoken
contract enltetoken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "ENLTE"; name = "ENLTE"; decimals = 8; _totalSupply = 1000000000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
balanceOf
function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; }
// ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://911335bf0d9378167c76e71057d638c7817c3dc87432f96ddfc688989b7d3f0b
{ "func_code_index": [ 1248, 1377 ] }
56,228
enltetoken
enltetoken.sol
0x031ac79c8e01adbd6f305578107e5424f10dfbef
Solidity
enltetoken
contract enltetoken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "ENLTE"; name = "ENLTE"; decimals = 8; _totalSupply = 1000000000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
transfer
function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; }
// ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://911335bf0d9378167c76e71057d638c7817c3dc87432f96ddfc688989b7d3f0b
{ "func_code_index": [ 1721, 2003 ] }
56,229
enltetoken
enltetoken.sol
0x031ac79c8e01adbd6f305578107e5424f10dfbef
Solidity
enltetoken
contract enltetoken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "ENLTE"; name = "ENLTE"; decimals = 8; _totalSupply = 1000000000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
approve
function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; }
// ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://911335bf0d9378167c76e71057d638c7817c3dc87432f96ddfc688989b7d3f0b
{ "func_code_index": [ 2511, 2724 ] }
56,230
enltetoken
enltetoken.sol
0x031ac79c8e01adbd6f305578107e5424f10dfbef
Solidity
enltetoken
contract enltetoken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "ENLTE"; name = "ENLTE"; decimals = 8; _totalSupply = 1000000000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
transferFrom
function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; }
// ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://911335bf0d9378167c76e71057d638c7817c3dc87432f96ddfc688989b7d3f0b
{ "func_code_index": [ 3255, 3618 ] }
56,231
enltetoken
enltetoken.sol
0x031ac79c8e01adbd6f305578107e5424f10dfbef
Solidity
enltetoken
contract enltetoken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "ENLTE"; name = "ENLTE"; decimals = 8; _totalSupply = 1000000000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
allowance
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; }
// ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://911335bf0d9378167c76e71057d638c7817c3dc87432f96ddfc688989b7d3f0b
{ "func_code_index": [ 3901, 4057 ] }
56,232
enltetoken
enltetoken.sol
0x031ac79c8e01adbd6f305578107e5424f10dfbef
Solidity
enltetoken
contract enltetoken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "ENLTE"; name = "ENLTE"; decimals = 8; _totalSupply = 1000000000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
approveAndCall
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; }
// ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://911335bf0d9378167c76e71057d638c7817c3dc87432f96ddfc688989b7d3f0b
{ "func_code_index": [ 4412, 4734 ] }
56,233
enltetoken
enltetoken.sol
0x031ac79c8e01adbd6f305578107e5424f10dfbef
Solidity
enltetoken
contract enltetoken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "ENLTE"; name = "ENLTE"; decimals = 8; _totalSupply = 1000000000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
function () public payable { revert(); }
// ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://911335bf0d9378167c76e71057d638c7817c3dc87432f96ddfc688989b7d3f0b
{ "func_code_index": [ 4926, 4985 ] }
56,234
enltetoken
enltetoken.sol
0x031ac79c8e01adbd6f305578107e5424f10dfbef
Solidity
enltetoken
contract enltetoken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "ENLTE"; name = "ENLTE"; decimals = 8; _totalSupply = 1000000000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
transferAnyERC20Token
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); }
// ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://911335bf0d9378167c76e71057d638c7817c3dc87432f96ddfc688989b7d3f0b
{ "func_code_index": [ 5218, 5407 ] }
56,235
seveninch
seveninch.sol
0x09a95a502a5f380eda8b7f1e8c3ff2ead41afc7e
Solidity
seveninch
contract seveninch is ERC20Detailed { using SafeMath for uint256; ERC20Detailed internal WETH = ERC20Detailed(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); IUniswapV2Factory public uniswapFactory = IUniswapV2Factory(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f); mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; string constant tokenName = "7inch"; string constant tokenSymbol = "7inch"; uint8 constant tokenDecimals = 18; uint256 constant easyDecimals = 1000000000000000000; // yes you can use an exponent instead if you want uint256 _totalSupply = 7000 * easyDecimals; //% uint256 public burnPercentage = 700; //any tokens sent here ? IERC20 currentToken ; address payable public _owner; address public _pairAddress; //modifiers modifier onlyOwner() { require(msg.sender == _owner); _; } constructor() public payable ERC20Detailed(tokenName, tokenSymbol, tokenDecimals) { _owner = msg.sender; //temporarily until the proper pair address is set. To prevent errors if transfer occurs prior to setting pair address. _pairAddress = msg.sender; require(_totalSupply != 0); //create initialSupply _balances[_owner] = _balances[_owner].add(_totalSupply); emit Transfer(address(0), _owner, _totalSupply); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } function transfer(address to, uint256 value) public returns (bool) { _executeTransfer(msg.sender, to, value); return true; } function multiTransfer(address[] memory receivers, uint256[] memory values) public { require(receivers.length == values.length); for(uint256 i = 0; i < receivers.length; i++) _executeTransfer(msg.sender, receivers[i], values[i]); } function transferFrom(address from, address to, uint256 value) public returns (bool) { require(value <= _allowed[from][msg.sender]); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _executeTransfer(from, to, value); return true; } uint256 public basePercentage = burnPercentage; function findPercentage(uint256 amount) public view returns (uint256) { uint256 percent = amount.mul(basePercentage).div(10000); return percent; } //turns burn on/off called by owner only function burnOnOff() external onlyOwner { if(basePercentage == 0) basePercentage = burnPercentage; else basePercentage = 0; } //burn function burn(uint256 amount) external { _burn(msg.sender, amount); } function _burn(address account, uint256 amount) internal { require(amount != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } //no zeros for decimals necessary function multiTransferEqualAmount(address[] memory receivers, uint256 amount) public { uint256 amountWithDecimals = amount * 10**uint256(tokenDecimals); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amountWithDecimals); } } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } //_pairAddress function setPairAddress() external onlyOwner { _pairAddress = uniswapFactory.getPair(address(WETH), address(this)); } //take back unclaimed tokens function withdrawUnclaimedTokens(address contractUnclaimed) external onlyOwner { currentToken = IERC20(contractUnclaimed); uint256 amount = currentToken.balanceOf(address(this)); currentToken.transfer(_owner, amount); } // transfer function _executeTransfer(address _from, address _to, uint256 _value) private { if (_to == address(0)) revert(); // Prevent transfer to 0x0 address. Use burn() instead if (_value <= 0) revert(); if (_balances[_from] < _value) revert(); // Check if the sender has enough if (_balances[_to] + _value < _balances[_to]) revert(); // Check for overflows //burn if selling only. do not burn if owner adds/removes Liquidity if(_to != _pairAddress || _from == _owner || _to == _owner) { _balances[_from] = SafeMath.sub(_balances[_from], _value); // Subtract from the sender _balances[_to] = SafeMath.add(_balances[_to], _value); // Add the same to the recipient emit Transfer(_from, _to, _value); // Notify anyone listening that this transfer took place }//if else //selling { //limit on sell //if(_value > 25 * easyDecimals) revert("25 token sell limit exceeded"); //sell limit uint256 tokensToBurn = findPercentage(_value); uint256 tokensToTransfer = _value.sub(tokensToBurn); _balances[_from] = SafeMath.sub(_balances[_from], tokensToTransfer); // Subtract from the sender _balances[_to] = _balances[_to].add(tokensToTransfer); emit Transfer(_from, _to, tokensToTransfer); // Notify anyone listening that this transfer took place //anything to burn? burn it if(tokensToBurn > 0) _burn(_from, tokensToBurn); }//else }//_executeTransfer }
burnOnOff
function burnOnOff() external onlyOwner { if(basePercentage == 0) basePercentage = burnPercentage; else basePercentage = 0;
//turns burn on/off called by owner only
LineComment
v0.5.17+commit.d19bba13
None
bzzr://f3b0126a79350b98825ba420c96b2577712250236eb83c0ea1425e8b2bf9c7ad
{ "func_code_index": [ 2834, 3003 ] }
56,236
seveninch
seveninch.sol
0x09a95a502a5f380eda8b7f1e8c3ff2ead41afc7e
Solidity
seveninch
contract seveninch is ERC20Detailed { using SafeMath for uint256; ERC20Detailed internal WETH = ERC20Detailed(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); IUniswapV2Factory public uniswapFactory = IUniswapV2Factory(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f); mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; string constant tokenName = "7inch"; string constant tokenSymbol = "7inch"; uint8 constant tokenDecimals = 18; uint256 constant easyDecimals = 1000000000000000000; // yes you can use an exponent instead if you want uint256 _totalSupply = 7000 * easyDecimals; //% uint256 public burnPercentage = 700; //any tokens sent here ? IERC20 currentToken ; address payable public _owner; address public _pairAddress; //modifiers modifier onlyOwner() { require(msg.sender == _owner); _; } constructor() public payable ERC20Detailed(tokenName, tokenSymbol, tokenDecimals) { _owner = msg.sender; //temporarily until the proper pair address is set. To prevent errors if transfer occurs prior to setting pair address. _pairAddress = msg.sender; require(_totalSupply != 0); //create initialSupply _balances[_owner] = _balances[_owner].add(_totalSupply); emit Transfer(address(0), _owner, _totalSupply); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } function transfer(address to, uint256 value) public returns (bool) { _executeTransfer(msg.sender, to, value); return true; } function multiTransfer(address[] memory receivers, uint256[] memory values) public { require(receivers.length == values.length); for(uint256 i = 0; i < receivers.length; i++) _executeTransfer(msg.sender, receivers[i], values[i]); } function transferFrom(address from, address to, uint256 value) public returns (bool) { require(value <= _allowed[from][msg.sender]); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _executeTransfer(from, to, value); return true; } uint256 public basePercentage = burnPercentage; function findPercentage(uint256 amount) public view returns (uint256) { uint256 percent = amount.mul(basePercentage).div(10000); return percent; } //turns burn on/off called by owner only function burnOnOff() external onlyOwner { if(basePercentage == 0) basePercentage = burnPercentage; else basePercentage = 0; } //burn function burn(uint256 amount) external { _burn(msg.sender, amount); } function _burn(address account, uint256 amount) internal { require(amount != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } //no zeros for decimals necessary function multiTransferEqualAmount(address[] memory receivers, uint256 amount) public { uint256 amountWithDecimals = amount * 10**uint256(tokenDecimals); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amountWithDecimals); } } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } //_pairAddress function setPairAddress() external onlyOwner { _pairAddress = uniswapFactory.getPair(address(WETH), address(this)); } //take back unclaimed tokens function withdrawUnclaimedTokens(address contractUnclaimed) external onlyOwner { currentToken = IERC20(contractUnclaimed); uint256 amount = currentToken.balanceOf(address(this)); currentToken.transfer(_owner, amount); } // transfer function _executeTransfer(address _from, address _to, uint256 _value) private { if (_to == address(0)) revert(); // Prevent transfer to 0x0 address. Use burn() instead if (_value <= 0) revert(); if (_balances[_from] < _value) revert(); // Check if the sender has enough if (_balances[_to] + _value < _balances[_to]) revert(); // Check for overflows //burn if selling only. do not burn if owner adds/removes Liquidity if(_to != _pairAddress || _from == _owner || _to == _owner) { _balances[_from] = SafeMath.sub(_balances[_from], _value); // Subtract from the sender _balances[_to] = SafeMath.add(_balances[_to], _value); // Add the same to the recipient emit Transfer(_from, _to, _value); // Notify anyone listening that this transfer took place }//if else //selling { //limit on sell //if(_value > 25 * easyDecimals) revert("25 token sell limit exceeded"); //sell limit uint256 tokensToBurn = findPercentage(_value); uint256 tokensToTransfer = _value.sub(tokensToBurn); _balances[_from] = SafeMath.sub(_balances[_from], tokensToTransfer); // Subtract from the sender _balances[_to] = _balances[_to].add(tokensToTransfer); emit Transfer(_from, _to, tokensToTransfer); // Notify anyone listening that this transfer took place //anything to burn? burn it if(tokensToBurn > 0) _burn(_from, tokensToBurn); }//else }//_executeTransfer }
burn
function burn(uint256 amount) external { _burn(msg.sender, amount); }
//burn
LineComment
v0.5.17+commit.d19bba13
None
bzzr://f3b0126a79350b98825ba420c96b2577712250236eb83c0ea1425e8b2bf9c7ad
{ "func_code_index": [ 3024, 3124 ] }
56,237
seveninch
seveninch.sol
0x09a95a502a5f380eda8b7f1e8c3ff2ead41afc7e
Solidity
seveninch
contract seveninch is ERC20Detailed { using SafeMath for uint256; ERC20Detailed internal WETH = ERC20Detailed(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); IUniswapV2Factory public uniswapFactory = IUniswapV2Factory(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f); mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; string constant tokenName = "7inch"; string constant tokenSymbol = "7inch"; uint8 constant tokenDecimals = 18; uint256 constant easyDecimals = 1000000000000000000; // yes you can use an exponent instead if you want uint256 _totalSupply = 7000 * easyDecimals; //% uint256 public burnPercentage = 700; //any tokens sent here ? IERC20 currentToken ; address payable public _owner; address public _pairAddress; //modifiers modifier onlyOwner() { require(msg.sender == _owner); _; } constructor() public payable ERC20Detailed(tokenName, tokenSymbol, tokenDecimals) { _owner = msg.sender; //temporarily until the proper pair address is set. To prevent errors if transfer occurs prior to setting pair address. _pairAddress = msg.sender; require(_totalSupply != 0); //create initialSupply _balances[_owner] = _balances[_owner].add(_totalSupply); emit Transfer(address(0), _owner, _totalSupply); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } function transfer(address to, uint256 value) public returns (bool) { _executeTransfer(msg.sender, to, value); return true; } function multiTransfer(address[] memory receivers, uint256[] memory values) public { require(receivers.length == values.length); for(uint256 i = 0; i < receivers.length; i++) _executeTransfer(msg.sender, receivers[i], values[i]); } function transferFrom(address from, address to, uint256 value) public returns (bool) { require(value <= _allowed[from][msg.sender]); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _executeTransfer(from, to, value); return true; } uint256 public basePercentage = burnPercentage; function findPercentage(uint256 amount) public view returns (uint256) { uint256 percent = amount.mul(basePercentage).div(10000); return percent; } //turns burn on/off called by owner only function burnOnOff() external onlyOwner { if(basePercentage == 0) basePercentage = burnPercentage; else basePercentage = 0; } //burn function burn(uint256 amount) external { _burn(msg.sender, amount); } function _burn(address account, uint256 amount) internal { require(amount != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } //no zeros for decimals necessary function multiTransferEqualAmount(address[] memory receivers, uint256 amount) public { uint256 amountWithDecimals = amount * 10**uint256(tokenDecimals); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amountWithDecimals); } } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } //_pairAddress function setPairAddress() external onlyOwner { _pairAddress = uniswapFactory.getPair(address(WETH), address(this)); } //take back unclaimed tokens function withdrawUnclaimedTokens(address contractUnclaimed) external onlyOwner { currentToken = IERC20(contractUnclaimed); uint256 amount = currentToken.balanceOf(address(this)); currentToken.transfer(_owner, amount); } // transfer function _executeTransfer(address _from, address _to, uint256 _value) private { if (_to == address(0)) revert(); // Prevent transfer to 0x0 address. Use burn() instead if (_value <= 0) revert(); if (_balances[_from] < _value) revert(); // Check if the sender has enough if (_balances[_to] + _value < _balances[_to]) revert(); // Check for overflows //burn if selling only. do not burn if owner adds/removes Liquidity if(_to != _pairAddress || _from == _owner || _to == _owner) { _balances[_from] = SafeMath.sub(_balances[_from], _value); // Subtract from the sender _balances[_to] = SafeMath.add(_balances[_to], _value); // Add the same to the recipient emit Transfer(_from, _to, _value); // Notify anyone listening that this transfer took place }//if else //selling { //limit on sell //if(_value > 25 * easyDecimals) revert("25 token sell limit exceeded"); //sell limit uint256 tokensToBurn = findPercentage(_value); uint256 tokensToTransfer = _value.sub(tokensToBurn); _balances[_from] = SafeMath.sub(_balances[_from], tokensToTransfer); // Subtract from the sender _balances[_to] = _balances[_to].add(tokensToTransfer); emit Transfer(_from, _to, tokensToTransfer); // Notify anyone listening that this transfer took place //anything to burn? burn it if(tokensToBurn > 0) _burn(_from, tokensToBurn); }//else }//_executeTransfer }
multiTransferEqualAmount
function multiTransferEqualAmount(address[] memory receivers, uint256 amount) public { uint256 amountWithDecimals = amount * 10**uint256(tokenDecimals); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amountWithDecimals); } }
//no zeros for decimals necessary
LineComment
v0.5.17+commit.d19bba13
None
bzzr://f3b0126a79350b98825ba420c96b2577712250236eb83c0ea1425e8b2bf9c7ad
{ "func_code_index": [ 3548, 3827 ] }
56,238
seveninch
seveninch.sol
0x09a95a502a5f380eda8b7f1e8c3ff2ead41afc7e
Solidity
seveninch
contract seveninch is ERC20Detailed { using SafeMath for uint256; ERC20Detailed internal WETH = ERC20Detailed(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); IUniswapV2Factory public uniswapFactory = IUniswapV2Factory(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f); mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; string constant tokenName = "7inch"; string constant tokenSymbol = "7inch"; uint8 constant tokenDecimals = 18; uint256 constant easyDecimals = 1000000000000000000; // yes you can use an exponent instead if you want uint256 _totalSupply = 7000 * easyDecimals; //% uint256 public burnPercentage = 700; //any tokens sent here ? IERC20 currentToken ; address payable public _owner; address public _pairAddress; //modifiers modifier onlyOwner() { require(msg.sender == _owner); _; } constructor() public payable ERC20Detailed(tokenName, tokenSymbol, tokenDecimals) { _owner = msg.sender; //temporarily until the proper pair address is set. To prevent errors if transfer occurs prior to setting pair address. _pairAddress = msg.sender; require(_totalSupply != 0); //create initialSupply _balances[_owner] = _balances[_owner].add(_totalSupply); emit Transfer(address(0), _owner, _totalSupply); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } function transfer(address to, uint256 value) public returns (bool) { _executeTransfer(msg.sender, to, value); return true; } function multiTransfer(address[] memory receivers, uint256[] memory values) public { require(receivers.length == values.length); for(uint256 i = 0; i < receivers.length; i++) _executeTransfer(msg.sender, receivers[i], values[i]); } function transferFrom(address from, address to, uint256 value) public returns (bool) { require(value <= _allowed[from][msg.sender]); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _executeTransfer(from, to, value); return true; } uint256 public basePercentage = burnPercentage; function findPercentage(uint256 amount) public view returns (uint256) { uint256 percent = amount.mul(basePercentage).div(10000); return percent; } //turns burn on/off called by owner only function burnOnOff() external onlyOwner { if(basePercentage == 0) basePercentage = burnPercentage; else basePercentage = 0; } //burn function burn(uint256 amount) external { _burn(msg.sender, amount); } function _burn(address account, uint256 amount) internal { require(amount != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } //no zeros for decimals necessary function multiTransferEqualAmount(address[] memory receivers, uint256 amount) public { uint256 amountWithDecimals = amount * 10**uint256(tokenDecimals); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amountWithDecimals); } } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } //_pairAddress function setPairAddress() external onlyOwner { _pairAddress = uniswapFactory.getPair(address(WETH), address(this)); } //take back unclaimed tokens function withdrawUnclaimedTokens(address contractUnclaimed) external onlyOwner { currentToken = IERC20(contractUnclaimed); uint256 amount = currentToken.balanceOf(address(this)); currentToken.transfer(_owner, amount); } // transfer function _executeTransfer(address _from, address _to, uint256 _value) private { if (_to == address(0)) revert(); // Prevent transfer to 0x0 address. Use burn() instead if (_value <= 0) revert(); if (_balances[_from] < _value) revert(); // Check if the sender has enough if (_balances[_to] + _value < _balances[_to]) revert(); // Check for overflows //burn if selling only. do not burn if owner adds/removes Liquidity if(_to != _pairAddress || _from == _owner || _to == _owner) { _balances[_from] = SafeMath.sub(_balances[_from], _value); // Subtract from the sender _balances[_to] = SafeMath.add(_balances[_to], _value); // Add the same to the recipient emit Transfer(_from, _to, _value); // Notify anyone listening that this transfer took place }//if else //selling { //limit on sell //if(_value > 25 * easyDecimals) revert("25 token sell limit exceeded"); //sell limit uint256 tokensToBurn = findPercentage(_value); uint256 tokensToTransfer = _value.sub(tokensToBurn); _balances[_from] = SafeMath.sub(_balances[_from], tokensToTransfer); // Subtract from the sender _balances[_to] = _balances[_to].add(tokensToTransfer); emit Transfer(_from, _to, tokensToTransfer); // Notify anyone listening that this transfer took place //anything to burn? burn it if(tokensToBurn > 0) _burn(_from, tokensToBurn); }//else }//_executeTransfer }
setPairAddress
function setPairAddress() external onlyOwner { _pairAddress = uniswapFactory.getPair(address(WETH), address(this)); }
//_pairAddress
LineComment
v0.5.17+commit.d19bba13
None
bzzr://f3b0126a79350b98825ba420c96b2577712250236eb83c0ea1425e8b2bf9c7ad
{ "func_code_index": [ 4750, 4892 ] }
56,239
seveninch
seveninch.sol
0x09a95a502a5f380eda8b7f1e8c3ff2ead41afc7e
Solidity
seveninch
contract seveninch is ERC20Detailed { using SafeMath for uint256; ERC20Detailed internal WETH = ERC20Detailed(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); IUniswapV2Factory public uniswapFactory = IUniswapV2Factory(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f); mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; string constant tokenName = "7inch"; string constant tokenSymbol = "7inch"; uint8 constant tokenDecimals = 18; uint256 constant easyDecimals = 1000000000000000000; // yes you can use an exponent instead if you want uint256 _totalSupply = 7000 * easyDecimals; //% uint256 public burnPercentage = 700; //any tokens sent here ? IERC20 currentToken ; address payable public _owner; address public _pairAddress; //modifiers modifier onlyOwner() { require(msg.sender == _owner); _; } constructor() public payable ERC20Detailed(tokenName, tokenSymbol, tokenDecimals) { _owner = msg.sender; //temporarily until the proper pair address is set. To prevent errors if transfer occurs prior to setting pair address. _pairAddress = msg.sender; require(_totalSupply != 0); //create initialSupply _balances[_owner] = _balances[_owner].add(_totalSupply); emit Transfer(address(0), _owner, _totalSupply); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } function transfer(address to, uint256 value) public returns (bool) { _executeTransfer(msg.sender, to, value); return true; } function multiTransfer(address[] memory receivers, uint256[] memory values) public { require(receivers.length == values.length); for(uint256 i = 0; i < receivers.length; i++) _executeTransfer(msg.sender, receivers[i], values[i]); } function transferFrom(address from, address to, uint256 value) public returns (bool) { require(value <= _allowed[from][msg.sender]); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _executeTransfer(from, to, value); return true; } uint256 public basePercentage = burnPercentage; function findPercentage(uint256 amount) public view returns (uint256) { uint256 percent = amount.mul(basePercentage).div(10000); return percent; } //turns burn on/off called by owner only function burnOnOff() external onlyOwner { if(basePercentage == 0) basePercentage = burnPercentage; else basePercentage = 0; } //burn function burn(uint256 amount) external { _burn(msg.sender, amount); } function _burn(address account, uint256 amount) internal { require(amount != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } //no zeros for decimals necessary function multiTransferEqualAmount(address[] memory receivers, uint256 amount) public { uint256 amountWithDecimals = amount * 10**uint256(tokenDecimals); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amountWithDecimals); } } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } //_pairAddress function setPairAddress() external onlyOwner { _pairAddress = uniswapFactory.getPair(address(WETH), address(this)); } //take back unclaimed tokens function withdrawUnclaimedTokens(address contractUnclaimed) external onlyOwner { currentToken = IERC20(contractUnclaimed); uint256 amount = currentToken.balanceOf(address(this)); currentToken.transfer(_owner, amount); } // transfer function _executeTransfer(address _from, address _to, uint256 _value) private { if (_to == address(0)) revert(); // Prevent transfer to 0x0 address. Use burn() instead if (_value <= 0) revert(); if (_balances[_from] < _value) revert(); // Check if the sender has enough if (_balances[_to] + _value < _balances[_to]) revert(); // Check for overflows //burn if selling only. do not burn if owner adds/removes Liquidity if(_to != _pairAddress || _from == _owner || _to == _owner) { _balances[_from] = SafeMath.sub(_balances[_from], _value); // Subtract from the sender _balances[_to] = SafeMath.add(_balances[_to], _value); // Add the same to the recipient emit Transfer(_from, _to, _value); // Notify anyone listening that this transfer took place }//if else //selling { //limit on sell //if(_value > 25 * easyDecimals) revert("25 token sell limit exceeded"); //sell limit uint256 tokensToBurn = findPercentage(_value); uint256 tokensToTransfer = _value.sub(tokensToBurn); _balances[_from] = SafeMath.sub(_balances[_from], tokensToTransfer); // Subtract from the sender _balances[_to] = _balances[_to].add(tokensToTransfer); emit Transfer(_from, _to, tokensToTransfer); // Notify anyone listening that this transfer took place //anything to burn? burn it if(tokensToBurn > 0) _burn(_from, tokensToBurn); }//else }//_executeTransfer }
withdrawUnclaimedTokens
function withdrawUnclaimedTokens(address contractUnclaimed) external onlyOwner { currentToken = IERC20(contractUnclaimed); uint256 amount = currentToken.balanceOf(address(this)); currentToken.transfer(_owner, amount); }
//take back unclaimed tokens
LineComment
v0.5.17+commit.d19bba13
None
bzzr://f3b0126a79350b98825ba420c96b2577712250236eb83c0ea1425e8b2bf9c7ad
{ "func_code_index": [ 4940, 5208 ] }
56,240
seveninch
seveninch.sol
0x09a95a502a5f380eda8b7f1e8c3ff2ead41afc7e
Solidity
seveninch
contract seveninch is ERC20Detailed { using SafeMath for uint256; ERC20Detailed internal WETH = ERC20Detailed(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); IUniswapV2Factory public uniswapFactory = IUniswapV2Factory(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f); mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; string constant tokenName = "7inch"; string constant tokenSymbol = "7inch"; uint8 constant tokenDecimals = 18; uint256 constant easyDecimals = 1000000000000000000; // yes you can use an exponent instead if you want uint256 _totalSupply = 7000 * easyDecimals; //% uint256 public burnPercentage = 700; //any tokens sent here ? IERC20 currentToken ; address payable public _owner; address public _pairAddress; //modifiers modifier onlyOwner() { require(msg.sender == _owner); _; } constructor() public payable ERC20Detailed(tokenName, tokenSymbol, tokenDecimals) { _owner = msg.sender; //temporarily until the proper pair address is set. To prevent errors if transfer occurs prior to setting pair address. _pairAddress = msg.sender; require(_totalSupply != 0); //create initialSupply _balances[_owner] = _balances[_owner].add(_totalSupply); emit Transfer(address(0), _owner, _totalSupply); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } function transfer(address to, uint256 value) public returns (bool) { _executeTransfer(msg.sender, to, value); return true; } function multiTransfer(address[] memory receivers, uint256[] memory values) public { require(receivers.length == values.length); for(uint256 i = 0; i < receivers.length; i++) _executeTransfer(msg.sender, receivers[i], values[i]); } function transferFrom(address from, address to, uint256 value) public returns (bool) { require(value <= _allowed[from][msg.sender]); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _executeTransfer(from, to, value); return true; } uint256 public basePercentage = burnPercentage; function findPercentage(uint256 amount) public view returns (uint256) { uint256 percent = amount.mul(basePercentage).div(10000); return percent; } //turns burn on/off called by owner only function burnOnOff() external onlyOwner { if(basePercentage == 0) basePercentage = burnPercentage; else basePercentage = 0; } //burn function burn(uint256 amount) external { _burn(msg.sender, amount); } function _burn(address account, uint256 amount) internal { require(amount != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } //no zeros for decimals necessary function multiTransferEqualAmount(address[] memory receivers, uint256 amount) public { uint256 amountWithDecimals = amount * 10**uint256(tokenDecimals); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amountWithDecimals); } } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } //_pairAddress function setPairAddress() external onlyOwner { _pairAddress = uniswapFactory.getPair(address(WETH), address(this)); } //take back unclaimed tokens function withdrawUnclaimedTokens(address contractUnclaimed) external onlyOwner { currentToken = IERC20(contractUnclaimed); uint256 amount = currentToken.balanceOf(address(this)); currentToken.transfer(_owner, amount); } // transfer function _executeTransfer(address _from, address _to, uint256 _value) private { if (_to == address(0)) revert(); // Prevent transfer to 0x0 address. Use burn() instead if (_value <= 0) revert(); if (_balances[_from] < _value) revert(); // Check if the sender has enough if (_balances[_to] + _value < _balances[_to]) revert(); // Check for overflows //burn if selling only. do not burn if owner adds/removes Liquidity if(_to != _pairAddress || _from == _owner || _to == _owner) { _balances[_from] = SafeMath.sub(_balances[_from], _value); // Subtract from the sender _balances[_to] = SafeMath.add(_balances[_to], _value); // Add the same to the recipient emit Transfer(_from, _to, _value); // Notify anyone listening that this transfer took place }//if else //selling { //limit on sell //if(_value > 25 * easyDecimals) revert("25 token sell limit exceeded"); //sell limit uint256 tokensToBurn = findPercentage(_value); uint256 tokensToTransfer = _value.sub(tokensToBurn); _balances[_from] = SafeMath.sub(_balances[_from], tokensToTransfer); // Subtract from the sender _balances[_to] = _balances[_to].add(tokensToTransfer); emit Transfer(_from, _to, tokensToTransfer); // Notify anyone listening that this transfer took place //anything to burn? burn it if(tokensToBurn > 0) _burn(_from, tokensToBurn); }//else }//_executeTransfer }
_executeTransfer
function _executeTransfer(address _from, address _to, uint256 _value) private { if (_to == address(0)) revert(); // Prevent transfer to 0x0 address. Use burn() instead if (_value <= 0) revert(); if (_balances[_from] < _value) revert(); // Check if the sender has enough if (_balances[_to] + _value < _balances[_to]) revert(); // Check for overflows //burn if selling only. do not burn if owner adds/removes Liquidity if(_to != _pairAddress || _from == _owner || _to == _owner) { _balances[_from] = SafeMath.sub(_balances[_from], _value); // Subtract from the sender _balances[_to] = SafeMath.add(_balances[_to], _value); // Add the same to the recipient emit Transfer(_from, _to, _value); // Notify anyone listening that this transfer took place }//if else //selling { //limit on sell //if(_value > 25 * easyDecimals) revert("25 token sell limit exceeded"); //sell limit uint256 tokensToBurn = findPercentage(_value); uint256 tokensToTransfer = _value.sub(tokensToBurn); _balances[_from] = SafeMath.sub(_balances[_from], tokensToTransfer); // Subtract from the sender _balances[_to] = _balances[_to].add(tokensToTransfer); emit Transfer(_from, _to, tokensToTransfer); // Notify anyone listening that this transfer took place //anything to burn? burn it if(tokensToBurn > 0) _burn(_from, tokensToBurn); }//else }//_executeTransfer
// transfer
LineComment
v0.5.17+commit.d19bba13
None
bzzr://f3b0126a79350b98825ba420c96b2577712250236eb83c0ea1425e8b2bf9c7ad
{ "func_code_index": [ 5250, 7129 ] }
56,241
Boardroom
/C/Coding/lfBTC-Seigniorage/contracts/Boardroom.sol
0x3223689b39db8a897a9a9f0907c8a75d42268787
Solidity
Boardroom
contract Boardroom is ShareWrapper, ContractGuard, Operator { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; /* ========== DATA STRUCTURES ========== */ //uint256[2][] is an array of [amount][timestamp] //used to handle the timelock of LIFT tokens struct StakingSeatShare { uint256 lastSnapshotIndex; uint256 rewardEarned; uint256[2][] stakingWhenQuatity; bool isEntity; } //used to handle the staking of CTRL tokens struct StakingSeatControl { uint256 lastSnapshotIndex; uint256 rewardEarned; bool isEntity; } struct BoardSnapshotShare { uint256 time; uint256 rewardReceived; uint256 rewardPerShare; } struct BoardSnapshotControl { uint256 time; uint256 rewardReceived; uint256 rewardPerControl; } /* ========== STATE VARIABLES ========== */ mapping(address => StakingSeatShare) private stakersShare; mapping(address => StakingSeatControl) private stakersControl; BoardSnapshotShare[] private boardShareHistory; BoardSnapshotControl[] private boardControlHistory; uint daysRequiredStaked = 90; // staking less than X days = X - Y reduction in withdrawl, Y = days staked address ideaFund; //Where the forfeited shares end up address theOracle; /* ========== CONSTRUCTOR ========== */ constructor(address _share, address _control, address _ideafund, address _theOracle) { share = _share; control = _control; ideaFund = _ideafund; theOracle = _theOracle; BoardSnapshotShare memory genesisSSnapshot = BoardSnapshotShare({ time: block.number, rewardReceived: 0, rewardPerShare: 0 }); boardShareHistory.push(genesisSSnapshot); BoardSnapshotControl memory genesisCSnapshot = BoardSnapshotControl({ time: block.number, rewardReceived: 0, rewardPerControl: 0 }); boardControlHistory.push(genesisCSnapshot); } /* ========== Modifiers =============== */ modifier stakerExists { require( getbalanceOfControl(msg.sender) > 0 || getbalanceOfShare(msg.sender) > 0, 'Boardroom: The director does not exist' ); _; } modifier updateRewardShare(address staker, uint256 amount) { if (staker != address(0)) { StakingSeatShare storage seatS = stakersShare[staker]; (seatS.rewardEarned, ) = earned(staker); seatS.lastSnapshotIndex = latestShareSnapshotIndex(); seatS.isEntity = true; //validate this is getting stored in the struct correctly if(amount > 0) { seatS.stakingWhenQuatity.push([amount, block.timestamp]); } stakersShare[staker] = seatS; } _; } modifier updateRewardControl(address staker, uint256 amount) { if (staker != address(0)) { StakingSeatControl memory seatC = stakersControl[staker]; (, seatC.rewardEarned) = earned(staker); seatC.lastSnapshotIndex= latestControlSnapshotIndex(); seatC.isEntity = true; stakersControl[staker] = seatC; } _; } modifier updateRewardWithdraw(address staker) { if (staker != address(0)) { StakingSeatShare memory seatS = stakersShare[staker]; StakingSeatControl memory seatC = stakersControl[staker]; (seatS.rewardEarned, seatC.rewardEarned) = earned(staker); seatS.lastSnapshotIndex = latestShareSnapshotIndex(); seatC.lastSnapshotIndex= latestControlSnapshotIndex(); seatS.isEntity = true; seatC.isEntity = true; stakersShare[staker] = seatS; stakersControl[staker] = seatC; } _; } /* ========== VIEW FUNCTIONS ========== */ // =========== Snapshot getters function latestShareSnapshotIndex() public view returns (uint256) { return boardShareHistory.length.sub(1); } function getLatestShareSnapshot() internal view returns (BoardSnapshotShare memory) { return boardShareHistory[latestShareSnapshotIndex()]; } function getLastShareSnapshotIndexOf(address staker) public view returns (uint256) { return stakersShare[staker].lastSnapshotIndex; } function getLastShareSnapshotOf(address staker) internal view returns (BoardSnapshotShare memory) { return boardShareHistory[getLastShareSnapshotIndexOf(staker)]; } // control getters function latestControlSnapshotIndex() internal view returns (uint256) { return boardControlHistory.length.sub(1); } function getLatestControlSnapshot() internal view returns (BoardSnapshotControl memory) { return boardControlHistory[latestControlSnapshotIndex()]; } function getLastControlSnapshotIndexOf(address staker) public view returns (uint256) { return stakersControl[staker].lastSnapshotIndex; } function getLastControlSnapshotOf(address staker) internal view returns (BoardSnapshotControl memory) { return boardControlHistory[getLastControlSnapshotIndexOf(staker)]; } // =========== Director getters function rewardPerShare() public view returns (uint256) { return getLatestShareSnapshot().rewardPerShare; } function rewardPerControl() public view returns (uint256) { return getLatestControlSnapshot().rewardPerControl; } // Staking and the dates staked calculate the percentage they would forfeit if they withdraw now // be the warning function getStakedAmountsShare() public view returns (uint256[2][] memory earned) { StakingSeatShare memory seatS = stakersShare[msg.sender]; return seatS.stakingWhenQuatity; } function earned(address staker) public view returns (uint256, uint256) { uint256 latestRPS = getLatestShareSnapshot().rewardPerShare; uint256 storedRPS = getLastShareSnapshotOf(staker).rewardPerShare; uint256 latestRPC = getLatestControlSnapshot().rewardPerControl; uint256 storedRPC = getLastControlSnapshotOf(staker).rewardPerControl; return (getbalanceOfShare(staker).mul(latestRPS.sub(storedRPS)).div(1e18).add(stakersShare[staker].rewardEarned), getbalanceOfControl(staker).mul(latestRPC.sub(storedRPC)).div(1e18).add(stakersControl[staker].rewardEarned)); } /* ========== MUTATIVE FUNCTIONS ========== */ function stakeShare(uint256 amount) public override onlyOneBlock { require(amount > 0, 'Boardroom: Cannot stake 0'); stakeShareForThirdParty(msg.sender, msg.sender,amount); emit Staked(msg.sender, amount); } function stakeShareForThirdParty(address staker, address from,uint256 amount) public override onlyOneBlock updateRewardShare(staker, amount) { require(amount > 0, 'Boardroom: Cannot stake 0'); super.stakeShareForThirdParty(staker, from, amount); emit Staked(from, amount); } function stakeControl(uint256 amount) public override onlyOneBlock { require(amount > 0, 'Boardroom: Cannot stake 0'); stakeControlForThirdParty(msg.sender, msg.sender, amount); emit Staked(msg.sender, amount); } function stakeControlForThirdParty(address staker, address from, uint256 amount) public override onlyOneBlock updateRewardControl(staker, amount) { require(amount > 0, 'Boardroom: Cannot stake 0'); super.stakeControlForThirdParty(staker, from, amount); emit Staked(staker, amount); } // this function withdraws all of your LIFT tokens regardless of timestamp // using this function could lead to significant reductions if claimed LIFT function withdrawShareDontCallMeUnlessYouAreCertain() public onlyOneBlock stakerExists updateRewardWithdraw(msg.sender) { uint256 actualAmount = 0; require(getbalanceOfShare(msg.sender) > 0, 'Boardroom: Cannot withdraw 0'); StakingSeatShare storage seatS = stakersShare[msg.sender]; //forloop that iterates on the stakings and determines the reduction if any before creating a final amount for withdrawl for (uint256 i = 0; i < seatS.stakingWhenQuatity.length; i++) { uint256[2] storage arrStaked = seatS.stakingWhenQuatity[i]; uint daysStaked = (block.timestamp - arrStaked[1]) / 60 / 60 / 24; // = Y Days if (daysStaked >= daysRequiredStaked){ settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, arrStaked[0]); actualAmount += arrStaked[0]; } else { //calculate reduction percentage // EX only staked 35 days of 60 // 60 - 35 = 25% reduction // 100 - 25% = 75% remaining (multiply by that / div 100) uint256 reducedAmount = arrStaked[0].mul(uint256(100).sub(daysRequiredStaked.sub(daysStaked))).div(100); settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, reducedAmount); IERC20(share).safeTransfer(address(ideaFund), arrStaked[0].sub(reducedAmount)); actualAmount += reducedAmount; } //Make sure this is actually 0ing out and saving to the struct arrStaked[0] = 0; arrStaked[1] = 0; } emit WithdrawnWithReductionShare(msg.sender, actualAmount); } // The withdrawShare function with a timestamp input should take that data right out of the below // and feed it back to withdraw function withdrawShare(uint256 stakedTimeStamp) public onlyOneBlock stakerExists updateRewardWithdraw(msg.sender) { uint256 amount = 0; uint256 actualAmount = 0; StakingSeatShare storage seatS = stakersShare[msg.sender]; //forloop that iterates on the stakings and determines the reduction if any before creating a final amount for withdrawl for (uint256 i = 0; i < seatS.stakingWhenQuatity.length; i++) { uint256[2] storage arrStaked = seatS.stakingWhenQuatity[i]; if(arrStaked[1] == stakedTimeStamp) { amount = arrStaked[0]; uint daysStaked = (block.timestamp - arrStaked[1]) / 60 / 60 / 24; // = Y Days //console.log("days staked", daysStaked); if (daysStaked >= daysRequiredStaked){ settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, arrStaked[0]); actualAmount += arrStaked[0]; } else { //calculate reduction percentage // EX only staked 35 days of 60 // 60 - 35 = 25% reduction // 100 - 25% = 75% remaining (multiply by that / div 100) uint256 reducedAmount = arrStaked[0].mul(uint256(100).sub(daysRequiredStaked.sub(daysStaked))).div(100); settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, reducedAmount); IERC20(share).safeTransfer(address(ideaFund), arrStaked[0].sub(reducedAmount)); actualAmount += reducedAmount; } //Make sure this is actually 0ing out and saving to the struct arrStaked[0] = 0; arrStaked[1] = 0; } } emit WithdrawnWithReductionShare(msg.sender, actualAmount); } function withdrawControl(uint256 amount) public override onlyOneBlock stakerExists updateRewardWithdraw(msg.sender) { require(amount > 0, 'Boardroom: Cannot withdraw 0'); super.withdrawControl(amount); emit WithdrawControl(msg.sender, amount); } function claimReward() public updateRewardWithdraw(msg.sender) { uint256 reward = stakersShare[msg.sender].rewardEarned; reward += stakersControl[msg.sender].rewardEarned; if (reward > 0) { stakersShare[msg.sender].rewardEarned = 0; stakersControl[msg.sender].rewardEarned = 0; IERC20(control).safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } function allocateSeigniorage(uint256 amount) external onlyOneBlock onlyOperator { if(amount == 0) return; if(gettotalSupplyShare() == 0 && gettotalSupplyControl() == 0) return; uint256 shareValue = gettotalSupplyShare().mul(IOracle(theOracle).priceOf(share)); uint256 controlValue = gettotalSupplyControl().mul(IOracle(theOracle).priceOf(control)); uint256 totalStakedValue = shareValue + controlValue; uint percision = 9; uint256 rewardPerShareValue = amount.mul(shareValue.mul(10**percision).div(totalStakedValue)).div(10**percision); uint256 rewardPerControlValue = amount.mul(controlValue.mul(10**percision).div(totalStakedValue)).div(10**percision); if (rewardPerShareValue > 0) { uint256 prevRPS = getLatestShareSnapshot().rewardPerShare; uint256 nextRPS = prevRPS.add(rewardPerShareValue.mul(1e18).div(gettotalSupplyShare())); BoardSnapshotShare memory newSSnapshot = BoardSnapshotShare({ time: block.number, rewardReceived: amount, rewardPerShare: nextRPS }); boardShareHistory.push(newSSnapshot); } if (rewardPerControlValue > 0 ) { uint256 prevRPC = getLatestControlSnapshot().rewardPerControl; uint256 nextRPC = prevRPC.add(rewardPerControlValue.mul(1e18).div(gettotalSupplyControl())); BoardSnapshotControl memory newCSnapshot = BoardSnapshotControl({ time: block.number, rewardReceived: amount, rewardPerControl: nextRPC }); boardControlHistory.push(newCSnapshot); } IERC20(control).safeTransferFrom(msg.sender, address(this), amount); emit RewardAdded(msg.sender, amount); } function updateOracle(address newOracle) public onlyOwner { theOracle = newOracle; } function setIdeaFund(address newFund) public onlyOwner { ideaFund = newFund; } /* ========== EVENTS ========== */ event Staked(address indexed user, uint256 amount); event WithdrawControl(address indexed user, uint256 amount); event WithdrawnWithReductionShare(address indexed user, uint256 actualAmount); event RewardPaid(address indexed user, uint256 reward); event RewardAdded(address indexed user, uint256 reward); }
//import 'hardhat/console.sol';
LineComment
latestShareSnapshotIndex
function latestShareSnapshotIndex() public view returns (uint256) { return boardShareHistory.length.sub(1); }
// =========== Snapshot getters
LineComment
v0.7.0+commit.9e61f92b
{ "func_code_index": [ 4233, 4361 ] }
56,242
Boardroom
/C/Coding/lfBTC-Seigniorage/contracts/Boardroom.sol
0x3223689b39db8a897a9a9f0907c8a75d42268787
Solidity
Boardroom
contract Boardroom is ShareWrapper, ContractGuard, Operator { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; /* ========== DATA STRUCTURES ========== */ //uint256[2][] is an array of [amount][timestamp] //used to handle the timelock of LIFT tokens struct StakingSeatShare { uint256 lastSnapshotIndex; uint256 rewardEarned; uint256[2][] stakingWhenQuatity; bool isEntity; } //used to handle the staking of CTRL tokens struct StakingSeatControl { uint256 lastSnapshotIndex; uint256 rewardEarned; bool isEntity; } struct BoardSnapshotShare { uint256 time; uint256 rewardReceived; uint256 rewardPerShare; } struct BoardSnapshotControl { uint256 time; uint256 rewardReceived; uint256 rewardPerControl; } /* ========== STATE VARIABLES ========== */ mapping(address => StakingSeatShare) private stakersShare; mapping(address => StakingSeatControl) private stakersControl; BoardSnapshotShare[] private boardShareHistory; BoardSnapshotControl[] private boardControlHistory; uint daysRequiredStaked = 90; // staking less than X days = X - Y reduction in withdrawl, Y = days staked address ideaFund; //Where the forfeited shares end up address theOracle; /* ========== CONSTRUCTOR ========== */ constructor(address _share, address _control, address _ideafund, address _theOracle) { share = _share; control = _control; ideaFund = _ideafund; theOracle = _theOracle; BoardSnapshotShare memory genesisSSnapshot = BoardSnapshotShare({ time: block.number, rewardReceived: 0, rewardPerShare: 0 }); boardShareHistory.push(genesisSSnapshot); BoardSnapshotControl memory genesisCSnapshot = BoardSnapshotControl({ time: block.number, rewardReceived: 0, rewardPerControl: 0 }); boardControlHistory.push(genesisCSnapshot); } /* ========== Modifiers =============== */ modifier stakerExists { require( getbalanceOfControl(msg.sender) > 0 || getbalanceOfShare(msg.sender) > 0, 'Boardroom: The director does not exist' ); _; } modifier updateRewardShare(address staker, uint256 amount) { if (staker != address(0)) { StakingSeatShare storage seatS = stakersShare[staker]; (seatS.rewardEarned, ) = earned(staker); seatS.lastSnapshotIndex = latestShareSnapshotIndex(); seatS.isEntity = true; //validate this is getting stored in the struct correctly if(amount > 0) { seatS.stakingWhenQuatity.push([amount, block.timestamp]); } stakersShare[staker] = seatS; } _; } modifier updateRewardControl(address staker, uint256 amount) { if (staker != address(0)) { StakingSeatControl memory seatC = stakersControl[staker]; (, seatC.rewardEarned) = earned(staker); seatC.lastSnapshotIndex= latestControlSnapshotIndex(); seatC.isEntity = true; stakersControl[staker] = seatC; } _; } modifier updateRewardWithdraw(address staker) { if (staker != address(0)) { StakingSeatShare memory seatS = stakersShare[staker]; StakingSeatControl memory seatC = stakersControl[staker]; (seatS.rewardEarned, seatC.rewardEarned) = earned(staker); seatS.lastSnapshotIndex = latestShareSnapshotIndex(); seatC.lastSnapshotIndex= latestControlSnapshotIndex(); seatS.isEntity = true; seatC.isEntity = true; stakersShare[staker] = seatS; stakersControl[staker] = seatC; } _; } /* ========== VIEW FUNCTIONS ========== */ // =========== Snapshot getters function latestShareSnapshotIndex() public view returns (uint256) { return boardShareHistory.length.sub(1); } function getLatestShareSnapshot() internal view returns (BoardSnapshotShare memory) { return boardShareHistory[latestShareSnapshotIndex()]; } function getLastShareSnapshotIndexOf(address staker) public view returns (uint256) { return stakersShare[staker].lastSnapshotIndex; } function getLastShareSnapshotOf(address staker) internal view returns (BoardSnapshotShare memory) { return boardShareHistory[getLastShareSnapshotIndexOf(staker)]; } // control getters function latestControlSnapshotIndex() internal view returns (uint256) { return boardControlHistory.length.sub(1); } function getLatestControlSnapshot() internal view returns (BoardSnapshotControl memory) { return boardControlHistory[latestControlSnapshotIndex()]; } function getLastControlSnapshotIndexOf(address staker) public view returns (uint256) { return stakersControl[staker].lastSnapshotIndex; } function getLastControlSnapshotOf(address staker) internal view returns (BoardSnapshotControl memory) { return boardControlHistory[getLastControlSnapshotIndexOf(staker)]; } // =========== Director getters function rewardPerShare() public view returns (uint256) { return getLatestShareSnapshot().rewardPerShare; } function rewardPerControl() public view returns (uint256) { return getLatestControlSnapshot().rewardPerControl; } // Staking and the dates staked calculate the percentage they would forfeit if they withdraw now // be the warning function getStakedAmountsShare() public view returns (uint256[2][] memory earned) { StakingSeatShare memory seatS = stakersShare[msg.sender]; return seatS.stakingWhenQuatity; } function earned(address staker) public view returns (uint256, uint256) { uint256 latestRPS = getLatestShareSnapshot().rewardPerShare; uint256 storedRPS = getLastShareSnapshotOf(staker).rewardPerShare; uint256 latestRPC = getLatestControlSnapshot().rewardPerControl; uint256 storedRPC = getLastControlSnapshotOf(staker).rewardPerControl; return (getbalanceOfShare(staker).mul(latestRPS.sub(storedRPS)).div(1e18).add(stakersShare[staker].rewardEarned), getbalanceOfControl(staker).mul(latestRPC.sub(storedRPC)).div(1e18).add(stakersControl[staker].rewardEarned)); } /* ========== MUTATIVE FUNCTIONS ========== */ function stakeShare(uint256 amount) public override onlyOneBlock { require(amount > 0, 'Boardroom: Cannot stake 0'); stakeShareForThirdParty(msg.sender, msg.sender,amount); emit Staked(msg.sender, amount); } function stakeShareForThirdParty(address staker, address from,uint256 amount) public override onlyOneBlock updateRewardShare(staker, amount) { require(amount > 0, 'Boardroom: Cannot stake 0'); super.stakeShareForThirdParty(staker, from, amount); emit Staked(from, amount); } function stakeControl(uint256 amount) public override onlyOneBlock { require(amount > 0, 'Boardroom: Cannot stake 0'); stakeControlForThirdParty(msg.sender, msg.sender, amount); emit Staked(msg.sender, amount); } function stakeControlForThirdParty(address staker, address from, uint256 amount) public override onlyOneBlock updateRewardControl(staker, amount) { require(amount > 0, 'Boardroom: Cannot stake 0'); super.stakeControlForThirdParty(staker, from, amount); emit Staked(staker, amount); } // this function withdraws all of your LIFT tokens regardless of timestamp // using this function could lead to significant reductions if claimed LIFT function withdrawShareDontCallMeUnlessYouAreCertain() public onlyOneBlock stakerExists updateRewardWithdraw(msg.sender) { uint256 actualAmount = 0; require(getbalanceOfShare(msg.sender) > 0, 'Boardroom: Cannot withdraw 0'); StakingSeatShare storage seatS = stakersShare[msg.sender]; //forloop that iterates on the stakings and determines the reduction if any before creating a final amount for withdrawl for (uint256 i = 0; i < seatS.stakingWhenQuatity.length; i++) { uint256[2] storage arrStaked = seatS.stakingWhenQuatity[i]; uint daysStaked = (block.timestamp - arrStaked[1]) / 60 / 60 / 24; // = Y Days if (daysStaked >= daysRequiredStaked){ settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, arrStaked[0]); actualAmount += arrStaked[0]; } else { //calculate reduction percentage // EX only staked 35 days of 60 // 60 - 35 = 25% reduction // 100 - 25% = 75% remaining (multiply by that / div 100) uint256 reducedAmount = arrStaked[0].mul(uint256(100).sub(daysRequiredStaked.sub(daysStaked))).div(100); settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, reducedAmount); IERC20(share).safeTransfer(address(ideaFund), arrStaked[0].sub(reducedAmount)); actualAmount += reducedAmount; } //Make sure this is actually 0ing out and saving to the struct arrStaked[0] = 0; arrStaked[1] = 0; } emit WithdrawnWithReductionShare(msg.sender, actualAmount); } // The withdrawShare function with a timestamp input should take that data right out of the below // and feed it back to withdraw function withdrawShare(uint256 stakedTimeStamp) public onlyOneBlock stakerExists updateRewardWithdraw(msg.sender) { uint256 amount = 0; uint256 actualAmount = 0; StakingSeatShare storage seatS = stakersShare[msg.sender]; //forloop that iterates on the stakings and determines the reduction if any before creating a final amount for withdrawl for (uint256 i = 0; i < seatS.stakingWhenQuatity.length; i++) { uint256[2] storage arrStaked = seatS.stakingWhenQuatity[i]; if(arrStaked[1] == stakedTimeStamp) { amount = arrStaked[0]; uint daysStaked = (block.timestamp - arrStaked[1]) / 60 / 60 / 24; // = Y Days //console.log("days staked", daysStaked); if (daysStaked >= daysRequiredStaked){ settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, arrStaked[0]); actualAmount += arrStaked[0]; } else { //calculate reduction percentage // EX only staked 35 days of 60 // 60 - 35 = 25% reduction // 100 - 25% = 75% remaining (multiply by that / div 100) uint256 reducedAmount = arrStaked[0].mul(uint256(100).sub(daysRequiredStaked.sub(daysStaked))).div(100); settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, reducedAmount); IERC20(share).safeTransfer(address(ideaFund), arrStaked[0].sub(reducedAmount)); actualAmount += reducedAmount; } //Make sure this is actually 0ing out and saving to the struct arrStaked[0] = 0; arrStaked[1] = 0; } } emit WithdrawnWithReductionShare(msg.sender, actualAmount); } function withdrawControl(uint256 amount) public override onlyOneBlock stakerExists updateRewardWithdraw(msg.sender) { require(amount > 0, 'Boardroom: Cannot withdraw 0'); super.withdrawControl(amount); emit WithdrawControl(msg.sender, amount); } function claimReward() public updateRewardWithdraw(msg.sender) { uint256 reward = stakersShare[msg.sender].rewardEarned; reward += stakersControl[msg.sender].rewardEarned; if (reward > 0) { stakersShare[msg.sender].rewardEarned = 0; stakersControl[msg.sender].rewardEarned = 0; IERC20(control).safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } function allocateSeigniorage(uint256 amount) external onlyOneBlock onlyOperator { if(amount == 0) return; if(gettotalSupplyShare() == 0 && gettotalSupplyControl() == 0) return; uint256 shareValue = gettotalSupplyShare().mul(IOracle(theOracle).priceOf(share)); uint256 controlValue = gettotalSupplyControl().mul(IOracle(theOracle).priceOf(control)); uint256 totalStakedValue = shareValue + controlValue; uint percision = 9; uint256 rewardPerShareValue = amount.mul(shareValue.mul(10**percision).div(totalStakedValue)).div(10**percision); uint256 rewardPerControlValue = amount.mul(controlValue.mul(10**percision).div(totalStakedValue)).div(10**percision); if (rewardPerShareValue > 0) { uint256 prevRPS = getLatestShareSnapshot().rewardPerShare; uint256 nextRPS = prevRPS.add(rewardPerShareValue.mul(1e18).div(gettotalSupplyShare())); BoardSnapshotShare memory newSSnapshot = BoardSnapshotShare({ time: block.number, rewardReceived: amount, rewardPerShare: nextRPS }); boardShareHistory.push(newSSnapshot); } if (rewardPerControlValue > 0 ) { uint256 prevRPC = getLatestControlSnapshot().rewardPerControl; uint256 nextRPC = prevRPC.add(rewardPerControlValue.mul(1e18).div(gettotalSupplyControl())); BoardSnapshotControl memory newCSnapshot = BoardSnapshotControl({ time: block.number, rewardReceived: amount, rewardPerControl: nextRPC }); boardControlHistory.push(newCSnapshot); } IERC20(control).safeTransferFrom(msg.sender, address(this), amount); emit RewardAdded(msg.sender, amount); } function updateOracle(address newOracle) public onlyOwner { theOracle = newOracle; } function setIdeaFund(address newFund) public onlyOwner { ideaFund = newFund; } /* ========== EVENTS ========== */ event Staked(address indexed user, uint256 amount); event WithdrawControl(address indexed user, uint256 amount); event WithdrawnWithReductionShare(address indexed user, uint256 actualAmount); event RewardPaid(address indexed user, uint256 reward); event RewardAdded(address indexed user, uint256 reward); }
//import 'hardhat/console.sol';
LineComment
latestControlSnapshotIndex
function latestControlSnapshotIndex() internal view returns (uint256) { return boardControlHistory.length.sub(1); }
// control getters
LineComment
v0.7.0+commit.9e61f92b
{ "func_code_index": [ 4956, 5090 ] }
56,243
Boardroom
/C/Coding/lfBTC-Seigniorage/contracts/Boardroom.sol
0x3223689b39db8a897a9a9f0907c8a75d42268787
Solidity
Boardroom
contract Boardroom is ShareWrapper, ContractGuard, Operator { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; /* ========== DATA STRUCTURES ========== */ //uint256[2][] is an array of [amount][timestamp] //used to handle the timelock of LIFT tokens struct StakingSeatShare { uint256 lastSnapshotIndex; uint256 rewardEarned; uint256[2][] stakingWhenQuatity; bool isEntity; } //used to handle the staking of CTRL tokens struct StakingSeatControl { uint256 lastSnapshotIndex; uint256 rewardEarned; bool isEntity; } struct BoardSnapshotShare { uint256 time; uint256 rewardReceived; uint256 rewardPerShare; } struct BoardSnapshotControl { uint256 time; uint256 rewardReceived; uint256 rewardPerControl; } /* ========== STATE VARIABLES ========== */ mapping(address => StakingSeatShare) private stakersShare; mapping(address => StakingSeatControl) private stakersControl; BoardSnapshotShare[] private boardShareHistory; BoardSnapshotControl[] private boardControlHistory; uint daysRequiredStaked = 90; // staking less than X days = X - Y reduction in withdrawl, Y = days staked address ideaFund; //Where the forfeited shares end up address theOracle; /* ========== CONSTRUCTOR ========== */ constructor(address _share, address _control, address _ideafund, address _theOracle) { share = _share; control = _control; ideaFund = _ideafund; theOracle = _theOracle; BoardSnapshotShare memory genesisSSnapshot = BoardSnapshotShare({ time: block.number, rewardReceived: 0, rewardPerShare: 0 }); boardShareHistory.push(genesisSSnapshot); BoardSnapshotControl memory genesisCSnapshot = BoardSnapshotControl({ time: block.number, rewardReceived: 0, rewardPerControl: 0 }); boardControlHistory.push(genesisCSnapshot); } /* ========== Modifiers =============== */ modifier stakerExists { require( getbalanceOfControl(msg.sender) > 0 || getbalanceOfShare(msg.sender) > 0, 'Boardroom: The director does not exist' ); _; } modifier updateRewardShare(address staker, uint256 amount) { if (staker != address(0)) { StakingSeatShare storage seatS = stakersShare[staker]; (seatS.rewardEarned, ) = earned(staker); seatS.lastSnapshotIndex = latestShareSnapshotIndex(); seatS.isEntity = true; //validate this is getting stored in the struct correctly if(amount > 0) { seatS.stakingWhenQuatity.push([amount, block.timestamp]); } stakersShare[staker] = seatS; } _; } modifier updateRewardControl(address staker, uint256 amount) { if (staker != address(0)) { StakingSeatControl memory seatC = stakersControl[staker]; (, seatC.rewardEarned) = earned(staker); seatC.lastSnapshotIndex= latestControlSnapshotIndex(); seatC.isEntity = true; stakersControl[staker] = seatC; } _; } modifier updateRewardWithdraw(address staker) { if (staker != address(0)) { StakingSeatShare memory seatS = stakersShare[staker]; StakingSeatControl memory seatC = stakersControl[staker]; (seatS.rewardEarned, seatC.rewardEarned) = earned(staker); seatS.lastSnapshotIndex = latestShareSnapshotIndex(); seatC.lastSnapshotIndex= latestControlSnapshotIndex(); seatS.isEntity = true; seatC.isEntity = true; stakersShare[staker] = seatS; stakersControl[staker] = seatC; } _; } /* ========== VIEW FUNCTIONS ========== */ // =========== Snapshot getters function latestShareSnapshotIndex() public view returns (uint256) { return boardShareHistory.length.sub(1); } function getLatestShareSnapshot() internal view returns (BoardSnapshotShare memory) { return boardShareHistory[latestShareSnapshotIndex()]; } function getLastShareSnapshotIndexOf(address staker) public view returns (uint256) { return stakersShare[staker].lastSnapshotIndex; } function getLastShareSnapshotOf(address staker) internal view returns (BoardSnapshotShare memory) { return boardShareHistory[getLastShareSnapshotIndexOf(staker)]; } // control getters function latestControlSnapshotIndex() internal view returns (uint256) { return boardControlHistory.length.sub(1); } function getLatestControlSnapshot() internal view returns (BoardSnapshotControl memory) { return boardControlHistory[latestControlSnapshotIndex()]; } function getLastControlSnapshotIndexOf(address staker) public view returns (uint256) { return stakersControl[staker].lastSnapshotIndex; } function getLastControlSnapshotOf(address staker) internal view returns (BoardSnapshotControl memory) { return boardControlHistory[getLastControlSnapshotIndexOf(staker)]; } // =========== Director getters function rewardPerShare() public view returns (uint256) { return getLatestShareSnapshot().rewardPerShare; } function rewardPerControl() public view returns (uint256) { return getLatestControlSnapshot().rewardPerControl; } // Staking and the dates staked calculate the percentage they would forfeit if they withdraw now // be the warning function getStakedAmountsShare() public view returns (uint256[2][] memory earned) { StakingSeatShare memory seatS = stakersShare[msg.sender]; return seatS.stakingWhenQuatity; } function earned(address staker) public view returns (uint256, uint256) { uint256 latestRPS = getLatestShareSnapshot().rewardPerShare; uint256 storedRPS = getLastShareSnapshotOf(staker).rewardPerShare; uint256 latestRPC = getLatestControlSnapshot().rewardPerControl; uint256 storedRPC = getLastControlSnapshotOf(staker).rewardPerControl; return (getbalanceOfShare(staker).mul(latestRPS.sub(storedRPS)).div(1e18).add(stakersShare[staker].rewardEarned), getbalanceOfControl(staker).mul(latestRPC.sub(storedRPC)).div(1e18).add(stakersControl[staker].rewardEarned)); } /* ========== MUTATIVE FUNCTIONS ========== */ function stakeShare(uint256 amount) public override onlyOneBlock { require(amount > 0, 'Boardroom: Cannot stake 0'); stakeShareForThirdParty(msg.sender, msg.sender,amount); emit Staked(msg.sender, amount); } function stakeShareForThirdParty(address staker, address from,uint256 amount) public override onlyOneBlock updateRewardShare(staker, amount) { require(amount > 0, 'Boardroom: Cannot stake 0'); super.stakeShareForThirdParty(staker, from, amount); emit Staked(from, amount); } function stakeControl(uint256 amount) public override onlyOneBlock { require(amount > 0, 'Boardroom: Cannot stake 0'); stakeControlForThirdParty(msg.sender, msg.sender, amount); emit Staked(msg.sender, amount); } function stakeControlForThirdParty(address staker, address from, uint256 amount) public override onlyOneBlock updateRewardControl(staker, amount) { require(amount > 0, 'Boardroom: Cannot stake 0'); super.stakeControlForThirdParty(staker, from, amount); emit Staked(staker, amount); } // this function withdraws all of your LIFT tokens regardless of timestamp // using this function could lead to significant reductions if claimed LIFT function withdrawShareDontCallMeUnlessYouAreCertain() public onlyOneBlock stakerExists updateRewardWithdraw(msg.sender) { uint256 actualAmount = 0; require(getbalanceOfShare(msg.sender) > 0, 'Boardroom: Cannot withdraw 0'); StakingSeatShare storage seatS = stakersShare[msg.sender]; //forloop that iterates on the stakings and determines the reduction if any before creating a final amount for withdrawl for (uint256 i = 0; i < seatS.stakingWhenQuatity.length; i++) { uint256[2] storage arrStaked = seatS.stakingWhenQuatity[i]; uint daysStaked = (block.timestamp - arrStaked[1]) / 60 / 60 / 24; // = Y Days if (daysStaked >= daysRequiredStaked){ settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, arrStaked[0]); actualAmount += arrStaked[0]; } else { //calculate reduction percentage // EX only staked 35 days of 60 // 60 - 35 = 25% reduction // 100 - 25% = 75% remaining (multiply by that / div 100) uint256 reducedAmount = arrStaked[0].mul(uint256(100).sub(daysRequiredStaked.sub(daysStaked))).div(100); settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, reducedAmount); IERC20(share).safeTransfer(address(ideaFund), arrStaked[0].sub(reducedAmount)); actualAmount += reducedAmount; } //Make sure this is actually 0ing out and saving to the struct arrStaked[0] = 0; arrStaked[1] = 0; } emit WithdrawnWithReductionShare(msg.sender, actualAmount); } // The withdrawShare function with a timestamp input should take that data right out of the below // and feed it back to withdraw function withdrawShare(uint256 stakedTimeStamp) public onlyOneBlock stakerExists updateRewardWithdraw(msg.sender) { uint256 amount = 0; uint256 actualAmount = 0; StakingSeatShare storage seatS = stakersShare[msg.sender]; //forloop that iterates on the stakings and determines the reduction if any before creating a final amount for withdrawl for (uint256 i = 0; i < seatS.stakingWhenQuatity.length; i++) { uint256[2] storage arrStaked = seatS.stakingWhenQuatity[i]; if(arrStaked[1] == stakedTimeStamp) { amount = arrStaked[0]; uint daysStaked = (block.timestamp - arrStaked[1]) / 60 / 60 / 24; // = Y Days //console.log("days staked", daysStaked); if (daysStaked >= daysRequiredStaked){ settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, arrStaked[0]); actualAmount += arrStaked[0]; } else { //calculate reduction percentage // EX only staked 35 days of 60 // 60 - 35 = 25% reduction // 100 - 25% = 75% remaining (multiply by that / div 100) uint256 reducedAmount = arrStaked[0].mul(uint256(100).sub(daysRequiredStaked.sub(daysStaked))).div(100); settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, reducedAmount); IERC20(share).safeTransfer(address(ideaFund), arrStaked[0].sub(reducedAmount)); actualAmount += reducedAmount; } //Make sure this is actually 0ing out and saving to the struct arrStaked[0] = 0; arrStaked[1] = 0; } } emit WithdrawnWithReductionShare(msg.sender, actualAmount); } function withdrawControl(uint256 amount) public override onlyOneBlock stakerExists updateRewardWithdraw(msg.sender) { require(amount > 0, 'Boardroom: Cannot withdraw 0'); super.withdrawControl(amount); emit WithdrawControl(msg.sender, amount); } function claimReward() public updateRewardWithdraw(msg.sender) { uint256 reward = stakersShare[msg.sender].rewardEarned; reward += stakersControl[msg.sender].rewardEarned; if (reward > 0) { stakersShare[msg.sender].rewardEarned = 0; stakersControl[msg.sender].rewardEarned = 0; IERC20(control).safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } function allocateSeigniorage(uint256 amount) external onlyOneBlock onlyOperator { if(amount == 0) return; if(gettotalSupplyShare() == 0 && gettotalSupplyControl() == 0) return; uint256 shareValue = gettotalSupplyShare().mul(IOracle(theOracle).priceOf(share)); uint256 controlValue = gettotalSupplyControl().mul(IOracle(theOracle).priceOf(control)); uint256 totalStakedValue = shareValue + controlValue; uint percision = 9; uint256 rewardPerShareValue = amount.mul(shareValue.mul(10**percision).div(totalStakedValue)).div(10**percision); uint256 rewardPerControlValue = amount.mul(controlValue.mul(10**percision).div(totalStakedValue)).div(10**percision); if (rewardPerShareValue > 0) { uint256 prevRPS = getLatestShareSnapshot().rewardPerShare; uint256 nextRPS = prevRPS.add(rewardPerShareValue.mul(1e18).div(gettotalSupplyShare())); BoardSnapshotShare memory newSSnapshot = BoardSnapshotShare({ time: block.number, rewardReceived: amount, rewardPerShare: nextRPS }); boardShareHistory.push(newSSnapshot); } if (rewardPerControlValue > 0 ) { uint256 prevRPC = getLatestControlSnapshot().rewardPerControl; uint256 nextRPC = prevRPC.add(rewardPerControlValue.mul(1e18).div(gettotalSupplyControl())); BoardSnapshotControl memory newCSnapshot = BoardSnapshotControl({ time: block.number, rewardReceived: amount, rewardPerControl: nextRPC }); boardControlHistory.push(newCSnapshot); } IERC20(control).safeTransferFrom(msg.sender, address(this), amount); emit RewardAdded(msg.sender, amount); } function updateOracle(address newOracle) public onlyOwner { theOracle = newOracle; } function setIdeaFund(address newFund) public onlyOwner { ideaFund = newFund; } /* ========== EVENTS ========== */ event Staked(address indexed user, uint256 amount); event WithdrawControl(address indexed user, uint256 amount); event WithdrawnWithReductionShare(address indexed user, uint256 actualAmount); event RewardPaid(address indexed user, uint256 reward); event RewardAdded(address indexed user, uint256 reward); }
//import 'hardhat/console.sol';
LineComment
rewardPerShare
function rewardPerShare() public view returns (uint256) { return getLatestShareSnapshot().rewardPerShare; }
// =========== Director getters
LineComment
v0.7.0+commit.9e61f92b
{ "func_code_index": [ 5720, 5846 ] }
56,244
Boardroom
/C/Coding/lfBTC-Seigniorage/contracts/Boardroom.sol
0x3223689b39db8a897a9a9f0907c8a75d42268787
Solidity
Boardroom
contract Boardroom is ShareWrapper, ContractGuard, Operator { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; /* ========== DATA STRUCTURES ========== */ //uint256[2][] is an array of [amount][timestamp] //used to handle the timelock of LIFT tokens struct StakingSeatShare { uint256 lastSnapshotIndex; uint256 rewardEarned; uint256[2][] stakingWhenQuatity; bool isEntity; } //used to handle the staking of CTRL tokens struct StakingSeatControl { uint256 lastSnapshotIndex; uint256 rewardEarned; bool isEntity; } struct BoardSnapshotShare { uint256 time; uint256 rewardReceived; uint256 rewardPerShare; } struct BoardSnapshotControl { uint256 time; uint256 rewardReceived; uint256 rewardPerControl; } /* ========== STATE VARIABLES ========== */ mapping(address => StakingSeatShare) private stakersShare; mapping(address => StakingSeatControl) private stakersControl; BoardSnapshotShare[] private boardShareHistory; BoardSnapshotControl[] private boardControlHistory; uint daysRequiredStaked = 90; // staking less than X days = X - Y reduction in withdrawl, Y = days staked address ideaFund; //Where the forfeited shares end up address theOracle; /* ========== CONSTRUCTOR ========== */ constructor(address _share, address _control, address _ideafund, address _theOracle) { share = _share; control = _control; ideaFund = _ideafund; theOracle = _theOracle; BoardSnapshotShare memory genesisSSnapshot = BoardSnapshotShare({ time: block.number, rewardReceived: 0, rewardPerShare: 0 }); boardShareHistory.push(genesisSSnapshot); BoardSnapshotControl memory genesisCSnapshot = BoardSnapshotControl({ time: block.number, rewardReceived: 0, rewardPerControl: 0 }); boardControlHistory.push(genesisCSnapshot); } /* ========== Modifiers =============== */ modifier stakerExists { require( getbalanceOfControl(msg.sender) > 0 || getbalanceOfShare(msg.sender) > 0, 'Boardroom: The director does not exist' ); _; } modifier updateRewardShare(address staker, uint256 amount) { if (staker != address(0)) { StakingSeatShare storage seatS = stakersShare[staker]; (seatS.rewardEarned, ) = earned(staker); seatS.lastSnapshotIndex = latestShareSnapshotIndex(); seatS.isEntity = true; //validate this is getting stored in the struct correctly if(amount > 0) { seatS.stakingWhenQuatity.push([amount, block.timestamp]); } stakersShare[staker] = seatS; } _; } modifier updateRewardControl(address staker, uint256 amount) { if (staker != address(0)) { StakingSeatControl memory seatC = stakersControl[staker]; (, seatC.rewardEarned) = earned(staker); seatC.lastSnapshotIndex= latestControlSnapshotIndex(); seatC.isEntity = true; stakersControl[staker] = seatC; } _; } modifier updateRewardWithdraw(address staker) { if (staker != address(0)) { StakingSeatShare memory seatS = stakersShare[staker]; StakingSeatControl memory seatC = stakersControl[staker]; (seatS.rewardEarned, seatC.rewardEarned) = earned(staker); seatS.lastSnapshotIndex = latestShareSnapshotIndex(); seatC.lastSnapshotIndex= latestControlSnapshotIndex(); seatS.isEntity = true; seatC.isEntity = true; stakersShare[staker] = seatS; stakersControl[staker] = seatC; } _; } /* ========== VIEW FUNCTIONS ========== */ // =========== Snapshot getters function latestShareSnapshotIndex() public view returns (uint256) { return boardShareHistory.length.sub(1); } function getLatestShareSnapshot() internal view returns (BoardSnapshotShare memory) { return boardShareHistory[latestShareSnapshotIndex()]; } function getLastShareSnapshotIndexOf(address staker) public view returns (uint256) { return stakersShare[staker].lastSnapshotIndex; } function getLastShareSnapshotOf(address staker) internal view returns (BoardSnapshotShare memory) { return boardShareHistory[getLastShareSnapshotIndexOf(staker)]; } // control getters function latestControlSnapshotIndex() internal view returns (uint256) { return boardControlHistory.length.sub(1); } function getLatestControlSnapshot() internal view returns (BoardSnapshotControl memory) { return boardControlHistory[latestControlSnapshotIndex()]; } function getLastControlSnapshotIndexOf(address staker) public view returns (uint256) { return stakersControl[staker].lastSnapshotIndex; } function getLastControlSnapshotOf(address staker) internal view returns (BoardSnapshotControl memory) { return boardControlHistory[getLastControlSnapshotIndexOf(staker)]; } // =========== Director getters function rewardPerShare() public view returns (uint256) { return getLatestShareSnapshot().rewardPerShare; } function rewardPerControl() public view returns (uint256) { return getLatestControlSnapshot().rewardPerControl; } // Staking and the dates staked calculate the percentage they would forfeit if they withdraw now // be the warning function getStakedAmountsShare() public view returns (uint256[2][] memory earned) { StakingSeatShare memory seatS = stakersShare[msg.sender]; return seatS.stakingWhenQuatity; } function earned(address staker) public view returns (uint256, uint256) { uint256 latestRPS = getLatestShareSnapshot().rewardPerShare; uint256 storedRPS = getLastShareSnapshotOf(staker).rewardPerShare; uint256 latestRPC = getLatestControlSnapshot().rewardPerControl; uint256 storedRPC = getLastControlSnapshotOf(staker).rewardPerControl; return (getbalanceOfShare(staker).mul(latestRPS.sub(storedRPS)).div(1e18).add(stakersShare[staker].rewardEarned), getbalanceOfControl(staker).mul(latestRPC.sub(storedRPC)).div(1e18).add(stakersControl[staker].rewardEarned)); } /* ========== MUTATIVE FUNCTIONS ========== */ function stakeShare(uint256 amount) public override onlyOneBlock { require(amount > 0, 'Boardroom: Cannot stake 0'); stakeShareForThirdParty(msg.sender, msg.sender,amount); emit Staked(msg.sender, amount); } function stakeShareForThirdParty(address staker, address from,uint256 amount) public override onlyOneBlock updateRewardShare(staker, amount) { require(amount > 0, 'Boardroom: Cannot stake 0'); super.stakeShareForThirdParty(staker, from, amount); emit Staked(from, amount); } function stakeControl(uint256 amount) public override onlyOneBlock { require(amount > 0, 'Boardroom: Cannot stake 0'); stakeControlForThirdParty(msg.sender, msg.sender, amount); emit Staked(msg.sender, amount); } function stakeControlForThirdParty(address staker, address from, uint256 amount) public override onlyOneBlock updateRewardControl(staker, amount) { require(amount > 0, 'Boardroom: Cannot stake 0'); super.stakeControlForThirdParty(staker, from, amount); emit Staked(staker, amount); } // this function withdraws all of your LIFT tokens regardless of timestamp // using this function could lead to significant reductions if claimed LIFT function withdrawShareDontCallMeUnlessYouAreCertain() public onlyOneBlock stakerExists updateRewardWithdraw(msg.sender) { uint256 actualAmount = 0; require(getbalanceOfShare(msg.sender) > 0, 'Boardroom: Cannot withdraw 0'); StakingSeatShare storage seatS = stakersShare[msg.sender]; //forloop that iterates on the stakings and determines the reduction if any before creating a final amount for withdrawl for (uint256 i = 0; i < seatS.stakingWhenQuatity.length; i++) { uint256[2] storage arrStaked = seatS.stakingWhenQuatity[i]; uint daysStaked = (block.timestamp - arrStaked[1]) / 60 / 60 / 24; // = Y Days if (daysStaked >= daysRequiredStaked){ settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, arrStaked[0]); actualAmount += arrStaked[0]; } else { //calculate reduction percentage // EX only staked 35 days of 60 // 60 - 35 = 25% reduction // 100 - 25% = 75% remaining (multiply by that / div 100) uint256 reducedAmount = arrStaked[0].mul(uint256(100).sub(daysRequiredStaked.sub(daysStaked))).div(100); settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, reducedAmount); IERC20(share).safeTransfer(address(ideaFund), arrStaked[0].sub(reducedAmount)); actualAmount += reducedAmount; } //Make sure this is actually 0ing out and saving to the struct arrStaked[0] = 0; arrStaked[1] = 0; } emit WithdrawnWithReductionShare(msg.sender, actualAmount); } // The withdrawShare function with a timestamp input should take that data right out of the below // and feed it back to withdraw function withdrawShare(uint256 stakedTimeStamp) public onlyOneBlock stakerExists updateRewardWithdraw(msg.sender) { uint256 amount = 0; uint256 actualAmount = 0; StakingSeatShare storage seatS = stakersShare[msg.sender]; //forloop that iterates on the stakings and determines the reduction if any before creating a final amount for withdrawl for (uint256 i = 0; i < seatS.stakingWhenQuatity.length; i++) { uint256[2] storage arrStaked = seatS.stakingWhenQuatity[i]; if(arrStaked[1] == stakedTimeStamp) { amount = arrStaked[0]; uint daysStaked = (block.timestamp - arrStaked[1]) / 60 / 60 / 24; // = Y Days //console.log("days staked", daysStaked); if (daysStaked >= daysRequiredStaked){ settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, arrStaked[0]); actualAmount += arrStaked[0]; } else { //calculate reduction percentage // EX only staked 35 days of 60 // 60 - 35 = 25% reduction // 100 - 25% = 75% remaining (multiply by that / div 100) uint256 reducedAmount = arrStaked[0].mul(uint256(100).sub(daysRequiredStaked.sub(daysStaked))).div(100); settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, reducedAmount); IERC20(share).safeTransfer(address(ideaFund), arrStaked[0].sub(reducedAmount)); actualAmount += reducedAmount; } //Make sure this is actually 0ing out and saving to the struct arrStaked[0] = 0; arrStaked[1] = 0; } } emit WithdrawnWithReductionShare(msg.sender, actualAmount); } function withdrawControl(uint256 amount) public override onlyOneBlock stakerExists updateRewardWithdraw(msg.sender) { require(amount > 0, 'Boardroom: Cannot withdraw 0'); super.withdrawControl(amount); emit WithdrawControl(msg.sender, amount); } function claimReward() public updateRewardWithdraw(msg.sender) { uint256 reward = stakersShare[msg.sender].rewardEarned; reward += stakersControl[msg.sender].rewardEarned; if (reward > 0) { stakersShare[msg.sender].rewardEarned = 0; stakersControl[msg.sender].rewardEarned = 0; IERC20(control).safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } function allocateSeigniorage(uint256 amount) external onlyOneBlock onlyOperator { if(amount == 0) return; if(gettotalSupplyShare() == 0 && gettotalSupplyControl() == 0) return; uint256 shareValue = gettotalSupplyShare().mul(IOracle(theOracle).priceOf(share)); uint256 controlValue = gettotalSupplyControl().mul(IOracle(theOracle).priceOf(control)); uint256 totalStakedValue = shareValue + controlValue; uint percision = 9; uint256 rewardPerShareValue = amount.mul(shareValue.mul(10**percision).div(totalStakedValue)).div(10**percision); uint256 rewardPerControlValue = amount.mul(controlValue.mul(10**percision).div(totalStakedValue)).div(10**percision); if (rewardPerShareValue > 0) { uint256 prevRPS = getLatestShareSnapshot().rewardPerShare; uint256 nextRPS = prevRPS.add(rewardPerShareValue.mul(1e18).div(gettotalSupplyShare())); BoardSnapshotShare memory newSSnapshot = BoardSnapshotShare({ time: block.number, rewardReceived: amount, rewardPerShare: nextRPS }); boardShareHistory.push(newSSnapshot); } if (rewardPerControlValue > 0 ) { uint256 prevRPC = getLatestControlSnapshot().rewardPerControl; uint256 nextRPC = prevRPC.add(rewardPerControlValue.mul(1e18).div(gettotalSupplyControl())); BoardSnapshotControl memory newCSnapshot = BoardSnapshotControl({ time: block.number, rewardReceived: amount, rewardPerControl: nextRPC }); boardControlHistory.push(newCSnapshot); } IERC20(control).safeTransferFrom(msg.sender, address(this), amount); emit RewardAdded(msg.sender, amount); } function updateOracle(address newOracle) public onlyOwner { theOracle = newOracle; } function setIdeaFund(address newFund) public onlyOwner { ideaFund = newFund; } /* ========== EVENTS ========== */ event Staked(address indexed user, uint256 amount); event WithdrawControl(address indexed user, uint256 amount); event WithdrawnWithReductionShare(address indexed user, uint256 actualAmount); event RewardPaid(address indexed user, uint256 reward); event RewardAdded(address indexed user, uint256 reward); }
//import 'hardhat/console.sol';
LineComment
getStakedAmountsShare
function getStakedAmountsShare() public view returns (uint256[2][] memory earned) { StakingSeatShare memory seatS = stakersShare[msg.sender]; return seatS.stakingWhenQuatity; }
// Staking and the dates staked calculate the percentage they would forfeit if they withdraw now // be the warning
LineComment
v0.7.0+commit.9e61f92b
{ "func_code_index": [ 6115, 6327 ] }
56,245
Boardroom
/C/Coding/lfBTC-Seigniorage/contracts/Boardroom.sol
0x3223689b39db8a897a9a9f0907c8a75d42268787
Solidity
Boardroom
contract Boardroom is ShareWrapper, ContractGuard, Operator { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; /* ========== DATA STRUCTURES ========== */ //uint256[2][] is an array of [amount][timestamp] //used to handle the timelock of LIFT tokens struct StakingSeatShare { uint256 lastSnapshotIndex; uint256 rewardEarned; uint256[2][] stakingWhenQuatity; bool isEntity; } //used to handle the staking of CTRL tokens struct StakingSeatControl { uint256 lastSnapshotIndex; uint256 rewardEarned; bool isEntity; } struct BoardSnapshotShare { uint256 time; uint256 rewardReceived; uint256 rewardPerShare; } struct BoardSnapshotControl { uint256 time; uint256 rewardReceived; uint256 rewardPerControl; } /* ========== STATE VARIABLES ========== */ mapping(address => StakingSeatShare) private stakersShare; mapping(address => StakingSeatControl) private stakersControl; BoardSnapshotShare[] private boardShareHistory; BoardSnapshotControl[] private boardControlHistory; uint daysRequiredStaked = 90; // staking less than X days = X - Y reduction in withdrawl, Y = days staked address ideaFund; //Where the forfeited shares end up address theOracle; /* ========== CONSTRUCTOR ========== */ constructor(address _share, address _control, address _ideafund, address _theOracle) { share = _share; control = _control; ideaFund = _ideafund; theOracle = _theOracle; BoardSnapshotShare memory genesisSSnapshot = BoardSnapshotShare({ time: block.number, rewardReceived: 0, rewardPerShare: 0 }); boardShareHistory.push(genesisSSnapshot); BoardSnapshotControl memory genesisCSnapshot = BoardSnapshotControl({ time: block.number, rewardReceived: 0, rewardPerControl: 0 }); boardControlHistory.push(genesisCSnapshot); } /* ========== Modifiers =============== */ modifier stakerExists { require( getbalanceOfControl(msg.sender) > 0 || getbalanceOfShare(msg.sender) > 0, 'Boardroom: The director does not exist' ); _; } modifier updateRewardShare(address staker, uint256 amount) { if (staker != address(0)) { StakingSeatShare storage seatS = stakersShare[staker]; (seatS.rewardEarned, ) = earned(staker); seatS.lastSnapshotIndex = latestShareSnapshotIndex(); seatS.isEntity = true; //validate this is getting stored in the struct correctly if(amount > 0) { seatS.stakingWhenQuatity.push([amount, block.timestamp]); } stakersShare[staker] = seatS; } _; } modifier updateRewardControl(address staker, uint256 amount) { if (staker != address(0)) { StakingSeatControl memory seatC = stakersControl[staker]; (, seatC.rewardEarned) = earned(staker); seatC.lastSnapshotIndex= latestControlSnapshotIndex(); seatC.isEntity = true; stakersControl[staker] = seatC; } _; } modifier updateRewardWithdraw(address staker) { if (staker != address(0)) { StakingSeatShare memory seatS = stakersShare[staker]; StakingSeatControl memory seatC = stakersControl[staker]; (seatS.rewardEarned, seatC.rewardEarned) = earned(staker); seatS.lastSnapshotIndex = latestShareSnapshotIndex(); seatC.lastSnapshotIndex= latestControlSnapshotIndex(); seatS.isEntity = true; seatC.isEntity = true; stakersShare[staker] = seatS; stakersControl[staker] = seatC; } _; } /* ========== VIEW FUNCTIONS ========== */ // =========== Snapshot getters function latestShareSnapshotIndex() public view returns (uint256) { return boardShareHistory.length.sub(1); } function getLatestShareSnapshot() internal view returns (BoardSnapshotShare memory) { return boardShareHistory[latestShareSnapshotIndex()]; } function getLastShareSnapshotIndexOf(address staker) public view returns (uint256) { return stakersShare[staker].lastSnapshotIndex; } function getLastShareSnapshotOf(address staker) internal view returns (BoardSnapshotShare memory) { return boardShareHistory[getLastShareSnapshotIndexOf(staker)]; } // control getters function latestControlSnapshotIndex() internal view returns (uint256) { return boardControlHistory.length.sub(1); } function getLatestControlSnapshot() internal view returns (BoardSnapshotControl memory) { return boardControlHistory[latestControlSnapshotIndex()]; } function getLastControlSnapshotIndexOf(address staker) public view returns (uint256) { return stakersControl[staker].lastSnapshotIndex; } function getLastControlSnapshotOf(address staker) internal view returns (BoardSnapshotControl memory) { return boardControlHistory[getLastControlSnapshotIndexOf(staker)]; } // =========== Director getters function rewardPerShare() public view returns (uint256) { return getLatestShareSnapshot().rewardPerShare; } function rewardPerControl() public view returns (uint256) { return getLatestControlSnapshot().rewardPerControl; } // Staking and the dates staked calculate the percentage they would forfeit if they withdraw now // be the warning function getStakedAmountsShare() public view returns (uint256[2][] memory earned) { StakingSeatShare memory seatS = stakersShare[msg.sender]; return seatS.stakingWhenQuatity; } function earned(address staker) public view returns (uint256, uint256) { uint256 latestRPS = getLatestShareSnapshot().rewardPerShare; uint256 storedRPS = getLastShareSnapshotOf(staker).rewardPerShare; uint256 latestRPC = getLatestControlSnapshot().rewardPerControl; uint256 storedRPC = getLastControlSnapshotOf(staker).rewardPerControl; return (getbalanceOfShare(staker).mul(latestRPS.sub(storedRPS)).div(1e18).add(stakersShare[staker].rewardEarned), getbalanceOfControl(staker).mul(latestRPC.sub(storedRPC)).div(1e18).add(stakersControl[staker].rewardEarned)); } /* ========== MUTATIVE FUNCTIONS ========== */ function stakeShare(uint256 amount) public override onlyOneBlock { require(amount > 0, 'Boardroom: Cannot stake 0'); stakeShareForThirdParty(msg.sender, msg.sender,amount); emit Staked(msg.sender, amount); } function stakeShareForThirdParty(address staker, address from,uint256 amount) public override onlyOneBlock updateRewardShare(staker, amount) { require(amount > 0, 'Boardroom: Cannot stake 0'); super.stakeShareForThirdParty(staker, from, amount); emit Staked(from, amount); } function stakeControl(uint256 amount) public override onlyOneBlock { require(amount > 0, 'Boardroom: Cannot stake 0'); stakeControlForThirdParty(msg.sender, msg.sender, amount); emit Staked(msg.sender, amount); } function stakeControlForThirdParty(address staker, address from, uint256 amount) public override onlyOneBlock updateRewardControl(staker, amount) { require(amount > 0, 'Boardroom: Cannot stake 0'); super.stakeControlForThirdParty(staker, from, amount); emit Staked(staker, amount); } // this function withdraws all of your LIFT tokens regardless of timestamp // using this function could lead to significant reductions if claimed LIFT function withdrawShareDontCallMeUnlessYouAreCertain() public onlyOneBlock stakerExists updateRewardWithdraw(msg.sender) { uint256 actualAmount = 0; require(getbalanceOfShare(msg.sender) > 0, 'Boardroom: Cannot withdraw 0'); StakingSeatShare storage seatS = stakersShare[msg.sender]; //forloop that iterates on the stakings and determines the reduction if any before creating a final amount for withdrawl for (uint256 i = 0; i < seatS.stakingWhenQuatity.length; i++) { uint256[2] storage arrStaked = seatS.stakingWhenQuatity[i]; uint daysStaked = (block.timestamp - arrStaked[1]) / 60 / 60 / 24; // = Y Days if (daysStaked >= daysRequiredStaked){ settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, arrStaked[0]); actualAmount += arrStaked[0]; } else { //calculate reduction percentage // EX only staked 35 days of 60 // 60 - 35 = 25% reduction // 100 - 25% = 75% remaining (multiply by that / div 100) uint256 reducedAmount = arrStaked[0].mul(uint256(100).sub(daysRequiredStaked.sub(daysStaked))).div(100); settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, reducedAmount); IERC20(share).safeTransfer(address(ideaFund), arrStaked[0].sub(reducedAmount)); actualAmount += reducedAmount; } //Make sure this is actually 0ing out and saving to the struct arrStaked[0] = 0; arrStaked[1] = 0; } emit WithdrawnWithReductionShare(msg.sender, actualAmount); } // The withdrawShare function with a timestamp input should take that data right out of the below // and feed it back to withdraw function withdrawShare(uint256 stakedTimeStamp) public onlyOneBlock stakerExists updateRewardWithdraw(msg.sender) { uint256 amount = 0; uint256 actualAmount = 0; StakingSeatShare storage seatS = stakersShare[msg.sender]; //forloop that iterates on the stakings and determines the reduction if any before creating a final amount for withdrawl for (uint256 i = 0; i < seatS.stakingWhenQuatity.length; i++) { uint256[2] storage arrStaked = seatS.stakingWhenQuatity[i]; if(arrStaked[1] == stakedTimeStamp) { amount = arrStaked[0]; uint daysStaked = (block.timestamp - arrStaked[1]) / 60 / 60 / 24; // = Y Days //console.log("days staked", daysStaked); if (daysStaked >= daysRequiredStaked){ settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, arrStaked[0]); actualAmount += arrStaked[0]; } else { //calculate reduction percentage // EX only staked 35 days of 60 // 60 - 35 = 25% reduction // 100 - 25% = 75% remaining (multiply by that / div 100) uint256 reducedAmount = arrStaked[0].mul(uint256(100).sub(daysRequiredStaked.sub(daysStaked))).div(100); settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, reducedAmount); IERC20(share).safeTransfer(address(ideaFund), arrStaked[0].sub(reducedAmount)); actualAmount += reducedAmount; } //Make sure this is actually 0ing out and saving to the struct arrStaked[0] = 0; arrStaked[1] = 0; } } emit WithdrawnWithReductionShare(msg.sender, actualAmount); } function withdrawControl(uint256 amount) public override onlyOneBlock stakerExists updateRewardWithdraw(msg.sender) { require(amount > 0, 'Boardroom: Cannot withdraw 0'); super.withdrawControl(amount); emit WithdrawControl(msg.sender, amount); } function claimReward() public updateRewardWithdraw(msg.sender) { uint256 reward = stakersShare[msg.sender].rewardEarned; reward += stakersControl[msg.sender].rewardEarned; if (reward > 0) { stakersShare[msg.sender].rewardEarned = 0; stakersControl[msg.sender].rewardEarned = 0; IERC20(control).safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } function allocateSeigniorage(uint256 amount) external onlyOneBlock onlyOperator { if(amount == 0) return; if(gettotalSupplyShare() == 0 && gettotalSupplyControl() == 0) return; uint256 shareValue = gettotalSupplyShare().mul(IOracle(theOracle).priceOf(share)); uint256 controlValue = gettotalSupplyControl().mul(IOracle(theOracle).priceOf(control)); uint256 totalStakedValue = shareValue + controlValue; uint percision = 9; uint256 rewardPerShareValue = amount.mul(shareValue.mul(10**percision).div(totalStakedValue)).div(10**percision); uint256 rewardPerControlValue = amount.mul(controlValue.mul(10**percision).div(totalStakedValue)).div(10**percision); if (rewardPerShareValue > 0) { uint256 prevRPS = getLatestShareSnapshot().rewardPerShare; uint256 nextRPS = prevRPS.add(rewardPerShareValue.mul(1e18).div(gettotalSupplyShare())); BoardSnapshotShare memory newSSnapshot = BoardSnapshotShare({ time: block.number, rewardReceived: amount, rewardPerShare: nextRPS }); boardShareHistory.push(newSSnapshot); } if (rewardPerControlValue > 0 ) { uint256 prevRPC = getLatestControlSnapshot().rewardPerControl; uint256 nextRPC = prevRPC.add(rewardPerControlValue.mul(1e18).div(gettotalSupplyControl())); BoardSnapshotControl memory newCSnapshot = BoardSnapshotControl({ time: block.number, rewardReceived: amount, rewardPerControl: nextRPC }); boardControlHistory.push(newCSnapshot); } IERC20(control).safeTransferFrom(msg.sender, address(this), amount); emit RewardAdded(msg.sender, amount); } function updateOracle(address newOracle) public onlyOwner { theOracle = newOracle; } function setIdeaFund(address newFund) public onlyOwner { ideaFund = newFund; } /* ========== EVENTS ========== */ event Staked(address indexed user, uint256 amount); event WithdrawControl(address indexed user, uint256 amount); event WithdrawnWithReductionShare(address indexed user, uint256 actualAmount); event RewardPaid(address indexed user, uint256 reward); event RewardAdded(address indexed user, uint256 reward); }
//import 'hardhat/console.sol';
LineComment
stakeShare
function stakeShare(uint256 amount) public override onlyOneBlock { require(amount > 0, 'Boardroom: Cannot stake 0'); stakeShareForThirdParty(msg.sender, msg.sender,amount); emit Staked(msg.sender, amount); }
/* ========== MUTATIVE FUNCTIONS ========== */
Comment
v0.7.0+commit.9e61f92b
{ "func_code_index": [ 7035, 7311 ] }
56,246
Boardroom
/C/Coding/lfBTC-Seigniorage/contracts/Boardroom.sol
0x3223689b39db8a897a9a9f0907c8a75d42268787
Solidity
Boardroom
contract Boardroom is ShareWrapper, ContractGuard, Operator { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; /* ========== DATA STRUCTURES ========== */ //uint256[2][] is an array of [amount][timestamp] //used to handle the timelock of LIFT tokens struct StakingSeatShare { uint256 lastSnapshotIndex; uint256 rewardEarned; uint256[2][] stakingWhenQuatity; bool isEntity; } //used to handle the staking of CTRL tokens struct StakingSeatControl { uint256 lastSnapshotIndex; uint256 rewardEarned; bool isEntity; } struct BoardSnapshotShare { uint256 time; uint256 rewardReceived; uint256 rewardPerShare; } struct BoardSnapshotControl { uint256 time; uint256 rewardReceived; uint256 rewardPerControl; } /* ========== STATE VARIABLES ========== */ mapping(address => StakingSeatShare) private stakersShare; mapping(address => StakingSeatControl) private stakersControl; BoardSnapshotShare[] private boardShareHistory; BoardSnapshotControl[] private boardControlHistory; uint daysRequiredStaked = 90; // staking less than X days = X - Y reduction in withdrawl, Y = days staked address ideaFund; //Where the forfeited shares end up address theOracle; /* ========== CONSTRUCTOR ========== */ constructor(address _share, address _control, address _ideafund, address _theOracle) { share = _share; control = _control; ideaFund = _ideafund; theOracle = _theOracle; BoardSnapshotShare memory genesisSSnapshot = BoardSnapshotShare({ time: block.number, rewardReceived: 0, rewardPerShare: 0 }); boardShareHistory.push(genesisSSnapshot); BoardSnapshotControl memory genesisCSnapshot = BoardSnapshotControl({ time: block.number, rewardReceived: 0, rewardPerControl: 0 }); boardControlHistory.push(genesisCSnapshot); } /* ========== Modifiers =============== */ modifier stakerExists { require( getbalanceOfControl(msg.sender) > 0 || getbalanceOfShare(msg.sender) > 0, 'Boardroom: The director does not exist' ); _; } modifier updateRewardShare(address staker, uint256 amount) { if (staker != address(0)) { StakingSeatShare storage seatS = stakersShare[staker]; (seatS.rewardEarned, ) = earned(staker); seatS.lastSnapshotIndex = latestShareSnapshotIndex(); seatS.isEntity = true; //validate this is getting stored in the struct correctly if(amount > 0) { seatS.stakingWhenQuatity.push([amount, block.timestamp]); } stakersShare[staker] = seatS; } _; } modifier updateRewardControl(address staker, uint256 amount) { if (staker != address(0)) { StakingSeatControl memory seatC = stakersControl[staker]; (, seatC.rewardEarned) = earned(staker); seatC.lastSnapshotIndex= latestControlSnapshotIndex(); seatC.isEntity = true; stakersControl[staker] = seatC; } _; } modifier updateRewardWithdraw(address staker) { if (staker != address(0)) { StakingSeatShare memory seatS = stakersShare[staker]; StakingSeatControl memory seatC = stakersControl[staker]; (seatS.rewardEarned, seatC.rewardEarned) = earned(staker); seatS.lastSnapshotIndex = latestShareSnapshotIndex(); seatC.lastSnapshotIndex= latestControlSnapshotIndex(); seatS.isEntity = true; seatC.isEntity = true; stakersShare[staker] = seatS; stakersControl[staker] = seatC; } _; } /* ========== VIEW FUNCTIONS ========== */ // =========== Snapshot getters function latestShareSnapshotIndex() public view returns (uint256) { return boardShareHistory.length.sub(1); } function getLatestShareSnapshot() internal view returns (BoardSnapshotShare memory) { return boardShareHistory[latestShareSnapshotIndex()]; } function getLastShareSnapshotIndexOf(address staker) public view returns (uint256) { return stakersShare[staker].lastSnapshotIndex; } function getLastShareSnapshotOf(address staker) internal view returns (BoardSnapshotShare memory) { return boardShareHistory[getLastShareSnapshotIndexOf(staker)]; } // control getters function latestControlSnapshotIndex() internal view returns (uint256) { return boardControlHistory.length.sub(1); } function getLatestControlSnapshot() internal view returns (BoardSnapshotControl memory) { return boardControlHistory[latestControlSnapshotIndex()]; } function getLastControlSnapshotIndexOf(address staker) public view returns (uint256) { return stakersControl[staker].lastSnapshotIndex; } function getLastControlSnapshotOf(address staker) internal view returns (BoardSnapshotControl memory) { return boardControlHistory[getLastControlSnapshotIndexOf(staker)]; } // =========== Director getters function rewardPerShare() public view returns (uint256) { return getLatestShareSnapshot().rewardPerShare; } function rewardPerControl() public view returns (uint256) { return getLatestControlSnapshot().rewardPerControl; } // Staking and the dates staked calculate the percentage they would forfeit if they withdraw now // be the warning function getStakedAmountsShare() public view returns (uint256[2][] memory earned) { StakingSeatShare memory seatS = stakersShare[msg.sender]; return seatS.stakingWhenQuatity; } function earned(address staker) public view returns (uint256, uint256) { uint256 latestRPS = getLatestShareSnapshot().rewardPerShare; uint256 storedRPS = getLastShareSnapshotOf(staker).rewardPerShare; uint256 latestRPC = getLatestControlSnapshot().rewardPerControl; uint256 storedRPC = getLastControlSnapshotOf(staker).rewardPerControl; return (getbalanceOfShare(staker).mul(latestRPS.sub(storedRPS)).div(1e18).add(stakersShare[staker].rewardEarned), getbalanceOfControl(staker).mul(latestRPC.sub(storedRPC)).div(1e18).add(stakersControl[staker].rewardEarned)); } /* ========== MUTATIVE FUNCTIONS ========== */ function stakeShare(uint256 amount) public override onlyOneBlock { require(amount > 0, 'Boardroom: Cannot stake 0'); stakeShareForThirdParty(msg.sender, msg.sender,amount); emit Staked(msg.sender, amount); } function stakeShareForThirdParty(address staker, address from,uint256 amount) public override onlyOneBlock updateRewardShare(staker, amount) { require(amount > 0, 'Boardroom: Cannot stake 0'); super.stakeShareForThirdParty(staker, from, amount); emit Staked(from, amount); } function stakeControl(uint256 amount) public override onlyOneBlock { require(amount > 0, 'Boardroom: Cannot stake 0'); stakeControlForThirdParty(msg.sender, msg.sender, amount); emit Staked(msg.sender, amount); } function stakeControlForThirdParty(address staker, address from, uint256 amount) public override onlyOneBlock updateRewardControl(staker, amount) { require(amount > 0, 'Boardroom: Cannot stake 0'); super.stakeControlForThirdParty(staker, from, amount); emit Staked(staker, amount); } // this function withdraws all of your LIFT tokens regardless of timestamp // using this function could lead to significant reductions if claimed LIFT function withdrawShareDontCallMeUnlessYouAreCertain() public onlyOneBlock stakerExists updateRewardWithdraw(msg.sender) { uint256 actualAmount = 0; require(getbalanceOfShare(msg.sender) > 0, 'Boardroom: Cannot withdraw 0'); StakingSeatShare storage seatS = stakersShare[msg.sender]; //forloop that iterates on the stakings and determines the reduction if any before creating a final amount for withdrawl for (uint256 i = 0; i < seatS.stakingWhenQuatity.length; i++) { uint256[2] storage arrStaked = seatS.stakingWhenQuatity[i]; uint daysStaked = (block.timestamp - arrStaked[1]) / 60 / 60 / 24; // = Y Days if (daysStaked >= daysRequiredStaked){ settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, arrStaked[0]); actualAmount += arrStaked[0]; } else { //calculate reduction percentage // EX only staked 35 days of 60 // 60 - 35 = 25% reduction // 100 - 25% = 75% remaining (multiply by that / div 100) uint256 reducedAmount = arrStaked[0].mul(uint256(100).sub(daysRequiredStaked.sub(daysStaked))).div(100); settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, reducedAmount); IERC20(share).safeTransfer(address(ideaFund), arrStaked[0].sub(reducedAmount)); actualAmount += reducedAmount; } //Make sure this is actually 0ing out and saving to the struct arrStaked[0] = 0; arrStaked[1] = 0; } emit WithdrawnWithReductionShare(msg.sender, actualAmount); } // The withdrawShare function with a timestamp input should take that data right out of the below // and feed it back to withdraw function withdrawShare(uint256 stakedTimeStamp) public onlyOneBlock stakerExists updateRewardWithdraw(msg.sender) { uint256 amount = 0; uint256 actualAmount = 0; StakingSeatShare storage seatS = stakersShare[msg.sender]; //forloop that iterates on the stakings and determines the reduction if any before creating a final amount for withdrawl for (uint256 i = 0; i < seatS.stakingWhenQuatity.length; i++) { uint256[2] storage arrStaked = seatS.stakingWhenQuatity[i]; if(arrStaked[1] == stakedTimeStamp) { amount = arrStaked[0]; uint daysStaked = (block.timestamp - arrStaked[1]) / 60 / 60 / 24; // = Y Days //console.log("days staked", daysStaked); if (daysStaked >= daysRequiredStaked){ settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, arrStaked[0]); actualAmount += arrStaked[0]; } else { //calculate reduction percentage // EX only staked 35 days of 60 // 60 - 35 = 25% reduction // 100 - 25% = 75% remaining (multiply by that / div 100) uint256 reducedAmount = arrStaked[0].mul(uint256(100).sub(daysRequiredStaked.sub(daysStaked))).div(100); settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, reducedAmount); IERC20(share).safeTransfer(address(ideaFund), arrStaked[0].sub(reducedAmount)); actualAmount += reducedAmount; } //Make sure this is actually 0ing out and saving to the struct arrStaked[0] = 0; arrStaked[1] = 0; } } emit WithdrawnWithReductionShare(msg.sender, actualAmount); } function withdrawControl(uint256 amount) public override onlyOneBlock stakerExists updateRewardWithdraw(msg.sender) { require(amount > 0, 'Boardroom: Cannot withdraw 0'); super.withdrawControl(amount); emit WithdrawControl(msg.sender, amount); } function claimReward() public updateRewardWithdraw(msg.sender) { uint256 reward = stakersShare[msg.sender].rewardEarned; reward += stakersControl[msg.sender].rewardEarned; if (reward > 0) { stakersShare[msg.sender].rewardEarned = 0; stakersControl[msg.sender].rewardEarned = 0; IERC20(control).safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } function allocateSeigniorage(uint256 amount) external onlyOneBlock onlyOperator { if(amount == 0) return; if(gettotalSupplyShare() == 0 && gettotalSupplyControl() == 0) return; uint256 shareValue = gettotalSupplyShare().mul(IOracle(theOracle).priceOf(share)); uint256 controlValue = gettotalSupplyControl().mul(IOracle(theOracle).priceOf(control)); uint256 totalStakedValue = shareValue + controlValue; uint percision = 9; uint256 rewardPerShareValue = amount.mul(shareValue.mul(10**percision).div(totalStakedValue)).div(10**percision); uint256 rewardPerControlValue = amount.mul(controlValue.mul(10**percision).div(totalStakedValue)).div(10**percision); if (rewardPerShareValue > 0) { uint256 prevRPS = getLatestShareSnapshot().rewardPerShare; uint256 nextRPS = prevRPS.add(rewardPerShareValue.mul(1e18).div(gettotalSupplyShare())); BoardSnapshotShare memory newSSnapshot = BoardSnapshotShare({ time: block.number, rewardReceived: amount, rewardPerShare: nextRPS }); boardShareHistory.push(newSSnapshot); } if (rewardPerControlValue > 0 ) { uint256 prevRPC = getLatestControlSnapshot().rewardPerControl; uint256 nextRPC = prevRPC.add(rewardPerControlValue.mul(1e18).div(gettotalSupplyControl())); BoardSnapshotControl memory newCSnapshot = BoardSnapshotControl({ time: block.number, rewardReceived: amount, rewardPerControl: nextRPC }); boardControlHistory.push(newCSnapshot); } IERC20(control).safeTransferFrom(msg.sender, address(this), amount); emit RewardAdded(msg.sender, amount); } function updateOracle(address newOracle) public onlyOwner { theOracle = newOracle; } function setIdeaFund(address newFund) public onlyOwner { ideaFund = newFund; } /* ========== EVENTS ========== */ event Staked(address indexed user, uint256 amount); event WithdrawControl(address indexed user, uint256 amount); event WithdrawnWithReductionShare(address indexed user, uint256 actualAmount); event RewardPaid(address indexed user, uint256 reward); event RewardAdded(address indexed user, uint256 reward); }
//import 'hardhat/console.sol';
LineComment
withdrawShareDontCallMeUnlessYouAreCertain
function withdrawShareDontCallMeUnlessYouAreCertain() public onlyOneBlock stakerExists updateRewardWithdraw(msg.sender) { uint256 actualAmount = 0; require(getbalanceOfShare(msg.sender) > 0, 'Boardroom: Cannot withdraw 0'); StakingSeatShare storage seatS = stakersShare[msg.sender]; //forloop that iterates on the stakings and determines the reduction if any before creating a final amount for withdrawl for (uint256 i = 0; i < seatS.stakingWhenQuatity.length; i++) { uint256[2] storage arrStaked = seatS.stakingWhenQuatity[i]; uint daysStaked = (block.timestamp - arrStaked[1]) / 60 / 60 / 24; // = Y Days if (daysStaked >= daysRequiredStaked){ settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, arrStaked[0]); actualAmount += arrStaked[0]; } else { //calculate reduction percentage // EX only staked 35 days of 60 // 60 - 35 = 25% reduction // 100 - 25% = 75% remaining (multiply by that / div 100) uint256 reducedAmount = arrStaked[0].mul(uint256(100).sub(daysRequiredStaked.sub(daysStaked))).div(100); settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, reducedAmount); IERC20(share).safeTransfer(address(ideaFund), arrStaked[0].sub(reducedAmount)); actualAmount += reducedAmount; } //Make sure this is actually 0ing out and saving to the struct arrStaked[0] = 0; arrStaked[1] = 0; } emit WithdrawnWithReductionShare(msg.sender, actualAmount); }
// this function withdraws all of your LIFT tokens regardless of timestamp // using this function could lead to significant reductions if claimed LIFT
LineComment
v0.7.0+commit.9e61f92b
{ "func_code_index": [ 8499, 10591 ] }
56,247
Boardroom
/C/Coding/lfBTC-Seigniorage/contracts/Boardroom.sol
0x3223689b39db8a897a9a9f0907c8a75d42268787
Solidity
Boardroom
contract Boardroom is ShareWrapper, ContractGuard, Operator { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; /* ========== DATA STRUCTURES ========== */ //uint256[2][] is an array of [amount][timestamp] //used to handle the timelock of LIFT tokens struct StakingSeatShare { uint256 lastSnapshotIndex; uint256 rewardEarned; uint256[2][] stakingWhenQuatity; bool isEntity; } //used to handle the staking of CTRL tokens struct StakingSeatControl { uint256 lastSnapshotIndex; uint256 rewardEarned; bool isEntity; } struct BoardSnapshotShare { uint256 time; uint256 rewardReceived; uint256 rewardPerShare; } struct BoardSnapshotControl { uint256 time; uint256 rewardReceived; uint256 rewardPerControl; } /* ========== STATE VARIABLES ========== */ mapping(address => StakingSeatShare) private stakersShare; mapping(address => StakingSeatControl) private stakersControl; BoardSnapshotShare[] private boardShareHistory; BoardSnapshotControl[] private boardControlHistory; uint daysRequiredStaked = 90; // staking less than X days = X - Y reduction in withdrawl, Y = days staked address ideaFund; //Where the forfeited shares end up address theOracle; /* ========== CONSTRUCTOR ========== */ constructor(address _share, address _control, address _ideafund, address _theOracle) { share = _share; control = _control; ideaFund = _ideafund; theOracle = _theOracle; BoardSnapshotShare memory genesisSSnapshot = BoardSnapshotShare({ time: block.number, rewardReceived: 0, rewardPerShare: 0 }); boardShareHistory.push(genesisSSnapshot); BoardSnapshotControl memory genesisCSnapshot = BoardSnapshotControl({ time: block.number, rewardReceived: 0, rewardPerControl: 0 }); boardControlHistory.push(genesisCSnapshot); } /* ========== Modifiers =============== */ modifier stakerExists { require( getbalanceOfControl(msg.sender) > 0 || getbalanceOfShare(msg.sender) > 0, 'Boardroom: The director does not exist' ); _; } modifier updateRewardShare(address staker, uint256 amount) { if (staker != address(0)) { StakingSeatShare storage seatS = stakersShare[staker]; (seatS.rewardEarned, ) = earned(staker); seatS.lastSnapshotIndex = latestShareSnapshotIndex(); seatS.isEntity = true; //validate this is getting stored in the struct correctly if(amount > 0) { seatS.stakingWhenQuatity.push([amount, block.timestamp]); } stakersShare[staker] = seatS; } _; } modifier updateRewardControl(address staker, uint256 amount) { if (staker != address(0)) { StakingSeatControl memory seatC = stakersControl[staker]; (, seatC.rewardEarned) = earned(staker); seatC.lastSnapshotIndex= latestControlSnapshotIndex(); seatC.isEntity = true; stakersControl[staker] = seatC; } _; } modifier updateRewardWithdraw(address staker) { if (staker != address(0)) { StakingSeatShare memory seatS = stakersShare[staker]; StakingSeatControl memory seatC = stakersControl[staker]; (seatS.rewardEarned, seatC.rewardEarned) = earned(staker); seatS.lastSnapshotIndex = latestShareSnapshotIndex(); seatC.lastSnapshotIndex= latestControlSnapshotIndex(); seatS.isEntity = true; seatC.isEntity = true; stakersShare[staker] = seatS; stakersControl[staker] = seatC; } _; } /* ========== VIEW FUNCTIONS ========== */ // =========== Snapshot getters function latestShareSnapshotIndex() public view returns (uint256) { return boardShareHistory.length.sub(1); } function getLatestShareSnapshot() internal view returns (BoardSnapshotShare memory) { return boardShareHistory[latestShareSnapshotIndex()]; } function getLastShareSnapshotIndexOf(address staker) public view returns (uint256) { return stakersShare[staker].lastSnapshotIndex; } function getLastShareSnapshotOf(address staker) internal view returns (BoardSnapshotShare memory) { return boardShareHistory[getLastShareSnapshotIndexOf(staker)]; } // control getters function latestControlSnapshotIndex() internal view returns (uint256) { return boardControlHistory.length.sub(1); } function getLatestControlSnapshot() internal view returns (BoardSnapshotControl memory) { return boardControlHistory[latestControlSnapshotIndex()]; } function getLastControlSnapshotIndexOf(address staker) public view returns (uint256) { return stakersControl[staker].lastSnapshotIndex; } function getLastControlSnapshotOf(address staker) internal view returns (BoardSnapshotControl memory) { return boardControlHistory[getLastControlSnapshotIndexOf(staker)]; } // =========== Director getters function rewardPerShare() public view returns (uint256) { return getLatestShareSnapshot().rewardPerShare; } function rewardPerControl() public view returns (uint256) { return getLatestControlSnapshot().rewardPerControl; } // Staking and the dates staked calculate the percentage they would forfeit if they withdraw now // be the warning function getStakedAmountsShare() public view returns (uint256[2][] memory earned) { StakingSeatShare memory seatS = stakersShare[msg.sender]; return seatS.stakingWhenQuatity; } function earned(address staker) public view returns (uint256, uint256) { uint256 latestRPS = getLatestShareSnapshot().rewardPerShare; uint256 storedRPS = getLastShareSnapshotOf(staker).rewardPerShare; uint256 latestRPC = getLatestControlSnapshot().rewardPerControl; uint256 storedRPC = getLastControlSnapshotOf(staker).rewardPerControl; return (getbalanceOfShare(staker).mul(latestRPS.sub(storedRPS)).div(1e18).add(stakersShare[staker].rewardEarned), getbalanceOfControl(staker).mul(latestRPC.sub(storedRPC)).div(1e18).add(stakersControl[staker].rewardEarned)); } /* ========== MUTATIVE FUNCTIONS ========== */ function stakeShare(uint256 amount) public override onlyOneBlock { require(amount > 0, 'Boardroom: Cannot stake 0'); stakeShareForThirdParty(msg.sender, msg.sender,amount); emit Staked(msg.sender, amount); } function stakeShareForThirdParty(address staker, address from,uint256 amount) public override onlyOneBlock updateRewardShare(staker, amount) { require(amount > 0, 'Boardroom: Cannot stake 0'); super.stakeShareForThirdParty(staker, from, amount); emit Staked(from, amount); } function stakeControl(uint256 amount) public override onlyOneBlock { require(amount > 0, 'Boardroom: Cannot stake 0'); stakeControlForThirdParty(msg.sender, msg.sender, amount); emit Staked(msg.sender, amount); } function stakeControlForThirdParty(address staker, address from, uint256 amount) public override onlyOneBlock updateRewardControl(staker, amount) { require(amount > 0, 'Boardroom: Cannot stake 0'); super.stakeControlForThirdParty(staker, from, amount); emit Staked(staker, amount); } // this function withdraws all of your LIFT tokens regardless of timestamp // using this function could lead to significant reductions if claimed LIFT function withdrawShareDontCallMeUnlessYouAreCertain() public onlyOneBlock stakerExists updateRewardWithdraw(msg.sender) { uint256 actualAmount = 0; require(getbalanceOfShare(msg.sender) > 0, 'Boardroom: Cannot withdraw 0'); StakingSeatShare storage seatS = stakersShare[msg.sender]; //forloop that iterates on the stakings and determines the reduction if any before creating a final amount for withdrawl for (uint256 i = 0; i < seatS.stakingWhenQuatity.length; i++) { uint256[2] storage arrStaked = seatS.stakingWhenQuatity[i]; uint daysStaked = (block.timestamp - arrStaked[1]) / 60 / 60 / 24; // = Y Days if (daysStaked >= daysRequiredStaked){ settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, arrStaked[0]); actualAmount += arrStaked[0]; } else { //calculate reduction percentage // EX only staked 35 days of 60 // 60 - 35 = 25% reduction // 100 - 25% = 75% remaining (multiply by that / div 100) uint256 reducedAmount = arrStaked[0].mul(uint256(100).sub(daysRequiredStaked.sub(daysStaked))).div(100); settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, reducedAmount); IERC20(share).safeTransfer(address(ideaFund), arrStaked[0].sub(reducedAmount)); actualAmount += reducedAmount; } //Make sure this is actually 0ing out and saving to the struct arrStaked[0] = 0; arrStaked[1] = 0; } emit WithdrawnWithReductionShare(msg.sender, actualAmount); } // The withdrawShare function with a timestamp input should take that data right out of the below // and feed it back to withdraw function withdrawShare(uint256 stakedTimeStamp) public onlyOneBlock stakerExists updateRewardWithdraw(msg.sender) { uint256 amount = 0; uint256 actualAmount = 0; StakingSeatShare storage seatS = stakersShare[msg.sender]; //forloop that iterates on the stakings and determines the reduction if any before creating a final amount for withdrawl for (uint256 i = 0; i < seatS.stakingWhenQuatity.length; i++) { uint256[2] storage arrStaked = seatS.stakingWhenQuatity[i]; if(arrStaked[1] == stakedTimeStamp) { amount = arrStaked[0]; uint daysStaked = (block.timestamp - arrStaked[1]) / 60 / 60 / 24; // = Y Days //console.log("days staked", daysStaked); if (daysStaked >= daysRequiredStaked){ settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, arrStaked[0]); actualAmount += arrStaked[0]; } else { //calculate reduction percentage // EX only staked 35 days of 60 // 60 - 35 = 25% reduction // 100 - 25% = 75% remaining (multiply by that / div 100) uint256 reducedAmount = arrStaked[0].mul(uint256(100).sub(daysRequiredStaked.sub(daysStaked))).div(100); settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, reducedAmount); IERC20(share).safeTransfer(address(ideaFund), arrStaked[0].sub(reducedAmount)); actualAmount += reducedAmount; } //Make sure this is actually 0ing out and saving to the struct arrStaked[0] = 0; arrStaked[1] = 0; } } emit WithdrawnWithReductionShare(msg.sender, actualAmount); } function withdrawControl(uint256 amount) public override onlyOneBlock stakerExists updateRewardWithdraw(msg.sender) { require(amount > 0, 'Boardroom: Cannot withdraw 0'); super.withdrawControl(amount); emit WithdrawControl(msg.sender, amount); } function claimReward() public updateRewardWithdraw(msg.sender) { uint256 reward = stakersShare[msg.sender].rewardEarned; reward += stakersControl[msg.sender].rewardEarned; if (reward > 0) { stakersShare[msg.sender].rewardEarned = 0; stakersControl[msg.sender].rewardEarned = 0; IERC20(control).safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } function allocateSeigniorage(uint256 amount) external onlyOneBlock onlyOperator { if(amount == 0) return; if(gettotalSupplyShare() == 0 && gettotalSupplyControl() == 0) return; uint256 shareValue = gettotalSupplyShare().mul(IOracle(theOracle).priceOf(share)); uint256 controlValue = gettotalSupplyControl().mul(IOracle(theOracle).priceOf(control)); uint256 totalStakedValue = shareValue + controlValue; uint percision = 9; uint256 rewardPerShareValue = amount.mul(shareValue.mul(10**percision).div(totalStakedValue)).div(10**percision); uint256 rewardPerControlValue = amount.mul(controlValue.mul(10**percision).div(totalStakedValue)).div(10**percision); if (rewardPerShareValue > 0) { uint256 prevRPS = getLatestShareSnapshot().rewardPerShare; uint256 nextRPS = prevRPS.add(rewardPerShareValue.mul(1e18).div(gettotalSupplyShare())); BoardSnapshotShare memory newSSnapshot = BoardSnapshotShare({ time: block.number, rewardReceived: amount, rewardPerShare: nextRPS }); boardShareHistory.push(newSSnapshot); } if (rewardPerControlValue > 0 ) { uint256 prevRPC = getLatestControlSnapshot().rewardPerControl; uint256 nextRPC = prevRPC.add(rewardPerControlValue.mul(1e18).div(gettotalSupplyControl())); BoardSnapshotControl memory newCSnapshot = BoardSnapshotControl({ time: block.number, rewardReceived: amount, rewardPerControl: nextRPC }); boardControlHistory.push(newCSnapshot); } IERC20(control).safeTransferFrom(msg.sender, address(this), amount); emit RewardAdded(msg.sender, amount); } function updateOracle(address newOracle) public onlyOwner { theOracle = newOracle; } function setIdeaFund(address newFund) public onlyOwner { ideaFund = newFund; } /* ========== EVENTS ========== */ event Staked(address indexed user, uint256 amount); event WithdrawControl(address indexed user, uint256 amount); event WithdrawnWithReductionShare(address indexed user, uint256 actualAmount); event RewardPaid(address indexed user, uint256 reward); event RewardAdded(address indexed user, uint256 reward); }
//import 'hardhat/console.sol';
LineComment
withdrawShare
function withdrawShare(uint256 stakedTimeStamp) public onlyOneBlock stakerExists updateRewardWithdraw(msg.sender) { uint256 amount = 0; uint256 actualAmount = 0; StakingSeatShare storage seatS = stakersShare[msg.sender]; //forloop that iterates on the stakings and determines the reduction if any before creating a final amount for withdrawl for (uint256 i = 0; i < seatS.stakingWhenQuatity.length; i++) { uint256[2] storage arrStaked = seatS.stakingWhenQuatity[i]; if(arrStaked[1] == stakedTimeStamp) { amount = arrStaked[0]; uint daysStaked = (block.timestamp - arrStaked[1]) / 60 / 60 / 24; // = Y Days //console.log("days staked", daysStaked); if (daysStaked >= daysRequiredStaked){ settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, arrStaked[0]); actualAmount += arrStaked[0]; } else { //calculate reduction percentage // EX only staked 35 days of 60 // 60 - 35 = 25% reduction // 100 - 25% = 75% remaining (multiply by that / div 100) uint256 reducedAmount = arrStaked[0].mul(uint256(100).sub(daysRequiredStaked.sub(daysStaked))).div(100); settotalSupplyShare(gettotalSupplyShare().sub(arrStaked[0])); setbalanceOfShare(msg.sender, getbalanceOfShare(msg.sender).sub(arrStaked[0])); IERC20(share).safeTransfer(msg.sender, reducedAmount); IERC20(share).safeTransfer(address(ideaFund), arrStaked[0].sub(reducedAmount)); actualAmount += reducedAmount; } //Make sure this is actually 0ing out and saving to the struct arrStaked[0] = 0; arrStaked[1] = 0; } } emit WithdrawnWithReductionShare(msg.sender, actualAmount); }
// The withdrawShare function with a timestamp input should take that data right out of the below // and feed it back to withdraw
LineComment
v0.7.0+commit.9e61f92b
{ "func_code_index": [ 10735, 13030 ] }
56,248
CryptoChristmaz
contracts/CryptoChristmaz.sol
0xeec8344983d8523ceba6ad016c258139e6e5ca0c
Solidity
CryptoChristmaz
contract CryptoChristmaz is ERC721, Ownable { using Strings for uint256; using Counters for Counters.Counter; Counters.Counter private _tokenIds; string baseURI; string baseContractURI; string public baseExtension = ".json"; uint256 public cost = 0.035 ether; uint256 public maxSupply = 2222; uint256 public maxMintAmount = 10; bool public publicActive = false; bool public presaleActive = false; bool public revealed = false; string public notRevealedUri; uint256 public teamClaimAmount = 50; bool public teamClaimed = false; // Payment Addresses address christmas = 0xE73c1BdaDF6e81bF63Ca1DC482DebE7E44F6a778; address shufflemint = 0xC79108A7151814A77e1916E61e0d88D5EA935c84; mapping (address => bool) public claimWhitelist; event Minted(uint256 indexed tokenId, address indexed owner); constructor( string memory _name, string memory _symbol, string memory _initBaseURI, string memory _initNotRevealedUri, string memory _contractURI_ ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); baseContractURI = _contractURI_; setNotRevealedURI(_initNotRevealedUri); _tokenIds.increment(); } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function publicMint(uint256 _mintAmount) public payable { require(publicActive, "Sale has not started yet."); require(_mintAmount > 0, "Quantity cannot be zero"); require(_mintAmount <= maxMintAmount, "Exceeds 20, the max qty per mint."); require(totalSupply() + _mintAmount <= maxSupply, "Quantity requested exceeds max supply."); require(msg.value >= cost * _mintAmount, "Ether value sent is below the price"); for (uint256 i = 1; i <= _mintAmount; i++) { uint256 mintIndex = _tokenIds.current(); _safeMint(msg.sender, mintIndex); // increment id counter _tokenIds.increment(); emit Minted(mintIndex, msg.sender); } } function claim() public { require(presaleActive || publicActive, "A sale period must be active to claim"); require(claimWhitelist[msg.sender], "No claim available for this address"); require(totalSupply() + 1 <= maxSupply, "Quantity requested exceeds max supply."); uint256 mintIndex = _tokenIds.current(); _safeMint(msg.sender, mintIndex); // increment id counter _tokenIds.increment(); emit Minted(mintIndex, msg.sender); claimWhitelist[msg.sender] = false; } function teamClaim() public onlyOwner { require(totalSupply() + teamClaimAmount <= maxSupply, "Quantity requested exceeds max supply."); require(!teamClaimed, "Team has claimed"); for (uint256 i = 1; i <= teamClaimAmount; i++) { uint256 mintIndex = _tokenIds.current(); _safeMint(christmas, mintIndex); _tokenIds.increment(); } teamClaimed = true; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); if(revealed == false) { return bytes(notRevealedUri).length > 0 ? string(abi.encodePacked(notRevealedUri, tokenId.toString(), baseExtension)) : ""; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } //only owner function reveal() public onlyOwner { revealed = true; } function setCost(uint256 _newCost) public onlyOwner { cost = _newCost; } function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner { maxMintAmount = _newmaxMintAmount; } function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function publicLive(bool _state) public onlyOwner { publicActive = _state; } function presaleLive(bool _state) public onlyOwner { presaleActive = _state; } function totalSupply() public view returns (uint256) { return _tokenIds.current() - 1; } function withdraw() public payable onlyOwner { // Shufflemint 10% (bool sm, ) = payable(shufflemint).call{value: address(this).balance * 50 / 100}(""); require(sm); // Notables 90% (bool os, ) = payable(christmas).call{value: address(this).balance}(""); require(os); } function editClaimList(address[] calldata claimAddresses) public onlyOwner { for(uint256 i; i < claimAddresses.length; i++){ claimWhitelist[claimAddresses[i]] = true; } } function contractURI() public view returns (string memory) { return baseContractURI; } function setContractURI(string memory uri) public onlyOwner { baseContractURI = uri; } }
_baseURI
function _baseURI() internal view virtual override returns (string memory) { return baseURI; }
// internal
LineComment
v0.8.7+commit.e28d00a7
{ "func_code_index": [ 1190, 1292 ] }
56,249
CryptoChristmaz
contracts/CryptoChristmaz.sol
0xeec8344983d8523ceba6ad016c258139e6e5ca0c
Solidity
CryptoChristmaz
contract CryptoChristmaz is ERC721, Ownable { using Strings for uint256; using Counters for Counters.Counter; Counters.Counter private _tokenIds; string baseURI; string baseContractURI; string public baseExtension = ".json"; uint256 public cost = 0.035 ether; uint256 public maxSupply = 2222; uint256 public maxMintAmount = 10; bool public publicActive = false; bool public presaleActive = false; bool public revealed = false; string public notRevealedUri; uint256 public teamClaimAmount = 50; bool public teamClaimed = false; // Payment Addresses address christmas = 0xE73c1BdaDF6e81bF63Ca1DC482DebE7E44F6a778; address shufflemint = 0xC79108A7151814A77e1916E61e0d88D5EA935c84; mapping (address => bool) public claimWhitelist; event Minted(uint256 indexed tokenId, address indexed owner); constructor( string memory _name, string memory _symbol, string memory _initBaseURI, string memory _initNotRevealedUri, string memory _contractURI_ ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); baseContractURI = _contractURI_; setNotRevealedURI(_initNotRevealedUri); _tokenIds.increment(); } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function publicMint(uint256 _mintAmount) public payable { require(publicActive, "Sale has not started yet."); require(_mintAmount > 0, "Quantity cannot be zero"); require(_mintAmount <= maxMintAmount, "Exceeds 20, the max qty per mint."); require(totalSupply() + _mintAmount <= maxSupply, "Quantity requested exceeds max supply."); require(msg.value >= cost * _mintAmount, "Ether value sent is below the price"); for (uint256 i = 1; i <= _mintAmount; i++) { uint256 mintIndex = _tokenIds.current(); _safeMint(msg.sender, mintIndex); // increment id counter _tokenIds.increment(); emit Minted(mintIndex, msg.sender); } } function claim() public { require(presaleActive || publicActive, "A sale period must be active to claim"); require(claimWhitelist[msg.sender], "No claim available for this address"); require(totalSupply() + 1 <= maxSupply, "Quantity requested exceeds max supply."); uint256 mintIndex = _tokenIds.current(); _safeMint(msg.sender, mintIndex); // increment id counter _tokenIds.increment(); emit Minted(mintIndex, msg.sender); claimWhitelist[msg.sender] = false; } function teamClaim() public onlyOwner { require(totalSupply() + teamClaimAmount <= maxSupply, "Quantity requested exceeds max supply."); require(!teamClaimed, "Team has claimed"); for (uint256 i = 1; i <= teamClaimAmount; i++) { uint256 mintIndex = _tokenIds.current(); _safeMint(christmas, mintIndex); _tokenIds.increment(); } teamClaimed = true; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); if(revealed == false) { return bytes(notRevealedUri).length > 0 ? string(abi.encodePacked(notRevealedUri, tokenId.toString(), baseExtension)) : ""; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } //only owner function reveal() public onlyOwner { revealed = true; } function setCost(uint256 _newCost) public onlyOwner { cost = _newCost; } function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner { maxMintAmount = _newmaxMintAmount; } function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function publicLive(bool _state) public onlyOwner { publicActive = _state; } function presaleLive(bool _state) public onlyOwner { presaleActive = _state; } function totalSupply() public view returns (uint256) { return _tokenIds.current() - 1; } function withdraw() public payable onlyOwner { // Shufflemint 10% (bool sm, ) = payable(shufflemint).call{value: address(this).balance * 50 / 100}(""); require(sm); // Notables 90% (bool os, ) = payable(christmas).call{value: address(this).balance}(""); require(os); } function editClaimList(address[] calldata claimAddresses) public onlyOwner { for(uint256 i; i < claimAddresses.length; i++){ claimWhitelist[claimAddresses[i]] = true; } } function contractURI() public view returns (string memory) { return baseContractURI; } function setContractURI(string memory uri) public onlyOwner { baseContractURI = uri; } }
publicMint
function publicMint(uint256 _mintAmount) public payable { require(publicActive, "Sale has not started yet."); require(_mintAmount > 0, "Quantity cannot be zero"); require(_mintAmount <= maxMintAmount, "Exceeds 20, the max qty per mint."); require(totalSupply() + _mintAmount <= maxSupply, "Quantity requested exceeds max supply."); require(msg.value >= cost * _mintAmount, "Ether value sent is below the price"); for (uint256 i = 1; i <= _mintAmount; i++) { uint256 mintIndex = _tokenIds.current(); _safeMint(msg.sender, mintIndex); // increment id counter _tokenIds.increment(); emit Minted(mintIndex, msg.sender); } }
// public
LineComment
v0.8.7+commit.e28d00a7
{ "func_code_index": [ 1306, 1989 ] }
56,250
CryptoChristmaz
contracts/CryptoChristmaz.sol
0xeec8344983d8523ceba6ad016c258139e6e5ca0c
Solidity
CryptoChristmaz
contract CryptoChristmaz is ERC721, Ownable { using Strings for uint256; using Counters for Counters.Counter; Counters.Counter private _tokenIds; string baseURI; string baseContractURI; string public baseExtension = ".json"; uint256 public cost = 0.035 ether; uint256 public maxSupply = 2222; uint256 public maxMintAmount = 10; bool public publicActive = false; bool public presaleActive = false; bool public revealed = false; string public notRevealedUri; uint256 public teamClaimAmount = 50; bool public teamClaimed = false; // Payment Addresses address christmas = 0xE73c1BdaDF6e81bF63Ca1DC482DebE7E44F6a778; address shufflemint = 0xC79108A7151814A77e1916E61e0d88D5EA935c84; mapping (address => bool) public claimWhitelist; event Minted(uint256 indexed tokenId, address indexed owner); constructor( string memory _name, string memory _symbol, string memory _initBaseURI, string memory _initNotRevealedUri, string memory _contractURI_ ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); baseContractURI = _contractURI_; setNotRevealedURI(_initNotRevealedUri); _tokenIds.increment(); } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function publicMint(uint256 _mintAmount) public payable { require(publicActive, "Sale has not started yet."); require(_mintAmount > 0, "Quantity cannot be zero"); require(_mintAmount <= maxMintAmount, "Exceeds 20, the max qty per mint."); require(totalSupply() + _mintAmount <= maxSupply, "Quantity requested exceeds max supply."); require(msg.value >= cost * _mintAmount, "Ether value sent is below the price"); for (uint256 i = 1; i <= _mintAmount; i++) { uint256 mintIndex = _tokenIds.current(); _safeMint(msg.sender, mintIndex); // increment id counter _tokenIds.increment(); emit Minted(mintIndex, msg.sender); } } function claim() public { require(presaleActive || publicActive, "A sale period must be active to claim"); require(claimWhitelist[msg.sender], "No claim available for this address"); require(totalSupply() + 1 <= maxSupply, "Quantity requested exceeds max supply."); uint256 mintIndex = _tokenIds.current(); _safeMint(msg.sender, mintIndex); // increment id counter _tokenIds.increment(); emit Minted(mintIndex, msg.sender); claimWhitelist[msg.sender] = false; } function teamClaim() public onlyOwner { require(totalSupply() + teamClaimAmount <= maxSupply, "Quantity requested exceeds max supply."); require(!teamClaimed, "Team has claimed"); for (uint256 i = 1; i <= teamClaimAmount; i++) { uint256 mintIndex = _tokenIds.current(); _safeMint(christmas, mintIndex); _tokenIds.increment(); } teamClaimed = true; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); if(revealed == false) { return bytes(notRevealedUri).length > 0 ? string(abi.encodePacked(notRevealedUri, tokenId.toString(), baseExtension)) : ""; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } //only owner function reveal() public onlyOwner { revealed = true; } function setCost(uint256 _newCost) public onlyOwner { cost = _newCost; } function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner { maxMintAmount = _newmaxMintAmount; } function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function publicLive(bool _state) public onlyOwner { publicActive = _state; } function presaleLive(bool _state) public onlyOwner { presaleActive = _state; } function totalSupply() public view returns (uint256) { return _tokenIds.current() - 1; } function withdraw() public payable onlyOwner { // Shufflemint 10% (bool sm, ) = payable(shufflemint).call{value: address(this).balance * 50 / 100}(""); require(sm); // Notables 90% (bool os, ) = payable(christmas).call{value: address(this).balance}(""); require(os); } function editClaimList(address[] calldata claimAddresses) public onlyOwner { for(uint256 i; i < claimAddresses.length; i++){ claimWhitelist[claimAddresses[i]] = true; } } function contractURI() public view returns (string memory) { return baseContractURI; } function setContractURI(string memory uri) public onlyOwner { baseContractURI = uri; } }
reveal
function reveal() public onlyOwner { revealed = true; }
//only owner
LineComment
v0.8.7+commit.e28d00a7
{ "func_code_index": [ 3540, 3605 ] }
56,251
MultiVesting
MultiVesting.sol
0x66e9aeedc17558cfc97b6734600b7a835f8e7ceb
Solidity
Ownable
contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } }
Ownable
function Ownable() public { owner = msg.sender; }
/** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://bd1d9802790e0281240ddbd34fb7e404a0dc8500b3639c2b04a8a6c42f0133ab
{ "func_code_index": [ 257, 317 ] }
56,252
MultiVesting
MultiVesting.sol
0x66e9aeedc17558cfc97b6734600b7a835f8e7ceb
Solidity
Ownable
contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } }
transferOwnership
function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; }
/** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://bd1d9802790e0281240ddbd34fb7e404a0dc8500b3639c2b04a8a6c42f0133ab
{ "func_code_index": [ 636, 812 ] }
56,253
MultiVesting
MultiVesting.sol
0x66e9aeedc17558cfc97b6734600b7a835f8e7ceb
Solidity
Destroyable
contract Destroyable is Ownable{ /** * @notice Allows to destroy the contract and return the tokens to the owner. */ function destroy() public onlyOwner{ selfdestruct(owner); } }
destroy
function destroy() public onlyOwner{ selfdestruct(owner); }
/** * @notice Allows to destroy the contract and return the tokens to the owner. */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://bd1d9802790e0281240ddbd34fb7e404a0dc8500b3639c2b04a8a6c42f0133ab
{ "func_code_index": [ 135, 213 ] }
56,254
MultiVesting
MultiVesting.sol
0x66e9aeedc17558cfc97b6734600b7a835f8e7ceb
Solidity
MultiVesting
contract MultiVesting is Ownable, Destroyable { using SafeMath for uint256; // beneficiary of tokens struct Beneficiary { uint256 released; uint256 vested; uint256 start; uint256 cliff; uint256 duration; bool revoked; bool revocable; bool isBeneficiary; } event Released(address _beneficiary, uint256 amount); event Revoked(address _beneficiary); event NewBeneficiary(address _beneficiary); event BeneficiaryDestroyed(address _beneficiary); mapping(address => Beneficiary) public beneficiaries; Token public token; uint256 public totalVested; uint256 public totalReleased; /* * Modifiers */ modifier isNotBeneficiary(address _beneficiary) { require(!beneficiaries[_beneficiary].isBeneficiary); _; } modifier isBeneficiary(address _beneficiary) { require(beneficiaries[_beneficiary].isBeneficiary); _; } modifier wasRevoked(address _beneficiary) { require(beneficiaries[_beneficiary].revoked); _; } modifier wasNotRevoked(address _beneficiary) { require(!beneficiaries[_beneficiary].revoked); _; } /** * @dev Creates a vesting contract that vests its balance of any ERC20 token to the * beneficiary, gradually in a linear fashion until _start + _duration. By then all * of the balance will have vested. * @param _token address of the token of vested tokens */ function MultiVesting(address _token) public { require(_token != address(0)); token = Token(_token); } function() payable public { release(msg.sender); } /** * @notice Transfers vested tokens to beneficiary (alternative to fallback function). */ function release() public { release(msg.sender); } /** * @notice Transfers vested tokens to beneficiary. * @param _beneficiary Beneficiary address */ function release(address _beneficiary) private isBeneficiary(_beneficiary) { Beneficiary storage beneficiary = beneficiaries[_beneficiary]; uint256 unreleased = releasableAmount(_beneficiary); require(unreleased > 0); beneficiary.released = beneficiary.released.add(unreleased); totalReleased = totalReleased.add(unreleased); token.transfer(_beneficiary, unreleased); if((beneficiary.vested - beneficiary.released) == 0){ beneficiary.isBeneficiary = false; } Released(_beneficiary, unreleased); } /** * @notice Allows the owner to transfers vested tokens to beneficiary. * @param _beneficiary Beneficiary address */ function releaseTo(address _beneficiary) public onlyOwner { release(_beneficiary); } /** * @dev Add new beneficiary to start vesting * @param _beneficiary address of the beneficiary to whom vested tokens are transferred * @param _start time in seconds which the tokens will vest * @param _cliff time in seconds of the cliff in which tokens will begin to vest * @param _duration duration in seconds of the period in which the tokens will vest * @param _revocable whether the vesting is revocable or not */ function addBeneficiary(address _beneficiary, uint256 _vested, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable) onlyOwner isNotBeneficiary(_beneficiary) public { require(_beneficiary != address(0)); require(_cliff >= _start); require(token.balanceOf(this) >= totalVested.sub(totalReleased).add(_vested)); beneficiaries[_beneficiary] = Beneficiary({ released : 0, vested : _vested, start : _start, cliff : _cliff, duration : _duration, revoked : false, revocable : _revocable, isBeneficiary : true }); totalVested = totalVested.add(_vested); NewBeneficiary(_beneficiary); } /** * @notice Allows the owner to revoke the vesting. Tokens already vested * remain in the contract, the rest are returned to the owner. * @param _beneficiary Beneficiary address */ function revoke(address _beneficiary) public onlyOwner { Beneficiary storage beneficiary = beneficiaries[_beneficiary]; require(beneficiary.revocable); require(!beneficiary.revoked); uint256 balance = beneficiary.vested.sub(beneficiary.released); uint256 unreleased = releasableAmount(_beneficiary); uint256 refund = balance.sub(unreleased); token.transfer(owner, refund); totalReleased = totalReleased.add(refund); beneficiary.revoked = true; beneficiary.released = beneficiary.released.add(refund); Revoked(_beneficiary); } /** * @notice Allows the owner to destroy a beneficiary. Remain tokens are returned to the owner. * @param _beneficiary Beneficiary address */ function destroyBeneficiary(address _beneficiary) public onlyOwner { Beneficiary storage beneficiary = beneficiaries[_beneficiary]; uint256 balance = beneficiary.vested.sub(beneficiary.released); token.transfer(owner, balance); totalReleased = totalReleased.add(balance); beneficiary.isBeneficiary = false; beneficiary.released = beneficiary.released.add(balance); BeneficiaryDestroyed(_beneficiary); } /** * @dev Calculates the amount that has already vested but hasn't been released yet. * @param _beneficiary Beneficiary address */ function releasableAmount(address _beneficiary) public view returns (uint256) { return vestedAmount(_beneficiary).sub(beneficiaries[_beneficiary].released); } /** * @dev Calculates the amount that has already vested. * @param _beneficiary Beneficiary address */ function vestedAmount(address _beneficiary) public view returns (uint256) { Beneficiary storage beneficiary = beneficiaries[_beneficiary]; uint256 totalBalance = beneficiary.vested; if (now < beneficiary.cliff) { return 0; } else if (now >= beneficiary.start.add(beneficiary.duration) || beneficiary.revoked) { return totalBalance; } else { return totalBalance.mul(now.sub(beneficiary.start)).div(beneficiary.duration); } } /** * @notice Allows the owner to flush the eth. */ function flushEth() public onlyOwner { owner.transfer(this.balance); } /** * @notice Allows the owner to destroy the contract and return the tokens to the owner. */ function destroy() public onlyOwner { token.transfer(owner, token.balanceOf(this)); selfdestruct(owner); } }
MultiVesting
function MultiVesting(address _token) public { require(_token != address(0)); token = Token(_token); }
/** * @dev Creates a vesting contract that vests its balance of any ERC20 token to the * beneficiary, gradually in a linear fashion until _start + _duration. By then all * of the balance will have vested. * @param _token address of the token of vested tokens */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://bd1d9802790e0281240ddbd34fb7e404a0dc8500b3639c2b04a8a6c42f0133ab
{ "func_code_index": [ 1573, 1703 ] }
56,255
MultiVesting
MultiVesting.sol
0x66e9aeedc17558cfc97b6734600b7a835f8e7ceb
Solidity
MultiVesting
contract MultiVesting is Ownable, Destroyable { using SafeMath for uint256; // beneficiary of tokens struct Beneficiary { uint256 released; uint256 vested; uint256 start; uint256 cliff; uint256 duration; bool revoked; bool revocable; bool isBeneficiary; } event Released(address _beneficiary, uint256 amount); event Revoked(address _beneficiary); event NewBeneficiary(address _beneficiary); event BeneficiaryDestroyed(address _beneficiary); mapping(address => Beneficiary) public beneficiaries; Token public token; uint256 public totalVested; uint256 public totalReleased; /* * Modifiers */ modifier isNotBeneficiary(address _beneficiary) { require(!beneficiaries[_beneficiary].isBeneficiary); _; } modifier isBeneficiary(address _beneficiary) { require(beneficiaries[_beneficiary].isBeneficiary); _; } modifier wasRevoked(address _beneficiary) { require(beneficiaries[_beneficiary].revoked); _; } modifier wasNotRevoked(address _beneficiary) { require(!beneficiaries[_beneficiary].revoked); _; } /** * @dev Creates a vesting contract that vests its balance of any ERC20 token to the * beneficiary, gradually in a linear fashion until _start + _duration. By then all * of the balance will have vested. * @param _token address of the token of vested tokens */ function MultiVesting(address _token) public { require(_token != address(0)); token = Token(_token); } function() payable public { release(msg.sender); } /** * @notice Transfers vested tokens to beneficiary (alternative to fallback function). */ function release() public { release(msg.sender); } /** * @notice Transfers vested tokens to beneficiary. * @param _beneficiary Beneficiary address */ function release(address _beneficiary) private isBeneficiary(_beneficiary) { Beneficiary storage beneficiary = beneficiaries[_beneficiary]; uint256 unreleased = releasableAmount(_beneficiary); require(unreleased > 0); beneficiary.released = beneficiary.released.add(unreleased); totalReleased = totalReleased.add(unreleased); token.transfer(_beneficiary, unreleased); if((beneficiary.vested - beneficiary.released) == 0){ beneficiary.isBeneficiary = false; } Released(_beneficiary, unreleased); } /** * @notice Allows the owner to transfers vested tokens to beneficiary. * @param _beneficiary Beneficiary address */ function releaseTo(address _beneficiary) public onlyOwner { release(_beneficiary); } /** * @dev Add new beneficiary to start vesting * @param _beneficiary address of the beneficiary to whom vested tokens are transferred * @param _start time in seconds which the tokens will vest * @param _cliff time in seconds of the cliff in which tokens will begin to vest * @param _duration duration in seconds of the period in which the tokens will vest * @param _revocable whether the vesting is revocable or not */ function addBeneficiary(address _beneficiary, uint256 _vested, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable) onlyOwner isNotBeneficiary(_beneficiary) public { require(_beneficiary != address(0)); require(_cliff >= _start); require(token.balanceOf(this) >= totalVested.sub(totalReleased).add(_vested)); beneficiaries[_beneficiary] = Beneficiary({ released : 0, vested : _vested, start : _start, cliff : _cliff, duration : _duration, revoked : false, revocable : _revocable, isBeneficiary : true }); totalVested = totalVested.add(_vested); NewBeneficiary(_beneficiary); } /** * @notice Allows the owner to revoke the vesting. Tokens already vested * remain in the contract, the rest are returned to the owner. * @param _beneficiary Beneficiary address */ function revoke(address _beneficiary) public onlyOwner { Beneficiary storage beneficiary = beneficiaries[_beneficiary]; require(beneficiary.revocable); require(!beneficiary.revoked); uint256 balance = beneficiary.vested.sub(beneficiary.released); uint256 unreleased = releasableAmount(_beneficiary); uint256 refund = balance.sub(unreleased); token.transfer(owner, refund); totalReleased = totalReleased.add(refund); beneficiary.revoked = true; beneficiary.released = beneficiary.released.add(refund); Revoked(_beneficiary); } /** * @notice Allows the owner to destroy a beneficiary. Remain tokens are returned to the owner. * @param _beneficiary Beneficiary address */ function destroyBeneficiary(address _beneficiary) public onlyOwner { Beneficiary storage beneficiary = beneficiaries[_beneficiary]; uint256 balance = beneficiary.vested.sub(beneficiary.released); token.transfer(owner, balance); totalReleased = totalReleased.add(balance); beneficiary.isBeneficiary = false; beneficiary.released = beneficiary.released.add(balance); BeneficiaryDestroyed(_beneficiary); } /** * @dev Calculates the amount that has already vested but hasn't been released yet. * @param _beneficiary Beneficiary address */ function releasableAmount(address _beneficiary) public view returns (uint256) { return vestedAmount(_beneficiary).sub(beneficiaries[_beneficiary].released); } /** * @dev Calculates the amount that has already vested. * @param _beneficiary Beneficiary address */ function vestedAmount(address _beneficiary) public view returns (uint256) { Beneficiary storage beneficiary = beneficiaries[_beneficiary]; uint256 totalBalance = beneficiary.vested; if (now < beneficiary.cliff) { return 0; } else if (now >= beneficiary.start.add(beneficiary.duration) || beneficiary.revoked) { return totalBalance; } else { return totalBalance.mul(now.sub(beneficiary.start)).div(beneficiary.duration); } } /** * @notice Allows the owner to flush the eth. */ function flushEth() public onlyOwner { owner.transfer(this.balance); } /** * @notice Allows the owner to destroy the contract and return the tokens to the owner. */ function destroy() public onlyOwner { token.transfer(owner, token.balanceOf(this)); selfdestruct(owner); } }
release
function release() public { release(msg.sender); }
/** * @notice Transfers vested tokens to beneficiary (alternative to fallback function). */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://bd1d9802790e0281240ddbd34fb7e404a0dc8500b3639c2b04a8a6c42f0133ab
{ "func_code_index": [ 1887, 1956 ] }
56,256
MultiVesting
MultiVesting.sol
0x66e9aeedc17558cfc97b6734600b7a835f8e7ceb
Solidity
MultiVesting
contract MultiVesting is Ownable, Destroyable { using SafeMath for uint256; // beneficiary of tokens struct Beneficiary { uint256 released; uint256 vested; uint256 start; uint256 cliff; uint256 duration; bool revoked; bool revocable; bool isBeneficiary; } event Released(address _beneficiary, uint256 amount); event Revoked(address _beneficiary); event NewBeneficiary(address _beneficiary); event BeneficiaryDestroyed(address _beneficiary); mapping(address => Beneficiary) public beneficiaries; Token public token; uint256 public totalVested; uint256 public totalReleased; /* * Modifiers */ modifier isNotBeneficiary(address _beneficiary) { require(!beneficiaries[_beneficiary].isBeneficiary); _; } modifier isBeneficiary(address _beneficiary) { require(beneficiaries[_beneficiary].isBeneficiary); _; } modifier wasRevoked(address _beneficiary) { require(beneficiaries[_beneficiary].revoked); _; } modifier wasNotRevoked(address _beneficiary) { require(!beneficiaries[_beneficiary].revoked); _; } /** * @dev Creates a vesting contract that vests its balance of any ERC20 token to the * beneficiary, gradually in a linear fashion until _start + _duration. By then all * of the balance will have vested. * @param _token address of the token of vested tokens */ function MultiVesting(address _token) public { require(_token != address(0)); token = Token(_token); } function() payable public { release(msg.sender); } /** * @notice Transfers vested tokens to beneficiary (alternative to fallback function). */ function release() public { release(msg.sender); } /** * @notice Transfers vested tokens to beneficiary. * @param _beneficiary Beneficiary address */ function release(address _beneficiary) private isBeneficiary(_beneficiary) { Beneficiary storage beneficiary = beneficiaries[_beneficiary]; uint256 unreleased = releasableAmount(_beneficiary); require(unreleased > 0); beneficiary.released = beneficiary.released.add(unreleased); totalReleased = totalReleased.add(unreleased); token.transfer(_beneficiary, unreleased); if((beneficiary.vested - beneficiary.released) == 0){ beneficiary.isBeneficiary = false; } Released(_beneficiary, unreleased); } /** * @notice Allows the owner to transfers vested tokens to beneficiary. * @param _beneficiary Beneficiary address */ function releaseTo(address _beneficiary) public onlyOwner { release(_beneficiary); } /** * @dev Add new beneficiary to start vesting * @param _beneficiary address of the beneficiary to whom vested tokens are transferred * @param _start time in seconds which the tokens will vest * @param _cliff time in seconds of the cliff in which tokens will begin to vest * @param _duration duration in seconds of the period in which the tokens will vest * @param _revocable whether the vesting is revocable or not */ function addBeneficiary(address _beneficiary, uint256 _vested, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable) onlyOwner isNotBeneficiary(_beneficiary) public { require(_beneficiary != address(0)); require(_cliff >= _start); require(token.balanceOf(this) >= totalVested.sub(totalReleased).add(_vested)); beneficiaries[_beneficiary] = Beneficiary({ released : 0, vested : _vested, start : _start, cliff : _cliff, duration : _duration, revoked : false, revocable : _revocable, isBeneficiary : true }); totalVested = totalVested.add(_vested); NewBeneficiary(_beneficiary); } /** * @notice Allows the owner to revoke the vesting. Tokens already vested * remain in the contract, the rest are returned to the owner. * @param _beneficiary Beneficiary address */ function revoke(address _beneficiary) public onlyOwner { Beneficiary storage beneficiary = beneficiaries[_beneficiary]; require(beneficiary.revocable); require(!beneficiary.revoked); uint256 balance = beneficiary.vested.sub(beneficiary.released); uint256 unreleased = releasableAmount(_beneficiary); uint256 refund = balance.sub(unreleased); token.transfer(owner, refund); totalReleased = totalReleased.add(refund); beneficiary.revoked = true; beneficiary.released = beneficiary.released.add(refund); Revoked(_beneficiary); } /** * @notice Allows the owner to destroy a beneficiary. Remain tokens are returned to the owner. * @param _beneficiary Beneficiary address */ function destroyBeneficiary(address _beneficiary) public onlyOwner { Beneficiary storage beneficiary = beneficiaries[_beneficiary]; uint256 balance = beneficiary.vested.sub(beneficiary.released); token.transfer(owner, balance); totalReleased = totalReleased.add(balance); beneficiary.isBeneficiary = false; beneficiary.released = beneficiary.released.add(balance); BeneficiaryDestroyed(_beneficiary); } /** * @dev Calculates the amount that has already vested but hasn't been released yet. * @param _beneficiary Beneficiary address */ function releasableAmount(address _beneficiary) public view returns (uint256) { return vestedAmount(_beneficiary).sub(beneficiaries[_beneficiary].released); } /** * @dev Calculates the amount that has already vested. * @param _beneficiary Beneficiary address */ function vestedAmount(address _beneficiary) public view returns (uint256) { Beneficiary storage beneficiary = beneficiaries[_beneficiary]; uint256 totalBalance = beneficiary.vested; if (now < beneficiary.cliff) { return 0; } else if (now >= beneficiary.start.add(beneficiary.duration) || beneficiary.revoked) { return totalBalance; } else { return totalBalance.mul(now.sub(beneficiary.start)).div(beneficiary.duration); } } /** * @notice Allows the owner to flush the eth. */ function flushEth() public onlyOwner { owner.transfer(this.balance); } /** * @notice Allows the owner to destroy the contract and return the tokens to the owner. */ function destroy() public onlyOwner { token.transfer(owner, token.balanceOf(this)); selfdestruct(owner); } }
release
function release(address _beneficiary) private isBeneficiary(_beneficiary) { Beneficiary storage beneficiary = beneficiaries[_beneficiary]; uint256 unreleased = releasableAmount(_beneficiary); require(unreleased > 0); beneficiary.released = beneficiary.released.add(unreleased); totalReleased = totalReleased.add(unreleased); token.transfer(_beneficiary, unreleased); if((beneficiary.vested - beneficiary.released) == 0){ beneficiary.isBeneficiary = false; } Released(_beneficiary, unreleased); }
/** * @notice Transfers vested tokens to beneficiary. * @param _beneficiary Beneficiary address */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://bd1d9802790e0281240ddbd34fb7e404a0dc8500b3639c2b04a8a6c42f0133ab
{ "func_code_index": [ 2081, 2705 ] }
56,257
MultiVesting
MultiVesting.sol
0x66e9aeedc17558cfc97b6734600b7a835f8e7ceb
Solidity
MultiVesting
contract MultiVesting is Ownable, Destroyable { using SafeMath for uint256; // beneficiary of tokens struct Beneficiary { uint256 released; uint256 vested; uint256 start; uint256 cliff; uint256 duration; bool revoked; bool revocable; bool isBeneficiary; } event Released(address _beneficiary, uint256 amount); event Revoked(address _beneficiary); event NewBeneficiary(address _beneficiary); event BeneficiaryDestroyed(address _beneficiary); mapping(address => Beneficiary) public beneficiaries; Token public token; uint256 public totalVested; uint256 public totalReleased; /* * Modifiers */ modifier isNotBeneficiary(address _beneficiary) { require(!beneficiaries[_beneficiary].isBeneficiary); _; } modifier isBeneficiary(address _beneficiary) { require(beneficiaries[_beneficiary].isBeneficiary); _; } modifier wasRevoked(address _beneficiary) { require(beneficiaries[_beneficiary].revoked); _; } modifier wasNotRevoked(address _beneficiary) { require(!beneficiaries[_beneficiary].revoked); _; } /** * @dev Creates a vesting contract that vests its balance of any ERC20 token to the * beneficiary, gradually in a linear fashion until _start + _duration. By then all * of the balance will have vested. * @param _token address of the token of vested tokens */ function MultiVesting(address _token) public { require(_token != address(0)); token = Token(_token); } function() payable public { release(msg.sender); } /** * @notice Transfers vested tokens to beneficiary (alternative to fallback function). */ function release() public { release(msg.sender); } /** * @notice Transfers vested tokens to beneficiary. * @param _beneficiary Beneficiary address */ function release(address _beneficiary) private isBeneficiary(_beneficiary) { Beneficiary storage beneficiary = beneficiaries[_beneficiary]; uint256 unreleased = releasableAmount(_beneficiary); require(unreleased > 0); beneficiary.released = beneficiary.released.add(unreleased); totalReleased = totalReleased.add(unreleased); token.transfer(_beneficiary, unreleased); if((beneficiary.vested - beneficiary.released) == 0){ beneficiary.isBeneficiary = false; } Released(_beneficiary, unreleased); } /** * @notice Allows the owner to transfers vested tokens to beneficiary. * @param _beneficiary Beneficiary address */ function releaseTo(address _beneficiary) public onlyOwner { release(_beneficiary); } /** * @dev Add new beneficiary to start vesting * @param _beneficiary address of the beneficiary to whom vested tokens are transferred * @param _start time in seconds which the tokens will vest * @param _cliff time in seconds of the cliff in which tokens will begin to vest * @param _duration duration in seconds of the period in which the tokens will vest * @param _revocable whether the vesting is revocable or not */ function addBeneficiary(address _beneficiary, uint256 _vested, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable) onlyOwner isNotBeneficiary(_beneficiary) public { require(_beneficiary != address(0)); require(_cliff >= _start); require(token.balanceOf(this) >= totalVested.sub(totalReleased).add(_vested)); beneficiaries[_beneficiary] = Beneficiary({ released : 0, vested : _vested, start : _start, cliff : _cliff, duration : _duration, revoked : false, revocable : _revocable, isBeneficiary : true }); totalVested = totalVested.add(_vested); NewBeneficiary(_beneficiary); } /** * @notice Allows the owner to revoke the vesting. Tokens already vested * remain in the contract, the rest are returned to the owner. * @param _beneficiary Beneficiary address */ function revoke(address _beneficiary) public onlyOwner { Beneficiary storage beneficiary = beneficiaries[_beneficiary]; require(beneficiary.revocable); require(!beneficiary.revoked); uint256 balance = beneficiary.vested.sub(beneficiary.released); uint256 unreleased = releasableAmount(_beneficiary); uint256 refund = balance.sub(unreleased); token.transfer(owner, refund); totalReleased = totalReleased.add(refund); beneficiary.revoked = true; beneficiary.released = beneficiary.released.add(refund); Revoked(_beneficiary); } /** * @notice Allows the owner to destroy a beneficiary. Remain tokens are returned to the owner. * @param _beneficiary Beneficiary address */ function destroyBeneficiary(address _beneficiary) public onlyOwner { Beneficiary storage beneficiary = beneficiaries[_beneficiary]; uint256 balance = beneficiary.vested.sub(beneficiary.released); token.transfer(owner, balance); totalReleased = totalReleased.add(balance); beneficiary.isBeneficiary = false; beneficiary.released = beneficiary.released.add(balance); BeneficiaryDestroyed(_beneficiary); } /** * @dev Calculates the amount that has already vested but hasn't been released yet. * @param _beneficiary Beneficiary address */ function releasableAmount(address _beneficiary) public view returns (uint256) { return vestedAmount(_beneficiary).sub(beneficiaries[_beneficiary].released); } /** * @dev Calculates the amount that has already vested. * @param _beneficiary Beneficiary address */ function vestedAmount(address _beneficiary) public view returns (uint256) { Beneficiary storage beneficiary = beneficiaries[_beneficiary]; uint256 totalBalance = beneficiary.vested; if (now < beneficiary.cliff) { return 0; } else if (now >= beneficiary.start.add(beneficiary.duration) || beneficiary.revoked) { return totalBalance; } else { return totalBalance.mul(now.sub(beneficiary.start)).div(beneficiary.duration); } } /** * @notice Allows the owner to flush the eth. */ function flushEth() public onlyOwner { owner.transfer(this.balance); } /** * @notice Allows the owner to destroy the contract and return the tokens to the owner. */ function destroy() public onlyOwner { token.transfer(owner, token.balanceOf(this)); selfdestruct(owner); } }
releaseTo
function releaseTo(address _beneficiary) public onlyOwner { release(_beneficiary); }
/** * @notice Allows the owner to transfers vested tokens to beneficiary. * @param _beneficiary Beneficiary address */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://bd1d9802790e0281240ddbd34fb7e404a0dc8500b3639c2b04a8a6c42f0133ab
{ "func_code_index": [ 2850, 2953 ] }
56,258
MultiVesting
MultiVesting.sol
0x66e9aeedc17558cfc97b6734600b7a835f8e7ceb
Solidity
MultiVesting
contract MultiVesting is Ownable, Destroyable { using SafeMath for uint256; // beneficiary of tokens struct Beneficiary { uint256 released; uint256 vested; uint256 start; uint256 cliff; uint256 duration; bool revoked; bool revocable; bool isBeneficiary; } event Released(address _beneficiary, uint256 amount); event Revoked(address _beneficiary); event NewBeneficiary(address _beneficiary); event BeneficiaryDestroyed(address _beneficiary); mapping(address => Beneficiary) public beneficiaries; Token public token; uint256 public totalVested; uint256 public totalReleased; /* * Modifiers */ modifier isNotBeneficiary(address _beneficiary) { require(!beneficiaries[_beneficiary].isBeneficiary); _; } modifier isBeneficiary(address _beneficiary) { require(beneficiaries[_beneficiary].isBeneficiary); _; } modifier wasRevoked(address _beneficiary) { require(beneficiaries[_beneficiary].revoked); _; } modifier wasNotRevoked(address _beneficiary) { require(!beneficiaries[_beneficiary].revoked); _; } /** * @dev Creates a vesting contract that vests its balance of any ERC20 token to the * beneficiary, gradually in a linear fashion until _start + _duration. By then all * of the balance will have vested. * @param _token address of the token of vested tokens */ function MultiVesting(address _token) public { require(_token != address(0)); token = Token(_token); } function() payable public { release(msg.sender); } /** * @notice Transfers vested tokens to beneficiary (alternative to fallback function). */ function release() public { release(msg.sender); } /** * @notice Transfers vested tokens to beneficiary. * @param _beneficiary Beneficiary address */ function release(address _beneficiary) private isBeneficiary(_beneficiary) { Beneficiary storage beneficiary = beneficiaries[_beneficiary]; uint256 unreleased = releasableAmount(_beneficiary); require(unreleased > 0); beneficiary.released = beneficiary.released.add(unreleased); totalReleased = totalReleased.add(unreleased); token.transfer(_beneficiary, unreleased); if((beneficiary.vested - beneficiary.released) == 0){ beneficiary.isBeneficiary = false; } Released(_beneficiary, unreleased); } /** * @notice Allows the owner to transfers vested tokens to beneficiary. * @param _beneficiary Beneficiary address */ function releaseTo(address _beneficiary) public onlyOwner { release(_beneficiary); } /** * @dev Add new beneficiary to start vesting * @param _beneficiary address of the beneficiary to whom vested tokens are transferred * @param _start time in seconds which the tokens will vest * @param _cliff time in seconds of the cliff in which tokens will begin to vest * @param _duration duration in seconds of the period in which the tokens will vest * @param _revocable whether the vesting is revocable or not */ function addBeneficiary(address _beneficiary, uint256 _vested, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable) onlyOwner isNotBeneficiary(_beneficiary) public { require(_beneficiary != address(0)); require(_cliff >= _start); require(token.balanceOf(this) >= totalVested.sub(totalReleased).add(_vested)); beneficiaries[_beneficiary] = Beneficiary({ released : 0, vested : _vested, start : _start, cliff : _cliff, duration : _duration, revoked : false, revocable : _revocable, isBeneficiary : true }); totalVested = totalVested.add(_vested); NewBeneficiary(_beneficiary); } /** * @notice Allows the owner to revoke the vesting. Tokens already vested * remain in the contract, the rest are returned to the owner. * @param _beneficiary Beneficiary address */ function revoke(address _beneficiary) public onlyOwner { Beneficiary storage beneficiary = beneficiaries[_beneficiary]; require(beneficiary.revocable); require(!beneficiary.revoked); uint256 balance = beneficiary.vested.sub(beneficiary.released); uint256 unreleased = releasableAmount(_beneficiary); uint256 refund = balance.sub(unreleased); token.transfer(owner, refund); totalReleased = totalReleased.add(refund); beneficiary.revoked = true; beneficiary.released = beneficiary.released.add(refund); Revoked(_beneficiary); } /** * @notice Allows the owner to destroy a beneficiary. Remain tokens are returned to the owner. * @param _beneficiary Beneficiary address */ function destroyBeneficiary(address _beneficiary) public onlyOwner { Beneficiary storage beneficiary = beneficiaries[_beneficiary]; uint256 balance = beneficiary.vested.sub(beneficiary.released); token.transfer(owner, balance); totalReleased = totalReleased.add(balance); beneficiary.isBeneficiary = false; beneficiary.released = beneficiary.released.add(balance); BeneficiaryDestroyed(_beneficiary); } /** * @dev Calculates the amount that has already vested but hasn't been released yet. * @param _beneficiary Beneficiary address */ function releasableAmount(address _beneficiary) public view returns (uint256) { return vestedAmount(_beneficiary).sub(beneficiaries[_beneficiary].released); } /** * @dev Calculates the amount that has already vested. * @param _beneficiary Beneficiary address */ function vestedAmount(address _beneficiary) public view returns (uint256) { Beneficiary storage beneficiary = beneficiaries[_beneficiary]; uint256 totalBalance = beneficiary.vested; if (now < beneficiary.cliff) { return 0; } else if (now >= beneficiary.start.add(beneficiary.duration) || beneficiary.revoked) { return totalBalance; } else { return totalBalance.mul(now.sub(beneficiary.start)).div(beneficiary.duration); } } /** * @notice Allows the owner to flush the eth. */ function flushEth() public onlyOwner { owner.transfer(this.balance); } /** * @notice Allows the owner to destroy the contract and return the tokens to the owner. */ function destroy() public onlyOwner { token.transfer(owner, token.balanceOf(this)); selfdestruct(owner); } }
addBeneficiary
function addBeneficiary(address _beneficiary, uint256 _vested, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable) onlyOwner isNotBeneficiary(_beneficiary) public { require(_beneficiary != address(0)); require(_cliff >= _start); require(token.balanceOf(this) >= totalVested.sub(totalReleased).add(_vested)); beneficiaries[_beneficiary] = Beneficiary({ released : 0, vested : _vested, start : _start, cliff : _cliff, duration : _duration, revoked : false, revocable : _revocable, isBeneficiary : true }); totalVested = totalVested.add(_vested); NewBeneficiary(_beneficiary); }
/** * @dev Add new beneficiary to start vesting * @param _beneficiary address of the beneficiary to whom vested tokens are transferred * @param _start time in seconds which the tokens will vest * @param _cliff time in seconds of the cliff in which tokens will begin to vest * @param _duration duration in seconds of the period in which the tokens will vest * @param _revocable whether the vesting is revocable or not */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://bd1d9802790e0281240ddbd34fb7e404a0dc8500b3639c2b04a8a6c42f0133ab
{ "func_code_index": [ 3423, 4210 ] }
56,259
MultiVesting
MultiVesting.sol
0x66e9aeedc17558cfc97b6734600b7a835f8e7ceb
Solidity
MultiVesting
contract MultiVesting is Ownable, Destroyable { using SafeMath for uint256; // beneficiary of tokens struct Beneficiary { uint256 released; uint256 vested; uint256 start; uint256 cliff; uint256 duration; bool revoked; bool revocable; bool isBeneficiary; } event Released(address _beneficiary, uint256 amount); event Revoked(address _beneficiary); event NewBeneficiary(address _beneficiary); event BeneficiaryDestroyed(address _beneficiary); mapping(address => Beneficiary) public beneficiaries; Token public token; uint256 public totalVested; uint256 public totalReleased; /* * Modifiers */ modifier isNotBeneficiary(address _beneficiary) { require(!beneficiaries[_beneficiary].isBeneficiary); _; } modifier isBeneficiary(address _beneficiary) { require(beneficiaries[_beneficiary].isBeneficiary); _; } modifier wasRevoked(address _beneficiary) { require(beneficiaries[_beneficiary].revoked); _; } modifier wasNotRevoked(address _beneficiary) { require(!beneficiaries[_beneficiary].revoked); _; } /** * @dev Creates a vesting contract that vests its balance of any ERC20 token to the * beneficiary, gradually in a linear fashion until _start + _duration. By then all * of the balance will have vested. * @param _token address of the token of vested tokens */ function MultiVesting(address _token) public { require(_token != address(0)); token = Token(_token); } function() payable public { release(msg.sender); } /** * @notice Transfers vested tokens to beneficiary (alternative to fallback function). */ function release() public { release(msg.sender); } /** * @notice Transfers vested tokens to beneficiary. * @param _beneficiary Beneficiary address */ function release(address _beneficiary) private isBeneficiary(_beneficiary) { Beneficiary storage beneficiary = beneficiaries[_beneficiary]; uint256 unreleased = releasableAmount(_beneficiary); require(unreleased > 0); beneficiary.released = beneficiary.released.add(unreleased); totalReleased = totalReleased.add(unreleased); token.transfer(_beneficiary, unreleased); if((beneficiary.vested - beneficiary.released) == 0){ beneficiary.isBeneficiary = false; } Released(_beneficiary, unreleased); } /** * @notice Allows the owner to transfers vested tokens to beneficiary. * @param _beneficiary Beneficiary address */ function releaseTo(address _beneficiary) public onlyOwner { release(_beneficiary); } /** * @dev Add new beneficiary to start vesting * @param _beneficiary address of the beneficiary to whom vested tokens are transferred * @param _start time in seconds which the tokens will vest * @param _cliff time in seconds of the cliff in which tokens will begin to vest * @param _duration duration in seconds of the period in which the tokens will vest * @param _revocable whether the vesting is revocable or not */ function addBeneficiary(address _beneficiary, uint256 _vested, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable) onlyOwner isNotBeneficiary(_beneficiary) public { require(_beneficiary != address(0)); require(_cliff >= _start); require(token.balanceOf(this) >= totalVested.sub(totalReleased).add(_vested)); beneficiaries[_beneficiary] = Beneficiary({ released : 0, vested : _vested, start : _start, cliff : _cliff, duration : _duration, revoked : false, revocable : _revocable, isBeneficiary : true }); totalVested = totalVested.add(_vested); NewBeneficiary(_beneficiary); } /** * @notice Allows the owner to revoke the vesting. Tokens already vested * remain in the contract, the rest are returned to the owner. * @param _beneficiary Beneficiary address */ function revoke(address _beneficiary) public onlyOwner { Beneficiary storage beneficiary = beneficiaries[_beneficiary]; require(beneficiary.revocable); require(!beneficiary.revoked); uint256 balance = beneficiary.vested.sub(beneficiary.released); uint256 unreleased = releasableAmount(_beneficiary); uint256 refund = balance.sub(unreleased); token.transfer(owner, refund); totalReleased = totalReleased.add(refund); beneficiary.revoked = true; beneficiary.released = beneficiary.released.add(refund); Revoked(_beneficiary); } /** * @notice Allows the owner to destroy a beneficiary. Remain tokens are returned to the owner. * @param _beneficiary Beneficiary address */ function destroyBeneficiary(address _beneficiary) public onlyOwner { Beneficiary storage beneficiary = beneficiaries[_beneficiary]; uint256 balance = beneficiary.vested.sub(beneficiary.released); token.transfer(owner, balance); totalReleased = totalReleased.add(balance); beneficiary.isBeneficiary = false; beneficiary.released = beneficiary.released.add(balance); BeneficiaryDestroyed(_beneficiary); } /** * @dev Calculates the amount that has already vested but hasn't been released yet. * @param _beneficiary Beneficiary address */ function releasableAmount(address _beneficiary) public view returns (uint256) { return vestedAmount(_beneficiary).sub(beneficiaries[_beneficiary].released); } /** * @dev Calculates the amount that has already vested. * @param _beneficiary Beneficiary address */ function vestedAmount(address _beneficiary) public view returns (uint256) { Beneficiary storage beneficiary = beneficiaries[_beneficiary]; uint256 totalBalance = beneficiary.vested; if (now < beneficiary.cliff) { return 0; } else if (now >= beneficiary.start.add(beneficiary.duration) || beneficiary.revoked) { return totalBalance; } else { return totalBalance.mul(now.sub(beneficiary.start)).div(beneficiary.duration); } } /** * @notice Allows the owner to flush the eth. */ function flushEth() public onlyOwner { owner.transfer(this.balance); } /** * @notice Allows the owner to destroy the contract and return the tokens to the owner. */ function destroy() public onlyOwner { token.transfer(owner, token.balanceOf(this)); selfdestruct(owner); } }
revoke
function revoke(address _beneficiary) public onlyOwner { Beneficiary storage beneficiary = beneficiaries[_beneficiary]; require(beneficiary.revocable); require(!beneficiary.revoked); uint256 balance = beneficiary.vested.sub(beneficiary.released); uint256 unreleased = releasableAmount(_beneficiary); uint256 refund = balance.sub(unreleased); token.transfer(owner, refund); totalReleased = totalReleased.add(refund); beneficiary.revoked = true; beneficiary.released = beneficiary.released.add(refund); Revoked(_beneficiary); }
/** * @notice Allows the owner to revoke the vesting. Tokens already vested * remain in the contract, the rest are returned to the owner. * @param _beneficiary Beneficiary address */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://bd1d9802790e0281240ddbd34fb7e404a0dc8500b3639c2b04a8a6c42f0133ab
{ "func_code_index": [ 4425, 5071 ] }
56,260