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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
RiyadhAgency | RiyadhAgency.sol | 0x5e65eb881346dfba15419bbf14bfc3927984e9dc | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view 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 {_setupDecimals} is
* called.
*
* 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 returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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].add(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) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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 = _totalSupply.add(amount);
_balances[account] = _balances[account].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `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 Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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 override returns (uint256) {
return _balances[account];
}
| /**
* @dev See {IERC20-balanceOf}.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://a6496326497b0de5d5b38adbd1cc2dbef988d0badfd0c2478195ea13870bf0c9 | {
"func_code_index": [
2140,
2264
]
} | 5,500 |
RiyadhAgency | RiyadhAgency.sol | 0x5e65eb881346dfba15419bbf14bfc3927984e9dc | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view 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 {_setupDecimals} is
* called.
*
* 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 returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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].add(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) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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 = _totalSupply.add(amount);
_balances[account] = _balances[account].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `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 Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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.6.12+commit.27d51765 | MIT | ipfs://a6496326497b0de5d5b38adbd1cc2dbef988d0badfd0c2478195ea13870bf0c9 | {
"func_code_index": [
2472,
2652
]
} | 5,501 |
RiyadhAgency | RiyadhAgency.sol | 0x5e65eb881346dfba15419bbf14bfc3927984e9dc | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view 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 {_setupDecimals} is
* called.
*
* 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 returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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].add(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) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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 = _totalSupply.add(amount);
_balances[account] = _balances[account].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `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 Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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.6.12+commit.27d51765 | MIT | ipfs://a6496326497b0de5d5b38adbd1cc2dbef988d0badfd0c2478195ea13870bf0c9 | {
"func_code_index": [
2710,
2866
]
} | 5,502 |
RiyadhAgency | RiyadhAgency.sol | 0x5e65eb881346dfba15419bbf14bfc3927984e9dc | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view 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 {_setupDecimals} is
* called.
*
* 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 returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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].add(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) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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 = _totalSupply.add(amount);
_balances[account] = _balances[account].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `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 Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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.6.12+commit.27d51765 | MIT | ipfs://a6496326497b0de5d5b38adbd1cc2dbef988d0badfd0c2478195ea13870bf0c9 | {
"func_code_index": [
3008,
3182
]
} | 5,503 |
RiyadhAgency | RiyadhAgency.sol | 0x5e65eb881346dfba15419bbf14bfc3927984e9dc | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view 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 {_setupDecimals} is
* called.
*
* 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 returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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].add(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) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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 = _totalSupply.add(amount);
_balances[account] = _balances[account].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `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 Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
| /**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://a6496326497b0de5d5b38adbd1cc2dbef988d0badfd0c2478195ea13870bf0c9 | {
"func_code_index": [
3651,
3977
]
} | 5,504 |
RiyadhAgency | RiyadhAgency.sol | 0x5e65eb881346dfba15419bbf14bfc3927984e9dc | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view 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 {_setupDecimals} is
* called.
*
* 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 returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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].add(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) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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 = _totalSupply.add(amount);
_balances[account] = _balances[account].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `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 Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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].add(addedValue));
return true;
}
| /**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://a6496326497b0de5d5b38adbd1cc2dbef988d0badfd0c2478195ea13870bf0c9 | {
"func_code_index": [
4381,
4604
]
} | 5,505 |
RiyadhAgency | RiyadhAgency.sol | 0x5e65eb881346dfba15419bbf14bfc3927984e9dc | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view 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 {_setupDecimals} is
* called.
*
* 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 returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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].add(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) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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 = _totalSupply.add(amount);
_balances[account] = _balances[account].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `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 Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
| /**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://a6496326497b0de5d5b38adbd1cc2dbef988d0badfd0c2478195ea13870bf0c9 | {
"func_code_index": [
5102,
5376
]
} | 5,506 |
RiyadhAgency | RiyadhAgency.sol | 0x5e65eb881346dfba15419bbf14bfc3927984e9dc | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view 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 {_setupDecimals} is
* called.
*
* 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 returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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].add(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) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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 = _totalSupply.add(amount);
_balances[account] = _balances[account].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `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 Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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.6.12+commit.27d51765 | MIT | ipfs://a6496326497b0de5d5b38adbd1cc2dbef988d0badfd0c2478195ea13870bf0c9 | {
"func_code_index": [
5861,
6405
]
} | 5,507 |
RiyadhAgency | RiyadhAgency.sol | 0x5e65eb881346dfba15419bbf14bfc3927984e9dc | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view 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 {_setupDecimals} is
* called.
*
* 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 returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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].add(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) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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 = _totalSupply.add(amount);
_balances[account] = _balances[account].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `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 Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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 = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
| /** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://a6496326497b0de5d5b38adbd1cc2dbef988d0badfd0c2478195ea13870bf0c9 | {
"func_code_index": [
6681,
7064
]
} | 5,508 |
RiyadhAgency | RiyadhAgency.sol | 0x5e65eb881346dfba15419bbf14bfc3927984e9dc | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view 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 {_setupDecimals} is
* called.
*
* 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 returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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].add(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) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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 = _totalSupply.add(amount);
_balances[account] = _balances[account].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `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 Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(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.6.12+commit.27d51765 | MIT | ipfs://a6496326497b0de5d5b38adbd1cc2dbef988d0badfd0c2478195ea13870bf0c9 | {
"func_code_index": [
7391,
7814
]
} | 5,509 |
RiyadhAgency | RiyadhAgency.sol | 0x5e65eb881346dfba15419bbf14bfc3927984e9dc | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view 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 {_setupDecimals} is
* called.
*
* 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 returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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].add(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) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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 = _totalSupply.add(amount);
_balances[account] = _balances[account].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `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 Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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 is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://a6496326497b0de5d5b38adbd1cc2dbef988d0badfd0c2478195ea13870bf0c9 | {
"func_code_index": [
8249,
8600
]
} | 5,510 |
RiyadhAgency | RiyadhAgency.sol | 0x5e65eb881346dfba15419bbf14bfc3927984e9dc | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view 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 {_setupDecimals} is
* called.
*
* 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 returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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].add(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) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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 = _totalSupply.add(amount);
_balances[account] = _balances[account].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `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 Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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 | _setupDecimals | function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
| /**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://a6496326497b0de5d5b38adbd1cc2dbef988d0badfd0c2478195ea13870bf0c9 | {
"func_code_index": [
8927,
9022
]
} | 5,511 |
RiyadhAgency | RiyadhAgency.sol | 0x5e65eb881346dfba15419bbf14bfc3927984e9dc | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view 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 {_setupDecimals} is
* called.
*
* 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 returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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].add(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) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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 = _totalSupply.add(amount);
_balances[account] = _balances[account].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `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 Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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.6.12+commit.27d51765 | MIT | ipfs://a6496326497b0de5d5b38adbd1cc2dbef988d0badfd0c2478195ea13870bf0c9 | {
"func_code_index": [
9620,
9717
]
} | 5,512 |
RiyadhAgency | RiyadhAgency.sol | 0x5e65eb881346dfba15419bbf14bfc3927984e9dc | Solidity | RiyadhCityToken | contract RiyadhCityToken is ERC20("RIYADH.cityswap.io", "RIYADH"), Ownable {
uint256 public constant MAX_SUPPLY = 5041000 * 10**18;
/**
* @notice Creates `_amount` token to `_to`. Must only be called by the owner (TravelAgency).
*/
function mint(address _to, uint256 _amount) public onlyOwner {
uint256 _totalSupply = totalSupply();
if(_totalSupply.add(_amount) > MAX_SUPPLY) {
_amount = MAX_SUPPLY.sub(_totalSupply);
}
require(_totalSupply.add(_amount) <= MAX_SUPPLY);
_mint(_to, _amount);
}
} | // CityToken with Governance. | LineComment | mint | function mint(address _to, uint256 _amount) public onlyOwner {
uint256 _totalSupply = totalSupply();
if(_totalSupply.add(_amount) > MAX_SUPPLY) {
_amount = MAX_SUPPLY.sub(_totalSupply);
}
require(_totalSupply.add(_amount) <= MAX_SUPPLY);
_mint(_to, _amount);
}
| /**
* @notice Creates `_amount` token to `_to`. Must only be called by the owner (TravelAgency).
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://a6496326497b0de5d5b38adbd1cc2dbef988d0badfd0c2478195ea13870bf0c9 | {
"func_code_index": [
272,
622
]
} | 5,513 |
RiyadhAgency | RiyadhAgency.sol | 0x5e65eb881346dfba15419bbf14bfc3927984e9dc | Solidity | RiyadhAgency | contract RiyadhAgency is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some fancy math here. Basically, any point in time, the amount of CITYs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accCityPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accCityPerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
}
// Info of each pool.
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. CITYs to distribute per block.
uint256 lastRewardBlock; // Last block number that CITYs distribution occurs.
uint256 accCityPerShare; // Accumulated CITYs per share, times 1e12. See below.
}
// The CITY TOKEN!
RiyadhCityToken public city;
// Dev address.
address public devaddr;
// Block number when bonus CITY period ends.
uint256 public bonusEndBlock;
// CITY tokens created per block.
uint256 public cityPerBlock;
// Bonus muliplier for early city travels.
uint256 public constant BONUS_MULTIPLIER = 1; // no bonus
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes LP tokens.
mapping (uint256 => mapping (address => UserInfo)) public userInfo;
// Total allocation poitns. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
// The block number when CITY mining starts.
uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
RiyadhCityToken _city,
address _devaddr,
uint256 _cityPerBlock,
uint256 _startBlock,
uint256 _bonusEndBlock
) public {
city = _city;
devaddr = _devaddr;
cityPerBlock = _cityPerBlock;
bonusEndBlock = _bonusEndBlock;
startBlock = _startBlock;
}
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
// Add a new lp to the pool. Can only be called by the owner.
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accCityPerShare: 0
}));
}
// Update the given pool's CITY allocation point. Can only be called by the owner.
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint;
}
// Return reward multiplier over the given _from to _to block.
function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) {
if (_to <= bonusEndBlock) {
return _to.sub(_from).mul(BONUS_MULTIPLIER);
} else if (_from >= bonusEndBlock) {
return _to.sub(_from);
} else {
return bonusEndBlock.sub(_from).mul(BONUS_MULTIPLIER).add(
_to.sub(bonusEndBlock)
);
}
}
// View function to see pending CITYs on frontend.
function pendingCity(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accCityPerShare = pool.accCityPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accCityPerShare = accCityPerShare.add(cityReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accCityPerShare).div(1e12).sub(user.rewardDebt);
}
// Update reward vairables for all pools. Be careful of gas spending!
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
// Update reward variables of the given pool to be up-to-date.
function mint(uint256 amount) public onlyOwner{
city.mint(devaddr, amount);
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
city.mint(devaddr, cityReward.div(20)); // 5%
city.mint(address(this), cityReward);
pool.accCityPerShare = pool.accCityPerShare.add(cityReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.number;
}
// Deposit LP tokens to TravelAgency for CITY allocation.
function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending);
}
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending);
user.amount = user.amount.sub(_amount);
user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit Withdraw(msg.sender, _pid, _amount);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
}
// Safe city transfer function, just in case if rounding error causes pool to not have enough CITYs.
function safeCityTransfer(address _to, uint256 _amount) internal {
uint256 cityBal = city.balanceOf(address(this));
if (_amount > cityBal) {
city.transfer(_to, cityBal);
} else {
city.transfer(_to, _amount);
}
}
// Update dev address by the previous dev.
function dev(address _devaddr) public {
require(msg.sender == devaddr, "dev: wut?");
devaddr = _devaddr;
}
} | add | function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accCityPerShare: 0
}));
}
| // Add a new lp to the pool. Can only be called by the owner.
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do. | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://a6496326497b0de5d5b38adbd1cc2dbef988d0badfd0c2478195ea13870bf0c9 | {
"func_code_index": [
3008,
3530
]
} | 5,514 |
||
RiyadhAgency | RiyadhAgency.sol | 0x5e65eb881346dfba15419bbf14bfc3927984e9dc | Solidity | RiyadhAgency | contract RiyadhAgency is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some fancy math here. Basically, any point in time, the amount of CITYs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accCityPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accCityPerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
}
// Info of each pool.
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. CITYs to distribute per block.
uint256 lastRewardBlock; // Last block number that CITYs distribution occurs.
uint256 accCityPerShare; // Accumulated CITYs per share, times 1e12. See below.
}
// The CITY TOKEN!
RiyadhCityToken public city;
// Dev address.
address public devaddr;
// Block number when bonus CITY period ends.
uint256 public bonusEndBlock;
// CITY tokens created per block.
uint256 public cityPerBlock;
// Bonus muliplier for early city travels.
uint256 public constant BONUS_MULTIPLIER = 1; // no bonus
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes LP tokens.
mapping (uint256 => mapping (address => UserInfo)) public userInfo;
// Total allocation poitns. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
// The block number when CITY mining starts.
uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
RiyadhCityToken _city,
address _devaddr,
uint256 _cityPerBlock,
uint256 _startBlock,
uint256 _bonusEndBlock
) public {
city = _city;
devaddr = _devaddr;
cityPerBlock = _cityPerBlock;
bonusEndBlock = _bonusEndBlock;
startBlock = _startBlock;
}
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
// Add a new lp to the pool. Can only be called by the owner.
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accCityPerShare: 0
}));
}
// Update the given pool's CITY allocation point. Can only be called by the owner.
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint;
}
// Return reward multiplier over the given _from to _to block.
function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) {
if (_to <= bonusEndBlock) {
return _to.sub(_from).mul(BONUS_MULTIPLIER);
} else if (_from >= bonusEndBlock) {
return _to.sub(_from);
} else {
return bonusEndBlock.sub(_from).mul(BONUS_MULTIPLIER).add(
_to.sub(bonusEndBlock)
);
}
}
// View function to see pending CITYs on frontend.
function pendingCity(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accCityPerShare = pool.accCityPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accCityPerShare = accCityPerShare.add(cityReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accCityPerShare).div(1e12).sub(user.rewardDebt);
}
// Update reward vairables for all pools. Be careful of gas spending!
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
// Update reward variables of the given pool to be up-to-date.
function mint(uint256 amount) public onlyOwner{
city.mint(devaddr, amount);
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
city.mint(devaddr, cityReward.div(20)); // 5%
city.mint(address(this), cityReward);
pool.accCityPerShare = pool.accCityPerShare.add(cityReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.number;
}
// Deposit LP tokens to TravelAgency for CITY allocation.
function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending);
}
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending);
user.amount = user.amount.sub(_amount);
user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit Withdraw(msg.sender, _pid, _amount);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
}
// Safe city transfer function, just in case if rounding error causes pool to not have enough CITYs.
function safeCityTransfer(address _to, uint256 _amount) internal {
uint256 cityBal = city.balanceOf(address(this));
if (_amount > cityBal) {
city.transfer(_to, cityBal);
} else {
city.transfer(_to, _amount);
}
}
// Update dev address by the previous dev.
function dev(address _devaddr) public {
require(msg.sender == devaddr, "dev: wut?");
devaddr = _devaddr;
}
} | set | function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint;
}
| // Update the given pool's CITY allocation point. Can only be called by the owner. | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://a6496326497b0de5d5b38adbd1cc2dbef988d0badfd0c2478195ea13870bf0c9 | {
"func_code_index": [
3621,
3930
]
} | 5,515 |
||
RiyadhAgency | RiyadhAgency.sol | 0x5e65eb881346dfba15419bbf14bfc3927984e9dc | Solidity | RiyadhAgency | contract RiyadhAgency is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some fancy math here. Basically, any point in time, the amount of CITYs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accCityPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accCityPerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
}
// Info of each pool.
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. CITYs to distribute per block.
uint256 lastRewardBlock; // Last block number that CITYs distribution occurs.
uint256 accCityPerShare; // Accumulated CITYs per share, times 1e12. See below.
}
// The CITY TOKEN!
RiyadhCityToken public city;
// Dev address.
address public devaddr;
// Block number when bonus CITY period ends.
uint256 public bonusEndBlock;
// CITY tokens created per block.
uint256 public cityPerBlock;
// Bonus muliplier for early city travels.
uint256 public constant BONUS_MULTIPLIER = 1; // no bonus
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes LP tokens.
mapping (uint256 => mapping (address => UserInfo)) public userInfo;
// Total allocation poitns. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
// The block number when CITY mining starts.
uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
RiyadhCityToken _city,
address _devaddr,
uint256 _cityPerBlock,
uint256 _startBlock,
uint256 _bonusEndBlock
) public {
city = _city;
devaddr = _devaddr;
cityPerBlock = _cityPerBlock;
bonusEndBlock = _bonusEndBlock;
startBlock = _startBlock;
}
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
// Add a new lp to the pool. Can only be called by the owner.
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accCityPerShare: 0
}));
}
// Update the given pool's CITY allocation point. Can only be called by the owner.
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint;
}
// Return reward multiplier over the given _from to _to block.
function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) {
if (_to <= bonusEndBlock) {
return _to.sub(_from).mul(BONUS_MULTIPLIER);
} else if (_from >= bonusEndBlock) {
return _to.sub(_from);
} else {
return bonusEndBlock.sub(_from).mul(BONUS_MULTIPLIER).add(
_to.sub(bonusEndBlock)
);
}
}
// View function to see pending CITYs on frontend.
function pendingCity(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accCityPerShare = pool.accCityPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accCityPerShare = accCityPerShare.add(cityReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accCityPerShare).div(1e12).sub(user.rewardDebt);
}
// Update reward vairables for all pools. Be careful of gas spending!
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
// Update reward variables of the given pool to be up-to-date.
function mint(uint256 amount) public onlyOwner{
city.mint(devaddr, amount);
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
city.mint(devaddr, cityReward.div(20)); // 5%
city.mint(address(this), cityReward);
pool.accCityPerShare = pool.accCityPerShare.add(cityReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.number;
}
// Deposit LP tokens to TravelAgency for CITY allocation.
function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending);
}
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending);
user.amount = user.amount.sub(_amount);
user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit Withdraw(msg.sender, _pid, _amount);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
}
// Safe city transfer function, just in case if rounding error causes pool to not have enough CITYs.
function safeCityTransfer(address _to, uint256 _amount) internal {
uint256 cityBal = city.balanceOf(address(this));
if (_amount > cityBal) {
city.transfer(_to, cityBal);
} else {
city.transfer(_to, _amount);
}
}
// Update dev address by the previous dev.
function dev(address _devaddr) public {
require(msg.sender == devaddr, "dev: wut?");
devaddr = _devaddr;
}
} | getMultiplier | function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) {
if (_to <= bonusEndBlock) {
return _to.sub(_from).mul(BONUS_MULTIPLIER);
} else if (_from >= bonusEndBlock) {
return _to.sub(_from);
} else {
return bonusEndBlock.sub(_from).mul(BONUS_MULTIPLIER).add(
_to.sub(bonusEndBlock)
);
}
}
| // Return reward multiplier over the given _from to _to block. | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://a6496326497b0de5d5b38adbd1cc2dbef988d0badfd0c2478195ea13870bf0c9 | {
"func_code_index": [
4001,
4429
]
} | 5,516 |
||
RiyadhAgency | RiyadhAgency.sol | 0x5e65eb881346dfba15419bbf14bfc3927984e9dc | Solidity | RiyadhAgency | contract RiyadhAgency is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some fancy math here. Basically, any point in time, the amount of CITYs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accCityPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accCityPerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
}
// Info of each pool.
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. CITYs to distribute per block.
uint256 lastRewardBlock; // Last block number that CITYs distribution occurs.
uint256 accCityPerShare; // Accumulated CITYs per share, times 1e12. See below.
}
// The CITY TOKEN!
RiyadhCityToken public city;
// Dev address.
address public devaddr;
// Block number when bonus CITY period ends.
uint256 public bonusEndBlock;
// CITY tokens created per block.
uint256 public cityPerBlock;
// Bonus muliplier for early city travels.
uint256 public constant BONUS_MULTIPLIER = 1; // no bonus
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes LP tokens.
mapping (uint256 => mapping (address => UserInfo)) public userInfo;
// Total allocation poitns. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
// The block number when CITY mining starts.
uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
RiyadhCityToken _city,
address _devaddr,
uint256 _cityPerBlock,
uint256 _startBlock,
uint256 _bonusEndBlock
) public {
city = _city;
devaddr = _devaddr;
cityPerBlock = _cityPerBlock;
bonusEndBlock = _bonusEndBlock;
startBlock = _startBlock;
}
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
// Add a new lp to the pool. Can only be called by the owner.
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accCityPerShare: 0
}));
}
// Update the given pool's CITY allocation point. Can only be called by the owner.
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint;
}
// Return reward multiplier over the given _from to _to block.
function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) {
if (_to <= bonusEndBlock) {
return _to.sub(_from).mul(BONUS_MULTIPLIER);
} else if (_from >= bonusEndBlock) {
return _to.sub(_from);
} else {
return bonusEndBlock.sub(_from).mul(BONUS_MULTIPLIER).add(
_to.sub(bonusEndBlock)
);
}
}
// View function to see pending CITYs on frontend.
function pendingCity(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accCityPerShare = pool.accCityPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accCityPerShare = accCityPerShare.add(cityReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accCityPerShare).div(1e12).sub(user.rewardDebt);
}
// Update reward vairables for all pools. Be careful of gas spending!
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
// Update reward variables of the given pool to be up-to-date.
function mint(uint256 amount) public onlyOwner{
city.mint(devaddr, amount);
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
city.mint(devaddr, cityReward.div(20)); // 5%
city.mint(address(this), cityReward);
pool.accCityPerShare = pool.accCityPerShare.add(cityReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.number;
}
// Deposit LP tokens to TravelAgency for CITY allocation.
function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending);
}
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending);
user.amount = user.amount.sub(_amount);
user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit Withdraw(msg.sender, _pid, _amount);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
}
// Safe city transfer function, just in case if rounding error causes pool to not have enough CITYs.
function safeCityTransfer(address _to, uint256 _amount) internal {
uint256 cityBal = city.balanceOf(address(this));
if (_amount > cityBal) {
city.transfer(_to, cityBal);
} else {
city.transfer(_to, _amount);
}
}
// Update dev address by the previous dev.
function dev(address _devaddr) public {
require(msg.sender == devaddr, "dev: wut?");
devaddr = _devaddr;
}
} | pendingCity | function pendingCity(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accCityPerShare = pool.accCityPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accCityPerShare = accCityPerShare.add(cityReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accCityPerShare).div(1e12).sub(user.rewardDebt);
}
| // View function to see pending CITYs on frontend. | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://a6496326497b0de5d5b38adbd1cc2dbef988d0badfd0c2478195ea13870bf0c9 | {
"func_code_index": [
4488,
5252
]
} | 5,517 |
||
RiyadhAgency | RiyadhAgency.sol | 0x5e65eb881346dfba15419bbf14bfc3927984e9dc | Solidity | RiyadhAgency | contract RiyadhAgency is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some fancy math here. Basically, any point in time, the amount of CITYs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accCityPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accCityPerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
}
// Info of each pool.
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. CITYs to distribute per block.
uint256 lastRewardBlock; // Last block number that CITYs distribution occurs.
uint256 accCityPerShare; // Accumulated CITYs per share, times 1e12. See below.
}
// The CITY TOKEN!
RiyadhCityToken public city;
// Dev address.
address public devaddr;
// Block number when bonus CITY period ends.
uint256 public bonusEndBlock;
// CITY tokens created per block.
uint256 public cityPerBlock;
// Bonus muliplier for early city travels.
uint256 public constant BONUS_MULTIPLIER = 1; // no bonus
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes LP tokens.
mapping (uint256 => mapping (address => UserInfo)) public userInfo;
// Total allocation poitns. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
// The block number when CITY mining starts.
uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
RiyadhCityToken _city,
address _devaddr,
uint256 _cityPerBlock,
uint256 _startBlock,
uint256 _bonusEndBlock
) public {
city = _city;
devaddr = _devaddr;
cityPerBlock = _cityPerBlock;
bonusEndBlock = _bonusEndBlock;
startBlock = _startBlock;
}
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
// Add a new lp to the pool. Can only be called by the owner.
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accCityPerShare: 0
}));
}
// Update the given pool's CITY allocation point. Can only be called by the owner.
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint;
}
// Return reward multiplier over the given _from to _to block.
function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) {
if (_to <= bonusEndBlock) {
return _to.sub(_from).mul(BONUS_MULTIPLIER);
} else if (_from >= bonusEndBlock) {
return _to.sub(_from);
} else {
return bonusEndBlock.sub(_from).mul(BONUS_MULTIPLIER).add(
_to.sub(bonusEndBlock)
);
}
}
// View function to see pending CITYs on frontend.
function pendingCity(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accCityPerShare = pool.accCityPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accCityPerShare = accCityPerShare.add(cityReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accCityPerShare).div(1e12).sub(user.rewardDebt);
}
// Update reward vairables for all pools. Be careful of gas spending!
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
// Update reward variables of the given pool to be up-to-date.
function mint(uint256 amount) public onlyOwner{
city.mint(devaddr, amount);
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
city.mint(devaddr, cityReward.div(20)); // 5%
city.mint(address(this), cityReward);
pool.accCityPerShare = pool.accCityPerShare.add(cityReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.number;
}
// Deposit LP tokens to TravelAgency for CITY allocation.
function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending);
}
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending);
user.amount = user.amount.sub(_amount);
user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit Withdraw(msg.sender, _pid, _amount);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
}
// Safe city transfer function, just in case if rounding error causes pool to not have enough CITYs.
function safeCityTransfer(address _to, uint256 _amount) internal {
uint256 cityBal = city.balanceOf(address(this));
if (_amount > cityBal) {
city.transfer(_to, cityBal);
} else {
city.transfer(_to, _amount);
}
}
// Update dev address by the previous dev.
function dev(address _devaddr) public {
require(msg.sender == devaddr, "dev: wut?");
devaddr = _devaddr;
}
} | massUpdatePools | function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
| // Update reward vairables for all pools. Be careful of gas spending! | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://a6496326497b0de5d5b38adbd1cc2dbef988d0badfd0c2478195ea13870bf0c9 | {
"func_code_index": [
5330,
5515
]
} | 5,518 |
||
RiyadhAgency | RiyadhAgency.sol | 0x5e65eb881346dfba15419bbf14bfc3927984e9dc | Solidity | RiyadhAgency | contract RiyadhAgency is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some fancy math here. Basically, any point in time, the amount of CITYs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accCityPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accCityPerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
}
// Info of each pool.
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. CITYs to distribute per block.
uint256 lastRewardBlock; // Last block number that CITYs distribution occurs.
uint256 accCityPerShare; // Accumulated CITYs per share, times 1e12. See below.
}
// The CITY TOKEN!
RiyadhCityToken public city;
// Dev address.
address public devaddr;
// Block number when bonus CITY period ends.
uint256 public bonusEndBlock;
// CITY tokens created per block.
uint256 public cityPerBlock;
// Bonus muliplier for early city travels.
uint256 public constant BONUS_MULTIPLIER = 1; // no bonus
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes LP tokens.
mapping (uint256 => mapping (address => UserInfo)) public userInfo;
// Total allocation poitns. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
// The block number when CITY mining starts.
uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
RiyadhCityToken _city,
address _devaddr,
uint256 _cityPerBlock,
uint256 _startBlock,
uint256 _bonusEndBlock
) public {
city = _city;
devaddr = _devaddr;
cityPerBlock = _cityPerBlock;
bonusEndBlock = _bonusEndBlock;
startBlock = _startBlock;
}
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
// Add a new lp to the pool. Can only be called by the owner.
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accCityPerShare: 0
}));
}
// Update the given pool's CITY allocation point. Can only be called by the owner.
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint;
}
// Return reward multiplier over the given _from to _to block.
function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) {
if (_to <= bonusEndBlock) {
return _to.sub(_from).mul(BONUS_MULTIPLIER);
} else if (_from >= bonusEndBlock) {
return _to.sub(_from);
} else {
return bonusEndBlock.sub(_from).mul(BONUS_MULTIPLIER).add(
_to.sub(bonusEndBlock)
);
}
}
// View function to see pending CITYs on frontend.
function pendingCity(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accCityPerShare = pool.accCityPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accCityPerShare = accCityPerShare.add(cityReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accCityPerShare).div(1e12).sub(user.rewardDebt);
}
// Update reward vairables for all pools. Be careful of gas spending!
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
// Update reward variables of the given pool to be up-to-date.
function mint(uint256 amount) public onlyOwner{
city.mint(devaddr, amount);
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
city.mint(devaddr, cityReward.div(20)); // 5%
city.mint(address(this), cityReward);
pool.accCityPerShare = pool.accCityPerShare.add(cityReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.number;
}
// Deposit LP tokens to TravelAgency for CITY allocation.
function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending);
}
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending);
user.amount = user.amount.sub(_amount);
user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit Withdraw(msg.sender, _pid, _amount);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
}
// Safe city transfer function, just in case if rounding error causes pool to not have enough CITYs.
function safeCityTransfer(address _to, uint256 _amount) internal {
uint256 cityBal = city.balanceOf(address(this));
if (_amount > cityBal) {
city.transfer(_to, cityBal);
} else {
city.transfer(_to, _amount);
}
}
// Update dev address by the previous dev.
function dev(address _devaddr) public {
require(msg.sender == devaddr, "dev: wut?");
devaddr = _devaddr;
}
} | mint | function mint(uint256 amount) public onlyOwner{
city.mint(devaddr, amount);
}
| // Update reward variables of the given pool to be up-to-date. | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://a6496326497b0de5d5b38adbd1cc2dbef988d0badfd0c2478195ea13870bf0c9 | {
"func_code_index": [
5584,
5680
]
} | 5,519 |
||
RiyadhAgency | RiyadhAgency.sol | 0x5e65eb881346dfba15419bbf14bfc3927984e9dc | Solidity | RiyadhAgency | contract RiyadhAgency is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some fancy math here. Basically, any point in time, the amount of CITYs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accCityPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accCityPerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
}
// Info of each pool.
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. CITYs to distribute per block.
uint256 lastRewardBlock; // Last block number that CITYs distribution occurs.
uint256 accCityPerShare; // Accumulated CITYs per share, times 1e12. See below.
}
// The CITY TOKEN!
RiyadhCityToken public city;
// Dev address.
address public devaddr;
// Block number when bonus CITY period ends.
uint256 public bonusEndBlock;
// CITY tokens created per block.
uint256 public cityPerBlock;
// Bonus muliplier for early city travels.
uint256 public constant BONUS_MULTIPLIER = 1; // no bonus
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes LP tokens.
mapping (uint256 => mapping (address => UserInfo)) public userInfo;
// Total allocation poitns. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
// The block number when CITY mining starts.
uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
RiyadhCityToken _city,
address _devaddr,
uint256 _cityPerBlock,
uint256 _startBlock,
uint256 _bonusEndBlock
) public {
city = _city;
devaddr = _devaddr;
cityPerBlock = _cityPerBlock;
bonusEndBlock = _bonusEndBlock;
startBlock = _startBlock;
}
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
// Add a new lp to the pool. Can only be called by the owner.
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accCityPerShare: 0
}));
}
// Update the given pool's CITY allocation point. Can only be called by the owner.
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint;
}
// Return reward multiplier over the given _from to _to block.
function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) {
if (_to <= bonusEndBlock) {
return _to.sub(_from).mul(BONUS_MULTIPLIER);
} else if (_from >= bonusEndBlock) {
return _to.sub(_from);
} else {
return bonusEndBlock.sub(_from).mul(BONUS_MULTIPLIER).add(
_to.sub(bonusEndBlock)
);
}
}
// View function to see pending CITYs on frontend.
function pendingCity(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accCityPerShare = pool.accCityPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accCityPerShare = accCityPerShare.add(cityReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accCityPerShare).div(1e12).sub(user.rewardDebt);
}
// Update reward vairables for all pools. Be careful of gas spending!
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
// Update reward variables of the given pool to be up-to-date.
function mint(uint256 amount) public onlyOwner{
city.mint(devaddr, amount);
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
city.mint(devaddr, cityReward.div(20)); // 5%
city.mint(address(this), cityReward);
pool.accCityPerShare = pool.accCityPerShare.add(cityReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.number;
}
// Deposit LP tokens to TravelAgency for CITY allocation.
function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending);
}
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending);
user.amount = user.amount.sub(_amount);
user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit Withdraw(msg.sender, _pid, _amount);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
}
// Safe city transfer function, just in case if rounding error causes pool to not have enough CITYs.
function safeCityTransfer(address _to, uint256 _amount) internal {
uint256 cityBal = city.balanceOf(address(this));
if (_amount > cityBal) {
city.transfer(_to, cityBal);
} else {
city.transfer(_to, _amount);
}
}
// Update dev address by the previous dev.
function dev(address _devaddr) public {
require(msg.sender == devaddr, "dev: wut?");
devaddr = _devaddr;
}
} | updatePool | function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
city.mint(devaddr, cityReward.div(20)); // 5%
city.mint(address(this), cityReward);
pool.accCityPerShare = pool.accCityPerShare.add(cityReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.number;
}
| // Update reward variables of the given pool to be up-to-date. | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://a6496326497b0de5d5b38adbd1cc2dbef988d0badfd0c2478195ea13870bf0c9 | {
"func_code_index": [
5749,
6541
]
} | 5,520 |
||
RiyadhAgency | RiyadhAgency.sol | 0x5e65eb881346dfba15419bbf14bfc3927984e9dc | Solidity | RiyadhAgency | contract RiyadhAgency is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some fancy math here. Basically, any point in time, the amount of CITYs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accCityPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accCityPerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
}
// Info of each pool.
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. CITYs to distribute per block.
uint256 lastRewardBlock; // Last block number that CITYs distribution occurs.
uint256 accCityPerShare; // Accumulated CITYs per share, times 1e12. See below.
}
// The CITY TOKEN!
RiyadhCityToken public city;
// Dev address.
address public devaddr;
// Block number when bonus CITY period ends.
uint256 public bonusEndBlock;
// CITY tokens created per block.
uint256 public cityPerBlock;
// Bonus muliplier for early city travels.
uint256 public constant BONUS_MULTIPLIER = 1; // no bonus
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes LP tokens.
mapping (uint256 => mapping (address => UserInfo)) public userInfo;
// Total allocation poitns. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
// The block number when CITY mining starts.
uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
RiyadhCityToken _city,
address _devaddr,
uint256 _cityPerBlock,
uint256 _startBlock,
uint256 _bonusEndBlock
) public {
city = _city;
devaddr = _devaddr;
cityPerBlock = _cityPerBlock;
bonusEndBlock = _bonusEndBlock;
startBlock = _startBlock;
}
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
// Add a new lp to the pool. Can only be called by the owner.
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accCityPerShare: 0
}));
}
// Update the given pool's CITY allocation point. Can only be called by the owner.
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint;
}
// Return reward multiplier over the given _from to _to block.
function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) {
if (_to <= bonusEndBlock) {
return _to.sub(_from).mul(BONUS_MULTIPLIER);
} else if (_from >= bonusEndBlock) {
return _to.sub(_from);
} else {
return bonusEndBlock.sub(_from).mul(BONUS_MULTIPLIER).add(
_to.sub(bonusEndBlock)
);
}
}
// View function to see pending CITYs on frontend.
function pendingCity(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accCityPerShare = pool.accCityPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accCityPerShare = accCityPerShare.add(cityReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accCityPerShare).div(1e12).sub(user.rewardDebt);
}
// Update reward vairables for all pools. Be careful of gas spending!
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
// Update reward variables of the given pool to be up-to-date.
function mint(uint256 amount) public onlyOwner{
city.mint(devaddr, amount);
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
city.mint(devaddr, cityReward.div(20)); // 5%
city.mint(address(this), cityReward);
pool.accCityPerShare = pool.accCityPerShare.add(cityReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.number;
}
// Deposit LP tokens to TravelAgency for CITY allocation.
function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending);
}
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending);
user.amount = user.amount.sub(_amount);
user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit Withdraw(msg.sender, _pid, _amount);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
}
// Safe city transfer function, just in case if rounding error causes pool to not have enough CITYs.
function safeCityTransfer(address _to, uint256 _amount) internal {
uint256 cityBal = city.balanceOf(address(this));
if (_amount > cityBal) {
city.transfer(_to, cityBal);
} else {
city.transfer(_to, _amount);
}
}
// Update dev address by the previous dev.
function dev(address _devaddr) public {
require(msg.sender == devaddr, "dev: wut?");
devaddr = _devaddr;
}
} | deposit | function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending);
}
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
| // Deposit LP tokens to TravelAgency for CITY allocation. | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://a6496326497b0de5d5b38adbd1cc2dbef988d0badfd0c2478195ea13870bf0c9 | {
"func_code_index": [
6607,
7268
]
} | 5,521 |
||
RiyadhAgency | RiyadhAgency.sol | 0x5e65eb881346dfba15419bbf14bfc3927984e9dc | Solidity | RiyadhAgency | contract RiyadhAgency is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some fancy math here. Basically, any point in time, the amount of CITYs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accCityPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accCityPerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
}
// Info of each pool.
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. CITYs to distribute per block.
uint256 lastRewardBlock; // Last block number that CITYs distribution occurs.
uint256 accCityPerShare; // Accumulated CITYs per share, times 1e12. See below.
}
// The CITY TOKEN!
RiyadhCityToken public city;
// Dev address.
address public devaddr;
// Block number when bonus CITY period ends.
uint256 public bonusEndBlock;
// CITY tokens created per block.
uint256 public cityPerBlock;
// Bonus muliplier for early city travels.
uint256 public constant BONUS_MULTIPLIER = 1; // no bonus
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes LP tokens.
mapping (uint256 => mapping (address => UserInfo)) public userInfo;
// Total allocation poitns. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
// The block number when CITY mining starts.
uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
RiyadhCityToken _city,
address _devaddr,
uint256 _cityPerBlock,
uint256 _startBlock,
uint256 _bonusEndBlock
) public {
city = _city;
devaddr = _devaddr;
cityPerBlock = _cityPerBlock;
bonusEndBlock = _bonusEndBlock;
startBlock = _startBlock;
}
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
// Add a new lp to the pool. Can only be called by the owner.
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accCityPerShare: 0
}));
}
// Update the given pool's CITY allocation point. Can only be called by the owner.
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint;
}
// Return reward multiplier over the given _from to _to block.
function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) {
if (_to <= bonusEndBlock) {
return _to.sub(_from).mul(BONUS_MULTIPLIER);
} else if (_from >= bonusEndBlock) {
return _to.sub(_from);
} else {
return bonusEndBlock.sub(_from).mul(BONUS_MULTIPLIER).add(
_to.sub(bonusEndBlock)
);
}
}
// View function to see pending CITYs on frontend.
function pendingCity(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accCityPerShare = pool.accCityPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accCityPerShare = accCityPerShare.add(cityReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accCityPerShare).div(1e12).sub(user.rewardDebt);
}
// Update reward vairables for all pools. Be careful of gas spending!
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
// Update reward variables of the given pool to be up-to-date.
function mint(uint256 amount) public onlyOwner{
city.mint(devaddr, amount);
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
city.mint(devaddr, cityReward.div(20)); // 5%
city.mint(address(this), cityReward);
pool.accCityPerShare = pool.accCityPerShare.add(cityReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.number;
}
// Deposit LP tokens to TravelAgency for CITY allocation.
function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending);
}
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending);
user.amount = user.amount.sub(_amount);
user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit Withdraw(msg.sender, _pid, _amount);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
}
// Safe city transfer function, just in case if rounding error causes pool to not have enough CITYs.
function safeCityTransfer(address _to, uint256 _amount) internal {
uint256 cityBal = city.balanceOf(address(this));
if (_amount > cityBal) {
city.transfer(_to, cityBal);
} else {
city.transfer(_to, _amount);
}
}
// Update dev address by the previous dev.
function dev(address _devaddr) public {
require(msg.sender == devaddr, "dev: wut?");
devaddr = _devaddr;
}
} | withdraw | function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending);
user.amount = user.amount.sub(_amount);
user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit Withdraw(msg.sender, _pid, _amount);
}
| // Withdraw LP tokens from MasterChef. | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://a6496326497b0de5d5b38adbd1cc2dbef988d0badfd0c2478195ea13870bf0c9 | {
"func_code_index": [
7315,
7972
]
} | 5,522 |
||
RiyadhAgency | RiyadhAgency.sol | 0x5e65eb881346dfba15419bbf14bfc3927984e9dc | Solidity | RiyadhAgency | contract RiyadhAgency is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some fancy math here. Basically, any point in time, the amount of CITYs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accCityPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accCityPerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
}
// Info of each pool.
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. CITYs to distribute per block.
uint256 lastRewardBlock; // Last block number that CITYs distribution occurs.
uint256 accCityPerShare; // Accumulated CITYs per share, times 1e12. See below.
}
// The CITY TOKEN!
RiyadhCityToken public city;
// Dev address.
address public devaddr;
// Block number when bonus CITY period ends.
uint256 public bonusEndBlock;
// CITY tokens created per block.
uint256 public cityPerBlock;
// Bonus muliplier for early city travels.
uint256 public constant BONUS_MULTIPLIER = 1; // no bonus
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes LP tokens.
mapping (uint256 => mapping (address => UserInfo)) public userInfo;
// Total allocation poitns. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
// The block number when CITY mining starts.
uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
RiyadhCityToken _city,
address _devaddr,
uint256 _cityPerBlock,
uint256 _startBlock,
uint256 _bonusEndBlock
) public {
city = _city;
devaddr = _devaddr;
cityPerBlock = _cityPerBlock;
bonusEndBlock = _bonusEndBlock;
startBlock = _startBlock;
}
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
// Add a new lp to the pool. Can only be called by the owner.
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accCityPerShare: 0
}));
}
// Update the given pool's CITY allocation point. Can only be called by the owner.
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint;
}
// Return reward multiplier over the given _from to _to block.
function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) {
if (_to <= bonusEndBlock) {
return _to.sub(_from).mul(BONUS_MULTIPLIER);
} else if (_from >= bonusEndBlock) {
return _to.sub(_from);
} else {
return bonusEndBlock.sub(_from).mul(BONUS_MULTIPLIER).add(
_to.sub(bonusEndBlock)
);
}
}
// View function to see pending CITYs on frontend.
function pendingCity(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accCityPerShare = pool.accCityPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accCityPerShare = accCityPerShare.add(cityReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accCityPerShare).div(1e12).sub(user.rewardDebt);
}
// Update reward vairables for all pools. Be careful of gas spending!
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
// Update reward variables of the given pool to be up-to-date.
function mint(uint256 amount) public onlyOwner{
city.mint(devaddr, amount);
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
city.mint(devaddr, cityReward.div(20)); // 5%
city.mint(address(this), cityReward);
pool.accCityPerShare = pool.accCityPerShare.add(cityReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.number;
}
// Deposit LP tokens to TravelAgency for CITY allocation.
function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending);
}
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending);
user.amount = user.amount.sub(_amount);
user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit Withdraw(msg.sender, _pid, _amount);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
}
// Safe city transfer function, just in case if rounding error causes pool to not have enough CITYs.
function safeCityTransfer(address _to, uint256 _amount) internal {
uint256 cityBal = city.balanceOf(address(this));
if (_amount > cityBal) {
city.transfer(_to, cityBal);
} else {
city.transfer(_to, _amount);
}
}
// Update dev address by the previous dev.
function dev(address _devaddr) public {
require(msg.sender == devaddr, "dev: wut?");
devaddr = _devaddr;
}
} | emergencyWithdraw | function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
}
| // Withdraw without caring about rewards. EMERGENCY ONLY. | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://a6496326497b0de5d5b38adbd1cc2dbef988d0badfd0c2478195ea13870bf0c9 | {
"func_code_index": [
8038,
8399
]
} | 5,523 |
||
RiyadhAgency | RiyadhAgency.sol | 0x5e65eb881346dfba15419bbf14bfc3927984e9dc | Solidity | RiyadhAgency | contract RiyadhAgency is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some fancy math here. Basically, any point in time, the amount of CITYs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accCityPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accCityPerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
}
// Info of each pool.
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. CITYs to distribute per block.
uint256 lastRewardBlock; // Last block number that CITYs distribution occurs.
uint256 accCityPerShare; // Accumulated CITYs per share, times 1e12. See below.
}
// The CITY TOKEN!
RiyadhCityToken public city;
// Dev address.
address public devaddr;
// Block number when bonus CITY period ends.
uint256 public bonusEndBlock;
// CITY tokens created per block.
uint256 public cityPerBlock;
// Bonus muliplier for early city travels.
uint256 public constant BONUS_MULTIPLIER = 1; // no bonus
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes LP tokens.
mapping (uint256 => mapping (address => UserInfo)) public userInfo;
// Total allocation poitns. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
// The block number when CITY mining starts.
uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
RiyadhCityToken _city,
address _devaddr,
uint256 _cityPerBlock,
uint256 _startBlock,
uint256 _bonusEndBlock
) public {
city = _city;
devaddr = _devaddr;
cityPerBlock = _cityPerBlock;
bonusEndBlock = _bonusEndBlock;
startBlock = _startBlock;
}
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
// Add a new lp to the pool. Can only be called by the owner.
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accCityPerShare: 0
}));
}
// Update the given pool's CITY allocation point. Can only be called by the owner.
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint;
}
// Return reward multiplier over the given _from to _to block.
function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) {
if (_to <= bonusEndBlock) {
return _to.sub(_from).mul(BONUS_MULTIPLIER);
} else if (_from >= bonusEndBlock) {
return _to.sub(_from);
} else {
return bonusEndBlock.sub(_from).mul(BONUS_MULTIPLIER).add(
_to.sub(bonusEndBlock)
);
}
}
// View function to see pending CITYs on frontend.
function pendingCity(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accCityPerShare = pool.accCityPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accCityPerShare = accCityPerShare.add(cityReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accCityPerShare).div(1e12).sub(user.rewardDebt);
}
// Update reward vairables for all pools. Be careful of gas spending!
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
// Update reward variables of the given pool to be up-to-date.
function mint(uint256 amount) public onlyOwner{
city.mint(devaddr, amount);
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
city.mint(devaddr, cityReward.div(20)); // 5%
city.mint(address(this), cityReward);
pool.accCityPerShare = pool.accCityPerShare.add(cityReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.number;
}
// Deposit LP tokens to TravelAgency for CITY allocation.
function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending);
}
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending);
user.amount = user.amount.sub(_amount);
user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit Withdraw(msg.sender, _pid, _amount);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
}
// Safe city transfer function, just in case if rounding error causes pool to not have enough CITYs.
function safeCityTransfer(address _to, uint256 _amount) internal {
uint256 cityBal = city.balanceOf(address(this));
if (_amount > cityBal) {
city.transfer(_to, cityBal);
} else {
city.transfer(_to, _amount);
}
}
// Update dev address by the previous dev.
function dev(address _devaddr) public {
require(msg.sender == devaddr, "dev: wut?");
devaddr = _devaddr;
}
} | safeCityTransfer | function safeCityTransfer(address _to, uint256 _amount) internal {
uint256 cityBal = city.balanceOf(address(this));
if (_amount > cityBal) {
city.transfer(_to, cityBal);
} else {
city.transfer(_to, _amount);
}
}
| // Safe city transfer function, just in case if rounding error causes pool to not have enough CITYs. | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://a6496326497b0de5d5b38adbd1cc2dbef988d0badfd0c2478195ea13870bf0c9 | {
"func_code_index": [
8508,
8791
]
} | 5,524 |
||
RiyadhAgency | RiyadhAgency.sol | 0x5e65eb881346dfba15419bbf14bfc3927984e9dc | Solidity | RiyadhAgency | contract RiyadhAgency is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some fancy math here. Basically, any point in time, the amount of CITYs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accCityPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accCityPerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
}
// Info of each pool.
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. CITYs to distribute per block.
uint256 lastRewardBlock; // Last block number that CITYs distribution occurs.
uint256 accCityPerShare; // Accumulated CITYs per share, times 1e12. See below.
}
// The CITY TOKEN!
RiyadhCityToken public city;
// Dev address.
address public devaddr;
// Block number when bonus CITY period ends.
uint256 public bonusEndBlock;
// CITY tokens created per block.
uint256 public cityPerBlock;
// Bonus muliplier for early city travels.
uint256 public constant BONUS_MULTIPLIER = 1; // no bonus
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes LP tokens.
mapping (uint256 => mapping (address => UserInfo)) public userInfo;
// Total allocation poitns. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
// The block number when CITY mining starts.
uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
RiyadhCityToken _city,
address _devaddr,
uint256 _cityPerBlock,
uint256 _startBlock,
uint256 _bonusEndBlock
) public {
city = _city;
devaddr = _devaddr;
cityPerBlock = _cityPerBlock;
bonusEndBlock = _bonusEndBlock;
startBlock = _startBlock;
}
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
// Add a new lp to the pool. Can only be called by the owner.
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accCityPerShare: 0
}));
}
// Update the given pool's CITY allocation point. Can only be called by the owner.
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint;
}
// Return reward multiplier over the given _from to _to block.
function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) {
if (_to <= bonusEndBlock) {
return _to.sub(_from).mul(BONUS_MULTIPLIER);
} else if (_from >= bonusEndBlock) {
return _to.sub(_from);
} else {
return bonusEndBlock.sub(_from).mul(BONUS_MULTIPLIER).add(
_to.sub(bonusEndBlock)
);
}
}
// View function to see pending CITYs on frontend.
function pendingCity(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accCityPerShare = pool.accCityPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accCityPerShare = accCityPerShare.add(cityReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accCityPerShare).div(1e12).sub(user.rewardDebt);
}
// Update reward vairables for all pools. Be careful of gas spending!
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
// Update reward variables of the given pool to be up-to-date.
function mint(uint256 amount) public onlyOwner{
city.mint(devaddr, amount);
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
city.mint(devaddr, cityReward.div(20)); // 5%
city.mint(address(this), cityReward);
pool.accCityPerShare = pool.accCityPerShare.add(cityReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.number;
}
// Deposit LP tokens to TravelAgency for CITY allocation.
function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending);
}
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt);
safeCityTransfer(msg.sender, pending);
user.amount = user.amount.sub(_amount);
user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit Withdraw(msg.sender, _pid, _amount);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
}
// Safe city transfer function, just in case if rounding error causes pool to not have enough CITYs.
function safeCityTransfer(address _to, uint256 _amount) internal {
uint256 cityBal = city.balanceOf(address(this));
if (_amount > cityBal) {
city.transfer(_to, cityBal);
} else {
city.transfer(_to, _amount);
}
}
// Update dev address by the previous dev.
function dev(address _devaddr) public {
require(msg.sender == devaddr, "dev: wut?");
devaddr = _devaddr;
}
} | dev | function dev(address _devaddr) public {
require(msg.sender == devaddr, "dev: wut?");
devaddr = _devaddr;
}
| // Update dev address by the previous dev. | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://a6496326497b0de5d5b38adbd1cc2dbef988d0badfd0c2478195ea13870bf0c9 | {
"func_code_index": [
8842,
8976
]
} | 5,525 |
||
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | 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;
}
} | /**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/ | NatSpecMultiLine | 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.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
261,
321
]
} | 5,526 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | 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;
}
} | /**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/ | NatSpecMultiLine | 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.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
644,
820
]
} | 5,527 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
} | /**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/ | NatSpecMultiLine | transfer | function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
| /**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
268,
659
]
} | 5,528 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
} | /**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/ | NatSpecMultiLine | balanceOf | function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
| /**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
865,
977
]
} | 5,529 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
* @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | transferFrom | function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
| /**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
401,
853
]
} | 5,530 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
* @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | approve | function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
| /**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
1485,
1675
]
} | 5,531 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
* @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | allowance | function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
| /**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
1999,
2130
]
} | 5,532 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
* @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | increaseApproval | function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
| /**
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
2596,
2860
]
} | 5,533 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
* @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | decreaseApproval | function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
| /**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
3331,
3741
]
} | 5,534 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | MintableToken | contract MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
totalSupply = totalSupply.add(_amount);
balances[_to] = balances[_to].add(_amount);
Mint(_to, _amount);
Transfer(address(0), _to, _amount);
return true;
}
/**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/
function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
MintFinished();
return true;
}
} | /**
* @title Mintable token
* @dev Simple ERC20 Token example, with mintable token creation
* @dev Issue: * https://github.com/OpenZeppelin/zeppelin-solidity/issues/120
* Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol
*/ | NatSpecMultiLine | mint | function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
totalSupply = totalSupply.add(_amount);
balances[_to] = balances[_to].add(_amount);
Mint(_to, _amount);
Transfer(address(0), _to, _amount);
return true;
}
| /**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
483,
754
]
} | 5,535 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | MintableToken | contract MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
totalSupply = totalSupply.add(_amount);
balances[_to] = balances[_to].add(_amount);
Mint(_to, _amount);
Transfer(address(0), _to, _amount);
return true;
}
/**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/
function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
MintFinished();
return true;
}
} | /**
* @title Mintable token
* @dev Simple ERC20 Token example, with mintable token creation
* @dev Issue: * https://github.com/OpenZeppelin/zeppelin-solidity/issues/120
* Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol
*/ | NatSpecMultiLine | finishMinting | function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
MintFinished();
return true;
}
| /**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
871,
1013
]
} | 5,536 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | SelfKeyToken | contract SelfKeyToken is MintableToken {
string public constant name = 'SelfKey'; //solhint-disable-line const-name-snakecase
string public constant symbol = 'KEY'; //solhint-disable-line const-name-snakecase
uint256 public constant decimals = 18; //solhint-disable-line const-name-snakecase
uint256 public cap;
bool private transfersEnabled = false;
event Burned(address indexed burner, uint256 value);
/**
* @dev Only the contract owner can transfer without restrictions.
* Regular holders need to wait until sale is finalized.
* @param _sender — The address sending the tokens
* @param _value — The number of tokens to send
*/
modifier canTransfer(address _sender, uint256 _value) {
require(transfersEnabled || _sender == owner);
_;
}
/**
* @dev Constructor that sets a maximum supply cap.
* @param _cap — The maximum supply cap.
*/
function SelfKeyToken(uint256 _cap) public {
cap = _cap;
}
/**
* @dev Overrides MintableToken.mint() for restricting supply under cap
* @param _to — The address to receive minted tokens
* @param _value — The number of tokens to mint
*/
function mint(address _to, uint256 _value) public onlyOwner canMint returns (bool) {
require(totalSupply.add(_value) <= cap);
return super.mint(_to, _value);
}
/**
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _to — The address to receive tokens
* @param _value — The number of tokens to send
*/
function transfer(address _to, uint256 _value)
public canTransfer(msg.sender, _value) returns (bool)
{
return super.transfer(_to, _value);
}
/**
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _from — The address to send tokens from
* @param _to — The address to receive tokens
* @param _value — The number of tokens to send
*/
function transferFrom(address _from, address _to, uint256 _value)
public canTransfer(_from, _value) returns (bool)
{
return super.transferFrom(_from, _to, _value);
}
/**
* @dev Enables token transfers.
* Called when the token sale is successfully finalized
*/
function enableTransfers() public onlyOwner {
transfersEnabled = true;
}
/**
* @dev Burns a specific number of tokens.
* @param _value — The number of tokens to be burned.
*/
function burn(uint256 _value) public onlyOwner {
require(_value > 0);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply = totalSupply.sub(_value);
Burned(burner, _value);
}
} | /**
* @title SelfKeyToken
* @dev SelfKey Token implementation.
*/ | NatSpecMultiLine | SelfKeyToken | function SelfKeyToken(uint256 _cap) public {
cap = _cap;
}
| /**
* @dev Constructor that sets a maximum supply cap.
* @param _cap — The maximum supply cap.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
966,
1043
]
} | 5,537 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | SelfKeyToken | contract SelfKeyToken is MintableToken {
string public constant name = 'SelfKey'; //solhint-disable-line const-name-snakecase
string public constant symbol = 'KEY'; //solhint-disable-line const-name-snakecase
uint256 public constant decimals = 18; //solhint-disable-line const-name-snakecase
uint256 public cap;
bool private transfersEnabled = false;
event Burned(address indexed burner, uint256 value);
/**
* @dev Only the contract owner can transfer without restrictions.
* Regular holders need to wait until sale is finalized.
* @param _sender — The address sending the tokens
* @param _value — The number of tokens to send
*/
modifier canTransfer(address _sender, uint256 _value) {
require(transfersEnabled || _sender == owner);
_;
}
/**
* @dev Constructor that sets a maximum supply cap.
* @param _cap — The maximum supply cap.
*/
function SelfKeyToken(uint256 _cap) public {
cap = _cap;
}
/**
* @dev Overrides MintableToken.mint() for restricting supply under cap
* @param _to — The address to receive minted tokens
* @param _value — The number of tokens to mint
*/
function mint(address _to, uint256 _value) public onlyOwner canMint returns (bool) {
require(totalSupply.add(_value) <= cap);
return super.mint(_to, _value);
}
/**
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _to — The address to receive tokens
* @param _value — The number of tokens to send
*/
function transfer(address _to, uint256 _value)
public canTransfer(msg.sender, _value) returns (bool)
{
return super.transfer(_to, _value);
}
/**
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _from — The address to send tokens from
* @param _to — The address to receive tokens
* @param _value — The number of tokens to send
*/
function transferFrom(address _from, address _to, uint256 _value)
public canTransfer(_from, _value) returns (bool)
{
return super.transferFrom(_from, _to, _value);
}
/**
* @dev Enables token transfers.
* Called when the token sale is successfully finalized
*/
function enableTransfers() public onlyOwner {
transfersEnabled = true;
}
/**
* @dev Burns a specific number of tokens.
* @param _value — The number of tokens to be burned.
*/
function burn(uint256 _value) public onlyOwner {
require(_value > 0);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply = totalSupply.sub(_value);
Burned(burner, _value);
}
} | /**
* @title SelfKeyToken
* @dev SelfKey Token implementation.
*/ | NatSpecMultiLine | mint | function mint(address _to, uint256 _value) public onlyOwner canMint returns (bool) {
require(totalSupply.add(_value) <= cap);
return super.mint(_to, _value);
}
| /**
* @dev Overrides MintableToken.mint() for restricting supply under cap
* @param _to — The address to receive minted tokens
* @param _value — The number of tokens to mint
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
1252,
1439
]
} | 5,538 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | SelfKeyToken | contract SelfKeyToken is MintableToken {
string public constant name = 'SelfKey'; //solhint-disable-line const-name-snakecase
string public constant symbol = 'KEY'; //solhint-disable-line const-name-snakecase
uint256 public constant decimals = 18; //solhint-disable-line const-name-snakecase
uint256 public cap;
bool private transfersEnabled = false;
event Burned(address indexed burner, uint256 value);
/**
* @dev Only the contract owner can transfer without restrictions.
* Regular holders need to wait until sale is finalized.
* @param _sender — The address sending the tokens
* @param _value — The number of tokens to send
*/
modifier canTransfer(address _sender, uint256 _value) {
require(transfersEnabled || _sender == owner);
_;
}
/**
* @dev Constructor that sets a maximum supply cap.
* @param _cap — The maximum supply cap.
*/
function SelfKeyToken(uint256 _cap) public {
cap = _cap;
}
/**
* @dev Overrides MintableToken.mint() for restricting supply under cap
* @param _to — The address to receive minted tokens
* @param _value — The number of tokens to mint
*/
function mint(address _to, uint256 _value) public onlyOwner canMint returns (bool) {
require(totalSupply.add(_value) <= cap);
return super.mint(_to, _value);
}
/**
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _to — The address to receive tokens
* @param _value — The number of tokens to send
*/
function transfer(address _to, uint256 _value)
public canTransfer(msg.sender, _value) returns (bool)
{
return super.transfer(_to, _value);
}
/**
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _from — The address to send tokens from
* @param _to — The address to receive tokens
* @param _value — The number of tokens to send
*/
function transferFrom(address _from, address _to, uint256 _value)
public canTransfer(_from, _value) returns (bool)
{
return super.transferFrom(_from, _to, _value);
}
/**
* @dev Enables token transfers.
* Called when the token sale is successfully finalized
*/
function enableTransfers() public onlyOwner {
transfersEnabled = true;
}
/**
* @dev Burns a specific number of tokens.
* @param _value — The number of tokens to be burned.
*/
function burn(uint256 _value) public onlyOwner {
require(_value > 0);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply = totalSupply.sub(_value);
Burned(burner, _value);
}
} | /**
* @title SelfKeyToken
* @dev SelfKey Token implementation.
*/ | NatSpecMultiLine | transfer | function transfer(address _to, uint256 _value)
public canTransfer(msg.sender, _value) returns (bool)
{
return super.transfer(_to, _value);
}
| /**
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _to — The address to receive tokens
* @param _value — The number of tokens to send
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
1639,
1812
]
} | 5,539 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | SelfKeyToken | contract SelfKeyToken is MintableToken {
string public constant name = 'SelfKey'; //solhint-disable-line const-name-snakecase
string public constant symbol = 'KEY'; //solhint-disable-line const-name-snakecase
uint256 public constant decimals = 18; //solhint-disable-line const-name-snakecase
uint256 public cap;
bool private transfersEnabled = false;
event Burned(address indexed burner, uint256 value);
/**
* @dev Only the contract owner can transfer without restrictions.
* Regular holders need to wait until sale is finalized.
* @param _sender — The address sending the tokens
* @param _value — The number of tokens to send
*/
modifier canTransfer(address _sender, uint256 _value) {
require(transfersEnabled || _sender == owner);
_;
}
/**
* @dev Constructor that sets a maximum supply cap.
* @param _cap — The maximum supply cap.
*/
function SelfKeyToken(uint256 _cap) public {
cap = _cap;
}
/**
* @dev Overrides MintableToken.mint() for restricting supply under cap
* @param _to — The address to receive minted tokens
* @param _value — The number of tokens to mint
*/
function mint(address _to, uint256 _value) public onlyOwner canMint returns (bool) {
require(totalSupply.add(_value) <= cap);
return super.mint(_to, _value);
}
/**
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _to — The address to receive tokens
* @param _value — The number of tokens to send
*/
function transfer(address _to, uint256 _value)
public canTransfer(msg.sender, _value) returns (bool)
{
return super.transfer(_to, _value);
}
/**
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _from — The address to send tokens from
* @param _to — The address to receive tokens
* @param _value — The number of tokens to send
*/
function transferFrom(address _from, address _to, uint256 _value)
public canTransfer(_from, _value) returns (bool)
{
return super.transferFrom(_from, _to, _value);
}
/**
* @dev Enables token transfers.
* Called when the token sale is successfully finalized
*/
function enableTransfers() public onlyOwner {
transfersEnabled = true;
}
/**
* @dev Burns a specific number of tokens.
* @param _value — The number of tokens to be burned.
*/
function burn(uint256 _value) public onlyOwner {
require(_value > 0);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply = totalSupply.sub(_value);
Burned(burner, _value);
}
} | /**
* @title SelfKeyToken
* @dev SelfKey Token implementation.
*/ | NatSpecMultiLine | transferFrom | function transferFrom(address _from, address _to, uint256 _value)
public canTransfer(_from, _value) returns (bool)
{
return super.transferFrom(_from, _to, _value);
}
| /**
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _from — The address to send tokens from
* @param _to — The address to receive tokens
* @param _value — The number of tokens to send
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
2067,
2265
]
} | 5,540 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | SelfKeyToken | contract SelfKeyToken is MintableToken {
string public constant name = 'SelfKey'; //solhint-disable-line const-name-snakecase
string public constant symbol = 'KEY'; //solhint-disable-line const-name-snakecase
uint256 public constant decimals = 18; //solhint-disable-line const-name-snakecase
uint256 public cap;
bool private transfersEnabled = false;
event Burned(address indexed burner, uint256 value);
/**
* @dev Only the contract owner can transfer without restrictions.
* Regular holders need to wait until sale is finalized.
* @param _sender — The address sending the tokens
* @param _value — The number of tokens to send
*/
modifier canTransfer(address _sender, uint256 _value) {
require(transfersEnabled || _sender == owner);
_;
}
/**
* @dev Constructor that sets a maximum supply cap.
* @param _cap — The maximum supply cap.
*/
function SelfKeyToken(uint256 _cap) public {
cap = _cap;
}
/**
* @dev Overrides MintableToken.mint() for restricting supply under cap
* @param _to — The address to receive minted tokens
* @param _value — The number of tokens to mint
*/
function mint(address _to, uint256 _value) public onlyOwner canMint returns (bool) {
require(totalSupply.add(_value) <= cap);
return super.mint(_to, _value);
}
/**
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _to — The address to receive tokens
* @param _value — The number of tokens to send
*/
function transfer(address _to, uint256 _value)
public canTransfer(msg.sender, _value) returns (bool)
{
return super.transfer(_to, _value);
}
/**
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _from — The address to send tokens from
* @param _to — The address to receive tokens
* @param _value — The number of tokens to send
*/
function transferFrom(address _from, address _to, uint256 _value)
public canTransfer(_from, _value) returns (bool)
{
return super.transferFrom(_from, _to, _value);
}
/**
* @dev Enables token transfers.
* Called when the token sale is successfully finalized
*/
function enableTransfers() public onlyOwner {
transfersEnabled = true;
}
/**
* @dev Burns a specific number of tokens.
* @param _value — The number of tokens to be burned.
*/
function burn(uint256 _value) public onlyOwner {
require(_value > 0);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply = totalSupply.sub(_value);
Burned(burner, _value);
}
} | /**
* @title SelfKeyToken
* @dev SelfKey Token implementation.
*/ | NatSpecMultiLine | enableTransfers | function enableTransfers() public onlyOwner {
transfersEnabled = true;
}
| /**
* @dev Enables token transfers.
* Called when the token sale is successfully finalized
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
2390,
2481
]
} | 5,541 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | SelfKeyToken | contract SelfKeyToken is MintableToken {
string public constant name = 'SelfKey'; //solhint-disable-line const-name-snakecase
string public constant symbol = 'KEY'; //solhint-disable-line const-name-snakecase
uint256 public constant decimals = 18; //solhint-disable-line const-name-snakecase
uint256 public cap;
bool private transfersEnabled = false;
event Burned(address indexed burner, uint256 value);
/**
* @dev Only the contract owner can transfer without restrictions.
* Regular holders need to wait until sale is finalized.
* @param _sender — The address sending the tokens
* @param _value — The number of tokens to send
*/
modifier canTransfer(address _sender, uint256 _value) {
require(transfersEnabled || _sender == owner);
_;
}
/**
* @dev Constructor that sets a maximum supply cap.
* @param _cap — The maximum supply cap.
*/
function SelfKeyToken(uint256 _cap) public {
cap = _cap;
}
/**
* @dev Overrides MintableToken.mint() for restricting supply under cap
* @param _to — The address to receive minted tokens
* @param _value — The number of tokens to mint
*/
function mint(address _to, uint256 _value) public onlyOwner canMint returns (bool) {
require(totalSupply.add(_value) <= cap);
return super.mint(_to, _value);
}
/**
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _to — The address to receive tokens
* @param _value — The number of tokens to send
*/
function transfer(address _to, uint256 _value)
public canTransfer(msg.sender, _value) returns (bool)
{
return super.transfer(_to, _value);
}
/**
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _from — The address to send tokens from
* @param _to — The address to receive tokens
* @param _value — The number of tokens to send
*/
function transferFrom(address _from, address _to, uint256 _value)
public canTransfer(_from, _value) returns (bool)
{
return super.transferFrom(_from, _to, _value);
}
/**
* @dev Enables token transfers.
* Called when the token sale is successfully finalized
*/
function enableTransfers() public onlyOwner {
transfersEnabled = true;
}
/**
* @dev Burns a specific number of tokens.
* @param _value — The number of tokens to be burned.
*/
function burn(uint256 _value) public onlyOwner {
require(_value > 0);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply = totalSupply.sub(_value);
Burned(burner, _value);
}
} | /**
* @title SelfKeyToken
* @dev SelfKey Token implementation.
*/ | NatSpecMultiLine | burn | function burn(uint256 _value) public onlyOwner {
require(_value > 0);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply = totalSupply.sub(_value);
Burned(burner, _value);
}
| /**
* @dev Burns a specific number of tokens.
* @param _value — The number of tokens to be burned.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
2606,
2875
]
} | 5,542 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | TokenTimelock | contract TokenTimelock {
using SafeERC20 for ERC20Basic;
// ERC20 basic token contract being held
ERC20Basic public token;
// beneficiary of tokens after they are released
address public beneficiary;
// timestamp when token release is enabled
uint256 public releaseTime;
function TokenTimelock(ERC20Basic _token, address _beneficiary, uint256 _releaseTime) public {
require(_releaseTime > now);
token = _token;
beneficiary = _beneficiary;
releaseTime = _releaseTime;
}
/**
* @notice Transfers tokens held by timelock to beneficiary.
*/
function release() public {
require(now >= releaseTime);
uint256 amount = token.balanceOf(this);
require(amount > 0);
token.safeTransfer(beneficiary, amount);
}
} | /**
* @title TokenTimelock
* @dev TokenTimelock is a token holder contract that will allow a
* beneficiary to extract the tokens after a given release time
*/ | NatSpecMultiLine | release | function release() public {
require(now >= releaseTime);
uint256 amount = token.balanceOf(this);
require(amount > 0);
token.safeTransfer(beneficiary, amount);
}
| /**
* @notice Transfers tokens held by timelock to beneficiary.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
605,
795
]
} | 5,543 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | SelfKeyCrowdsale | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;
uint64 public startTime;
uint64 public endTime;
// Minimum tokens expected to sell
uint256 public goal;
// How many tokens a buyer gets per ETH
uint256 public rate = 51800;
// ETH price in USD, can be later updated until start date
uint256 public ethPrice = 777;
// Total amount of tokens purchased, including pre-sale
uint256 public totalPurchased = 0;
mapping(address => bool) public kycVerified;
mapping(address => uint256) public tokensPurchased;
// a mapping of dynamically instantiated token timelocks for each pre-commitment beneficiary
mapping(address => address) public vestedTokens;
bool public isFinalized = false;
// Token Timelocks
TokenTimelock public foundersTimelock1;
TokenTimelock public foundersTimelock2;
TokenTimelock public foundationTimelock;
// Vault to hold funds until crowdsale is finalized. Allows refunding if crowdsale is not successful.
RefundVault public vault;
// Crowdsale events
event TokenPurchase(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
uint256 amount
);
event VerifiedKYC(address indexed participant);
event AddedPrecommitment(
address indexed participant,
uint256 tokensAllocated
);
event Finalized();
modifier verifierOnly() {
require(isVerifier[msg.sender]);
_;
}
/**
* @dev Crowdsale contract constructor
* @param _startTime — Unix timestamp representing the crowdsale start time
* @param _endTime — Unix timestamp representing the crowdsale start time
* @param _goal — Minimum amount of tokens expected to sell.
*/
function SelfKeyCrowdsale(
uint64 _startTime,
uint64 _endTime,
uint256 _goal
) public
{
require(_endTime > _startTime);
// sets contract owner as a verifier
isVerifier[msg.sender] = true;
token = new SelfKeyToken(TOTAL_SUPPLY_CAP);
// mints all possible tokens to the crowdsale contract
token.mint(address(this), TOTAL_SUPPLY_CAP);
token.finishMinting();
startTime = _startTime;
endTime = _endTime;
goal = _goal;
vault = new RefundVault(CROWDSALE_WALLET_ADDR);
// Set timelocks to 6 months and a year after startTime, respectively
uint64 sixMonthLock = uint64(startTime + 15552000);
uint64 yearLock = uint64(startTime + 31104000);
// Instantiation of token timelocks
foundersTimelock1 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, sixMonthLock);
foundersTimelock2 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, yearLock);
foundationTimelock = new TokenTimelock(token, FOUNDATION_POOL_ADDR_VEST, yearLock);
// Genesis allocation of tokens
token.safeTransfer(FOUNDATION_POOL_ADDR, FOUNDATION_POOL_TOKENS);
token.safeTransfer(COMMUNITY_POOL_ADDR, COMMUNITY_POOL_TOKENS);
token.safeTransfer(FOUNDERS_POOL_ADDR, FOUNDERS_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_1, LEGAL_EXPENSES_1_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_2, LEGAL_EXPENSES_2_TOKENS);
// Allocation of vested tokens
token.safeTransfer(foundersTimelock1, FOUNDERS_TOKENS_VESTED_1);
token.safeTransfer(foundersTimelock2, FOUNDERS_TOKENS_VESTED_2);
token.safeTransfer(foundationTimelock, FOUNDATION_POOL_TOKENS_VESTED);
}
/**
* @dev Fallback function is used to buy tokens.
* It's the only entry point since `buyTokens` is internal
*/
function () public payable {
buyTokens(msg.sender);
}
/**
* @dev Adds an address to the whitelist of Verifiers
* @param _address - address of the verifier
*/
function addVerifier (address _address) public onlyOwner {
isVerifier[_address] = true;
}
/**
* @dev Removes an address from the whitelist of Verifiers
* @param _address - address of the verifier to be removed
*/
function removeVerifier (address _address) public onlyOwner {
isVerifier[_address] = false;
}
/**
* @dev Sets a new start date as long as token hasn't started yet
* @param _startTime - unix timestamp of the new start time
*/
function setStartTime (uint64 _startTime) public onlyOwner {
require(now < startTime);
require(_startTime > now);
require(_startTime < endTime);
startTime = _startTime;
}
/**
* @dev Sets a new end date as long as end date hasn't been reached
* @param _endTime - unix timestamp of the new end time
*/
function setEndTime (uint64 _endTime) public onlyOwner {
require(now < endTime);
require(_endTime > now);
require(_endTime > startTime);
endTime = _endTime;
}
/**
* @dev Updates the ETH/USD conversion rate as long as the public sale hasn't started
* @param _ethPrice - Updated conversion rate
*/
function setEthPrice(uint256 _ethPrice) public onlyOwner {
require(now < startTime);
require(_ethPrice > 0);
ethPrice = _ethPrice;
rate = ethPrice.mul(1000).div(TOKEN_PRICE_THOUSANDTH);
}
/**
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function.
*/
function finalize() public onlyOwner {
require(now > startTime);
require(!isFinalized);
finalization();
Finalized();
isFinalized = true;
}
/**
* @dev If crowdsale is unsuccessful, a refund can be claimed back
*/
function claimRefund(address participant) public {
// requires sale to be finalized and goal not reached,
require(isFinalized);
require(!goalReached());
vault.refund(participant);
}
/**
* @dev If crowdsale is unsuccessful, participants can claim refunds
*/
function goalReached() public constant returns (bool) {
return totalPurchased >= goal;
}
/**
* @dev Release time-locked tokens
*/
function releaseLockFounders1() public {
foundersTimelock1.release();
}
function releaseLockFounders2() public {
foundersTimelock2.release();
}
function releaseLockFoundation() public {
foundationTimelock.release();
}
/**
* @dev Release time-locked tokens for any vested address
*/
function releaseLock(address participant) public {
require(vestedTokens[participant] != 0x0);
TokenTimelock timelock = TokenTimelock(vestedTokens[participant]);
timelock.release();
}
/**
* @dev Verifies KYC for given participant.
* This enables token purchases by the participant addres
*/
function verifyKYC(address participant) public verifierOnly {
kycVerified[participant] = true;
VerifiedKYC(participant);
}
/**
* @dev Adds an address for pre-sale commitments made off-chain.
* @param beneficiary — Address of the already verified participant
* @param tokensAllocated — Exact amount of KEY tokens (including decimal places) to allocate
* @param halfVesting — determines whether the half the tokens will be time-locked or not
*/
function addPrecommitment(
address beneficiary,
uint256 tokensAllocated,
bool halfVesting
) public verifierOnly
{
// requires to be on pre-sale
require(now < startTime); // solhint-disable-line not-rely-on-time
kycVerified[beneficiary] = true;
uint256 tokens = tokensAllocated;
totalPurchased = totalPurchased.add(tokens);
tokensPurchased[beneficiary] = tokensPurchased[beneficiary].add(tokens);
if (halfVesting) {
// half the tokens are put into a time-lock for a pre-defined period
uint64 endTimeLock = uint64(startTime + PRECOMMITMENT_VESTING_SECONDS);
// Sets a timelock for half the tokens allocated
uint256 half = tokens.div(2);
TokenTimelock timelock;
if (vestedTokens[beneficiary] == 0x0) {
timelock = new TokenTimelock(token, beneficiary, endTimeLock);
vestedTokens[beneficiary] = address(timelock);
} else {
timelock = TokenTimelock(vestedTokens[beneficiary]);
}
token.safeTransfer(beneficiary, half);
token.safeTransfer(timelock, tokens.sub(half));
} else {
// all tokens are sent to the participant's address
token.safeTransfer(beneficiary, tokens);
}
AddedPrecommitment(
beneficiary,
tokens
);
}
/**
* @dev Additional finalization logic. Enables token transfers.
*/
function finalization() internal {
if (goalReached()) {
burnUnsold();
vault.close();
token.enableTransfers();
} else {
vault.enableRefunds();
}
}
/**
* @dev Low level token purchase. Only callable internally. Participants MUST be KYC-verified before purchase
* @param participant — The address of the token purchaser
*/
function buyTokens(address participant) internal {
require(kycVerified[participant]);
require(now >= startTime);
require(now < endTime);
require(!isFinalized);
require(msg.value != 0);
// Calculate the token amount to be allocated
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(rate);
// Update state
tokensPurchased[participant] = tokensPurchased[participant].add(tokens);
totalPurchased = totalPurchased.add(tokens);
require(totalPurchased <= SALE_CAP);
require(tokensPurchased[participant] >= PURCHASER_MIN_TOKEN_CAP);
if (now < startTime + 86400) {
// if still during the first day of token sale, apply different max cap
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP_DAY1);
} else {
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP);
}
// Sends ETH contribution to the RefundVault and tokens to participant
vault.deposit.value(msg.value)(participant);
token.safeTransfer(participant, tokens);
TokenPurchase(
msg.sender,
participant,
weiAmount,
tokens
);
}
/**
* @dev Burn all remaining (unsold) tokens.
* This should be called after sale finalization
*/
function burnUnsold() internal {
// All tokens held by this contract get burned
token.burn(token.balanceOf(this));
}
} | // solhint-disable-next-line max-states-count | LineComment | SelfKeyCrowdsale | function SelfKeyCrowdsale(
uint64 _startTime,
uint64 _endTime,
uint256 _goal
) public
{
require(_endTime > _startTime);
// sets contract owner as a verifier
isVerifier[msg.sender] = true;
token = new SelfKeyToken(TOTAL_SUPPLY_CAP);
// mints all possible tokens to the crowdsale contract
token.mint(address(this), TOTAL_SUPPLY_CAP);
token.finishMinting();
startTime = _startTime;
endTime = _endTime;
goal = _goal;
vault = new RefundVault(CROWDSALE_WALLET_ADDR);
// Set timelocks to 6 months and a year after startTime, respectively
uint64 sixMonthLock = uint64(startTime + 15552000);
uint64 yearLock = uint64(startTime + 31104000);
// Instantiation of token timelocks
foundersTimelock1 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, sixMonthLock);
foundersTimelock2 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, yearLock);
foundationTimelock = new TokenTimelock(token, FOUNDATION_POOL_ADDR_VEST, yearLock);
// Genesis allocation of tokens
token.safeTransfer(FOUNDATION_POOL_ADDR, FOUNDATION_POOL_TOKENS);
token.safeTransfer(COMMUNITY_POOL_ADDR, COMMUNITY_POOL_TOKENS);
token.safeTransfer(FOUNDERS_POOL_ADDR, FOUNDERS_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_1, LEGAL_EXPENSES_1_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_2, LEGAL_EXPENSES_2_TOKENS);
// Allocation of vested tokens
token.safeTransfer(foundersTimelock1, FOUNDERS_TOKENS_VESTED_1);
token.safeTransfer(foundersTimelock2, FOUNDERS_TOKENS_VESTED_2);
token.safeTransfer(foundationTimelock, FOUNDATION_POOL_TOKENS_VESTED);
}
| /**
* @dev Crowdsale contract constructor
* @param _startTime — Unix timestamp representing the crowdsale start time
* @param _endTime — Unix timestamp representing the crowdsale start time
* @param _goal — Minimum amount of tokens expected to sell.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
2101,
3913
]
} | 5,544 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | SelfKeyCrowdsale | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;
uint64 public startTime;
uint64 public endTime;
// Minimum tokens expected to sell
uint256 public goal;
// How many tokens a buyer gets per ETH
uint256 public rate = 51800;
// ETH price in USD, can be later updated until start date
uint256 public ethPrice = 777;
// Total amount of tokens purchased, including pre-sale
uint256 public totalPurchased = 0;
mapping(address => bool) public kycVerified;
mapping(address => uint256) public tokensPurchased;
// a mapping of dynamically instantiated token timelocks for each pre-commitment beneficiary
mapping(address => address) public vestedTokens;
bool public isFinalized = false;
// Token Timelocks
TokenTimelock public foundersTimelock1;
TokenTimelock public foundersTimelock2;
TokenTimelock public foundationTimelock;
// Vault to hold funds until crowdsale is finalized. Allows refunding if crowdsale is not successful.
RefundVault public vault;
// Crowdsale events
event TokenPurchase(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
uint256 amount
);
event VerifiedKYC(address indexed participant);
event AddedPrecommitment(
address indexed participant,
uint256 tokensAllocated
);
event Finalized();
modifier verifierOnly() {
require(isVerifier[msg.sender]);
_;
}
/**
* @dev Crowdsale contract constructor
* @param _startTime — Unix timestamp representing the crowdsale start time
* @param _endTime — Unix timestamp representing the crowdsale start time
* @param _goal — Minimum amount of tokens expected to sell.
*/
function SelfKeyCrowdsale(
uint64 _startTime,
uint64 _endTime,
uint256 _goal
) public
{
require(_endTime > _startTime);
// sets contract owner as a verifier
isVerifier[msg.sender] = true;
token = new SelfKeyToken(TOTAL_SUPPLY_CAP);
// mints all possible tokens to the crowdsale contract
token.mint(address(this), TOTAL_SUPPLY_CAP);
token.finishMinting();
startTime = _startTime;
endTime = _endTime;
goal = _goal;
vault = new RefundVault(CROWDSALE_WALLET_ADDR);
// Set timelocks to 6 months and a year after startTime, respectively
uint64 sixMonthLock = uint64(startTime + 15552000);
uint64 yearLock = uint64(startTime + 31104000);
// Instantiation of token timelocks
foundersTimelock1 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, sixMonthLock);
foundersTimelock2 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, yearLock);
foundationTimelock = new TokenTimelock(token, FOUNDATION_POOL_ADDR_VEST, yearLock);
// Genesis allocation of tokens
token.safeTransfer(FOUNDATION_POOL_ADDR, FOUNDATION_POOL_TOKENS);
token.safeTransfer(COMMUNITY_POOL_ADDR, COMMUNITY_POOL_TOKENS);
token.safeTransfer(FOUNDERS_POOL_ADDR, FOUNDERS_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_1, LEGAL_EXPENSES_1_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_2, LEGAL_EXPENSES_2_TOKENS);
// Allocation of vested tokens
token.safeTransfer(foundersTimelock1, FOUNDERS_TOKENS_VESTED_1);
token.safeTransfer(foundersTimelock2, FOUNDERS_TOKENS_VESTED_2);
token.safeTransfer(foundationTimelock, FOUNDATION_POOL_TOKENS_VESTED);
}
/**
* @dev Fallback function is used to buy tokens.
* It's the only entry point since `buyTokens` is internal
*/
function () public payable {
buyTokens(msg.sender);
}
/**
* @dev Adds an address to the whitelist of Verifiers
* @param _address - address of the verifier
*/
function addVerifier (address _address) public onlyOwner {
isVerifier[_address] = true;
}
/**
* @dev Removes an address from the whitelist of Verifiers
* @param _address - address of the verifier to be removed
*/
function removeVerifier (address _address) public onlyOwner {
isVerifier[_address] = false;
}
/**
* @dev Sets a new start date as long as token hasn't started yet
* @param _startTime - unix timestamp of the new start time
*/
function setStartTime (uint64 _startTime) public onlyOwner {
require(now < startTime);
require(_startTime > now);
require(_startTime < endTime);
startTime = _startTime;
}
/**
* @dev Sets a new end date as long as end date hasn't been reached
* @param _endTime - unix timestamp of the new end time
*/
function setEndTime (uint64 _endTime) public onlyOwner {
require(now < endTime);
require(_endTime > now);
require(_endTime > startTime);
endTime = _endTime;
}
/**
* @dev Updates the ETH/USD conversion rate as long as the public sale hasn't started
* @param _ethPrice - Updated conversion rate
*/
function setEthPrice(uint256 _ethPrice) public onlyOwner {
require(now < startTime);
require(_ethPrice > 0);
ethPrice = _ethPrice;
rate = ethPrice.mul(1000).div(TOKEN_PRICE_THOUSANDTH);
}
/**
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function.
*/
function finalize() public onlyOwner {
require(now > startTime);
require(!isFinalized);
finalization();
Finalized();
isFinalized = true;
}
/**
* @dev If crowdsale is unsuccessful, a refund can be claimed back
*/
function claimRefund(address participant) public {
// requires sale to be finalized and goal not reached,
require(isFinalized);
require(!goalReached());
vault.refund(participant);
}
/**
* @dev If crowdsale is unsuccessful, participants can claim refunds
*/
function goalReached() public constant returns (bool) {
return totalPurchased >= goal;
}
/**
* @dev Release time-locked tokens
*/
function releaseLockFounders1() public {
foundersTimelock1.release();
}
function releaseLockFounders2() public {
foundersTimelock2.release();
}
function releaseLockFoundation() public {
foundationTimelock.release();
}
/**
* @dev Release time-locked tokens for any vested address
*/
function releaseLock(address participant) public {
require(vestedTokens[participant] != 0x0);
TokenTimelock timelock = TokenTimelock(vestedTokens[participant]);
timelock.release();
}
/**
* @dev Verifies KYC for given participant.
* This enables token purchases by the participant addres
*/
function verifyKYC(address participant) public verifierOnly {
kycVerified[participant] = true;
VerifiedKYC(participant);
}
/**
* @dev Adds an address for pre-sale commitments made off-chain.
* @param beneficiary — Address of the already verified participant
* @param tokensAllocated — Exact amount of KEY tokens (including decimal places) to allocate
* @param halfVesting — determines whether the half the tokens will be time-locked or not
*/
function addPrecommitment(
address beneficiary,
uint256 tokensAllocated,
bool halfVesting
) public verifierOnly
{
// requires to be on pre-sale
require(now < startTime); // solhint-disable-line not-rely-on-time
kycVerified[beneficiary] = true;
uint256 tokens = tokensAllocated;
totalPurchased = totalPurchased.add(tokens);
tokensPurchased[beneficiary] = tokensPurchased[beneficiary].add(tokens);
if (halfVesting) {
// half the tokens are put into a time-lock for a pre-defined period
uint64 endTimeLock = uint64(startTime + PRECOMMITMENT_VESTING_SECONDS);
// Sets a timelock for half the tokens allocated
uint256 half = tokens.div(2);
TokenTimelock timelock;
if (vestedTokens[beneficiary] == 0x0) {
timelock = new TokenTimelock(token, beneficiary, endTimeLock);
vestedTokens[beneficiary] = address(timelock);
} else {
timelock = TokenTimelock(vestedTokens[beneficiary]);
}
token.safeTransfer(beneficiary, half);
token.safeTransfer(timelock, tokens.sub(half));
} else {
// all tokens are sent to the participant's address
token.safeTransfer(beneficiary, tokens);
}
AddedPrecommitment(
beneficiary,
tokens
);
}
/**
* @dev Additional finalization logic. Enables token transfers.
*/
function finalization() internal {
if (goalReached()) {
burnUnsold();
vault.close();
token.enableTransfers();
} else {
vault.enableRefunds();
}
}
/**
* @dev Low level token purchase. Only callable internally. Participants MUST be KYC-verified before purchase
* @param participant — The address of the token purchaser
*/
function buyTokens(address participant) internal {
require(kycVerified[participant]);
require(now >= startTime);
require(now < endTime);
require(!isFinalized);
require(msg.value != 0);
// Calculate the token amount to be allocated
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(rate);
// Update state
tokensPurchased[participant] = tokensPurchased[participant].add(tokens);
totalPurchased = totalPurchased.add(tokens);
require(totalPurchased <= SALE_CAP);
require(tokensPurchased[participant] >= PURCHASER_MIN_TOKEN_CAP);
if (now < startTime + 86400) {
// if still during the first day of token sale, apply different max cap
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP_DAY1);
} else {
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP);
}
// Sends ETH contribution to the RefundVault and tokens to participant
vault.deposit.value(msg.value)(participant);
token.safeTransfer(participant, tokens);
TokenPurchase(
msg.sender,
participant,
weiAmount,
tokens
);
}
/**
* @dev Burn all remaining (unsold) tokens.
* This should be called after sale finalization
*/
function burnUnsold() internal {
// All tokens held by this contract get burned
token.burn(token.balanceOf(this));
}
} | // solhint-disable-next-line max-states-count | LineComment | function () public payable {
buyTokens(msg.sender);
}
| /**
* @dev Fallback function is used to buy tokens.
* It's the only entry point since `buyTokens` is internal
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
4057,
4129
]
} | 5,545 |
||
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | SelfKeyCrowdsale | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;
uint64 public startTime;
uint64 public endTime;
// Minimum tokens expected to sell
uint256 public goal;
// How many tokens a buyer gets per ETH
uint256 public rate = 51800;
// ETH price in USD, can be later updated until start date
uint256 public ethPrice = 777;
// Total amount of tokens purchased, including pre-sale
uint256 public totalPurchased = 0;
mapping(address => bool) public kycVerified;
mapping(address => uint256) public tokensPurchased;
// a mapping of dynamically instantiated token timelocks for each pre-commitment beneficiary
mapping(address => address) public vestedTokens;
bool public isFinalized = false;
// Token Timelocks
TokenTimelock public foundersTimelock1;
TokenTimelock public foundersTimelock2;
TokenTimelock public foundationTimelock;
// Vault to hold funds until crowdsale is finalized. Allows refunding if crowdsale is not successful.
RefundVault public vault;
// Crowdsale events
event TokenPurchase(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
uint256 amount
);
event VerifiedKYC(address indexed participant);
event AddedPrecommitment(
address indexed participant,
uint256 tokensAllocated
);
event Finalized();
modifier verifierOnly() {
require(isVerifier[msg.sender]);
_;
}
/**
* @dev Crowdsale contract constructor
* @param _startTime — Unix timestamp representing the crowdsale start time
* @param _endTime — Unix timestamp representing the crowdsale start time
* @param _goal — Minimum amount of tokens expected to sell.
*/
function SelfKeyCrowdsale(
uint64 _startTime,
uint64 _endTime,
uint256 _goal
) public
{
require(_endTime > _startTime);
// sets contract owner as a verifier
isVerifier[msg.sender] = true;
token = new SelfKeyToken(TOTAL_SUPPLY_CAP);
// mints all possible tokens to the crowdsale contract
token.mint(address(this), TOTAL_SUPPLY_CAP);
token.finishMinting();
startTime = _startTime;
endTime = _endTime;
goal = _goal;
vault = new RefundVault(CROWDSALE_WALLET_ADDR);
// Set timelocks to 6 months and a year after startTime, respectively
uint64 sixMonthLock = uint64(startTime + 15552000);
uint64 yearLock = uint64(startTime + 31104000);
// Instantiation of token timelocks
foundersTimelock1 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, sixMonthLock);
foundersTimelock2 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, yearLock);
foundationTimelock = new TokenTimelock(token, FOUNDATION_POOL_ADDR_VEST, yearLock);
// Genesis allocation of tokens
token.safeTransfer(FOUNDATION_POOL_ADDR, FOUNDATION_POOL_TOKENS);
token.safeTransfer(COMMUNITY_POOL_ADDR, COMMUNITY_POOL_TOKENS);
token.safeTransfer(FOUNDERS_POOL_ADDR, FOUNDERS_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_1, LEGAL_EXPENSES_1_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_2, LEGAL_EXPENSES_2_TOKENS);
// Allocation of vested tokens
token.safeTransfer(foundersTimelock1, FOUNDERS_TOKENS_VESTED_1);
token.safeTransfer(foundersTimelock2, FOUNDERS_TOKENS_VESTED_2);
token.safeTransfer(foundationTimelock, FOUNDATION_POOL_TOKENS_VESTED);
}
/**
* @dev Fallback function is used to buy tokens.
* It's the only entry point since `buyTokens` is internal
*/
function () public payable {
buyTokens(msg.sender);
}
/**
* @dev Adds an address to the whitelist of Verifiers
* @param _address - address of the verifier
*/
function addVerifier (address _address) public onlyOwner {
isVerifier[_address] = true;
}
/**
* @dev Removes an address from the whitelist of Verifiers
* @param _address - address of the verifier to be removed
*/
function removeVerifier (address _address) public onlyOwner {
isVerifier[_address] = false;
}
/**
* @dev Sets a new start date as long as token hasn't started yet
* @param _startTime - unix timestamp of the new start time
*/
function setStartTime (uint64 _startTime) public onlyOwner {
require(now < startTime);
require(_startTime > now);
require(_startTime < endTime);
startTime = _startTime;
}
/**
* @dev Sets a new end date as long as end date hasn't been reached
* @param _endTime - unix timestamp of the new end time
*/
function setEndTime (uint64 _endTime) public onlyOwner {
require(now < endTime);
require(_endTime > now);
require(_endTime > startTime);
endTime = _endTime;
}
/**
* @dev Updates the ETH/USD conversion rate as long as the public sale hasn't started
* @param _ethPrice - Updated conversion rate
*/
function setEthPrice(uint256 _ethPrice) public onlyOwner {
require(now < startTime);
require(_ethPrice > 0);
ethPrice = _ethPrice;
rate = ethPrice.mul(1000).div(TOKEN_PRICE_THOUSANDTH);
}
/**
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function.
*/
function finalize() public onlyOwner {
require(now > startTime);
require(!isFinalized);
finalization();
Finalized();
isFinalized = true;
}
/**
* @dev If crowdsale is unsuccessful, a refund can be claimed back
*/
function claimRefund(address participant) public {
// requires sale to be finalized and goal not reached,
require(isFinalized);
require(!goalReached());
vault.refund(participant);
}
/**
* @dev If crowdsale is unsuccessful, participants can claim refunds
*/
function goalReached() public constant returns (bool) {
return totalPurchased >= goal;
}
/**
* @dev Release time-locked tokens
*/
function releaseLockFounders1() public {
foundersTimelock1.release();
}
function releaseLockFounders2() public {
foundersTimelock2.release();
}
function releaseLockFoundation() public {
foundationTimelock.release();
}
/**
* @dev Release time-locked tokens for any vested address
*/
function releaseLock(address participant) public {
require(vestedTokens[participant] != 0x0);
TokenTimelock timelock = TokenTimelock(vestedTokens[participant]);
timelock.release();
}
/**
* @dev Verifies KYC for given participant.
* This enables token purchases by the participant addres
*/
function verifyKYC(address participant) public verifierOnly {
kycVerified[participant] = true;
VerifiedKYC(participant);
}
/**
* @dev Adds an address for pre-sale commitments made off-chain.
* @param beneficiary — Address of the already verified participant
* @param tokensAllocated — Exact amount of KEY tokens (including decimal places) to allocate
* @param halfVesting — determines whether the half the tokens will be time-locked or not
*/
function addPrecommitment(
address beneficiary,
uint256 tokensAllocated,
bool halfVesting
) public verifierOnly
{
// requires to be on pre-sale
require(now < startTime); // solhint-disable-line not-rely-on-time
kycVerified[beneficiary] = true;
uint256 tokens = tokensAllocated;
totalPurchased = totalPurchased.add(tokens);
tokensPurchased[beneficiary] = tokensPurchased[beneficiary].add(tokens);
if (halfVesting) {
// half the tokens are put into a time-lock for a pre-defined period
uint64 endTimeLock = uint64(startTime + PRECOMMITMENT_VESTING_SECONDS);
// Sets a timelock for half the tokens allocated
uint256 half = tokens.div(2);
TokenTimelock timelock;
if (vestedTokens[beneficiary] == 0x0) {
timelock = new TokenTimelock(token, beneficiary, endTimeLock);
vestedTokens[beneficiary] = address(timelock);
} else {
timelock = TokenTimelock(vestedTokens[beneficiary]);
}
token.safeTransfer(beneficiary, half);
token.safeTransfer(timelock, tokens.sub(half));
} else {
// all tokens are sent to the participant's address
token.safeTransfer(beneficiary, tokens);
}
AddedPrecommitment(
beneficiary,
tokens
);
}
/**
* @dev Additional finalization logic. Enables token transfers.
*/
function finalization() internal {
if (goalReached()) {
burnUnsold();
vault.close();
token.enableTransfers();
} else {
vault.enableRefunds();
}
}
/**
* @dev Low level token purchase. Only callable internally. Participants MUST be KYC-verified before purchase
* @param participant — The address of the token purchaser
*/
function buyTokens(address participant) internal {
require(kycVerified[participant]);
require(now >= startTime);
require(now < endTime);
require(!isFinalized);
require(msg.value != 0);
// Calculate the token amount to be allocated
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(rate);
// Update state
tokensPurchased[participant] = tokensPurchased[participant].add(tokens);
totalPurchased = totalPurchased.add(tokens);
require(totalPurchased <= SALE_CAP);
require(tokensPurchased[participant] >= PURCHASER_MIN_TOKEN_CAP);
if (now < startTime + 86400) {
// if still during the first day of token sale, apply different max cap
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP_DAY1);
} else {
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP);
}
// Sends ETH contribution to the RefundVault and tokens to participant
vault.deposit.value(msg.value)(participant);
token.safeTransfer(participant, tokens);
TokenPurchase(
msg.sender,
participant,
weiAmount,
tokens
);
}
/**
* @dev Burn all remaining (unsold) tokens.
* This should be called after sale finalization
*/
function burnUnsold() internal {
// All tokens held by this contract get burned
token.burn(token.balanceOf(this));
}
} | // solhint-disable-next-line max-states-count | LineComment | addVerifier | function addVerifier (address _address) public onlyOwner {
isVerifier[_address] = true;
}
| /**
* @dev Adds an address to the whitelist of Verifiers
* @param _address - address of the verifier
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
4259,
4367
]
} | 5,546 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | SelfKeyCrowdsale | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;
uint64 public startTime;
uint64 public endTime;
// Minimum tokens expected to sell
uint256 public goal;
// How many tokens a buyer gets per ETH
uint256 public rate = 51800;
// ETH price in USD, can be later updated until start date
uint256 public ethPrice = 777;
// Total amount of tokens purchased, including pre-sale
uint256 public totalPurchased = 0;
mapping(address => bool) public kycVerified;
mapping(address => uint256) public tokensPurchased;
// a mapping of dynamically instantiated token timelocks for each pre-commitment beneficiary
mapping(address => address) public vestedTokens;
bool public isFinalized = false;
// Token Timelocks
TokenTimelock public foundersTimelock1;
TokenTimelock public foundersTimelock2;
TokenTimelock public foundationTimelock;
// Vault to hold funds until crowdsale is finalized. Allows refunding if crowdsale is not successful.
RefundVault public vault;
// Crowdsale events
event TokenPurchase(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
uint256 amount
);
event VerifiedKYC(address indexed participant);
event AddedPrecommitment(
address indexed participant,
uint256 tokensAllocated
);
event Finalized();
modifier verifierOnly() {
require(isVerifier[msg.sender]);
_;
}
/**
* @dev Crowdsale contract constructor
* @param _startTime — Unix timestamp representing the crowdsale start time
* @param _endTime — Unix timestamp representing the crowdsale start time
* @param _goal — Minimum amount of tokens expected to sell.
*/
function SelfKeyCrowdsale(
uint64 _startTime,
uint64 _endTime,
uint256 _goal
) public
{
require(_endTime > _startTime);
// sets contract owner as a verifier
isVerifier[msg.sender] = true;
token = new SelfKeyToken(TOTAL_SUPPLY_CAP);
// mints all possible tokens to the crowdsale contract
token.mint(address(this), TOTAL_SUPPLY_CAP);
token.finishMinting();
startTime = _startTime;
endTime = _endTime;
goal = _goal;
vault = new RefundVault(CROWDSALE_WALLET_ADDR);
// Set timelocks to 6 months and a year after startTime, respectively
uint64 sixMonthLock = uint64(startTime + 15552000);
uint64 yearLock = uint64(startTime + 31104000);
// Instantiation of token timelocks
foundersTimelock1 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, sixMonthLock);
foundersTimelock2 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, yearLock);
foundationTimelock = new TokenTimelock(token, FOUNDATION_POOL_ADDR_VEST, yearLock);
// Genesis allocation of tokens
token.safeTransfer(FOUNDATION_POOL_ADDR, FOUNDATION_POOL_TOKENS);
token.safeTransfer(COMMUNITY_POOL_ADDR, COMMUNITY_POOL_TOKENS);
token.safeTransfer(FOUNDERS_POOL_ADDR, FOUNDERS_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_1, LEGAL_EXPENSES_1_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_2, LEGAL_EXPENSES_2_TOKENS);
// Allocation of vested tokens
token.safeTransfer(foundersTimelock1, FOUNDERS_TOKENS_VESTED_1);
token.safeTransfer(foundersTimelock2, FOUNDERS_TOKENS_VESTED_2);
token.safeTransfer(foundationTimelock, FOUNDATION_POOL_TOKENS_VESTED);
}
/**
* @dev Fallback function is used to buy tokens.
* It's the only entry point since `buyTokens` is internal
*/
function () public payable {
buyTokens(msg.sender);
}
/**
* @dev Adds an address to the whitelist of Verifiers
* @param _address - address of the verifier
*/
function addVerifier (address _address) public onlyOwner {
isVerifier[_address] = true;
}
/**
* @dev Removes an address from the whitelist of Verifiers
* @param _address - address of the verifier to be removed
*/
function removeVerifier (address _address) public onlyOwner {
isVerifier[_address] = false;
}
/**
* @dev Sets a new start date as long as token hasn't started yet
* @param _startTime - unix timestamp of the new start time
*/
function setStartTime (uint64 _startTime) public onlyOwner {
require(now < startTime);
require(_startTime > now);
require(_startTime < endTime);
startTime = _startTime;
}
/**
* @dev Sets a new end date as long as end date hasn't been reached
* @param _endTime - unix timestamp of the new end time
*/
function setEndTime (uint64 _endTime) public onlyOwner {
require(now < endTime);
require(_endTime > now);
require(_endTime > startTime);
endTime = _endTime;
}
/**
* @dev Updates the ETH/USD conversion rate as long as the public sale hasn't started
* @param _ethPrice - Updated conversion rate
*/
function setEthPrice(uint256 _ethPrice) public onlyOwner {
require(now < startTime);
require(_ethPrice > 0);
ethPrice = _ethPrice;
rate = ethPrice.mul(1000).div(TOKEN_PRICE_THOUSANDTH);
}
/**
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function.
*/
function finalize() public onlyOwner {
require(now > startTime);
require(!isFinalized);
finalization();
Finalized();
isFinalized = true;
}
/**
* @dev If crowdsale is unsuccessful, a refund can be claimed back
*/
function claimRefund(address participant) public {
// requires sale to be finalized and goal not reached,
require(isFinalized);
require(!goalReached());
vault.refund(participant);
}
/**
* @dev If crowdsale is unsuccessful, participants can claim refunds
*/
function goalReached() public constant returns (bool) {
return totalPurchased >= goal;
}
/**
* @dev Release time-locked tokens
*/
function releaseLockFounders1() public {
foundersTimelock1.release();
}
function releaseLockFounders2() public {
foundersTimelock2.release();
}
function releaseLockFoundation() public {
foundationTimelock.release();
}
/**
* @dev Release time-locked tokens for any vested address
*/
function releaseLock(address participant) public {
require(vestedTokens[participant] != 0x0);
TokenTimelock timelock = TokenTimelock(vestedTokens[participant]);
timelock.release();
}
/**
* @dev Verifies KYC for given participant.
* This enables token purchases by the participant addres
*/
function verifyKYC(address participant) public verifierOnly {
kycVerified[participant] = true;
VerifiedKYC(participant);
}
/**
* @dev Adds an address for pre-sale commitments made off-chain.
* @param beneficiary — Address of the already verified participant
* @param tokensAllocated — Exact amount of KEY tokens (including decimal places) to allocate
* @param halfVesting — determines whether the half the tokens will be time-locked or not
*/
function addPrecommitment(
address beneficiary,
uint256 tokensAllocated,
bool halfVesting
) public verifierOnly
{
// requires to be on pre-sale
require(now < startTime); // solhint-disable-line not-rely-on-time
kycVerified[beneficiary] = true;
uint256 tokens = tokensAllocated;
totalPurchased = totalPurchased.add(tokens);
tokensPurchased[beneficiary] = tokensPurchased[beneficiary].add(tokens);
if (halfVesting) {
// half the tokens are put into a time-lock for a pre-defined period
uint64 endTimeLock = uint64(startTime + PRECOMMITMENT_VESTING_SECONDS);
// Sets a timelock for half the tokens allocated
uint256 half = tokens.div(2);
TokenTimelock timelock;
if (vestedTokens[beneficiary] == 0x0) {
timelock = new TokenTimelock(token, beneficiary, endTimeLock);
vestedTokens[beneficiary] = address(timelock);
} else {
timelock = TokenTimelock(vestedTokens[beneficiary]);
}
token.safeTransfer(beneficiary, half);
token.safeTransfer(timelock, tokens.sub(half));
} else {
// all tokens are sent to the participant's address
token.safeTransfer(beneficiary, tokens);
}
AddedPrecommitment(
beneficiary,
tokens
);
}
/**
* @dev Additional finalization logic. Enables token transfers.
*/
function finalization() internal {
if (goalReached()) {
burnUnsold();
vault.close();
token.enableTransfers();
} else {
vault.enableRefunds();
}
}
/**
* @dev Low level token purchase. Only callable internally. Participants MUST be KYC-verified before purchase
* @param participant — The address of the token purchaser
*/
function buyTokens(address participant) internal {
require(kycVerified[participant]);
require(now >= startTime);
require(now < endTime);
require(!isFinalized);
require(msg.value != 0);
// Calculate the token amount to be allocated
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(rate);
// Update state
tokensPurchased[participant] = tokensPurchased[participant].add(tokens);
totalPurchased = totalPurchased.add(tokens);
require(totalPurchased <= SALE_CAP);
require(tokensPurchased[participant] >= PURCHASER_MIN_TOKEN_CAP);
if (now < startTime + 86400) {
// if still during the first day of token sale, apply different max cap
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP_DAY1);
} else {
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP);
}
// Sends ETH contribution to the RefundVault and tokens to participant
vault.deposit.value(msg.value)(participant);
token.safeTransfer(participant, tokens);
TokenPurchase(
msg.sender,
participant,
weiAmount,
tokens
);
}
/**
* @dev Burn all remaining (unsold) tokens.
* This should be called after sale finalization
*/
function burnUnsold() internal {
// All tokens held by this contract get burned
token.burn(token.balanceOf(this));
}
} | // solhint-disable-next-line max-states-count | LineComment | removeVerifier | function removeVerifier (address _address) public onlyOwner {
isVerifier[_address] = false;
}
| /**
* @dev Removes an address from the whitelist of Verifiers
* @param _address - address of the verifier to be removed
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
4516,
4628
]
} | 5,547 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | SelfKeyCrowdsale | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;
uint64 public startTime;
uint64 public endTime;
// Minimum tokens expected to sell
uint256 public goal;
// How many tokens a buyer gets per ETH
uint256 public rate = 51800;
// ETH price in USD, can be later updated until start date
uint256 public ethPrice = 777;
// Total amount of tokens purchased, including pre-sale
uint256 public totalPurchased = 0;
mapping(address => bool) public kycVerified;
mapping(address => uint256) public tokensPurchased;
// a mapping of dynamically instantiated token timelocks for each pre-commitment beneficiary
mapping(address => address) public vestedTokens;
bool public isFinalized = false;
// Token Timelocks
TokenTimelock public foundersTimelock1;
TokenTimelock public foundersTimelock2;
TokenTimelock public foundationTimelock;
// Vault to hold funds until crowdsale is finalized. Allows refunding if crowdsale is not successful.
RefundVault public vault;
// Crowdsale events
event TokenPurchase(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
uint256 amount
);
event VerifiedKYC(address indexed participant);
event AddedPrecommitment(
address indexed participant,
uint256 tokensAllocated
);
event Finalized();
modifier verifierOnly() {
require(isVerifier[msg.sender]);
_;
}
/**
* @dev Crowdsale contract constructor
* @param _startTime — Unix timestamp representing the crowdsale start time
* @param _endTime — Unix timestamp representing the crowdsale start time
* @param _goal — Minimum amount of tokens expected to sell.
*/
function SelfKeyCrowdsale(
uint64 _startTime,
uint64 _endTime,
uint256 _goal
) public
{
require(_endTime > _startTime);
// sets contract owner as a verifier
isVerifier[msg.sender] = true;
token = new SelfKeyToken(TOTAL_SUPPLY_CAP);
// mints all possible tokens to the crowdsale contract
token.mint(address(this), TOTAL_SUPPLY_CAP);
token.finishMinting();
startTime = _startTime;
endTime = _endTime;
goal = _goal;
vault = new RefundVault(CROWDSALE_WALLET_ADDR);
// Set timelocks to 6 months and a year after startTime, respectively
uint64 sixMonthLock = uint64(startTime + 15552000);
uint64 yearLock = uint64(startTime + 31104000);
// Instantiation of token timelocks
foundersTimelock1 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, sixMonthLock);
foundersTimelock2 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, yearLock);
foundationTimelock = new TokenTimelock(token, FOUNDATION_POOL_ADDR_VEST, yearLock);
// Genesis allocation of tokens
token.safeTransfer(FOUNDATION_POOL_ADDR, FOUNDATION_POOL_TOKENS);
token.safeTransfer(COMMUNITY_POOL_ADDR, COMMUNITY_POOL_TOKENS);
token.safeTransfer(FOUNDERS_POOL_ADDR, FOUNDERS_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_1, LEGAL_EXPENSES_1_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_2, LEGAL_EXPENSES_2_TOKENS);
// Allocation of vested tokens
token.safeTransfer(foundersTimelock1, FOUNDERS_TOKENS_VESTED_1);
token.safeTransfer(foundersTimelock2, FOUNDERS_TOKENS_VESTED_2);
token.safeTransfer(foundationTimelock, FOUNDATION_POOL_TOKENS_VESTED);
}
/**
* @dev Fallback function is used to buy tokens.
* It's the only entry point since `buyTokens` is internal
*/
function () public payable {
buyTokens(msg.sender);
}
/**
* @dev Adds an address to the whitelist of Verifiers
* @param _address - address of the verifier
*/
function addVerifier (address _address) public onlyOwner {
isVerifier[_address] = true;
}
/**
* @dev Removes an address from the whitelist of Verifiers
* @param _address - address of the verifier to be removed
*/
function removeVerifier (address _address) public onlyOwner {
isVerifier[_address] = false;
}
/**
* @dev Sets a new start date as long as token hasn't started yet
* @param _startTime - unix timestamp of the new start time
*/
function setStartTime (uint64 _startTime) public onlyOwner {
require(now < startTime);
require(_startTime > now);
require(_startTime < endTime);
startTime = _startTime;
}
/**
* @dev Sets a new end date as long as end date hasn't been reached
* @param _endTime - unix timestamp of the new end time
*/
function setEndTime (uint64 _endTime) public onlyOwner {
require(now < endTime);
require(_endTime > now);
require(_endTime > startTime);
endTime = _endTime;
}
/**
* @dev Updates the ETH/USD conversion rate as long as the public sale hasn't started
* @param _ethPrice - Updated conversion rate
*/
function setEthPrice(uint256 _ethPrice) public onlyOwner {
require(now < startTime);
require(_ethPrice > 0);
ethPrice = _ethPrice;
rate = ethPrice.mul(1000).div(TOKEN_PRICE_THOUSANDTH);
}
/**
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function.
*/
function finalize() public onlyOwner {
require(now > startTime);
require(!isFinalized);
finalization();
Finalized();
isFinalized = true;
}
/**
* @dev If crowdsale is unsuccessful, a refund can be claimed back
*/
function claimRefund(address participant) public {
// requires sale to be finalized and goal not reached,
require(isFinalized);
require(!goalReached());
vault.refund(participant);
}
/**
* @dev If crowdsale is unsuccessful, participants can claim refunds
*/
function goalReached() public constant returns (bool) {
return totalPurchased >= goal;
}
/**
* @dev Release time-locked tokens
*/
function releaseLockFounders1() public {
foundersTimelock1.release();
}
function releaseLockFounders2() public {
foundersTimelock2.release();
}
function releaseLockFoundation() public {
foundationTimelock.release();
}
/**
* @dev Release time-locked tokens for any vested address
*/
function releaseLock(address participant) public {
require(vestedTokens[participant] != 0x0);
TokenTimelock timelock = TokenTimelock(vestedTokens[participant]);
timelock.release();
}
/**
* @dev Verifies KYC for given participant.
* This enables token purchases by the participant addres
*/
function verifyKYC(address participant) public verifierOnly {
kycVerified[participant] = true;
VerifiedKYC(participant);
}
/**
* @dev Adds an address for pre-sale commitments made off-chain.
* @param beneficiary — Address of the already verified participant
* @param tokensAllocated — Exact amount of KEY tokens (including decimal places) to allocate
* @param halfVesting — determines whether the half the tokens will be time-locked or not
*/
function addPrecommitment(
address beneficiary,
uint256 tokensAllocated,
bool halfVesting
) public verifierOnly
{
// requires to be on pre-sale
require(now < startTime); // solhint-disable-line not-rely-on-time
kycVerified[beneficiary] = true;
uint256 tokens = tokensAllocated;
totalPurchased = totalPurchased.add(tokens);
tokensPurchased[beneficiary] = tokensPurchased[beneficiary].add(tokens);
if (halfVesting) {
// half the tokens are put into a time-lock for a pre-defined period
uint64 endTimeLock = uint64(startTime + PRECOMMITMENT_VESTING_SECONDS);
// Sets a timelock for half the tokens allocated
uint256 half = tokens.div(2);
TokenTimelock timelock;
if (vestedTokens[beneficiary] == 0x0) {
timelock = new TokenTimelock(token, beneficiary, endTimeLock);
vestedTokens[beneficiary] = address(timelock);
} else {
timelock = TokenTimelock(vestedTokens[beneficiary]);
}
token.safeTransfer(beneficiary, half);
token.safeTransfer(timelock, tokens.sub(half));
} else {
// all tokens are sent to the participant's address
token.safeTransfer(beneficiary, tokens);
}
AddedPrecommitment(
beneficiary,
tokens
);
}
/**
* @dev Additional finalization logic. Enables token transfers.
*/
function finalization() internal {
if (goalReached()) {
burnUnsold();
vault.close();
token.enableTransfers();
} else {
vault.enableRefunds();
}
}
/**
* @dev Low level token purchase. Only callable internally. Participants MUST be KYC-verified before purchase
* @param participant — The address of the token purchaser
*/
function buyTokens(address participant) internal {
require(kycVerified[participant]);
require(now >= startTime);
require(now < endTime);
require(!isFinalized);
require(msg.value != 0);
// Calculate the token amount to be allocated
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(rate);
// Update state
tokensPurchased[participant] = tokensPurchased[participant].add(tokens);
totalPurchased = totalPurchased.add(tokens);
require(totalPurchased <= SALE_CAP);
require(tokensPurchased[participant] >= PURCHASER_MIN_TOKEN_CAP);
if (now < startTime + 86400) {
// if still during the first day of token sale, apply different max cap
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP_DAY1);
} else {
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP);
}
// Sends ETH contribution to the RefundVault and tokens to participant
vault.deposit.value(msg.value)(participant);
token.safeTransfer(participant, tokens);
TokenPurchase(
msg.sender,
participant,
weiAmount,
tokens
);
}
/**
* @dev Burn all remaining (unsold) tokens.
* This should be called after sale finalization
*/
function burnUnsold() internal {
// All tokens held by this contract get burned
token.burn(token.balanceOf(this));
}
} | // solhint-disable-next-line max-states-count | LineComment | setStartTime | function setStartTime (uint64 _startTime) public onlyOwner {
require(now < startTime);
require(_startTime > now);
require(_startTime < endTime);
startTime = _startTime;
}
| /**
* @dev Sets a new start date as long as token hasn't started yet
* @param _startTime - unix timestamp of the new start time
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
4785,
5003
]
} | 5,548 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | SelfKeyCrowdsale | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;
uint64 public startTime;
uint64 public endTime;
// Minimum tokens expected to sell
uint256 public goal;
// How many tokens a buyer gets per ETH
uint256 public rate = 51800;
// ETH price in USD, can be later updated until start date
uint256 public ethPrice = 777;
// Total amount of tokens purchased, including pre-sale
uint256 public totalPurchased = 0;
mapping(address => bool) public kycVerified;
mapping(address => uint256) public tokensPurchased;
// a mapping of dynamically instantiated token timelocks for each pre-commitment beneficiary
mapping(address => address) public vestedTokens;
bool public isFinalized = false;
// Token Timelocks
TokenTimelock public foundersTimelock1;
TokenTimelock public foundersTimelock2;
TokenTimelock public foundationTimelock;
// Vault to hold funds until crowdsale is finalized. Allows refunding if crowdsale is not successful.
RefundVault public vault;
// Crowdsale events
event TokenPurchase(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
uint256 amount
);
event VerifiedKYC(address indexed participant);
event AddedPrecommitment(
address indexed participant,
uint256 tokensAllocated
);
event Finalized();
modifier verifierOnly() {
require(isVerifier[msg.sender]);
_;
}
/**
* @dev Crowdsale contract constructor
* @param _startTime — Unix timestamp representing the crowdsale start time
* @param _endTime — Unix timestamp representing the crowdsale start time
* @param _goal — Minimum amount of tokens expected to sell.
*/
function SelfKeyCrowdsale(
uint64 _startTime,
uint64 _endTime,
uint256 _goal
) public
{
require(_endTime > _startTime);
// sets contract owner as a verifier
isVerifier[msg.sender] = true;
token = new SelfKeyToken(TOTAL_SUPPLY_CAP);
// mints all possible tokens to the crowdsale contract
token.mint(address(this), TOTAL_SUPPLY_CAP);
token.finishMinting();
startTime = _startTime;
endTime = _endTime;
goal = _goal;
vault = new RefundVault(CROWDSALE_WALLET_ADDR);
// Set timelocks to 6 months and a year after startTime, respectively
uint64 sixMonthLock = uint64(startTime + 15552000);
uint64 yearLock = uint64(startTime + 31104000);
// Instantiation of token timelocks
foundersTimelock1 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, sixMonthLock);
foundersTimelock2 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, yearLock);
foundationTimelock = new TokenTimelock(token, FOUNDATION_POOL_ADDR_VEST, yearLock);
// Genesis allocation of tokens
token.safeTransfer(FOUNDATION_POOL_ADDR, FOUNDATION_POOL_TOKENS);
token.safeTransfer(COMMUNITY_POOL_ADDR, COMMUNITY_POOL_TOKENS);
token.safeTransfer(FOUNDERS_POOL_ADDR, FOUNDERS_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_1, LEGAL_EXPENSES_1_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_2, LEGAL_EXPENSES_2_TOKENS);
// Allocation of vested tokens
token.safeTransfer(foundersTimelock1, FOUNDERS_TOKENS_VESTED_1);
token.safeTransfer(foundersTimelock2, FOUNDERS_TOKENS_VESTED_2);
token.safeTransfer(foundationTimelock, FOUNDATION_POOL_TOKENS_VESTED);
}
/**
* @dev Fallback function is used to buy tokens.
* It's the only entry point since `buyTokens` is internal
*/
function () public payable {
buyTokens(msg.sender);
}
/**
* @dev Adds an address to the whitelist of Verifiers
* @param _address - address of the verifier
*/
function addVerifier (address _address) public onlyOwner {
isVerifier[_address] = true;
}
/**
* @dev Removes an address from the whitelist of Verifiers
* @param _address - address of the verifier to be removed
*/
function removeVerifier (address _address) public onlyOwner {
isVerifier[_address] = false;
}
/**
* @dev Sets a new start date as long as token hasn't started yet
* @param _startTime - unix timestamp of the new start time
*/
function setStartTime (uint64 _startTime) public onlyOwner {
require(now < startTime);
require(_startTime > now);
require(_startTime < endTime);
startTime = _startTime;
}
/**
* @dev Sets a new end date as long as end date hasn't been reached
* @param _endTime - unix timestamp of the new end time
*/
function setEndTime (uint64 _endTime) public onlyOwner {
require(now < endTime);
require(_endTime > now);
require(_endTime > startTime);
endTime = _endTime;
}
/**
* @dev Updates the ETH/USD conversion rate as long as the public sale hasn't started
* @param _ethPrice - Updated conversion rate
*/
function setEthPrice(uint256 _ethPrice) public onlyOwner {
require(now < startTime);
require(_ethPrice > 0);
ethPrice = _ethPrice;
rate = ethPrice.mul(1000).div(TOKEN_PRICE_THOUSANDTH);
}
/**
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function.
*/
function finalize() public onlyOwner {
require(now > startTime);
require(!isFinalized);
finalization();
Finalized();
isFinalized = true;
}
/**
* @dev If crowdsale is unsuccessful, a refund can be claimed back
*/
function claimRefund(address participant) public {
// requires sale to be finalized and goal not reached,
require(isFinalized);
require(!goalReached());
vault.refund(participant);
}
/**
* @dev If crowdsale is unsuccessful, participants can claim refunds
*/
function goalReached() public constant returns (bool) {
return totalPurchased >= goal;
}
/**
* @dev Release time-locked tokens
*/
function releaseLockFounders1() public {
foundersTimelock1.release();
}
function releaseLockFounders2() public {
foundersTimelock2.release();
}
function releaseLockFoundation() public {
foundationTimelock.release();
}
/**
* @dev Release time-locked tokens for any vested address
*/
function releaseLock(address participant) public {
require(vestedTokens[participant] != 0x0);
TokenTimelock timelock = TokenTimelock(vestedTokens[participant]);
timelock.release();
}
/**
* @dev Verifies KYC for given participant.
* This enables token purchases by the participant addres
*/
function verifyKYC(address participant) public verifierOnly {
kycVerified[participant] = true;
VerifiedKYC(participant);
}
/**
* @dev Adds an address for pre-sale commitments made off-chain.
* @param beneficiary — Address of the already verified participant
* @param tokensAllocated — Exact amount of KEY tokens (including decimal places) to allocate
* @param halfVesting — determines whether the half the tokens will be time-locked or not
*/
function addPrecommitment(
address beneficiary,
uint256 tokensAllocated,
bool halfVesting
) public verifierOnly
{
// requires to be on pre-sale
require(now < startTime); // solhint-disable-line not-rely-on-time
kycVerified[beneficiary] = true;
uint256 tokens = tokensAllocated;
totalPurchased = totalPurchased.add(tokens);
tokensPurchased[beneficiary] = tokensPurchased[beneficiary].add(tokens);
if (halfVesting) {
// half the tokens are put into a time-lock for a pre-defined period
uint64 endTimeLock = uint64(startTime + PRECOMMITMENT_VESTING_SECONDS);
// Sets a timelock for half the tokens allocated
uint256 half = tokens.div(2);
TokenTimelock timelock;
if (vestedTokens[beneficiary] == 0x0) {
timelock = new TokenTimelock(token, beneficiary, endTimeLock);
vestedTokens[beneficiary] = address(timelock);
} else {
timelock = TokenTimelock(vestedTokens[beneficiary]);
}
token.safeTransfer(beneficiary, half);
token.safeTransfer(timelock, tokens.sub(half));
} else {
// all tokens are sent to the participant's address
token.safeTransfer(beneficiary, tokens);
}
AddedPrecommitment(
beneficiary,
tokens
);
}
/**
* @dev Additional finalization logic. Enables token transfers.
*/
function finalization() internal {
if (goalReached()) {
burnUnsold();
vault.close();
token.enableTransfers();
} else {
vault.enableRefunds();
}
}
/**
* @dev Low level token purchase. Only callable internally. Participants MUST be KYC-verified before purchase
* @param participant — The address of the token purchaser
*/
function buyTokens(address participant) internal {
require(kycVerified[participant]);
require(now >= startTime);
require(now < endTime);
require(!isFinalized);
require(msg.value != 0);
// Calculate the token amount to be allocated
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(rate);
// Update state
tokensPurchased[participant] = tokensPurchased[participant].add(tokens);
totalPurchased = totalPurchased.add(tokens);
require(totalPurchased <= SALE_CAP);
require(tokensPurchased[participant] >= PURCHASER_MIN_TOKEN_CAP);
if (now < startTime + 86400) {
// if still during the first day of token sale, apply different max cap
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP_DAY1);
} else {
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP);
}
// Sends ETH contribution to the RefundVault and tokens to participant
vault.deposit.value(msg.value)(participant);
token.safeTransfer(participant, tokens);
TokenPurchase(
msg.sender,
participant,
weiAmount,
tokens
);
}
/**
* @dev Burn all remaining (unsold) tokens.
* This should be called after sale finalization
*/
function burnUnsold() internal {
// All tokens held by this contract get burned
token.burn(token.balanceOf(this));
}
} | // solhint-disable-next-line max-states-count | LineComment | setEndTime | function setEndTime (uint64 _endTime) public onlyOwner {
require(now < endTime);
require(_endTime > now);
require(_endTime > startTime);
endTime = _endTime;
}
| /**
* @dev Sets a new end date as long as end date hasn't been reached
* @param _endTime - unix timestamp of the new end time
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
5158,
5364
]
} | 5,549 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | SelfKeyCrowdsale | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;
uint64 public startTime;
uint64 public endTime;
// Minimum tokens expected to sell
uint256 public goal;
// How many tokens a buyer gets per ETH
uint256 public rate = 51800;
// ETH price in USD, can be later updated until start date
uint256 public ethPrice = 777;
// Total amount of tokens purchased, including pre-sale
uint256 public totalPurchased = 0;
mapping(address => bool) public kycVerified;
mapping(address => uint256) public tokensPurchased;
// a mapping of dynamically instantiated token timelocks for each pre-commitment beneficiary
mapping(address => address) public vestedTokens;
bool public isFinalized = false;
// Token Timelocks
TokenTimelock public foundersTimelock1;
TokenTimelock public foundersTimelock2;
TokenTimelock public foundationTimelock;
// Vault to hold funds until crowdsale is finalized. Allows refunding if crowdsale is not successful.
RefundVault public vault;
// Crowdsale events
event TokenPurchase(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
uint256 amount
);
event VerifiedKYC(address indexed participant);
event AddedPrecommitment(
address indexed participant,
uint256 tokensAllocated
);
event Finalized();
modifier verifierOnly() {
require(isVerifier[msg.sender]);
_;
}
/**
* @dev Crowdsale contract constructor
* @param _startTime — Unix timestamp representing the crowdsale start time
* @param _endTime — Unix timestamp representing the crowdsale start time
* @param _goal — Minimum amount of tokens expected to sell.
*/
function SelfKeyCrowdsale(
uint64 _startTime,
uint64 _endTime,
uint256 _goal
) public
{
require(_endTime > _startTime);
// sets contract owner as a verifier
isVerifier[msg.sender] = true;
token = new SelfKeyToken(TOTAL_SUPPLY_CAP);
// mints all possible tokens to the crowdsale contract
token.mint(address(this), TOTAL_SUPPLY_CAP);
token.finishMinting();
startTime = _startTime;
endTime = _endTime;
goal = _goal;
vault = new RefundVault(CROWDSALE_WALLET_ADDR);
// Set timelocks to 6 months and a year after startTime, respectively
uint64 sixMonthLock = uint64(startTime + 15552000);
uint64 yearLock = uint64(startTime + 31104000);
// Instantiation of token timelocks
foundersTimelock1 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, sixMonthLock);
foundersTimelock2 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, yearLock);
foundationTimelock = new TokenTimelock(token, FOUNDATION_POOL_ADDR_VEST, yearLock);
// Genesis allocation of tokens
token.safeTransfer(FOUNDATION_POOL_ADDR, FOUNDATION_POOL_TOKENS);
token.safeTransfer(COMMUNITY_POOL_ADDR, COMMUNITY_POOL_TOKENS);
token.safeTransfer(FOUNDERS_POOL_ADDR, FOUNDERS_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_1, LEGAL_EXPENSES_1_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_2, LEGAL_EXPENSES_2_TOKENS);
// Allocation of vested tokens
token.safeTransfer(foundersTimelock1, FOUNDERS_TOKENS_VESTED_1);
token.safeTransfer(foundersTimelock2, FOUNDERS_TOKENS_VESTED_2);
token.safeTransfer(foundationTimelock, FOUNDATION_POOL_TOKENS_VESTED);
}
/**
* @dev Fallback function is used to buy tokens.
* It's the only entry point since `buyTokens` is internal
*/
function () public payable {
buyTokens(msg.sender);
}
/**
* @dev Adds an address to the whitelist of Verifiers
* @param _address - address of the verifier
*/
function addVerifier (address _address) public onlyOwner {
isVerifier[_address] = true;
}
/**
* @dev Removes an address from the whitelist of Verifiers
* @param _address - address of the verifier to be removed
*/
function removeVerifier (address _address) public onlyOwner {
isVerifier[_address] = false;
}
/**
* @dev Sets a new start date as long as token hasn't started yet
* @param _startTime - unix timestamp of the new start time
*/
function setStartTime (uint64 _startTime) public onlyOwner {
require(now < startTime);
require(_startTime > now);
require(_startTime < endTime);
startTime = _startTime;
}
/**
* @dev Sets a new end date as long as end date hasn't been reached
* @param _endTime - unix timestamp of the new end time
*/
function setEndTime (uint64 _endTime) public onlyOwner {
require(now < endTime);
require(_endTime > now);
require(_endTime > startTime);
endTime = _endTime;
}
/**
* @dev Updates the ETH/USD conversion rate as long as the public sale hasn't started
* @param _ethPrice - Updated conversion rate
*/
function setEthPrice(uint256 _ethPrice) public onlyOwner {
require(now < startTime);
require(_ethPrice > 0);
ethPrice = _ethPrice;
rate = ethPrice.mul(1000).div(TOKEN_PRICE_THOUSANDTH);
}
/**
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function.
*/
function finalize() public onlyOwner {
require(now > startTime);
require(!isFinalized);
finalization();
Finalized();
isFinalized = true;
}
/**
* @dev If crowdsale is unsuccessful, a refund can be claimed back
*/
function claimRefund(address participant) public {
// requires sale to be finalized and goal not reached,
require(isFinalized);
require(!goalReached());
vault.refund(participant);
}
/**
* @dev If crowdsale is unsuccessful, participants can claim refunds
*/
function goalReached() public constant returns (bool) {
return totalPurchased >= goal;
}
/**
* @dev Release time-locked tokens
*/
function releaseLockFounders1() public {
foundersTimelock1.release();
}
function releaseLockFounders2() public {
foundersTimelock2.release();
}
function releaseLockFoundation() public {
foundationTimelock.release();
}
/**
* @dev Release time-locked tokens for any vested address
*/
function releaseLock(address participant) public {
require(vestedTokens[participant] != 0x0);
TokenTimelock timelock = TokenTimelock(vestedTokens[participant]);
timelock.release();
}
/**
* @dev Verifies KYC for given participant.
* This enables token purchases by the participant addres
*/
function verifyKYC(address participant) public verifierOnly {
kycVerified[participant] = true;
VerifiedKYC(participant);
}
/**
* @dev Adds an address for pre-sale commitments made off-chain.
* @param beneficiary — Address of the already verified participant
* @param tokensAllocated — Exact amount of KEY tokens (including decimal places) to allocate
* @param halfVesting — determines whether the half the tokens will be time-locked or not
*/
function addPrecommitment(
address beneficiary,
uint256 tokensAllocated,
bool halfVesting
) public verifierOnly
{
// requires to be on pre-sale
require(now < startTime); // solhint-disable-line not-rely-on-time
kycVerified[beneficiary] = true;
uint256 tokens = tokensAllocated;
totalPurchased = totalPurchased.add(tokens);
tokensPurchased[beneficiary] = tokensPurchased[beneficiary].add(tokens);
if (halfVesting) {
// half the tokens are put into a time-lock for a pre-defined period
uint64 endTimeLock = uint64(startTime + PRECOMMITMENT_VESTING_SECONDS);
// Sets a timelock for half the tokens allocated
uint256 half = tokens.div(2);
TokenTimelock timelock;
if (vestedTokens[beneficiary] == 0x0) {
timelock = new TokenTimelock(token, beneficiary, endTimeLock);
vestedTokens[beneficiary] = address(timelock);
} else {
timelock = TokenTimelock(vestedTokens[beneficiary]);
}
token.safeTransfer(beneficiary, half);
token.safeTransfer(timelock, tokens.sub(half));
} else {
// all tokens are sent to the participant's address
token.safeTransfer(beneficiary, tokens);
}
AddedPrecommitment(
beneficiary,
tokens
);
}
/**
* @dev Additional finalization logic. Enables token transfers.
*/
function finalization() internal {
if (goalReached()) {
burnUnsold();
vault.close();
token.enableTransfers();
} else {
vault.enableRefunds();
}
}
/**
* @dev Low level token purchase. Only callable internally. Participants MUST be KYC-verified before purchase
* @param participant — The address of the token purchaser
*/
function buyTokens(address participant) internal {
require(kycVerified[participant]);
require(now >= startTime);
require(now < endTime);
require(!isFinalized);
require(msg.value != 0);
// Calculate the token amount to be allocated
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(rate);
// Update state
tokensPurchased[participant] = tokensPurchased[participant].add(tokens);
totalPurchased = totalPurchased.add(tokens);
require(totalPurchased <= SALE_CAP);
require(tokensPurchased[participant] >= PURCHASER_MIN_TOKEN_CAP);
if (now < startTime + 86400) {
// if still during the first day of token sale, apply different max cap
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP_DAY1);
} else {
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP);
}
// Sends ETH contribution to the RefundVault and tokens to participant
vault.deposit.value(msg.value)(participant);
token.safeTransfer(participant, tokens);
TokenPurchase(
msg.sender,
participant,
weiAmount,
tokens
);
}
/**
* @dev Burn all remaining (unsold) tokens.
* This should be called after sale finalization
*/
function burnUnsold() internal {
// All tokens held by this contract get burned
token.burn(token.balanceOf(this));
}
} | // solhint-disable-next-line max-states-count | LineComment | setEthPrice | function setEthPrice(uint256 _ethPrice) public onlyOwner {
require(now < startTime);
require(_ethPrice > 0);
ethPrice = _ethPrice;
rate = ethPrice.mul(1000).div(TOKEN_PRICE_THOUSANDTH);
}
| /**
* @dev Updates the ETH/USD conversion rate as long as the public sale hasn't started
* @param _ethPrice - Updated conversion rate
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
5527,
5762
]
} | 5,550 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | SelfKeyCrowdsale | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;
uint64 public startTime;
uint64 public endTime;
// Minimum tokens expected to sell
uint256 public goal;
// How many tokens a buyer gets per ETH
uint256 public rate = 51800;
// ETH price in USD, can be later updated until start date
uint256 public ethPrice = 777;
// Total amount of tokens purchased, including pre-sale
uint256 public totalPurchased = 0;
mapping(address => bool) public kycVerified;
mapping(address => uint256) public tokensPurchased;
// a mapping of dynamically instantiated token timelocks for each pre-commitment beneficiary
mapping(address => address) public vestedTokens;
bool public isFinalized = false;
// Token Timelocks
TokenTimelock public foundersTimelock1;
TokenTimelock public foundersTimelock2;
TokenTimelock public foundationTimelock;
// Vault to hold funds until crowdsale is finalized. Allows refunding if crowdsale is not successful.
RefundVault public vault;
// Crowdsale events
event TokenPurchase(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
uint256 amount
);
event VerifiedKYC(address indexed participant);
event AddedPrecommitment(
address indexed participant,
uint256 tokensAllocated
);
event Finalized();
modifier verifierOnly() {
require(isVerifier[msg.sender]);
_;
}
/**
* @dev Crowdsale contract constructor
* @param _startTime — Unix timestamp representing the crowdsale start time
* @param _endTime — Unix timestamp representing the crowdsale start time
* @param _goal — Minimum amount of tokens expected to sell.
*/
function SelfKeyCrowdsale(
uint64 _startTime,
uint64 _endTime,
uint256 _goal
) public
{
require(_endTime > _startTime);
// sets contract owner as a verifier
isVerifier[msg.sender] = true;
token = new SelfKeyToken(TOTAL_SUPPLY_CAP);
// mints all possible tokens to the crowdsale contract
token.mint(address(this), TOTAL_SUPPLY_CAP);
token.finishMinting();
startTime = _startTime;
endTime = _endTime;
goal = _goal;
vault = new RefundVault(CROWDSALE_WALLET_ADDR);
// Set timelocks to 6 months and a year after startTime, respectively
uint64 sixMonthLock = uint64(startTime + 15552000);
uint64 yearLock = uint64(startTime + 31104000);
// Instantiation of token timelocks
foundersTimelock1 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, sixMonthLock);
foundersTimelock2 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, yearLock);
foundationTimelock = new TokenTimelock(token, FOUNDATION_POOL_ADDR_VEST, yearLock);
// Genesis allocation of tokens
token.safeTransfer(FOUNDATION_POOL_ADDR, FOUNDATION_POOL_TOKENS);
token.safeTransfer(COMMUNITY_POOL_ADDR, COMMUNITY_POOL_TOKENS);
token.safeTransfer(FOUNDERS_POOL_ADDR, FOUNDERS_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_1, LEGAL_EXPENSES_1_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_2, LEGAL_EXPENSES_2_TOKENS);
// Allocation of vested tokens
token.safeTransfer(foundersTimelock1, FOUNDERS_TOKENS_VESTED_1);
token.safeTransfer(foundersTimelock2, FOUNDERS_TOKENS_VESTED_2);
token.safeTransfer(foundationTimelock, FOUNDATION_POOL_TOKENS_VESTED);
}
/**
* @dev Fallback function is used to buy tokens.
* It's the only entry point since `buyTokens` is internal
*/
function () public payable {
buyTokens(msg.sender);
}
/**
* @dev Adds an address to the whitelist of Verifiers
* @param _address - address of the verifier
*/
function addVerifier (address _address) public onlyOwner {
isVerifier[_address] = true;
}
/**
* @dev Removes an address from the whitelist of Verifiers
* @param _address - address of the verifier to be removed
*/
function removeVerifier (address _address) public onlyOwner {
isVerifier[_address] = false;
}
/**
* @dev Sets a new start date as long as token hasn't started yet
* @param _startTime - unix timestamp of the new start time
*/
function setStartTime (uint64 _startTime) public onlyOwner {
require(now < startTime);
require(_startTime > now);
require(_startTime < endTime);
startTime = _startTime;
}
/**
* @dev Sets a new end date as long as end date hasn't been reached
* @param _endTime - unix timestamp of the new end time
*/
function setEndTime (uint64 _endTime) public onlyOwner {
require(now < endTime);
require(_endTime > now);
require(_endTime > startTime);
endTime = _endTime;
}
/**
* @dev Updates the ETH/USD conversion rate as long as the public sale hasn't started
* @param _ethPrice - Updated conversion rate
*/
function setEthPrice(uint256 _ethPrice) public onlyOwner {
require(now < startTime);
require(_ethPrice > 0);
ethPrice = _ethPrice;
rate = ethPrice.mul(1000).div(TOKEN_PRICE_THOUSANDTH);
}
/**
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function.
*/
function finalize() public onlyOwner {
require(now > startTime);
require(!isFinalized);
finalization();
Finalized();
isFinalized = true;
}
/**
* @dev If crowdsale is unsuccessful, a refund can be claimed back
*/
function claimRefund(address participant) public {
// requires sale to be finalized and goal not reached,
require(isFinalized);
require(!goalReached());
vault.refund(participant);
}
/**
* @dev If crowdsale is unsuccessful, participants can claim refunds
*/
function goalReached() public constant returns (bool) {
return totalPurchased >= goal;
}
/**
* @dev Release time-locked tokens
*/
function releaseLockFounders1() public {
foundersTimelock1.release();
}
function releaseLockFounders2() public {
foundersTimelock2.release();
}
function releaseLockFoundation() public {
foundationTimelock.release();
}
/**
* @dev Release time-locked tokens for any vested address
*/
function releaseLock(address participant) public {
require(vestedTokens[participant] != 0x0);
TokenTimelock timelock = TokenTimelock(vestedTokens[participant]);
timelock.release();
}
/**
* @dev Verifies KYC for given participant.
* This enables token purchases by the participant addres
*/
function verifyKYC(address participant) public verifierOnly {
kycVerified[participant] = true;
VerifiedKYC(participant);
}
/**
* @dev Adds an address for pre-sale commitments made off-chain.
* @param beneficiary — Address of the already verified participant
* @param tokensAllocated — Exact amount of KEY tokens (including decimal places) to allocate
* @param halfVesting — determines whether the half the tokens will be time-locked or not
*/
function addPrecommitment(
address beneficiary,
uint256 tokensAllocated,
bool halfVesting
) public verifierOnly
{
// requires to be on pre-sale
require(now < startTime); // solhint-disable-line not-rely-on-time
kycVerified[beneficiary] = true;
uint256 tokens = tokensAllocated;
totalPurchased = totalPurchased.add(tokens);
tokensPurchased[beneficiary] = tokensPurchased[beneficiary].add(tokens);
if (halfVesting) {
// half the tokens are put into a time-lock for a pre-defined period
uint64 endTimeLock = uint64(startTime + PRECOMMITMENT_VESTING_SECONDS);
// Sets a timelock for half the tokens allocated
uint256 half = tokens.div(2);
TokenTimelock timelock;
if (vestedTokens[beneficiary] == 0x0) {
timelock = new TokenTimelock(token, beneficiary, endTimeLock);
vestedTokens[beneficiary] = address(timelock);
} else {
timelock = TokenTimelock(vestedTokens[beneficiary]);
}
token.safeTransfer(beneficiary, half);
token.safeTransfer(timelock, tokens.sub(half));
} else {
// all tokens are sent to the participant's address
token.safeTransfer(beneficiary, tokens);
}
AddedPrecommitment(
beneficiary,
tokens
);
}
/**
* @dev Additional finalization logic. Enables token transfers.
*/
function finalization() internal {
if (goalReached()) {
burnUnsold();
vault.close();
token.enableTransfers();
} else {
vault.enableRefunds();
}
}
/**
* @dev Low level token purchase. Only callable internally. Participants MUST be KYC-verified before purchase
* @param participant — The address of the token purchaser
*/
function buyTokens(address participant) internal {
require(kycVerified[participant]);
require(now >= startTime);
require(now < endTime);
require(!isFinalized);
require(msg.value != 0);
// Calculate the token amount to be allocated
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(rate);
// Update state
tokensPurchased[participant] = tokensPurchased[participant].add(tokens);
totalPurchased = totalPurchased.add(tokens);
require(totalPurchased <= SALE_CAP);
require(tokensPurchased[participant] >= PURCHASER_MIN_TOKEN_CAP);
if (now < startTime + 86400) {
// if still during the first day of token sale, apply different max cap
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP_DAY1);
} else {
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP);
}
// Sends ETH contribution to the RefundVault and tokens to participant
vault.deposit.value(msg.value)(participant);
token.safeTransfer(participant, tokens);
TokenPurchase(
msg.sender,
participant,
weiAmount,
tokens
);
}
/**
* @dev Burn all remaining (unsold) tokens.
* This should be called after sale finalization
*/
function burnUnsold() internal {
// All tokens held by this contract get burned
token.burn(token.balanceOf(this));
}
} | // solhint-disable-next-line max-states-count | LineComment | finalize | function finalize() public onlyOwner {
require(now > startTime);
require(!isFinalized);
finalization();
Finalized();
isFinalized = true;
}
| /**
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
5926,
6123
]
} | 5,551 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | SelfKeyCrowdsale | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;
uint64 public startTime;
uint64 public endTime;
// Minimum tokens expected to sell
uint256 public goal;
// How many tokens a buyer gets per ETH
uint256 public rate = 51800;
// ETH price in USD, can be later updated until start date
uint256 public ethPrice = 777;
// Total amount of tokens purchased, including pre-sale
uint256 public totalPurchased = 0;
mapping(address => bool) public kycVerified;
mapping(address => uint256) public tokensPurchased;
// a mapping of dynamically instantiated token timelocks for each pre-commitment beneficiary
mapping(address => address) public vestedTokens;
bool public isFinalized = false;
// Token Timelocks
TokenTimelock public foundersTimelock1;
TokenTimelock public foundersTimelock2;
TokenTimelock public foundationTimelock;
// Vault to hold funds until crowdsale is finalized. Allows refunding if crowdsale is not successful.
RefundVault public vault;
// Crowdsale events
event TokenPurchase(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
uint256 amount
);
event VerifiedKYC(address indexed participant);
event AddedPrecommitment(
address indexed participant,
uint256 tokensAllocated
);
event Finalized();
modifier verifierOnly() {
require(isVerifier[msg.sender]);
_;
}
/**
* @dev Crowdsale contract constructor
* @param _startTime — Unix timestamp representing the crowdsale start time
* @param _endTime — Unix timestamp representing the crowdsale start time
* @param _goal — Minimum amount of tokens expected to sell.
*/
function SelfKeyCrowdsale(
uint64 _startTime,
uint64 _endTime,
uint256 _goal
) public
{
require(_endTime > _startTime);
// sets contract owner as a verifier
isVerifier[msg.sender] = true;
token = new SelfKeyToken(TOTAL_SUPPLY_CAP);
// mints all possible tokens to the crowdsale contract
token.mint(address(this), TOTAL_SUPPLY_CAP);
token.finishMinting();
startTime = _startTime;
endTime = _endTime;
goal = _goal;
vault = new RefundVault(CROWDSALE_WALLET_ADDR);
// Set timelocks to 6 months and a year after startTime, respectively
uint64 sixMonthLock = uint64(startTime + 15552000);
uint64 yearLock = uint64(startTime + 31104000);
// Instantiation of token timelocks
foundersTimelock1 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, sixMonthLock);
foundersTimelock2 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, yearLock);
foundationTimelock = new TokenTimelock(token, FOUNDATION_POOL_ADDR_VEST, yearLock);
// Genesis allocation of tokens
token.safeTransfer(FOUNDATION_POOL_ADDR, FOUNDATION_POOL_TOKENS);
token.safeTransfer(COMMUNITY_POOL_ADDR, COMMUNITY_POOL_TOKENS);
token.safeTransfer(FOUNDERS_POOL_ADDR, FOUNDERS_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_1, LEGAL_EXPENSES_1_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_2, LEGAL_EXPENSES_2_TOKENS);
// Allocation of vested tokens
token.safeTransfer(foundersTimelock1, FOUNDERS_TOKENS_VESTED_1);
token.safeTransfer(foundersTimelock2, FOUNDERS_TOKENS_VESTED_2);
token.safeTransfer(foundationTimelock, FOUNDATION_POOL_TOKENS_VESTED);
}
/**
* @dev Fallback function is used to buy tokens.
* It's the only entry point since `buyTokens` is internal
*/
function () public payable {
buyTokens(msg.sender);
}
/**
* @dev Adds an address to the whitelist of Verifiers
* @param _address - address of the verifier
*/
function addVerifier (address _address) public onlyOwner {
isVerifier[_address] = true;
}
/**
* @dev Removes an address from the whitelist of Verifiers
* @param _address - address of the verifier to be removed
*/
function removeVerifier (address _address) public onlyOwner {
isVerifier[_address] = false;
}
/**
* @dev Sets a new start date as long as token hasn't started yet
* @param _startTime - unix timestamp of the new start time
*/
function setStartTime (uint64 _startTime) public onlyOwner {
require(now < startTime);
require(_startTime > now);
require(_startTime < endTime);
startTime = _startTime;
}
/**
* @dev Sets a new end date as long as end date hasn't been reached
* @param _endTime - unix timestamp of the new end time
*/
function setEndTime (uint64 _endTime) public onlyOwner {
require(now < endTime);
require(_endTime > now);
require(_endTime > startTime);
endTime = _endTime;
}
/**
* @dev Updates the ETH/USD conversion rate as long as the public sale hasn't started
* @param _ethPrice - Updated conversion rate
*/
function setEthPrice(uint256 _ethPrice) public onlyOwner {
require(now < startTime);
require(_ethPrice > 0);
ethPrice = _ethPrice;
rate = ethPrice.mul(1000).div(TOKEN_PRICE_THOUSANDTH);
}
/**
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function.
*/
function finalize() public onlyOwner {
require(now > startTime);
require(!isFinalized);
finalization();
Finalized();
isFinalized = true;
}
/**
* @dev If crowdsale is unsuccessful, a refund can be claimed back
*/
function claimRefund(address participant) public {
// requires sale to be finalized and goal not reached,
require(isFinalized);
require(!goalReached());
vault.refund(participant);
}
/**
* @dev If crowdsale is unsuccessful, participants can claim refunds
*/
function goalReached() public constant returns (bool) {
return totalPurchased >= goal;
}
/**
* @dev Release time-locked tokens
*/
function releaseLockFounders1() public {
foundersTimelock1.release();
}
function releaseLockFounders2() public {
foundersTimelock2.release();
}
function releaseLockFoundation() public {
foundationTimelock.release();
}
/**
* @dev Release time-locked tokens for any vested address
*/
function releaseLock(address participant) public {
require(vestedTokens[participant] != 0x0);
TokenTimelock timelock = TokenTimelock(vestedTokens[participant]);
timelock.release();
}
/**
* @dev Verifies KYC for given participant.
* This enables token purchases by the participant addres
*/
function verifyKYC(address participant) public verifierOnly {
kycVerified[participant] = true;
VerifiedKYC(participant);
}
/**
* @dev Adds an address for pre-sale commitments made off-chain.
* @param beneficiary — Address of the already verified participant
* @param tokensAllocated — Exact amount of KEY tokens (including decimal places) to allocate
* @param halfVesting — determines whether the half the tokens will be time-locked or not
*/
function addPrecommitment(
address beneficiary,
uint256 tokensAllocated,
bool halfVesting
) public verifierOnly
{
// requires to be on pre-sale
require(now < startTime); // solhint-disable-line not-rely-on-time
kycVerified[beneficiary] = true;
uint256 tokens = tokensAllocated;
totalPurchased = totalPurchased.add(tokens);
tokensPurchased[beneficiary] = tokensPurchased[beneficiary].add(tokens);
if (halfVesting) {
// half the tokens are put into a time-lock for a pre-defined period
uint64 endTimeLock = uint64(startTime + PRECOMMITMENT_VESTING_SECONDS);
// Sets a timelock for half the tokens allocated
uint256 half = tokens.div(2);
TokenTimelock timelock;
if (vestedTokens[beneficiary] == 0x0) {
timelock = new TokenTimelock(token, beneficiary, endTimeLock);
vestedTokens[beneficiary] = address(timelock);
} else {
timelock = TokenTimelock(vestedTokens[beneficiary]);
}
token.safeTransfer(beneficiary, half);
token.safeTransfer(timelock, tokens.sub(half));
} else {
// all tokens are sent to the participant's address
token.safeTransfer(beneficiary, tokens);
}
AddedPrecommitment(
beneficiary,
tokens
);
}
/**
* @dev Additional finalization logic. Enables token transfers.
*/
function finalization() internal {
if (goalReached()) {
burnUnsold();
vault.close();
token.enableTransfers();
} else {
vault.enableRefunds();
}
}
/**
* @dev Low level token purchase. Only callable internally. Participants MUST be KYC-verified before purchase
* @param participant — The address of the token purchaser
*/
function buyTokens(address participant) internal {
require(kycVerified[participant]);
require(now >= startTime);
require(now < endTime);
require(!isFinalized);
require(msg.value != 0);
// Calculate the token amount to be allocated
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(rate);
// Update state
tokensPurchased[participant] = tokensPurchased[participant].add(tokens);
totalPurchased = totalPurchased.add(tokens);
require(totalPurchased <= SALE_CAP);
require(tokensPurchased[participant] >= PURCHASER_MIN_TOKEN_CAP);
if (now < startTime + 86400) {
// if still during the first day of token sale, apply different max cap
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP_DAY1);
} else {
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP);
}
// Sends ETH contribution to the RefundVault and tokens to participant
vault.deposit.value(msg.value)(participant);
token.safeTransfer(participant, tokens);
TokenPurchase(
msg.sender,
participant,
weiAmount,
tokens
);
}
/**
* @dev Burn all remaining (unsold) tokens.
* This should be called after sale finalization
*/
function burnUnsold() internal {
// All tokens held by this contract get burned
token.burn(token.balanceOf(this));
}
} | // solhint-disable-next-line max-states-count | LineComment | claimRefund | function claimRefund(address participant) public {
// requires sale to be finalized and goal not reached,
require(isFinalized);
require(!goalReached());
vault.refund(participant);
}
| /**
* @dev If crowdsale is unsuccessful, a refund can be claimed back
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
6216,
6445
]
} | 5,552 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | SelfKeyCrowdsale | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;
uint64 public startTime;
uint64 public endTime;
// Minimum tokens expected to sell
uint256 public goal;
// How many tokens a buyer gets per ETH
uint256 public rate = 51800;
// ETH price in USD, can be later updated until start date
uint256 public ethPrice = 777;
// Total amount of tokens purchased, including pre-sale
uint256 public totalPurchased = 0;
mapping(address => bool) public kycVerified;
mapping(address => uint256) public tokensPurchased;
// a mapping of dynamically instantiated token timelocks for each pre-commitment beneficiary
mapping(address => address) public vestedTokens;
bool public isFinalized = false;
// Token Timelocks
TokenTimelock public foundersTimelock1;
TokenTimelock public foundersTimelock2;
TokenTimelock public foundationTimelock;
// Vault to hold funds until crowdsale is finalized. Allows refunding if crowdsale is not successful.
RefundVault public vault;
// Crowdsale events
event TokenPurchase(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
uint256 amount
);
event VerifiedKYC(address indexed participant);
event AddedPrecommitment(
address indexed participant,
uint256 tokensAllocated
);
event Finalized();
modifier verifierOnly() {
require(isVerifier[msg.sender]);
_;
}
/**
* @dev Crowdsale contract constructor
* @param _startTime — Unix timestamp representing the crowdsale start time
* @param _endTime — Unix timestamp representing the crowdsale start time
* @param _goal — Minimum amount of tokens expected to sell.
*/
function SelfKeyCrowdsale(
uint64 _startTime,
uint64 _endTime,
uint256 _goal
) public
{
require(_endTime > _startTime);
// sets contract owner as a verifier
isVerifier[msg.sender] = true;
token = new SelfKeyToken(TOTAL_SUPPLY_CAP);
// mints all possible tokens to the crowdsale contract
token.mint(address(this), TOTAL_SUPPLY_CAP);
token.finishMinting();
startTime = _startTime;
endTime = _endTime;
goal = _goal;
vault = new RefundVault(CROWDSALE_WALLET_ADDR);
// Set timelocks to 6 months and a year after startTime, respectively
uint64 sixMonthLock = uint64(startTime + 15552000);
uint64 yearLock = uint64(startTime + 31104000);
// Instantiation of token timelocks
foundersTimelock1 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, sixMonthLock);
foundersTimelock2 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, yearLock);
foundationTimelock = new TokenTimelock(token, FOUNDATION_POOL_ADDR_VEST, yearLock);
// Genesis allocation of tokens
token.safeTransfer(FOUNDATION_POOL_ADDR, FOUNDATION_POOL_TOKENS);
token.safeTransfer(COMMUNITY_POOL_ADDR, COMMUNITY_POOL_TOKENS);
token.safeTransfer(FOUNDERS_POOL_ADDR, FOUNDERS_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_1, LEGAL_EXPENSES_1_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_2, LEGAL_EXPENSES_2_TOKENS);
// Allocation of vested tokens
token.safeTransfer(foundersTimelock1, FOUNDERS_TOKENS_VESTED_1);
token.safeTransfer(foundersTimelock2, FOUNDERS_TOKENS_VESTED_2);
token.safeTransfer(foundationTimelock, FOUNDATION_POOL_TOKENS_VESTED);
}
/**
* @dev Fallback function is used to buy tokens.
* It's the only entry point since `buyTokens` is internal
*/
function () public payable {
buyTokens(msg.sender);
}
/**
* @dev Adds an address to the whitelist of Verifiers
* @param _address - address of the verifier
*/
function addVerifier (address _address) public onlyOwner {
isVerifier[_address] = true;
}
/**
* @dev Removes an address from the whitelist of Verifiers
* @param _address - address of the verifier to be removed
*/
function removeVerifier (address _address) public onlyOwner {
isVerifier[_address] = false;
}
/**
* @dev Sets a new start date as long as token hasn't started yet
* @param _startTime - unix timestamp of the new start time
*/
function setStartTime (uint64 _startTime) public onlyOwner {
require(now < startTime);
require(_startTime > now);
require(_startTime < endTime);
startTime = _startTime;
}
/**
* @dev Sets a new end date as long as end date hasn't been reached
* @param _endTime - unix timestamp of the new end time
*/
function setEndTime (uint64 _endTime) public onlyOwner {
require(now < endTime);
require(_endTime > now);
require(_endTime > startTime);
endTime = _endTime;
}
/**
* @dev Updates the ETH/USD conversion rate as long as the public sale hasn't started
* @param _ethPrice - Updated conversion rate
*/
function setEthPrice(uint256 _ethPrice) public onlyOwner {
require(now < startTime);
require(_ethPrice > 0);
ethPrice = _ethPrice;
rate = ethPrice.mul(1000).div(TOKEN_PRICE_THOUSANDTH);
}
/**
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function.
*/
function finalize() public onlyOwner {
require(now > startTime);
require(!isFinalized);
finalization();
Finalized();
isFinalized = true;
}
/**
* @dev If crowdsale is unsuccessful, a refund can be claimed back
*/
function claimRefund(address participant) public {
// requires sale to be finalized and goal not reached,
require(isFinalized);
require(!goalReached());
vault.refund(participant);
}
/**
* @dev If crowdsale is unsuccessful, participants can claim refunds
*/
function goalReached() public constant returns (bool) {
return totalPurchased >= goal;
}
/**
* @dev Release time-locked tokens
*/
function releaseLockFounders1() public {
foundersTimelock1.release();
}
function releaseLockFounders2() public {
foundersTimelock2.release();
}
function releaseLockFoundation() public {
foundationTimelock.release();
}
/**
* @dev Release time-locked tokens for any vested address
*/
function releaseLock(address participant) public {
require(vestedTokens[participant] != 0x0);
TokenTimelock timelock = TokenTimelock(vestedTokens[participant]);
timelock.release();
}
/**
* @dev Verifies KYC for given participant.
* This enables token purchases by the participant addres
*/
function verifyKYC(address participant) public verifierOnly {
kycVerified[participant] = true;
VerifiedKYC(participant);
}
/**
* @dev Adds an address for pre-sale commitments made off-chain.
* @param beneficiary — Address of the already verified participant
* @param tokensAllocated — Exact amount of KEY tokens (including decimal places) to allocate
* @param halfVesting — determines whether the half the tokens will be time-locked or not
*/
function addPrecommitment(
address beneficiary,
uint256 tokensAllocated,
bool halfVesting
) public verifierOnly
{
// requires to be on pre-sale
require(now < startTime); // solhint-disable-line not-rely-on-time
kycVerified[beneficiary] = true;
uint256 tokens = tokensAllocated;
totalPurchased = totalPurchased.add(tokens);
tokensPurchased[beneficiary] = tokensPurchased[beneficiary].add(tokens);
if (halfVesting) {
// half the tokens are put into a time-lock for a pre-defined period
uint64 endTimeLock = uint64(startTime + PRECOMMITMENT_VESTING_SECONDS);
// Sets a timelock for half the tokens allocated
uint256 half = tokens.div(2);
TokenTimelock timelock;
if (vestedTokens[beneficiary] == 0x0) {
timelock = new TokenTimelock(token, beneficiary, endTimeLock);
vestedTokens[beneficiary] = address(timelock);
} else {
timelock = TokenTimelock(vestedTokens[beneficiary]);
}
token.safeTransfer(beneficiary, half);
token.safeTransfer(timelock, tokens.sub(half));
} else {
// all tokens are sent to the participant's address
token.safeTransfer(beneficiary, tokens);
}
AddedPrecommitment(
beneficiary,
tokens
);
}
/**
* @dev Additional finalization logic. Enables token transfers.
*/
function finalization() internal {
if (goalReached()) {
burnUnsold();
vault.close();
token.enableTransfers();
} else {
vault.enableRefunds();
}
}
/**
* @dev Low level token purchase. Only callable internally. Participants MUST be KYC-verified before purchase
* @param participant — The address of the token purchaser
*/
function buyTokens(address participant) internal {
require(kycVerified[participant]);
require(now >= startTime);
require(now < endTime);
require(!isFinalized);
require(msg.value != 0);
// Calculate the token amount to be allocated
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(rate);
// Update state
tokensPurchased[participant] = tokensPurchased[participant].add(tokens);
totalPurchased = totalPurchased.add(tokens);
require(totalPurchased <= SALE_CAP);
require(tokensPurchased[participant] >= PURCHASER_MIN_TOKEN_CAP);
if (now < startTime + 86400) {
// if still during the first day of token sale, apply different max cap
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP_DAY1);
} else {
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP);
}
// Sends ETH contribution to the RefundVault and tokens to participant
vault.deposit.value(msg.value)(participant);
token.safeTransfer(participant, tokens);
TokenPurchase(
msg.sender,
participant,
weiAmount,
tokens
);
}
/**
* @dev Burn all remaining (unsold) tokens.
* This should be called after sale finalization
*/
function burnUnsold() internal {
// All tokens held by this contract get burned
token.burn(token.balanceOf(this));
}
} | // solhint-disable-next-line max-states-count | LineComment | goalReached | function goalReached() public constant returns (bool) {
return totalPurchased >= goal;
}
| /**
* @dev If crowdsale is unsuccessful, participants can claim refunds
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
6540,
6647
]
} | 5,553 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | SelfKeyCrowdsale | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;
uint64 public startTime;
uint64 public endTime;
// Minimum tokens expected to sell
uint256 public goal;
// How many tokens a buyer gets per ETH
uint256 public rate = 51800;
// ETH price in USD, can be later updated until start date
uint256 public ethPrice = 777;
// Total amount of tokens purchased, including pre-sale
uint256 public totalPurchased = 0;
mapping(address => bool) public kycVerified;
mapping(address => uint256) public tokensPurchased;
// a mapping of dynamically instantiated token timelocks for each pre-commitment beneficiary
mapping(address => address) public vestedTokens;
bool public isFinalized = false;
// Token Timelocks
TokenTimelock public foundersTimelock1;
TokenTimelock public foundersTimelock2;
TokenTimelock public foundationTimelock;
// Vault to hold funds until crowdsale is finalized. Allows refunding if crowdsale is not successful.
RefundVault public vault;
// Crowdsale events
event TokenPurchase(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
uint256 amount
);
event VerifiedKYC(address indexed participant);
event AddedPrecommitment(
address indexed participant,
uint256 tokensAllocated
);
event Finalized();
modifier verifierOnly() {
require(isVerifier[msg.sender]);
_;
}
/**
* @dev Crowdsale contract constructor
* @param _startTime — Unix timestamp representing the crowdsale start time
* @param _endTime — Unix timestamp representing the crowdsale start time
* @param _goal — Minimum amount of tokens expected to sell.
*/
function SelfKeyCrowdsale(
uint64 _startTime,
uint64 _endTime,
uint256 _goal
) public
{
require(_endTime > _startTime);
// sets contract owner as a verifier
isVerifier[msg.sender] = true;
token = new SelfKeyToken(TOTAL_SUPPLY_CAP);
// mints all possible tokens to the crowdsale contract
token.mint(address(this), TOTAL_SUPPLY_CAP);
token.finishMinting();
startTime = _startTime;
endTime = _endTime;
goal = _goal;
vault = new RefundVault(CROWDSALE_WALLET_ADDR);
// Set timelocks to 6 months and a year after startTime, respectively
uint64 sixMonthLock = uint64(startTime + 15552000);
uint64 yearLock = uint64(startTime + 31104000);
// Instantiation of token timelocks
foundersTimelock1 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, sixMonthLock);
foundersTimelock2 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, yearLock);
foundationTimelock = new TokenTimelock(token, FOUNDATION_POOL_ADDR_VEST, yearLock);
// Genesis allocation of tokens
token.safeTransfer(FOUNDATION_POOL_ADDR, FOUNDATION_POOL_TOKENS);
token.safeTransfer(COMMUNITY_POOL_ADDR, COMMUNITY_POOL_TOKENS);
token.safeTransfer(FOUNDERS_POOL_ADDR, FOUNDERS_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_1, LEGAL_EXPENSES_1_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_2, LEGAL_EXPENSES_2_TOKENS);
// Allocation of vested tokens
token.safeTransfer(foundersTimelock1, FOUNDERS_TOKENS_VESTED_1);
token.safeTransfer(foundersTimelock2, FOUNDERS_TOKENS_VESTED_2);
token.safeTransfer(foundationTimelock, FOUNDATION_POOL_TOKENS_VESTED);
}
/**
* @dev Fallback function is used to buy tokens.
* It's the only entry point since `buyTokens` is internal
*/
function () public payable {
buyTokens(msg.sender);
}
/**
* @dev Adds an address to the whitelist of Verifiers
* @param _address - address of the verifier
*/
function addVerifier (address _address) public onlyOwner {
isVerifier[_address] = true;
}
/**
* @dev Removes an address from the whitelist of Verifiers
* @param _address - address of the verifier to be removed
*/
function removeVerifier (address _address) public onlyOwner {
isVerifier[_address] = false;
}
/**
* @dev Sets a new start date as long as token hasn't started yet
* @param _startTime - unix timestamp of the new start time
*/
function setStartTime (uint64 _startTime) public onlyOwner {
require(now < startTime);
require(_startTime > now);
require(_startTime < endTime);
startTime = _startTime;
}
/**
* @dev Sets a new end date as long as end date hasn't been reached
* @param _endTime - unix timestamp of the new end time
*/
function setEndTime (uint64 _endTime) public onlyOwner {
require(now < endTime);
require(_endTime > now);
require(_endTime > startTime);
endTime = _endTime;
}
/**
* @dev Updates the ETH/USD conversion rate as long as the public sale hasn't started
* @param _ethPrice - Updated conversion rate
*/
function setEthPrice(uint256 _ethPrice) public onlyOwner {
require(now < startTime);
require(_ethPrice > 0);
ethPrice = _ethPrice;
rate = ethPrice.mul(1000).div(TOKEN_PRICE_THOUSANDTH);
}
/**
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function.
*/
function finalize() public onlyOwner {
require(now > startTime);
require(!isFinalized);
finalization();
Finalized();
isFinalized = true;
}
/**
* @dev If crowdsale is unsuccessful, a refund can be claimed back
*/
function claimRefund(address participant) public {
// requires sale to be finalized and goal not reached,
require(isFinalized);
require(!goalReached());
vault.refund(participant);
}
/**
* @dev If crowdsale is unsuccessful, participants can claim refunds
*/
function goalReached() public constant returns (bool) {
return totalPurchased >= goal;
}
/**
* @dev Release time-locked tokens
*/
function releaseLockFounders1() public {
foundersTimelock1.release();
}
function releaseLockFounders2() public {
foundersTimelock2.release();
}
function releaseLockFoundation() public {
foundationTimelock.release();
}
/**
* @dev Release time-locked tokens for any vested address
*/
function releaseLock(address participant) public {
require(vestedTokens[participant] != 0x0);
TokenTimelock timelock = TokenTimelock(vestedTokens[participant]);
timelock.release();
}
/**
* @dev Verifies KYC for given participant.
* This enables token purchases by the participant addres
*/
function verifyKYC(address participant) public verifierOnly {
kycVerified[participant] = true;
VerifiedKYC(participant);
}
/**
* @dev Adds an address for pre-sale commitments made off-chain.
* @param beneficiary — Address of the already verified participant
* @param tokensAllocated — Exact amount of KEY tokens (including decimal places) to allocate
* @param halfVesting — determines whether the half the tokens will be time-locked or not
*/
function addPrecommitment(
address beneficiary,
uint256 tokensAllocated,
bool halfVesting
) public verifierOnly
{
// requires to be on pre-sale
require(now < startTime); // solhint-disable-line not-rely-on-time
kycVerified[beneficiary] = true;
uint256 tokens = tokensAllocated;
totalPurchased = totalPurchased.add(tokens);
tokensPurchased[beneficiary] = tokensPurchased[beneficiary].add(tokens);
if (halfVesting) {
// half the tokens are put into a time-lock for a pre-defined period
uint64 endTimeLock = uint64(startTime + PRECOMMITMENT_VESTING_SECONDS);
// Sets a timelock for half the tokens allocated
uint256 half = tokens.div(2);
TokenTimelock timelock;
if (vestedTokens[beneficiary] == 0x0) {
timelock = new TokenTimelock(token, beneficiary, endTimeLock);
vestedTokens[beneficiary] = address(timelock);
} else {
timelock = TokenTimelock(vestedTokens[beneficiary]);
}
token.safeTransfer(beneficiary, half);
token.safeTransfer(timelock, tokens.sub(half));
} else {
// all tokens are sent to the participant's address
token.safeTransfer(beneficiary, tokens);
}
AddedPrecommitment(
beneficiary,
tokens
);
}
/**
* @dev Additional finalization logic. Enables token transfers.
*/
function finalization() internal {
if (goalReached()) {
burnUnsold();
vault.close();
token.enableTransfers();
} else {
vault.enableRefunds();
}
}
/**
* @dev Low level token purchase. Only callable internally. Participants MUST be KYC-verified before purchase
* @param participant — The address of the token purchaser
*/
function buyTokens(address participant) internal {
require(kycVerified[participant]);
require(now >= startTime);
require(now < endTime);
require(!isFinalized);
require(msg.value != 0);
// Calculate the token amount to be allocated
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(rate);
// Update state
tokensPurchased[participant] = tokensPurchased[participant].add(tokens);
totalPurchased = totalPurchased.add(tokens);
require(totalPurchased <= SALE_CAP);
require(tokensPurchased[participant] >= PURCHASER_MIN_TOKEN_CAP);
if (now < startTime + 86400) {
// if still during the first day of token sale, apply different max cap
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP_DAY1);
} else {
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP);
}
// Sends ETH contribution to the RefundVault and tokens to participant
vault.deposit.value(msg.value)(participant);
token.safeTransfer(participant, tokens);
TokenPurchase(
msg.sender,
participant,
weiAmount,
tokens
);
}
/**
* @dev Burn all remaining (unsold) tokens.
* This should be called after sale finalization
*/
function burnUnsold() internal {
// All tokens held by this contract get burned
token.burn(token.balanceOf(this));
}
} | // solhint-disable-next-line max-states-count | LineComment | releaseLockFounders1 | function releaseLockFounders1() public {
foundersTimelock1.release();
}
| /**
* @dev Release time-locked tokens
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
6708,
6798
]
} | 5,554 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | SelfKeyCrowdsale | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;
uint64 public startTime;
uint64 public endTime;
// Minimum tokens expected to sell
uint256 public goal;
// How many tokens a buyer gets per ETH
uint256 public rate = 51800;
// ETH price in USD, can be later updated until start date
uint256 public ethPrice = 777;
// Total amount of tokens purchased, including pre-sale
uint256 public totalPurchased = 0;
mapping(address => bool) public kycVerified;
mapping(address => uint256) public tokensPurchased;
// a mapping of dynamically instantiated token timelocks for each pre-commitment beneficiary
mapping(address => address) public vestedTokens;
bool public isFinalized = false;
// Token Timelocks
TokenTimelock public foundersTimelock1;
TokenTimelock public foundersTimelock2;
TokenTimelock public foundationTimelock;
// Vault to hold funds until crowdsale is finalized. Allows refunding if crowdsale is not successful.
RefundVault public vault;
// Crowdsale events
event TokenPurchase(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
uint256 amount
);
event VerifiedKYC(address indexed participant);
event AddedPrecommitment(
address indexed participant,
uint256 tokensAllocated
);
event Finalized();
modifier verifierOnly() {
require(isVerifier[msg.sender]);
_;
}
/**
* @dev Crowdsale contract constructor
* @param _startTime — Unix timestamp representing the crowdsale start time
* @param _endTime — Unix timestamp representing the crowdsale start time
* @param _goal — Minimum amount of tokens expected to sell.
*/
function SelfKeyCrowdsale(
uint64 _startTime,
uint64 _endTime,
uint256 _goal
) public
{
require(_endTime > _startTime);
// sets contract owner as a verifier
isVerifier[msg.sender] = true;
token = new SelfKeyToken(TOTAL_SUPPLY_CAP);
// mints all possible tokens to the crowdsale contract
token.mint(address(this), TOTAL_SUPPLY_CAP);
token.finishMinting();
startTime = _startTime;
endTime = _endTime;
goal = _goal;
vault = new RefundVault(CROWDSALE_WALLET_ADDR);
// Set timelocks to 6 months and a year after startTime, respectively
uint64 sixMonthLock = uint64(startTime + 15552000);
uint64 yearLock = uint64(startTime + 31104000);
// Instantiation of token timelocks
foundersTimelock1 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, sixMonthLock);
foundersTimelock2 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, yearLock);
foundationTimelock = new TokenTimelock(token, FOUNDATION_POOL_ADDR_VEST, yearLock);
// Genesis allocation of tokens
token.safeTransfer(FOUNDATION_POOL_ADDR, FOUNDATION_POOL_TOKENS);
token.safeTransfer(COMMUNITY_POOL_ADDR, COMMUNITY_POOL_TOKENS);
token.safeTransfer(FOUNDERS_POOL_ADDR, FOUNDERS_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_1, LEGAL_EXPENSES_1_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_2, LEGAL_EXPENSES_2_TOKENS);
// Allocation of vested tokens
token.safeTransfer(foundersTimelock1, FOUNDERS_TOKENS_VESTED_1);
token.safeTransfer(foundersTimelock2, FOUNDERS_TOKENS_VESTED_2);
token.safeTransfer(foundationTimelock, FOUNDATION_POOL_TOKENS_VESTED);
}
/**
* @dev Fallback function is used to buy tokens.
* It's the only entry point since `buyTokens` is internal
*/
function () public payable {
buyTokens(msg.sender);
}
/**
* @dev Adds an address to the whitelist of Verifiers
* @param _address - address of the verifier
*/
function addVerifier (address _address) public onlyOwner {
isVerifier[_address] = true;
}
/**
* @dev Removes an address from the whitelist of Verifiers
* @param _address - address of the verifier to be removed
*/
function removeVerifier (address _address) public onlyOwner {
isVerifier[_address] = false;
}
/**
* @dev Sets a new start date as long as token hasn't started yet
* @param _startTime - unix timestamp of the new start time
*/
function setStartTime (uint64 _startTime) public onlyOwner {
require(now < startTime);
require(_startTime > now);
require(_startTime < endTime);
startTime = _startTime;
}
/**
* @dev Sets a new end date as long as end date hasn't been reached
* @param _endTime - unix timestamp of the new end time
*/
function setEndTime (uint64 _endTime) public onlyOwner {
require(now < endTime);
require(_endTime > now);
require(_endTime > startTime);
endTime = _endTime;
}
/**
* @dev Updates the ETH/USD conversion rate as long as the public sale hasn't started
* @param _ethPrice - Updated conversion rate
*/
function setEthPrice(uint256 _ethPrice) public onlyOwner {
require(now < startTime);
require(_ethPrice > 0);
ethPrice = _ethPrice;
rate = ethPrice.mul(1000).div(TOKEN_PRICE_THOUSANDTH);
}
/**
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function.
*/
function finalize() public onlyOwner {
require(now > startTime);
require(!isFinalized);
finalization();
Finalized();
isFinalized = true;
}
/**
* @dev If crowdsale is unsuccessful, a refund can be claimed back
*/
function claimRefund(address participant) public {
// requires sale to be finalized and goal not reached,
require(isFinalized);
require(!goalReached());
vault.refund(participant);
}
/**
* @dev If crowdsale is unsuccessful, participants can claim refunds
*/
function goalReached() public constant returns (bool) {
return totalPurchased >= goal;
}
/**
* @dev Release time-locked tokens
*/
function releaseLockFounders1() public {
foundersTimelock1.release();
}
function releaseLockFounders2() public {
foundersTimelock2.release();
}
function releaseLockFoundation() public {
foundationTimelock.release();
}
/**
* @dev Release time-locked tokens for any vested address
*/
function releaseLock(address participant) public {
require(vestedTokens[participant] != 0x0);
TokenTimelock timelock = TokenTimelock(vestedTokens[participant]);
timelock.release();
}
/**
* @dev Verifies KYC for given participant.
* This enables token purchases by the participant addres
*/
function verifyKYC(address participant) public verifierOnly {
kycVerified[participant] = true;
VerifiedKYC(participant);
}
/**
* @dev Adds an address for pre-sale commitments made off-chain.
* @param beneficiary — Address of the already verified participant
* @param tokensAllocated — Exact amount of KEY tokens (including decimal places) to allocate
* @param halfVesting — determines whether the half the tokens will be time-locked or not
*/
function addPrecommitment(
address beneficiary,
uint256 tokensAllocated,
bool halfVesting
) public verifierOnly
{
// requires to be on pre-sale
require(now < startTime); // solhint-disable-line not-rely-on-time
kycVerified[beneficiary] = true;
uint256 tokens = tokensAllocated;
totalPurchased = totalPurchased.add(tokens);
tokensPurchased[beneficiary] = tokensPurchased[beneficiary].add(tokens);
if (halfVesting) {
// half the tokens are put into a time-lock for a pre-defined period
uint64 endTimeLock = uint64(startTime + PRECOMMITMENT_VESTING_SECONDS);
// Sets a timelock for half the tokens allocated
uint256 half = tokens.div(2);
TokenTimelock timelock;
if (vestedTokens[beneficiary] == 0x0) {
timelock = new TokenTimelock(token, beneficiary, endTimeLock);
vestedTokens[beneficiary] = address(timelock);
} else {
timelock = TokenTimelock(vestedTokens[beneficiary]);
}
token.safeTransfer(beneficiary, half);
token.safeTransfer(timelock, tokens.sub(half));
} else {
// all tokens are sent to the participant's address
token.safeTransfer(beneficiary, tokens);
}
AddedPrecommitment(
beneficiary,
tokens
);
}
/**
* @dev Additional finalization logic. Enables token transfers.
*/
function finalization() internal {
if (goalReached()) {
burnUnsold();
vault.close();
token.enableTransfers();
} else {
vault.enableRefunds();
}
}
/**
* @dev Low level token purchase. Only callable internally. Participants MUST be KYC-verified before purchase
* @param participant — The address of the token purchaser
*/
function buyTokens(address participant) internal {
require(kycVerified[participant]);
require(now >= startTime);
require(now < endTime);
require(!isFinalized);
require(msg.value != 0);
// Calculate the token amount to be allocated
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(rate);
// Update state
tokensPurchased[participant] = tokensPurchased[participant].add(tokens);
totalPurchased = totalPurchased.add(tokens);
require(totalPurchased <= SALE_CAP);
require(tokensPurchased[participant] >= PURCHASER_MIN_TOKEN_CAP);
if (now < startTime + 86400) {
// if still during the first day of token sale, apply different max cap
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP_DAY1);
} else {
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP);
}
// Sends ETH contribution to the RefundVault and tokens to participant
vault.deposit.value(msg.value)(participant);
token.safeTransfer(participant, tokens);
TokenPurchase(
msg.sender,
participant,
weiAmount,
tokens
);
}
/**
* @dev Burn all remaining (unsold) tokens.
* This should be called after sale finalization
*/
function burnUnsold() internal {
// All tokens held by this contract get burned
token.burn(token.balanceOf(this));
}
} | // solhint-disable-next-line max-states-count | LineComment | releaseLock | function releaseLock(address participant) public {
require(vestedTokens[participant] != 0x0);
TokenTimelock timelock = TokenTimelock(vestedTokens[participant]);
timelock.release();
}
| /**
* @dev Release time-locked tokens for any vested address
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
7070,
7291
]
} | 5,555 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | SelfKeyCrowdsale | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;
uint64 public startTime;
uint64 public endTime;
// Minimum tokens expected to sell
uint256 public goal;
// How many tokens a buyer gets per ETH
uint256 public rate = 51800;
// ETH price in USD, can be later updated until start date
uint256 public ethPrice = 777;
// Total amount of tokens purchased, including pre-sale
uint256 public totalPurchased = 0;
mapping(address => bool) public kycVerified;
mapping(address => uint256) public tokensPurchased;
// a mapping of dynamically instantiated token timelocks for each pre-commitment beneficiary
mapping(address => address) public vestedTokens;
bool public isFinalized = false;
// Token Timelocks
TokenTimelock public foundersTimelock1;
TokenTimelock public foundersTimelock2;
TokenTimelock public foundationTimelock;
// Vault to hold funds until crowdsale is finalized. Allows refunding if crowdsale is not successful.
RefundVault public vault;
// Crowdsale events
event TokenPurchase(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
uint256 amount
);
event VerifiedKYC(address indexed participant);
event AddedPrecommitment(
address indexed participant,
uint256 tokensAllocated
);
event Finalized();
modifier verifierOnly() {
require(isVerifier[msg.sender]);
_;
}
/**
* @dev Crowdsale contract constructor
* @param _startTime — Unix timestamp representing the crowdsale start time
* @param _endTime — Unix timestamp representing the crowdsale start time
* @param _goal — Minimum amount of tokens expected to sell.
*/
function SelfKeyCrowdsale(
uint64 _startTime,
uint64 _endTime,
uint256 _goal
) public
{
require(_endTime > _startTime);
// sets contract owner as a verifier
isVerifier[msg.sender] = true;
token = new SelfKeyToken(TOTAL_SUPPLY_CAP);
// mints all possible tokens to the crowdsale contract
token.mint(address(this), TOTAL_SUPPLY_CAP);
token.finishMinting();
startTime = _startTime;
endTime = _endTime;
goal = _goal;
vault = new RefundVault(CROWDSALE_WALLET_ADDR);
// Set timelocks to 6 months and a year after startTime, respectively
uint64 sixMonthLock = uint64(startTime + 15552000);
uint64 yearLock = uint64(startTime + 31104000);
// Instantiation of token timelocks
foundersTimelock1 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, sixMonthLock);
foundersTimelock2 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, yearLock);
foundationTimelock = new TokenTimelock(token, FOUNDATION_POOL_ADDR_VEST, yearLock);
// Genesis allocation of tokens
token.safeTransfer(FOUNDATION_POOL_ADDR, FOUNDATION_POOL_TOKENS);
token.safeTransfer(COMMUNITY_POOL_ADDR, COMMUNITY_POOL_TOKENS);
token.safeTransfer(FOUNDERS_POOL_ADDR, FOUNDERS_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_1, LEGAL_EXPENSES_1_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_2, LEGAL_EXPENSES_2_TOKENS);
// Allocation of vested tokens
token.safeTransfer(foundersTimelock1, FOUNDERS_TOKENS_VESTED_1);
token.safeTransfer(foundersTimelock2, FOUNDERS_TOKENS_VESTED_2);
token.safeTransfer(foundationTimelock, FOUNDATION_POOL_TOKENS_VESTED);
}
/**
* @dev Fallback function is used to buy tokens.
* It's the only entry point since `buyTokens` is internal
*/
function () public payable {
buyTokens(msg.sender);
}
/**
* @dev Adds an address to the whitelist of Verifiers
* @param _address - address of the verifier
*/
function addVerifier (address _address) public onlyOwner {
isVerifier[_address] = true;
}
/**
* @dev Removes an address from the whitelist of Verifiers
* @param _address - address of the verifier to be removed
*/
function removeVerifier (address _address) public onlyOwner {
isVerifier[_address] = false;
}
/**
* @dev Sets a new start date as long as token hasn't started yet
* @param _startTime - unix timestamp of the new start time
*/
function setStartTime (uint64 _startTime) public onlyOwner {
require(now < startTime);
require(_startTime > now);
require(_startTime < endTime);
startTime = _startTime;
}
/**
* @dev Sets a new end date as long as end date hasn't been reached
* @param _endTime - unix timestamp of the new end time
*/
function setEndTime (uint64 _endTime) public onlyOwner {
require(now < endTime);
require(_endTime > now);
require(_endTime > startTime);
endTime = _endTime;
}
/**
* @dev Updates the ETH/USD conversion rate as long as the public sale hasn't started
* @param _ethPrice - Updated conversion rate
*/
function setEthPrice(uint256 _ethPrice) public onlyOwner {
require(now < startTime);
require(_ethPrice > 0);
ethPrice = _ethPrice;
rate = ethPrice.mul(1000).div(TOKEN_PRICE_THOUSANDTH);
}
/**
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function.
*/
function finalize() public onlyOwner {
require(now > startTime);
require(!isFinalized);
finalization();
Finalized();
isFinalized = true;
}
/**
* @dev If crowdsale is unsuccessful, a refund can be claimed back
*/
function claimRefund(address participant) public {
// requires sale to be finalized and goal not reached,
require(isFinalized);
require(!goalReached());
vault.refund(participant);
}
/**
* @dev If crowdsale is unsuccessful, participants can claim refunds
*/
function goalReached() public constant returns (bool) {
return totalPurchased >= goal;
}
/**
* @dev Release time-locked tokens
*/
function releaseLockFounders1() public {
foundersTimelock1.release();
}
function releaseLockFounders2() public {
foundersTimelock2.release();
}
function releaseLockFoundation() public {
foundationTimelock.release();
}
/**
* @dev Release time-locked tokens for any vested address
*/
function releaseLock(address participant) public {
require(vestedTokens[participant] != 0x0);
TokenTimelock timelock = TokenTimelock(vestedTokens[participant]);
timelock.release();
}
/**
* @dev Verifies KYC for given participant.
* This enables token purchases by the participant addres
*/
function verifyKYC(address participant) public verifierOnly {
kycVerified[participant] = true;
VerifiedKYC(participant);
}
/**
* @dev Adds an address for pre-sale commitments made off-chain.
* @param beneficiary — Address of the already verified participant
* @param tokensAllocated — Exact amount of KEY tokens (including decimal places) to allocate
* @param halfVesting — determines whether the half the tokens will be time-locked or not
*/
function addPrecommitment(
address beneficiary,
uint256 tokensAllocated,
bool halfVesting
) public verifierOnly
{
// requires to be on pre-sale
require(now < startTime); // solhint-disable-line not-rely-on-time
kycVerified[beneficiary] = true;
uint256 tokens = tokensAllocated;
totalPurchased = totalPurchased.add(tokens);
tokensPurchased[beneficiary] = tokensPurchased[beneficiary].add(tokens);
if (halfVesting) {
// half the tokens are put into a time-lock for a pre-defined period
uint64 endTimeLock = uint64(startTime + PRECOMMITMENT_VESTING_SECONDS);
// Sets a timelock for half the tokens allocated
uint256 half = tokens.div(2);
TokenTimelock timelock;
if (vestedTokens[beneficiary] == 0x0) {
timelock = new TokenTimelock(token, beneficiary, endTimeLock);
vestedTokens[beneficiary] = address(timelock);
} else {
timelock = TokenTimelock(vestedTokens[beneficiary]);
}
token.safeTransfer(beneficiary, half);
token.safeTransfer(timelock, tokens.sub(half));
} else {
// all tokens are sent to the participant's address
token.safeTransfer(beneficiary, tokens);
}
AddedPrecommitment(
beneficiary,
tokens
);
}
/**
* @dev Additional finalization logic. Enables token transfers.
*/
function finalization() internal {
if (goalReached()) {
burnUnsold();
vault.close();
token.enableTransfers();
} else {
vault.enableRefunds();
}
}
/**
* @dev Low level token purchase. Only callable internally. Participants MUST be KYC-verified before purchase
* @param participant — The address of the token purchaser
*/
function buyTokens(address participant) internal {
require(kycVerified[participant]);
require(now >= startTime);
require(now < endTime);
require(!isFinalized);
require(msg.value != 0);
// Calculate the token amount to be allocated
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(rate);
// Update state
tokensPurchased[participant] = tokensPurchased[participant].add(tokens);
totalPurchased = totalPurchased.add(tokens);
require(totalPurchased <= SALE_CAP);
require(tokensPurchased[participant] >= PURCHASER_MIN_TOKEN_CAP);
if (now < startTime + 86400) {
// if still during the first day of token sale, apply different max cap
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP_DAY1);
} else {
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP);
}
// Sends ETH contribution to the RefundVault and tokens to participant
vault.deposit.value(msg.value)(participant);
token.safeTransfer(participant, tokens);
TokenPurchase(
msg.sender,
participant,
weiAmount,
tokens
);
}
/**
* @dev Burn all remaining (unsold) tokens.
* This should be called after sale finalization
*/
function burnUnsold() internal {
// All tokens held by this contract get burned
token.burn(token.balanceOf(this));
}
} | // solhint-disable-next-line max-states-count | LineComment | verifyKYC | function verifyKYC(address participant) public verifierOnly {
kycVerified[participant] = true;
VerifiedKYC(participant);
}
| /**
* @dev Verifies KYC for given participant.
* This enables token purchases by the participant addres
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
7429,
7581
]
} | 5,556 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | SelfKeyCrowdsale | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;
uint64 public startTime;
uint64 public endTime;
// Minimum tokens expected to sell
uint256 public goal;
// How many tokens a buyer gets per ETH
uint256 public rate = 51800;
// ETH price in USD, can be later updated until start date
uint256 public ethPrice = 777;
// Total amount of tokens purchased, including pre-sale
uint256 public totalPurchased = 0;
mapping(address => bool) public kycVerified;
mapping(address => uint256) public tokensPurchased;
// a mapping of dynamically instantiated token timelocks for each pre-commitment beneficiary
mapping(address => address) public vestedTokens;
bool public isFinalized = false;
// Token Timelocks
TokenTimelock public foundersTimelock1;
TokenTimelock public foundersTimelock2;
TokenTimelock public foundationTimelock;
// Vault to hold funds until crowdsale is finalized. Allows refunding if crowdsale is not successful.
RefundVault public vault;
// Crowdsale events
event TokenPurchase(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
uint256 amount
);
event VerifiedKYC(address indexed participant);
event AddedPrecommitment(
address indexed participant,
uint256 tokensAllocated
);
event Finalized();
modifier verifierOnly() {
require(isVerifier[msg.sender]);
_;
}
/**
* @dev Crowdsale contract constructor
* @param _startTime — Unix timestamp representing the crowdsale start time
* @param _endTime — Unix timestamp representing the crowdsale start time
* @param _goal — Minimum amount of tokens expected to sell.
*/
function SelfKeyCrowdsale(
uint64 _startTime,
uint64 _endTime,
uint256 _goal
) public
{
require(_endTime > _startTime);
// sets contract owner as a verifier
isVerifier[msg.sender] = true;
token = new SelfKeyToken(TOTAL_SUPPLY_CAP);
// mints all possible tokens to the crowdsale contract
token.mint(address(this), TOTAL_SUPPLY_CAP);
token.finishMinting();
startTime = _startTime;
endTime = _endTime;
goal = _goal;
vault = new RefundVault(CROWDSALE_WALLET_ADDR);
// Set timelocks to 6 months and a year after startTime, respectively
uint64 sixMonthLock = uint64(startTime + 15552000);
uint64 yearLock = uint64(startTime + 31104000);
// Instantiation of token timelocks
foundersTimelock1 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, sixMonthLock);
foundersTimelock2 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, yearLock);
foundationTimelock = new TokenTimelock(token, FOUNDATION_POOL_ADDR_VEST, yearLock);
// Genesis allocation of tokens
token.safeTransfer(FOUNDATION_POOL_ADDR, FOUNDATION_POOL_TOKENS);
token.safeTransfer(COMMUNITY_POOL_ADDR, COMMUNITY_POOL_TOKENS);
token.safeTransfer(FOUNDERS_POOL_ADDR, FOUNDERS_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_1, LEGAL_EXPENSES_1_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_2, LEGAL_EXPENSES_2_TOKENS);
// Allocation of vested tokens
token.safeTransfer(foundersTimelock1, FOUNDERS_TOKENS_VESTED_1);
token.safeTransfer(foundersTimelock2, FOUNDERS_TOKENS_VESTED_2);
token.safeTransfer(foundationTimelock, FOUNDATION_POOL_TOKENS_VESTED);
}
/**
* @dev Fallback function is used to buy tokens.
* It's the only entry point since `buyTokens` is internal
*/
function () public payable {
buyTokens(msg.sender);
}
/**
* @dev Adds an address to the whitelist of Verifiers
* @param _address - address of the verifier
*/
function addVerifier (address _address) public onlyOwner {
isVerifier[_address] = true;
}
/**
* @dev Removes an address from the whitelist of Verifiers
* @param _address - address of the verifier to be removed
*/
function removeVerifier (address _address) public onlyOwner {
isVerifier[_address] = false;
}
/**
* @dev Sets a new start date as long as token hasn't started yet
* @param _startTime - unix timestamp of the new start time
*/
function setStartTime (uint64 _startTime) public onlyOwner {
require(now < startTime);
require(_startTime > now);
require(_startTime < endTime);
startTime = _startTime;
}
/**
* @dev Sets a new end date as long as end date hasn't been reached
* @param _endTime - unix timestamp of the new end time
*/
function setEndTime (uint64 _endTime) public onlyOwner {
require(now < endTime);
require(_endTime > now);
require(_endTime > startTime);
endTime = _endTime;
}
/**
* @dev Updates the ETH/USD conversion rate as long as the public sale hasn't started
* @param _ethPrice - Updated conversion rate
*/
function setEthPrice(uint256 _ethPrice) public onlyOwner {
require(now < startTime);
require(_ethPrice > 0);
ethPrice = _ethPrice;
rate = ethPrice.mul(1000).div(TOKEN_PRICE_THOUSANDTH);
}
/**
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function.
*/
function finalize() public onlyOwner {
require(now > startTime);
require(!isFinalized);
finalization();
Finalized();
isFinalized = true;
}
/**
* @dev If crowdsale is unsuccessful, a refund can be claimed back
*/
function claimRefund(address participant) public {
// requires sale to be finalized and goal not reached,
require(isFinalized);
require(!goalReached());
vault.refund(participant);
}
/**
* @dev If crowdsale is unsuccessful, participants can claim refunds
*/
function goalReached() public constant returns (bool) {
return totalPurchased >= goal;
}
/**
* @dev Release time-locked tokens
*/
function releaseLockFounders1() public {
foundersTimelock1.release();
}
function releaseLockFounders2() public {
foundersTimelock2.release();
}
function releaseLockFoundation() public {
foundationTimelock.release();
}
/**
* @dev Release time-locked tokens for any vested address
*/
function releaseLock(address participant) public {
require(vestedTokens[participant] != 0x0);
TokenTimelock timelock = TokenTimelock(vestedTokens[participant]);
timelock.release();
}
/**
* @dev Verifies KYC for given participant.
* This enables token purchases by the participant addres
*/
function verifyKYC(address participant) public verifierOnly {
kycVerified[participant] = true;
VerifiedKYC(participant);
}
/**
* @dev Adds an address for pre-sale commitments made off-chain.
* @param beneficiary — Address of the already verified participant
* @param tokensAllocated — Exact amount of KEY tokens (including decimal places) to allocate
* @param halfVesting — determines whether the half the tokens will be time-locked or not
*/
function addPrecommitment(
address beneficiary,
uint256 tokensAllocated,
bool halfVesting
) public verifierOnly
{
// requires to be on pre-sale
require(now < startTime); // solhint-disable-line not-rely-on-time
kycVerified[beneficiary] = true;
uint256 tokens = tokensAllocated;
totalPurchased = totalPurchased.add(tokens);
tokensPurchased[beneficiary] = tokensPurchased[beneficiary].add(tokens);
if (halfVesting) {
// half the tokens are put into a time-lock for a pre-defined period
uint64 endTimeLock = uint64(startTime + PRECOMMITMENT_VESTING_SECONDS);
// Sets a timelock for half the tokens allocated
uint256 half = tokens.div(2);
TokenTimelock timelock;
if (vestedTokens[beneficiary] == 0x0) {
timelock = new TokenTimelock(token, beneficiary, endTimeLock);
vestedTokens[beneficiary] = address(timelock);
} else {
timelock = TokenTimelock(vestedTokens[beneficiary]);
}
token.safeTransfer(beneficiary, half);
token.safeTransfer(timelock, tokens.sub(half));
} else {
// all tokens are sent to the participant's address
token.safeTransfer(beneficiary, tokens);
}
AddedPrecommitment(
beneficiary,
tokens
);
}
/**
* @dev Additional finalization logic. Enables token transfers.
*/
function finalization() internal {
if (goalReached()) {
burnUnsold();
vault.close();
token.enableTransfers();
} else {
vault.enableRefunds();
}
}
/**
* @dev Low level token purchase. Only callable internally. Participants MUST be KYC-verified before purchase
* @param participant — The address of the token purchaser
*/
function buyTokens(address participant) internal {
require(kycVerified[participant]);
require(now >= startTime);
require(now < endTime);
require(!isFinalized);
require(msg.value != 0);
// Calculate the token amount to be allocated
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(rate);
// Update state
tokensPurchased[participant] = tokensPurchased[participant].add(tokens);
totalPurchased = totalPurchased.add(tokens);
require(totalPurchased <= SALE_CAP);
require(tokensPurchased[participant] >= PURCHASER_MIN_TOKEN_CAP);
if (now < startTime + 86400) {
// if still during the first day of token sale, apply different max cap
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP_DAY1);
} else {
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP);
}
// Sends ETH contribution to the RefundVault and tokens to participant
vault.deposit.value(msg.value)(participant);
token.safeTransfer(participant, tokens);
TokenPurchase(
msg.sender,
participant,
weiAmount,
tokens
);
}
/**
* @dev Burn all remaining (unsold) tokens.
* This should be called after sale finalization
*/
function burnUnsold() internal {
// All tokens held by this contract get burned
token.burn(token.balanceOf(this));
}
} | // solhint-disable-next-line max-states-count | LineComment | addPrecommitment | function addPrecommitment(
address beneficiary,
uint256 tokensAllocated,
bool halfVesting
) public verifierOnly
{
// requires to be on pre-sale
require(now < startTime); // solhint-disable-line not-rely-on-time
kycVerified[beneficiary] = true;
uint256 tokens = tokensAllocated;
totalPurchased = totalPurchased.add(tokens);
tokensPurchased[beneficiary] = tokensPurchased[beneficiary].add(tokens);
if (halfVesting) {
// half the tokens are put into a time-lock for a pre-defined period
uint64 endTimeLock = uint64(startTime + PRECOMMITMENT_VESTING_SECONDS);
// Sets a timelock for half the tokens allocated
uint256 half = tokens.div(2);
TokenTimelock timelock;
if (vestedTokens[beneficiary] == 0x0) {
timelock = new TokenTimelock(token, beneficiary, endTimeLock);
vestedTokens[beneficiary] = address(timelock);
} else {
timelock = TokenTimelock(vestedTokens[beneficiary]);
}
token.safeTransfer(beneficiary, half);
token.safeTransfer(timelock, tokens.sub(half));
} else {
// all tokens are sent to the participant's address
token.safeTransfer(beneficiary, tokens);
}
AddedPrecommitment(
beneficiary,
tokens
);
}
| /**
* @dev Adds an address for pre-sale commitments made off-chain.
* @param beneficiary — Address of the already verified participant
* @param tokensAllocated — Exact amount of KEY tokens (including decimal places) to allocate
* @param halfVesting — determines whether the half the tokens will be time-locked or not
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
7939,
9440
]
} | 5,557 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | SelfKeyCrowdsale | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;
uint64 public startTime;
uint64 public endTime;
// Minimum tokens expected to sell
uint256 public goal;
// How many tokens a buyer gets per ETH
uint256 public rate = 51800;
// ETH price in USD, can be later updated until start date
uint256 public ethPrice = 777;
// Total amount of tokens purchased, including pre-sale
uint256 public totalPurchased = 0;
mapping(address => bool) public kycVerified;
mapping(address => uint256) public tokensPurchased;
// a mapping of dynamically instantiated token timelocks for each pre-commitment beneficiary
mapping(address => address) public vestedTokens;
bool public isFinalized = false;
// Token Timelocks
TokenTimelock public foundersTimelock1;
TokenTimelock public foundersTimelock2;
TokenTimelock public foundationTimelock;
// Vault to hold funds until crowdsale is finalized. Allows refunding if crowdsale is not successful.
RefundVault public vault;
// Crowdsale events
event TokenPurchase(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
uint256 amount
);
event VerifiedKYC(address indexed participant);
event AddedPrecommitment(
address indexed participant,
uint256 tokensAllocated
);
event Finalized();
modifier verifierOnly() {
require(isVerifier[msg.sender]);
_;
}
/**
* @dev Crowdsale contract constructor
* @param _startTime — Unix timestamp representing the crowdsale start time
* @param _endTime — Unix timestamp representing the crowdsale start time
* @param _goal — Minimum amount of tokens expected to sell.
*/
function SelfKeyCrowdsale(
uint64 _startTime,
uint64 _endTime,
uint256 _goal
) public
{
require(_endTime > _startTime);
// sets contract owner as a verifier
isVerifier[msg.sender] = true;
token = new SelfKeyToken(TOTAL_SUPPLY_CAP);
// mints all possible tokens to the crowdsale contract
token.mint(address(this), TOTAL_SUPPLY_CAP);
token.finishMinting();
startTime = _startTime;
endTime = _endTime;
goal = _goal;
vault = new RefundVault(CROWDSALE_WALLET_ADDR);
// Set timelocks to 6 months and a year after startTime, respectively
uint64 sixMonthLock = uint64(startTime + 15552000);
uint64 yearLock = uint64(startTime + 31104000);
// Instantiation of token timelocks
foundersTimelock1 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, sixMonthLock);
foundersTimelock2 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, yearLock);
foundationTimelock = new TokenTimelock(token, FOUNDATION_POOL_ADDR_VEST, yearLock);
// Genesis allocation of tokens
token.safeTransfer(FOUNDATION_POOL_ADDR, FOUNDATION_POOL_TOKENS);
token.safeTransfer(COMMUNITY_POOL_ADDR, COMMUNITY_POOL_TOKENS);
token.safeTransfer(FOUNDERS_POOL_ADDR, FOUNDERS_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_1, LEGAL_EXPENSES_1_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_2, LEGAL_EXPENSES_2_TOKENS);
// Allocation of vested tokens
token.safeTransfer(foundersTimelock1, FOUNDERS_TOKENS_VESTED_1);
token.safeTransfer(foundersTimelock2, FOUNDERS_TOKENS_VESTED_2);
token.safeTransfer(foundationTimelock, FOUNDATION_POOL_TOKENS_VESTED);
}
/**
* @dev Fallback function is used to buy tokens.
* It's the only entry point since `buyTokens` is internal
*/
function () public payable {
buyTokens(msg.sender);
}
/**
* @dev Adds an address to the whitelist of Verifiers
* @param _address - address of the verifier
*/
function addVerifier (address _address) public onlyOwner {
isVerifier[_address] = true;
}
/**
* @dev Removes an address from the whitelist of Verifiers
* @param _address - address of the verifier to be removed
*/
function removeVerifier (address _address) public onlyOwner {
isVerifier[_address] = false;
}
/**
* @dev Sets a new start date as long as token hasn't started yet
* @param _startTime - unix timestamp of the new start time
*/
function setStartTime (uint64 _startTime) public onlyOwner {
require(now < startTime);
require(_startTime > now);
require(_startTime < endTime);
startTime = _startTime;
}
/**
* @dev Sets a new end date as long as end date hasn't been reached
* @param _endTime - unix timestamp of the new end time
*/
function setEndTime (uint64 _endTime) public onlyOwner {
require(now < endTime);
require(_endTime > now);
require(_endTime > startTime);
endTime = _endTime;
}
/**
* @dev Updates the ETH/USD conversion rate as long as the public sale hasn't started
* @param _ethPrice - Updated conversion rate
*/
function setEthPrice(uint256 _ethPrice) public onlyOwner {
require(now < startTime);
require(_ethPrice > 0);
ethPrice = _ethPrice;
rate = ethPrice.mul(1000).div(TOKEN_PRICE_THOUSANDTH);
}
/**
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function.
*/
function finalize() public onlyOwner {
require(now > startTime);
require(!isFinalized);
finalization();
Finalized();
isFinalized = true;
}
/**
* @dev If crowdsale is unsuccessful, a refund can be claimed back
*/
function claimRefund(address participant) public {
// requires sale to be finalized and goal not reached,
require(isFinalized);
require(!goalReached());
vault.refund(participant);
}
/**
* @dev If crowdsale is unsuccessful, participants can claim refunds
*/
function goalReached() public constant returns (bool) {
return totalPurchased >= goal;
}
/**
* @dev Release time-locked tokens
*/
function releaseLockFounders1() public {
foundersTimelock1.release();
}
function releaseLockFounders2() public {
foundersTimelock2.release();
}
function releaseLockFoundation() public {
foundationTimelock.release();
}
/**
* @dev Release time-locked tokens for any vested address
*/
function releaseLock(address participant) public {
require(vestedTokens[participant] != 0x0);
TokenTimelock timelock = TokenTimelock(vestedTokens[participant]);
timelock.release();
}
/**
* @dev Verifies KYC for given participant.
* This enables token purchases by the participant addres
*/
function verifyKYC(address participant) public verifierOnly {
kycVerified[participant] = true;
VerifiedKYC(participant);
}
/**
* @dev Adds an address for pre-sale commitments made off-chain.
* @param beneficiary — Address of the already verified participant
* @param tokensAllocated — Exact amount of KEY tokens (including decimal places) to allocate
* @param halfVesting — determines whether the half the tokens will be time-locked or not
*/
function addPrecommitment(
address beneficiary,
uint256 tokensAllocated,
bool halfVesting
) public verifierOnly
{
// requires to be on pre-sale
require(now < startTime); // solhint-disable-line not-rely-on-time
kycVerified[beneficiary] = true;
uint256 tokens = tokensAllocated;
totalPurchased = totalPurchased.add(tokens);
tokensPurchased[beneficiary] = tokensPurchased[beneficiary].add(tokens);
if (halfVesting) {
// half the tokens are put into a time-lock for a pre-defined period
uint64 endTimeLock = uint64(startTime + PRECOMMITMENT_VESTING_SECONDS);
// Sets a timelock for half the tokens allocated
uint256 half = tokens.div(2);
TokenTimelock timelock;
if (vestedTokens[beneficiary] == 0x0) {
timelock = new TokenTimelock(token, beneficiary, endTimeLock);
vestedTokens[beneficiary] = address(timelock);
} else {
timelock = TokenTimelock(vestedTokens[beneficiary]);
}
token.safeTransfer(beneficiary, half);
token.safeTransfer(timelock, tokens.sub(half));
} else {
// all tokens are sent to the participant's address
token.safeTransfer(beneficiary, tokens);
}
AddedPrecommitment(
beneficiary,
tokens
);
}
/**
* @dev Additional finalization logic. Enables token transfers.
*/
function finalization() internal {
if (goalReached()) {
burnUnsold();
vault.close();
token.enableTransfers();
} else {
vault.enableRefunds();
}
}
/**
* @dev Low level token purchase. Only callable internally. Participants MUST be KYC-verified before purchase
* @param participant — The address of the token purchaser
*/
function buyTokens(address participant) internal {
require(kycVerified[participant]);
require(now >= startTime);
require(now < endTime);
require(!isFinalized);
require(msg.value != 0);
// Calculate the token amount to be allocated
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(rate);
// Update state
tokensPurchased[participant] = tokensPurchased[participant].add(tokens);
totalPurchased = totalPurchased.add(tokens);
require(totalPurchased <= SALE_CAP);
require(tokensPurchased[participant] >= PURCHASER_MIN_TOKEN_CAP);
if (now < startTime + 86400) {
// if still during the first day of token sale, apply different max cap
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP_DAY1);
} else {
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP);
}
// Sends ETH contribution to the RefundVault and tokens to participant
vault.deposit.value(msg.value)(participant);
token.safeTransfer(participant, tokens);
TokenPurchase(
msg.sender,
participant,
weiAmount,
tokens
);
}
/**
* @dev Burn all remaining (unsold) tokens.
* This should be called after sale finalization
*/
function burnUnsold() internal {
// All tokens held by this contract get burned
token.burn(token.balanceOf(this));
}
} | // solhint-disable-next-line max-states-count | LineComment | finalization | function finalization() internal {
if (goalReached()) {
burnUnsold();
vault.close();
token.enableTransfers();
} else {
vault.enableRefunds();
}
}
| /**
* @dev Additional finalization logic. Enables token transfers.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
9530,
9764
]
} | 5,558 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | SelfKeyCrowdsale | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;
uint64 public startTime;
uint64 public endTime;
// Minimum tokens expected to sell
uint256 public goal;
// How many tokens a buyer gets per ETH
uint256 public rate = 51800;
// ETH price in USD, can be later updated until start date
uint256 public ethPrice = 777;
// Total amount of tokens purchased, including pre-sale
uint256 public totalPurchased = 0;
mapping(address => bool) public kycVerified;
mapping(address => uint256) public tokensPurchased;
// a mapping of dynamically instantiated token timelocks for each pre-commitment beneficiary
mapping(address => address) public vestedTokens;
bool public isFinalized = false;
// Token Timelocks
TokenTimelock public foundersTimelock1;
TokenTimelock public foundersTimelock2;
TokenTimelock public foundationTimelock;
// Vault to hold funds until crowdsale is finalized. Allows refunding if crowdsale is not successful.
RefundVault public vault;
// Crowdsale events
event TokenPurchase(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
uint256 amount
);
event VerifiedKYC(address indexed participant);
event AddedPrecommitment(
address indexed participant,
uint256 tokensAllocated
);
event Finalized();
modifier verifierOnly() {
require(isVerifier[msg.sender]);
_;
}
/**
* @dev Crowdsale contract constructor
* @param _startTime — Unix timestamp representing the crowdsale start time
* @param _endTime — Unix timestamp representing the crowdsale start time
* @param _goal — Minimum amount of tokens expected to sell.
*/
function SelfKeyCrowdsale(
uint64 _startTime,
uint64 _endTime,
uint256 _goal
) public
{
require(_endTime > _startTime);
// sets contract owner as a verifier
isVerifier[msg.sender] = true;
token = new SelfKeyToken(TOTAL_SUPPLY_CAP);
// mints all possible tokens to the crowdsale contract
token.mint(address(this), TOTAL_SUPPLY_CAP);
token.finishMinting();
startTime = _startTime;
endTime = _endTime;
goal = _goal;
vault = new RefundVault(CROWDSALE_WALLET_ADDR);
// Set timelocks to 6 months and a year after startTime, respectively
uint64 sixMonthLock = uint64(startTime + 15552000);
uint64 yearLock = uint64(startTime + 31104000);
// Instantiation of token timelocks
foundersTimelock1 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, sixMonthLock);
foundersTimelock2 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, yearLock);
foundationTimelock = new TokenTimelock(token, FOUNDATION_POOL_ADDR_VEST, yearLock);
// Genesis allocation of tokens
token.safeTransfer(FOUNDATION_POOL_ADDR, FOUNDATION_POOL_TOKENS);
token.safeTransfer(COMMUNITY_POOL_ADDR, COMMUNITY_POOL_TOKENS);
token.safeTransfer(FOUNDERS_POOL_ADDR, FOUNDERS_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_1, LEGAL_EXPENSES_1_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_2, LEGAL_EXPENSES_2_TOKENS);
// Allocation of vested tokens
token.safeTransfer(foundersTimelock1, FOUNDERS_TOKENS_VESTED_1);
token.safeTransfer(foundersTimelock2, FOUNDERS_TOKENS_VESTED_2);
token.safeTransfer(foundationTimelock, FOUNDATION_POOL_TOKENS_VESTED);
}
/**
* @dev Fallback function is used to buy tokens.
* It's the only entry point since `buyTokens` is internal
*/
function () public payable {
buyTokens(msg.sender);
}
/**
* @dev Adds an address to the whitelist of Verifiers
* @param _address - address of the verifier
*/
function addVerifier (address _address) public onlyOwner {
isVerifier[_address] = true;
}
/**
* @dev Removes an address from the whitelist of Verifiers
* @param _address - address of the verifier to be removed
*/
function removeVerifier (address _address) public onlyOwner {
isVerifier[_address] = false;
}
/**
* @dev Sets a new start date as long as token hasn't started yet
* @param _startTime - unix timestamp of the new start time
*/
function setStartTime (uint64 _startTime) public onlyOwner {
require(now < startTime);
require(_startTime > now);
require(_startTime < endTime);
startTime = _startTime;
}
/**
* @dev Sets a new end date as long as end date hasn't been reached
* @param _endTime - unix timestamp of the new end time
*/
function setEndTime (uint64 _endTime) public onlyOwner {
require(now < endTime);
require(_endTime > now);
require(_endTime > startTime);
endTime = _endTime;
}
/**
* @dev Updates the ETH/USD conversion rate as long as the public sale hasn't started
* @param _ethPrice - Updated conversion rate
*/
function setEthPrice(uint256 _ethPrice) public onlyOwner {
require(now < startTime);
require(_ethPrice > 0);
ethPrice = _ethPrice;
rate = ethPrice.mul(1000).div(TOKEN_PRICE_THOUSANDTH);
}
/**
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function.
*/
function finalize() public onlyOwner {
require(now > startTime);
require(!isFinalized);
finalization();
Finalized();
isFinalized = true;
}
/**
* @dev If crowdsale is unsuccessful, a refund can be claimed back
*/
function claimRefund(address participant) public {
// requires sale to be finalized and goal not reached,
require(isFinalized);
require(!goalReached());
vault.refund(participant);
}
/**
* @dev If crowdsale is unsuccessful, participants can claim refunds
*/
function goalReached() public constant returns (bool) {
return totalPurchased >= goal;
}
/**
* @dev Release time-locked tokens
*/
function releaseLockFounders1() public {
foundersTimelock1.release();
}
function releaseLockFounders2() public {
foundersTimelock2.release();
}
function releaseLockFoundation() public {
foundationTimelock.release();
}
/**
* @dev Release time-locked tokens for any vested address
*/
function releaseLock(address participant) public {
require(vestedTokens[participant] != 0x0);
TokenTimelock timelock = TokenTimelock(vestedTokens[participant]);
timelock.release();
}
/**
* @dev Verifies KYC for given participant.
* This enables token purchases by the participant addres
*/
function verifyKYC(address participant) public verifierOnly {
kycVerified[participant] = true;
VerifiedKYC(participant);
}
/**
* @dev Adds an address for pre-sale commitments made off-chain.
* @param beneficiary — Address of the already verified participant
* @param tokensAllocated — Exact amount of KEY tokens (including decimal places) to allocate
* @param halfVesting — determines whether the half the tokens will be time-locked or not
*/
function addPrecommitment(
address beneficiary,
uint256 tokensAllocated,
bool halfVesting
) public verifierOnly
{
// requires to be on pre-sale
require(now < startTime); // solhint-disable-line not-rely-on-time
kycVerified[beneficiary] = true;
uint256 tokens = tokensAllocated;
totalPurchased = totalPurchased.add(tokens);
tokensPurchased[beneficiary] = tokensPurchased[beneficiary].add(tokens);
if (halfVesting) {
// half the tokens are put into a time-lock for a pre-defined period
uint64 endTimeLock = uint64(startTime + PRECOMMITMENT_VESTING_SECONDS);
// Sets a timelock for half the tokens allocated
uint256 half = tokens.div(2);
TokenTimelock timelock;
if (vestedTokens[beneficiary] == 0x0) {
timelock = new TokenTimelock(token, beneficiary, endTimeLock);
vestedTokens[beneficiary] = address(timelock);
} else {
timelock = TokenTimelock(vestedTokens[beneficiary]);
}
token.safeTransfer(beneficiary, half);
token.safeTransfer(timelock, tokens.sub(half));
} else {
// all tokens are sent to the participant's address
token.safeTransfer(beneficiary, tokens);
}
AddedPrecommitment(
beneficiary,
tokens
);
}
/**
* @dev Additional finalization logic. Enables token transfers.
*/
function finalization() internal {
if (goalReached()) {
burnUnsold();
vault.close();
token.enableTransfers();
} else {
vault.enableRefunds();
}
}
/**
* @dev Low level token purchase. Only callable internally. Participants MUST be KYC-verified before purchase
* @param participant — The address of the token purchaser
*/
function buyTokens(address participant) internal {
require(kycVerified[participant]);
require(now >= startTime);
require(now < endTime);
require(!isFinalized);
require(msg.value != 0);
// Calculate the token amount to be allocated
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(rate);
// Update state
tokensPurchased[participant] = tokensPurchased[participant].add(tokens);
totalPurchased = totalPurchased.add(tokens);
require(totalPurchased <= SALE_CAP);
require(tokensPurchased[participant] >= PURCHASER_MIN_TOKEN_CAP);
if (now < startTime + 86400) {
// if still during the first day of token sale, apply different max cap
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP_DAY1);
} else {
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP);
}
// Sends ETH contribution to the RefundVault and tokens to participant
vault.deposit.value(msg.value)(participant);
token.safeTransfer(participant, tokens);
TokenPurchase(
msg.sender,
participant,
weiAmount,
tokens
);
}
/**
* @dev Burn all remaining (unsold) tokens.
* This should be called after sale finalization
*/
function burnUnsold() internal {
// All tokens held by this contract get burned
token.burn(token.balanceOf(this));
}
} | // solhint-disable-next-line max-states-count | LineComment | buyTokens | function buyTokens(address participant) internal {
require(kycVerified[participant]);
require(now >= startTime);
require(now < endTime);
require(!isFinalized);
require(msg.value != 0);
// Calculate the token amount to be allocated
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(rate);
// Update state
tokensPurchased[participant] = tokensPurchased[participant].add(tokens);
totalPurchased = totalPurchased.add(tokens);
require(totalPurchased <= SALE_CAP);
require(tokensPurchased[participant] >= PURCHASER_MIN_TOKEN_CAP);
if (now < startTime + 86400) {
// if still during the first day of token sale, apply different max cap
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP_DAY1);
} else {
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP);
}
// Sends ETH contribution to the RefundVault and tokens to participant
vault.deposit.value(msg.value)(participant);
token.safeTransfer(participant, tokens);
TokenPurchase(
msg.sender,
participant,
weiAmount,
tokens
);
}
| /**
* @dev Low level token purchase. Only callable internally. Participants MUST be KYC-verified before purchase
* @param participant — The address of the token purchaser
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
9966,
11275
]
} | 5,559 |
|
SelfKeyCrowdsale | SelfKeyCrowdsale.sol | 0x8d4b2cffe2dcbbf06eaa5920401db86ca5fb8177 | Solidity | SelfKeyCrowdsale | contract SelfKeyCrowdsale is Ownable, CrowdsaleConfig {
using SafeMath for uint256;
using SafeERC20 for SelfKeyToken;
// whitelist of addresses that can perform precommitments and KYC verifications
mapping(address => bool) public isVerifier;
// Token contract
SelfKeyToken public token;
uint64 public startTime;
uint64 public endTime;
// Minimum tokens expected to sell
uint256 public goal;
// How many tokens a buyer gets per ETH
uint256 public rate = 51800;
// ETH price in USD, can be later updated until start date
uint256 public ethPrice = 777;
// Total amount of tokens purchased, including pre-sale
uint256 public totalPurchased = 0;
mapping(address => bool) public kycVerified;
mapping(address => uint256) public tokensPurchased;
// a mapping of dynamically instantiated token timelocks for each pre-commitment beneficiary
mapping(address => address) public vestedTokens;
bool public isFinalized = false;
// Token Timelocks
TokenTimelock public foundersTimelock1;
TokenTimelock public foundersTimelock2;
TokenTimelock public foundationTimelock;
// Vault to hold funds until crowdsale is finalized. Allows refunding if crowdsale is not successful.
RefundVault public vault;
// Crowdsale events
event TokenPurchase(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
uint256 amount
);
event VerifiedKYC(address indexed participant);
event AddedPrecommitment(
address indexed participant,
uint256 tokensAllocated
);
event Finalized();
modifier verifierOnly() {
require(isVerifier[msg.sender]);
_;
}
/**
* @dev Crowdsale contract constructor
* @param _startTime — Unix timestamp representing the crowdsale start time
* @param _endTime — Unix timestamp representing the crowdsale start time
* @param _goal — Minimum amount of tokens expected to sell.
*/
function SelfKeyCrowdsale(
uint64 _startTime,
uint64 _endTime,
uint256 _goal
) public
{
require(_endTime > _startTime);
// sets contract owner as a verifier
isVerifier[msg.sender] = true;
token = new SelfKeyToken(TOTAL_SUPPLY_CAP);
// mints all possible tokens to the crowdsale contract
token.mint(address(this), TOTAL_SUPPLY_CAP);
token.finishMinting();
startTime = _startTime;
endTime = _endTime;
goal = _goal;
vault = new RefundVault(CROWDSALE_WALLET_ADDR);
// Set timelocks to 6 months and a year after startTime, respectively
uint64 sixMonthLock = uint64(startTime + 15552000);
uint64 yearLock = uint64(startTime + 31104000);
// Instantiation of token timelocks
foundersTimelock1 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, sixMonthLock);
foundersTimelock2 = new TokenTimelock(token, FOUNDERS_POOL_ADDR, yearLock);
foundationTimelock = new TokenTimelock(token, FOUNDATION_POOL_ADDR_VEST, yearLock);
// Genesis allocation of tokens
token.safeTransfer(FOUNDATION_POOL_ADDR, FOUNDATION_POOL_TOKENS);
token.safeTransfer(COMMUNITY_POOL_ADDR, COMMUNITY_POOL_TOKENS);
token.safeTransfer(FOUNDERS_POOL_ADDR, FOUNDERS_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_1, LEGAL_EXPENSES_1_TOKENS);
token.safeTransfer(LEGAL_EXPENSES_ADDR_2, LEGAL_EXPENSES_2_TOKENS);
// Allocation of vested tokens
token.safeTransfer(foundersTimelock1, FOUNDERS_TOKENS_VESTED_1);
token.safeTransfer(foundersTimelock2, FOUNDERS_TOKENS_VESTED_2);
token.safeTransfer(foundationTimelock, FOUNDATION_POOL_TOKENS_VESTED);
}
/**
* @dev Fallback function is used to buy tokens.
* It's the only entry point since `buyTokens` is internal
*/
function () public payable {
buyTokens(msg.sender);
}
/**
* @dev Adds an address to the whitelist of Verifiers
* @param _address - address of the verifier
*/
function addVerifier (address _address) public onlyOwner {
isVerifier[_address] = true;
}
/**
* @dev Removes an address from the whitelist of Verifiers
* @param _address - address of the verifier to be removed
*/
function removeVerifier (address _address) public onlyOwner {
isVerifier[_address] = false;
}
/**
* @dev Sets a new start date as long as token hasn't started yet
* @param _startTime - unix timestamp of the new start time
*/
function setStartTime (uint64 _startTime) public onlyOwner {
require(now < startTime);
require(_startTime > now);
require(_startTime < endTime);
startTime = _startTime;
}
/**
* @dev Sets a new end date as long as end date hasn't been reached
* @param _endTime - unix timestamp of the new end time
*/
function setEndTime (uint64 _endTime) public onlyOwner {
require(now < endTime);
require(_endTime > now);
require(_endTime > startTime);
endTime = _endTime;
}
/**
* @dev Updates the ETH/USD conversion rate as long as the public sale hasn't started
* @param _ethPrice - Updated conversion rate
*/
function setEthPrice(uint256 _ethPrice) public onlyOwner {
require(now < startTime);
require(_ethPrice > 0);
ethPrice = _ethPrice;
rate = ethPrice.mul(1000).div(TOKEN_PRICE_THOUSANDTH);
}
/**
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function.
*/
function finalize() public onlyOwner {
require(now > startTime);
require(!isFinalized);
finalization();
Finalized();
isFinalized = true;
}
/**
* @dev If crowdsale is unsuccessful, a refund can be claimed back
*/
function claimRefund(address participant) public {
// requires sale to be finalized and goal not reached,
require(isFinalized);
require(!goalReached());
vault.refund(participant);
}
/**
* @dev If crowdsale is unsuccessful, participants can claim refunds
*/
function goalReached() public constant returns (bool) {
return totalPurchased >= goal;
}
/**
* @dev Release time-locked tokens
*/
function releaseLockFounders1() public {
foundersTimelock1.release();
}
function releaseLockFounders2() public {
foundersTimelock2.release();
}
function releaseLockFoundation() public {
foundationTimelock.release();
}
/**
* @dev Release time-locked tokens for any vested address
*/
function releaseLock(address participant) public {
require(vestedTokens[participant] != 0x0);
TokenTimelock timelock = TokenTimelock(vestedTokens[participant]);
timelock.release();
}
/**
* @dev Verifies KYC for given participant.
* This enables token purchases by the participant addres
*/
function verifyKYC(address participant) public verifierOnly {
kycVerified[participant] = true;
VerifiedKYC(participant);
}
/**
* @dev Adds an address for pre-sale commitments made off-chain.
* @param beneficiary — Address of the already verified participant
* @param tokensAllocated — Exact amount of KEY tokens (including decimal places) to allocate
* @param halfVesting — determines whether the half the tokens will be time-locked or not
*/
function addPrecommitment(
address beneficiary,
uint256 tokensAllocated,
bool halfVesting
) public verifierOnly
{
// requires to be on pre-sale
require(now < startTime); // solhint-disable-line not-rely-on-time
kycVerified[beneficiary] = true;
uint256 tokens = tokensAllocated;
totalPurchased = totalPurchased.add(tokens);
tokensPurchased[beneficiary] = tokensPurchased[beneficiary].add(tokens);
if (halfVesting) {
// half the tokens are put into a time-lock for a pre-defined period
uint64 endTimeLock = uint64(startTime + PRECOMMITMENT_VESTING_SECONDS);
// Sets a timelock for half the tokens allocated
uint256 half = tokens.div(2);
TokenTimelock timelock;
if (vestedTokens[beneficiary] == 0x0) {
timelock = new TokenTimelock(token, beneficiary, endTimeLock);
vestedTokens[beneficiary] = address(timelock);
} else {
timelock = TokenTimelock(vestedTokens[beneficiary]);
}
token.safeTransfer(beneficiary, half);
token.safeTransfer(timelock, tokens.sub(half));
} else {
// all tokens are sent to the participant's address
token.safeTransfer(beneficiary, tokens);
}
AddedPrecommitment(
beneficiary,
tokens
);
}
/**
* @dev Additional finalization logic. Enables token transfers.
*/
function finalization() internal {
if (goalReached()) {
burnUnsold();
vault.close();
token.enableTransfers();
} else {
vault.enableRefunds();
}
}
/**
* @dev Low level token purchase. Only callable internally. Participants MUST be KYC-verified before purchase
* @param participant — The address of the token purchaser
*/
function buyTokens(address participant) internal {
require(kycVerified[participant]);
require(now >= startTime);
require(now < endTime);
require(!isFinalized);
require(msg.value != 0);
// Calculate the token amount to be allocated
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(rate);
// Update state
tokensPurchased[participant] = tokensPurchased[participant].add(tokens);
totalPurchased = totalPurchased.add(tokens);
require(totalPurchased <= SALE_CAP);
require(tokensPurchased[participant] >= PURCHASER_MIN_TOKEN_CAP);
if (now < startTime + 86400) {
// if still during the first day of token sale, apply different max cap
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP_DAY1);
} else {
require(tokensPurchased[participant] <= PURCHASER_MAX_TOKEN_CAP);
}
// Sends ETH contribution to the RefundVault and tokens to participant
vault.deposit.value(msg.value)(participant);
token.safeTransfer(participant, tokens);
TokenPurchase(
msg.sender,
participant,
weiAmount,
tokens
);
}
/**
* @dev Burn all remaining (unsold) tokens.
* This should be called after sale finalization
*/
function burnUnsold() internal {
// All tokens held by this contract get burned
token.burn(token.balanceOf(this));
}
} | // solhint-disable-next-line max-states-count | LineComment | burnUnsold | function burnUnsold() internal {
// All tokens held by this contract get burned
token.burn(token.balanceOf(this));
}
| /**
* @dev Burn all remaining (unsold) tokens.
* This should be called after sale finalization
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://eeace2909ad96851c2cbf01b9bbc7140e82c263f6ff3790a8a0e12d0640aff77 | {
"func_code_index": [
11404,
11548
]
} | 5,560 |
|
DefiCoinToken | DefiCoinToken.sol | 0xe932cae1a787e80c8626d01811005cdbbc30edcd | Solidity | DefiCoinToken | contract DefiCoinToken is ERC20 {
uint256 public totalSupply;
uint public decimals;
string public symbol;
string public name;
mapping (address => mapping (address => uint256)) approach;
mapping (address => uint256) holders;
//***************************** REVERT IF ETHEREUM SEND ************************
function () public {
revert();
}
//***************************** CHECK BALANCE **********************************
function balanceOf(address _own)
public view returns (uint256) {
return holders[_own];
}
//***************************** TRANSFER TOKENS FROM YOUR ACCOUNT **************
function transfer(address _to, uint256 _val)
public returns (bool) {
require(holders[msg.sender] >= _val);
require(msg.sender != _to);
assert(_val <= holders[msg.sender]);
holders[msg.sender] = holders[msg.sender] - _val;
holders[_to] = holders[_to] + _val;
assert(holders[_to] >= _val);
emit Transfer(msg.sender, _to, _val);
return true;
}
//**************************** TRANSFER TOKENS FROM ANOTHER ACCOUNT ************
function transferFrom(address _from, address _to, uint256 _val)
public returns (bool) {
require(holders[_from] >= _val);
require(approach[_from][msg.sender] >= _val);
assert(_val <= holders[_from]);
holders[_from] = holders[_from] - _val;
assert(_val <= approach[_from][msg.sender]);
approach[_from][msg.sender] = approach[_from][msg.sender] - _val;
holders[_to] = holders[_to] + _val;
assert(holders[_to] >= _val);
emit Transfer(_from, _to, _val);
return true;
}
//***************************** APPROVE TOKENS TO SEND *************************
function approve(address _spender, uint256 _val)
public returns (bool) {
require(holders[msg.sender] >= _val);
approach[msg.sender][_spender] = _val;
emit Approval(msg.sender, _spender, _val);
return true;
}
//***************************** CHECK APPROVE **********************************
function allowance(address _owner, address _spender)
public view returns (uint256) {
return approach[_owner][_spender];
}
//***************************** CONSTRUCTOR CONTRACT ***************************
constructor() public {
symbol = "DFCT";
name = "DefiCoin Token";
decimals = 18;
totalSupply = 21000000* 1000000000000000000;
holders[msg.sender] = totalSupply;
}
} | //***************************** CONTRACT *************************************** | LineComment | function () public {
revert();
}
| //***************************** REVERT IF ETHEREUM SEND ************************ | LineComment | v0.4.26+commit.4563c3fc | Apache-2.0 | bzzr://32382a95e4a922fc13a06c97a2b92083e8b84af26f2a7db0202a61ad586208d7 | {
"func_code_index": [
313,
348
]
} | 5,561 |
|
DefiCoinToken | DefiCoinToken.sol | 0xe932cae1a787e80c8626d01811005cdbbc30edcd | Solidity | DefiCoinToken | contract DefiCoinToken is ERC20 {
uint256 public totalSupply;
uint public decimals;
string public symbol;
string public name;
mapping (address => mapping (address => uint256)) approach;
mapping (address => uint256) holders;
//***************************** REVERT IF ETHEREUM SEND ************************
function () public {
revert();
}
//***************************** CHECK BALANCE **********************************
function balanceOf(address _own)
public view returns (uint256) {
return holders[_own];
}
//***************************** TRANSFER TOKENS FROM YOUR ACCOUNT **************
function transfer(address _to, uint256 _val)
public returns (bool) {
require(holders[msg.sender] >= _val);
require(msg.sender != _to);
assert(_val <= holders[msg.sender]);
holders[msg.sender] = holders[msg.sender] - _val;
holders[_to] = holders[_to] + _val;
assert(holders[_to] >= _val);
emit Transfer(msg.sender, _to, _val);
return true;
}
//**************************** TRANSFER TOKENS FROM ANOTHER ACCOUNT ************
function transferFrom(address _from, address _to, uint256 _val)
public returns (bool) {
require(holders[_from] >= _val);
require(approach[_from][msg.sender] >= _val);
assert(_val <= holders[_from]);
holders[_from] = holders[_from] - _val;
assert(_val <= approach[_from][msg.sender]);
approach[_from][msg.sender] = approach[_from][msg.sender] - _val;
holders[_to] = holders[_to] + _val;
assert(holders[_to] >= _val);
emit Transfer(_from, _to, _val);
return true;
}
//***************************** APPROVE TOKENS TO SEND *************************
function approve(address _spender, uint256 _val)
public returns (bool) {
require(holders[msg.sender] >= _val);
approach[msg.sender][_spender] = _val;
emit Approval(msg.sender, _spender, _val);
return true;
}
//***************************** CHECK APPROVE **********************************
function allowance(address _owner, address _spender)
public view returns (uint256) {
return approach[_owner][_spender];
}
//***************************** CONSTRUCTOR CONTRACT ***************************
constructor() public {
symbol = "DFCT";
name = "DefiCoin Token";
decimals = 18;
totalSupply = 21000000* 1000000000000000000;
holders[msg.sender] = totalSupply;
}
} | //***************************** CONTRACT *************************************** | LineComment | balanceOf | function balanceOf(address _own)
public view returns (uint256) {
return holders[_own];
}
| //***************************** CHECK BALANCE ********************************** | LineComment | v0.4.26+commit.4563c3fc | Apache-2.0 | bzzr://32382a95e4a922fc13a06c97a2b92083e8b84af26f2a7db0202a61ad586208d7 | {
"func_code_index": [
431,
523
]
} | 5,562 |
DefiCoinToken | DefiCoinToken.sol | 0xe932cae1a787e80c8626d01811005cdbbc30edcd | Solidity | DefiCoinToken | contract DefiCoinToken is ERC20 {
uint256 public totalSupply;
uint public decimals;
string public symbol;
string public name;
mapping (address => mapping (address => uint256)) approach;
mapping (address => uint256) holders;
//***************************** REVERT IF ETHEREUM SEND ************************
function () public {
revert();
}
//***************************** CHECK BALANCE **********************************
function balanceOf(address _own)
public view returns (uint256) {
return holders[_own];
}
//***************************** TRANSFER TOKENS FROM YOUR ACCOUNT **************
function transfer(address _to, uint256 _val)
public returns (bool) {
require(holders[msg.sender] >= _val);
require(msg.sender != _to);
assert(_val <= holders[msg.sender]);
holders[msg.sender] = holders[msg.sender] - _val;
holders[_to] = holders[_to] + _val;
assert(holders[_to] >= _val);
emit Transfer(msg.sender, _to, _val);
return true;
}
//**************************** TRANSFER TOKENS FROM ANOTHER ACCOUNT ************
function transferFrom(address _from, address _to, uint256 _val)
public returns (bool) {
require(holders[_from] >= _val);
require(approach[_from][msg.sender] >= _val);
assert(_val <= holders[_from]);
holders[_from] = holders[_from] - _val;
assert(_val <= approach[_from][msg.sender]);
approach[_from][msg.sender] = approach[_from][msg.sender] - _val;
holders[_to] = holders[_to] + _val;
assert(holders[_to] >= _val);
emit Transfer(_from, _to, _val);
return true;
}
//***************************** APPROVE TOKENS TO SEND *************************
function approve(address _spender, uint256 _val)
public returns (bool) {
require(holders[msg.sender] >= _val);
approach[msg.sender][_spender] = _val;
emit Approval(msg.sender, _spender, _val);
return true;
}
//***************************** CHECK APPROVE **********************************
function allowance(address _owner, address _spender)
public view returns (uint256) {
return approach[_owner][_spender];
}
//***************************** CONSTRUCTOR CONTRACT ***************************
constructor() public {
symbol = "DFCT";
name = "DefiCoin Token";
decimals = 18;
totalSupply = 21000000* 1000000000000000000;
holders[msg.sender] = totalSupply;
}
} | //***************************** CONTRACT *************************************** | LineComment | transfer | function transfer(address _to, uint256 _val)
public returns (bool) {
require(holders[msg.sender] >= _val);
require(msg.sender != _to);
assert(_val <= holders[msg.sender]);
holders[msg.sender] = holders[msg.sender] - _val;
holders[_to] = holders[_to] + _val;
assert(holders[_to] >= _val);
emit Transfer(msg.sender, _to, _val);
return true;
}
| //***************************** TRANSFER TOKENS FROM YOUR ACCOUNT ************** | LineComment | v0.4.26+commit.4563c3fc | Apache-2.0 | bzzr://32382a95e4a922fc13a06c97a2b92083e8b84af26f2a7db0202a61ad586208d7 | {
"func_code_index": [
606,
957
]
} | 5,563 |
DefiCoinToken | DefiCoinToken.sol | 0xe932cae1a787e80c8626d01811005cdbbc30edcd | Solidity | DefiCoinToken | contract DefiCoinToken is ERC20 {
uint256 public totalSupply;
uint public decimals;
string public symbol;
string public name;
mapping (address => mapping (address => uint256)) approach;
mapping (address => uint256) holders;
//***************************** REVERT IF ETHEREUM SEND ************************
function () public {
revert();
}
//***************************** CHECK BALANCE **********************************
function balanceOf(address _own)
public view returns (uint256) {
return holders[_own];
}
//***************************** TRANSFER TOKENS FROM YOUR ACCOUNT **************
function transfer(address _to, uint256 _val)
public returns (bool) {
require(holders[msg.sender] >= _val);
require(msg.sender != _to);
assert(_val <= holders[msg.sender]);
holders[msg.sender] = holders[msg.sender] - _val;
holders[_to] = holders[_to] + _val;
assert(holders[_to] >= _val);
emit Transfer(msg.sender, _to, _val);
return true;
}
//**************************** TRANSFER TOKENS FROM ANOTHER ACCOUNT ************
function transferFrom(address _from, address _to, uint256 _val)
public returns (bool) {
require(holders[_from] >= _val);
require(approach[_from][msg.sender] >= _val);
assert(_val <= holders[_from]);
holders[_from] = holders[_from] - _val;
assert(_val <= approach[_from][msg.sender]);
approach[_from][msg.sender] = approach[_from][msg.sender] - _val;
holders[_to] = holders[_to] + _val;
assert(holders[_to] >= _val);
emit Transfer(_from, _to, _val);
return true;
}
//***************************** APPROVE TOKENS TO SEND *************************
function approve(address _spender, uint256 _val)
public returns (bool) {
require(holders[msg.sender] >= _val);
approach[msg.sender][_spender] = _val;
emit Approval(msg.sender, _spender, _val);
return true;
}
//***************************** CHECK APPROVE **********************************
function allowance(address _owner, address _spender)
public view returns (uint256) {
return approach[_owner][_spender];
}
//***************************** CONSTRUCTOR CONTRACT ***************************
constructor() public {
symbol = "DFCT";
name = "DefiCoin Token";
decimals = 18;
totalSupply = 21000000* 1000000000000000000;
holders[msg.sender] = totalSupply;
}
} | //***************************** CONTRACT *************************************** | LineComment | transferFrom | function transferFrom(address _from, address _to, uint256 _val)
public returns (bool) {
require(holders[_from] >= _val);
require(approach[_from][msg.sender] >= _val);
assert(_val <= holders[_from]);
holders[_from] = holders[_from] - _val;
assert(_val <= approach[_from][msg.sender]);
approach[_from][msg.sender] = approach[_from][msg.sender] - _val;
holders[_to] = holders[_to] + _val;
assert(holders[_to] >= _val);
emit Transfer(_from, _to, _val);
return true;
}
| //**************************** TRANSFER TOKENS FROM ANOTHER ACCOUNT ************ | LineComment | v0.4.26+commit.4563c3fc | Apache-2.0 | bzzr://32382a95e4a922fc13a06c97a2b92083e8b84af26f2a7db0202a61ad586208d7 | {
"func_code_index": [
1040,
1516
]
} | 5,564 |
DefiCoinToken | DefiCoinToken.sol | 0xe932cae1a787e80c8626d01811005cdbbc30edcd | Solidity | DefiCoinToken | contract DefiCoinToken is ERC20 {
uint256 public totalSupply;
uint public decimals;
string public symbol;
string public name;
mapping (address => mapping (address => uint256)) approach;
mapping (address => uint256) holders;
//***************************** REVERT IF ETHEREUM SEND ************************
function () public {
revert();
}
//***************************** CHECK BALANCE **********************************
function balanceOf(address _own)
public view returns (uint256) {
return holders[_own];
}
//***************************** TRANSFER TOKENS FROM YOUR ACCOUNT **************
function transfer(address _to, uint256 _val)
public returns (bool) {
require(holders[msg.sender] >= _val);
require(msg.sender != _to);
assert(_val <= holders[msg.sender]);
holders[msg.sender] = holders[msg.sender] - _val;
holders[_to] = holders[_to] + _val;
assert(holders[_to] >= _val);
emit Transfer(msg.sender, _to, _val);
return true;
}
//**************************** TRANSFER TOKENS FROM ANOTHER ACCOUNT ************
function transferFrom(address _from, address _to, uint256 _val)
public returns (bool) {
require(holders[_from] >= _val);
require(approach[_from][msg.sender] >= _val);
assert(_val <= holders[_from]);
holders[_from] = holders[_from] - _val;
assert(_val <= approach[_from][msg.sender]);
approach[_from][msg.sender] = approach[_from][msg.sender] - _val;
holders[_to] = holders[_to] + _val;
assert(holders[_to] >= _val);
emit Transfer(_from, _to, _val);
return true;
}
//***************************** APPROVE TOKENS TO SEND *************************
function approve(address _spender, uint256 _val)
public returns (bool) {
require(holders[msg.sender] >= _val);
approach[msg.sender][_spender] = _val;
emit Approval(msg.sender, _spender, _val);
return true;
}
//***************************** CHECK APPROVE **********************************
function allowance(address _owner, address _spender)
public view returns (uint256) {
return approach[_owner][_spender];
}
//***************************** CONSTRUCTOR CONTRACT ***************************
constructor() public {
symbol = "DFCT";
name = "DefiCoin Token";
decimals = 18;
totalSupply = 21000000* 1000000000000000000;
holders[msg.sender] = totalSupply;
}
} | //***************************** CONTRACT *************************************** | LineComment | approve | function approve(address _spender, uint256 _val)
public returns (bool) {
require(holders[msg.sender] >= _val);
approach[msg.sender][_spender] = _val;
emit Approval(msg.sender, _spender, _val);
return true;
}
| //***************************** APPROVE TOKENS TO SEND ************************* | LineComment | v0.4.26+commit.4563c3fc | Apache-2.0 | bzzr://32382a95e4a922fc13a06c97a2b92083e8b84af26f2a7db0202a61ad586208d7 | {
"func_code_index": [
1599,
1813
]
} | 5,565 |
DefiCoinToken | DefiCoinToken.sol | 0xe932cae1a787e80c8626d01811005cdbbc30edcd | Solidity | DefiCoinToken | contract DefiCoinToken is ERC20 {
uint256 public totalSupply;
uint public decimals;
string public symbol;
string public name;
mapping (address => mapping (address => uint256)) approach;
mapping (address => uint256) holders;
//***************************** REVERT IF ETHEREUM SEND ************************
function () public {
revert();
}
//***************************** CHECK BALANCE **********************************
function balanceOf(address _own)
public view returns (uint256) {
return holders[_own];
}
//***************************** TRANSFER TOKENS FROM YOUR ACCOUNT **************
function transfer(address _to, uint256 _val)
public returns (bool) {
require(holders[msg.sender] >= _val);
require(msg.sender != _to);
assert(_val <= holders[msg.sender]);
holders[msg.sender] = holders[msg.sender] - _val;
holders[_to] = holders[_to] + _val;
assert(holders[_to] >= _val);
emit Transfer(msg.sender, _to, _val);
return true;
}
//**************************** TRANSFER TOKENS FROM ANOTHER ACCOUNT ************
function transferFrom(address _from, address _to, uint256 _val)
public returns (bool) {
require(holders[_from] >= _val);
require(approach[_from][msg.sender] >= _val);
assert(_val <= holders[_from]);
holders[_from] = holders[_from] - _val;
assert(_val <= approach[_from][msg.sender]);
approach[_from][msg.sender] = approach[_from][msg.sender] - _val;
holders[_to] = holders[_to] + _val;
assert(holders[_to] >= _val);
emit Transfer(_from, _to, _val);
return true;
}
//***************************** APPROVE TOKENS TO SEND *************************
function approve(address _spender, uint256 _val)
public returns (bool) {
require(holders[msg.sender] >= _val);
approach[msg.sender][_spender] = _val;
emit Approval(msg.sender, _spender, _val);
return true;
}
//***************************** CHECK APPROVE **********************************
function allowance(address _owner, address _spender)
public view returns (uint256) {
return approach[_owner][_spender];
}
//***************************** CONSTRUCTOR CONTRACT ***************************
constructor() public {
symbol = "DFCT";
name = "DefiCoin Token";
decimals = 18;
totalSupply = 21000000* 1000000000000000000;
holders[msg.sender] = totalSupply;
}
} | //***************************** CONTRACT *************************************** | LineComment | allowance | function allowance(address _owner, address _spender)
public view returns (uint256) {
return approach[_owner][_spender];
}
| //***************************** CHECK APPROVE ********************************** | LineComment | v0.4.26+commit.4563c3fc | Apache-2.0 | bzzr://32382a95e4a922fc13a06c97a2b92083e8b84af26f2a7db0202a61ad586208d7 | {
"func_code_index": [
1896,
2021
]
} | 5,566 |
Token | Token.sol | 0x00c85c226a7899ae3c87ad2e8684d352dc83f180 | Solidity | Token | contract Token {
/* Public variables of the token */
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
/* This creates an array with all balances */
mapping (address => uint256) public balanceOf;
/* This generates a public event on the blockchain that will notify clients */
event Transfer(address indexed from, address indexed to, uint256 value);
function Token() {
totalSupply = 1*(10**8)*(10**3);
balanceOf[msg.sender] = 1*(10**8)*(10**3); // Give the creator all initial tokens
name = "catcoin"; // Set the name for display purposes
symbol = "CAB"; // Set the symbol for display purposes
decimals = 3; // Amount of decimals for display purposes
}
function transfer(address _to, uint256 _value) {
/* Check if sender has balance and for overflows */
if (balanceOf[msg.sender] < _value || balanceOf[_to] + _value < balanceOf[_to])
revert();
/* Add and subtract new balances */
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
/* Notifiy anyone listening that this transfer took place */
Transfer(msg.sender, _to, _value);
}
/* This unnamed function is called whenever someone tries to send ether to it */
function () {
revert(); // Prevents accidental sending of ether
}
} | function () {
revert(); // Prevents accidental sending of ether
}
| /* This unnamed function is called whenever someone tries to send ether to it */ | Comment | v0.4.13+commit.fb4cb1a | bzzr://e59a5c0abb3696f699407f672571120209b7d2ff2612d98fda68372b64de45e9 | {
"func_code_index": [
1347,
1422
]
} | 5,567 |
||||
ChillyPenguins | @openzeppelin/contracts/access/Ownable.sol | 0x65054198daf01505d1896f08b04033931cb9a045 | Solidity | Ownable | abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
} | /**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/ | NatSpecMultiLine | owner | function owner() public view virtual returns (address) {
return _owner;
}
| /**
* @dev Returns the address of the current owner.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://4833852de9a972c267c596d37354757c75adae8b504aaaa813ec5b955eb570e5 | {
"func_code_index": [
399,
491
]
} | 5,568 |
ChillyPenguins | @openzeppelin/contracts/access/Ownable.sol | 0x65054198daf01505d1896f08b04033931cb9a045 | Solidity | Ownable | abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
} | /**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/ | NatSpecMultiLine | renounceOwnership | function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
| /**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://4833852de9a972c267c596d37354757c75adae8b504aaaa813ec5b955eb570e5 | {
"func_code_index": [
1050,
1149
]
} | 5,569 |
ChillyPenguins | @openzeppelin/contracts/access/Ownable.sol | 0x65054198daf01505d1896f08b04033931cb9a045 | Solidity | Ownable | abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
} | /**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/ | NatSpecMultiLine | transferOwnership | function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
| /**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://4833852de9a972c267c596d37354757c75adae8b504aaaa813ec5b955eb570e5 | {
"func_code_index": [
1299,
1496
]
} | 5,570 |
Genesis_Voting | Genesis_Voting.sol | 0x8eca4809d16dad560c0685ceeecc042f6ffbd3e4 | Solidity | Ownable | abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
} | /**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/ | NatSpecMultiLine | owner | function owner() public view virtual returns (address) {
return _owner;
}
| /**
* @dev Returns the address of the current owner.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | MIT | ipfs://02021a45cce72f6e544aadac6319150725f4f1b67eacf824ff0905ecd61f5e34 | {
"func_code_index": [
497,
589
]
} | 5,571 |
Genesis_Voting | Genesis_Voting.sol | 0x8eca4809d16dad560c0685ceeecc042f6ffbd3e4 | Solidity | Ownable | abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
} | /**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/ | NatSpecMultiLine | renounceOwnership | function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
| /**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | MIT | ipfs://02021a45cce72f6e544aadac6319150725f4f1b67eacf824ff0905ecd61f5e34 | {
"func_code_index": [
1148,
1301
]
} | 5,572 |
Genesis_Voting | Genesis_Voting.sol | 0x8eca4809d16dad560c0685ceeecc042f6ffbd3e4 | Solidity | Ownable | abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
} | /**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/ | NatSpecMultiLine | transferOwnership | function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
| /**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | MIT | ipfs://02021a45cce72f6e544aadac6319150725f4f1b67eacf824ff0905ecd61f5e34 | {
"func_code_index": [
1451,
1700
]
} | 5,573 |
Genesis_Voting | Genesis_Voting.sol | 0x8eca4809d16dad560c0685ceeecc042f6ffbd3e4 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | totalSupply | function totalSupply() external view returns (uint256);
| /**
* @dev Returns the amount of tokens in existence.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | MIT | ipfs://02021a45cce72f6e544aadac6319150725f4f1b67eacf824ff0905ecd61f5e34 | {
"func_code_index": [
94,
154
]
} | 5,574 |
Genesis_Voting | Genesis_Voting.sol | 0x8eca4809d16dad560c0685ceeecc042f6ffbd3e4 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | balanceOf | function balanceOf(address account) external view returns (uint256);
| /**
* @dev Returns the amount of tokens owned by `account`.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | MIT | ipfs://02021a45cce72f6e544aadac6319150725f4f1b67eacf824ff0905ecd61f5e34 | {
"func_code_index": [
237,
310
]
} | 5,575 |
Genesis_Voting | Genesis_Voting.sol | 0x8eca4809d16dad560c0685ceeecc042f6ffbd3e4 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | transfer | function transfer(address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | MIT | ipfs://02021a45cce72f6e544aadac6319150725f4f1b67eacf824ff0905ecd61f5e34 | {
"func_code_index": [
534,
616
]
} | 5,576 |
Genesis_Voting | Genesis_Voting.sol | 0x8eca4809d16dad560c0685ceeecc042f6ffbd3e4 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | allowance | function allowance(address owner, address spender) external view returns (uint256);
| /**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | MIT | ipfs://02021a45cce72f6e544aadac6319150725f4f1b67eacf824ff0905ecd61f5e34 | {
"func_code_index": [
895,
983
]
} | 5,577 |
Genesis_Voting | Genesis_Voting.sol | 0x8eca4809d16dad560c0685ceeecc042f6ffbd3e4 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | approve | function approve(address spender, uint256 amount) external returns (bool);
| /**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | MIT | ipfs://02021a45cce72f6e544aadac6319150725f4f1b67eacf824ff0905ecd61f5e34 | {
"func_code_index": [
1647,
1726
]
} | 5,578 |
Genesis_Voting | Genesis_Voting.sol | 0x8eca4809d16dad560c0685ceeecc042f6ffbd3e4 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | transferFrom | function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | MIT | ipfs://02021a45cce72f6e544aadac6319150725f4f1b67eacf824ff0905ecd61f5e34 | {
"func_code_index": [
2039,
2141
]
} | 5,579 |
TokenERC20 | TokenERC20.sol | 0xeac224ec129b203bd9067db6e3df1646fd4e640a | Solidity | TokenERC20 | contract TokenERC20 {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
// This generates a public event on the blockchain that will notify clients
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
/**
* Constrctor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor(
uint256 initialSupply,
string memory tokenName,
string memory tokenSymbol
) public {
totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount
balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != address(0x0));
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to] + _value > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from] + balanceOf[_to];
// Subtract from the sender
balanceOf[_from] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public returns (bool success) {
_transfer(msg.sender, _to, _value);
return true;
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` in behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes memory _extraData)
public
returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, address(this), _extraData);
return true;
}
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
balanceOf[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
balanceOf[_from] -= _value; // Subtract from the targeted balance
allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
emit Burn(_from, _value);
return true;
}
} | _transfer | function _transfer(address _from, address _to, uint _value) internal {
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != address(0x0));
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to] + _value > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from] + balanceOf[_to];
// Subtract from the sender
balanceOf[_from] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
| /**
* Internal transfer, only can be called by this contract
*/ | NatSpecMultiLine | v0.5.1+commit.c8a2cb62 | GNU GPLv3 | bzzr://5370cc40a45c16341193a25ef627624af393a02b53482ed8db4811018656360d | {
"func_code_index": [
1661,
2517
]
} | 5,580 |
||
TokenERC20 | TokenERC20.sol | 0xeac224ec129b203bd9067db6e3df1646fd4e640a | Solidity | TokenERC20 | contract TokenERC20 {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
// This generates a public event on the blockchain that will notify clients
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
/**
* Constrctor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor(
uint256 initialSupply,
string memory tokenName,
string memory tokenSymbol
) public {
totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount
balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != address(0x0));
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to] + _value > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from] + balanceOf[_to];
// Subtract from the sender
balanceOf[_from] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public returns (bool success) {
_transfer(msg.sender, _to, _value);
return true;
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` in behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes memory _extraData)
public
returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, address(this), _extraData);
return true;
}
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
balanceOf[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
balanceOf[_from] -= _value; // Subtract from the targeted balance
allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
emit Burn(_from, _value);
return true;
}
} | transfer | function transfer(address _to, uint256 _value) public returns (bool success) {
_transfer(msg.sender, _to, _value);
return true;
}
| /**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/ | NatSpecMultiLine | v0.5.1+commit.c8a2cb62 | GNU GPLv3 | bzzr://5370cc40a45c16341193a25ef627624af393a02b53482ed8db4811018656360d | {
"func_code_index": [
2723,
2880
]
} | 5,581 |
||
TokenERC20 | TokenERC20.sol | 0xeac224ec129b203bd9067db6e3df1646fd4e640a | Solidity | TokenERC20 | contract TokenERC20 {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
// This generates a public event on the blockchain that will notify clients
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
/**
* Constrctor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor(
uint256 initialSupply,
string memory tokenName,
string memory tokenSymbol
) public {
totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount
balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != address(0x0));
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to] + _value > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from] + balanceOf[_to];
// Subtract from the sender
balanceOf[_from] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public returns (bool success) {
_transfer(msg.sender, _to, _value);
return true;
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` in behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes memory _extraData)
public
returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, address(this), _extraData);
return true;
}
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
balanceOf[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
balanceOf[_from] -= _value; // Subtract from the targeted balance
allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
emit Burn(_from, _value);
return true;
}
} | transferFrom | function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
| /**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` in behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/ | NatSpecMultiLine | v0.5.1+commit.c8a2cb62 | GNU GPLv3 | bzzr://5370cc40a45c16341193a25ef627624af393a02b53482ed8db4811018656360d | {
"func_code_index": [
3155,
3456
]
} | 5,582 |
||
TokenERC20 | TokenERC20.sol | 0xeac224ec129b203bd9067db6e3df1646fd4e640a | Solidity | TokenERC20 | contract TokenERC20 {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
// This generates a public event on the blockchain that will notify clients
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
/**
* Constrctor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor(
uint256 initialSupply,
string memory tokenName,
string memory tokenSymbol
) public {
totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount
balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != address(0x0));
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to] + _value > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from] + balanceOf[_to];
// Subtract from the sender
balanceOf[_from] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public returns (bool success) {
_transfer(msg.sender, _to, _value);
return true;
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` in behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes memory _extraData)
public
returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, address(this), _extraData);
return true;
}
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
balanceOf[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
balanceOf[_from] -= _value; // Subtract from the targeted balance
allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
emit Burn(_from, _value);
return true;
}
} | approve | function approve(address _spender, uint256 _value) public
returns (bool success) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
| /**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/ | NatSpecMultiLine | v0.5.1+commit.c8a2cb62 | GNU GPLv3 | bzzr://5370cc40a45c16341193a25ef627624af393a02b53482ed8db4811018656360d | {
"func_code_index": [
3720,
3950
]
} | 5,583 |
||
TokenERC20 | TokenERC20.sol | 0xeac224ec129b203bd9067db6e3df1646fd4e640a | Solidity | TokenERC20 | contract TokenERC20 {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
// This generates a public event on the blockchain that will notify clients
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
/**
* Constrctor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor(
uint256 initialSupply,
string memory tokenName,
string memory tokenSymbol
) public {
totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount
balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != address(0x0));
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to] + _value > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from] + balanceOf[_to];
// Subtract from the sender
balanceOf[_from] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public returns (bool success) {
_transfer(msg.sender, _to, _value);
return true;
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` in behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes memory _extraData)
public
returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, address(this), _extraData);
return true;
}
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
balanceOf[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
balanceOf[_from] -= _value; // Subtract from the targeted balance
allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
emit Burn(_from, _value);
return true;
}
} | approveAndCall | function approveAndCall(address _spender, uint256 _value, bytes memory _extraData)
public
returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, address(this), _extraData);
return true;
}
}
| /**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/ | NatSpecMultiLine | v0.5.1+commit.c8a2cb62 | GNU GPLv3 | bzzr://5370cc40a45c16341193a25ef627624af393a02b53482ed8db4811018656360d | {
"func_code_index": [
4344,
4712
]
} | 5,584 |
||
TokenERC20 | TokenERC20.sol | 0xeac224ec129b203bd9067db6e3df1646fd4e640a | Solidity | TokenERC20 | contract TokenERC20 {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
// This generates a public event on the blockchain that will notify clients
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
/**
* Constrctor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor(
uint256 initialSupply,
string memory tokenName,
string memory tokenSymbol
) public {
totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount
balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != address(0x0));
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to] + _value > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from] + balanceOf[_to];
// Subtract from the sender
balanceOf[_from] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public returns (bool success) {
_transfer(msg.sender, _to, _value);
return true;
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` in behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes memory _extraData)
public
returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, address(this), _extraData);
return true;
}
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
balanceOf[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
balanceOf[_from] -= _value; // Subtract from the targeted balance
allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
emit Burn(_from, _value);
return true;
}
} | burn | function burn(uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
balanceOf[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
| /**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/ | NatSpecMultiLine | v0.5.1+commit.c8a2cb62 | GNU GPLv3 | bzzr://5370cc40a45c16341193a25ef627624af393a02b53482ed8db4811018656360d | {
"func_code_index": [
4882,
5261
]
} | 5,585 |
||
TokenERC20 | TokenERC20.sol | 0xeac224ec129b203bd9067db6e3df1646fd4e640a | Solidity | TokenERC20 | contract TokenERC20 {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
// This generates a public event on the blockchain that will notify clients
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
/**
* Constrctor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor(
uint256 initialSupply,
string memory tokenName,
string memory tokenSymbol
) public {
totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount
balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != address(0x0));
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to] + _value > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from] + balanceOf[_to];
// Subtract from the sender
balanceOf[_from] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public returns (bool success) {
_transfer(msg.sender, _to, _value);
return true;
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` in behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes memory _extraData)
public
returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, address(this), _extraData);
return true;
}
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
balanceOf[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
balanceOf[_from] -= _value; // Subtract from the targeted balance
allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
emit Burn(_from, _value);
return true;
}
} | burnFrom | function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
balanceOf[_from] -= _value; // Subtract from the targeted balance
allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
emit Burn(_from, _value);
return true;
}
| /**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/ | NatSpecMultiLine | v0.5.1+commit.c8a2cb62 | GNU GPLv3 | bzzr://5370cc40a45c16341193a25ef627624af393a02b53482ed8db4811018656360d | {
"func_code_index": [
5519,
6135
]
} | 5,586 |
||
TokenERC20 | TokenERC20.sol | 0xeac224ec129b203bd9067db6e3df1646fd4e640a | Solidity | MyAdvancedToken | contract MyAdvancedToken is owned, TokenERC20 {
uint256 public sellPrice;
uint256 public buyPrice;
mapping (address => bool) public frozenAccount;
/* This generates a public event on the blockchain that will notify clients */
event FrozenFunds(address target, bool frozen);
/* Initializes contract with initial supply tokens to the creator of the contract */
constructor(
uint256 initialSupply,
string memory tokenName,
string memory tokenSymbol
) TokenERC20(initialSupply, tokenName, tokenSymbol) public {}
/* Internal transfer, only can be called by this contract */
function _transfer(address _from, address _to, uint _value) internal {
require (_to != address(0x0)); // Prevent transfer to 0x0 address. Use burn() instead
require (balanceOf[_from] >= _value); // Check if the sender has enough
require (balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows
require(!frozenAccount[_from]); // Check if sender is frozen
require(!frozenAccount[_to]); // Check if recipient is frozen
balanceOf[_from] -= _value; // Subtract from the sender
balanceOf[_to] += _value; // Add the same to the recipient
emit Transfer(_from, _to, _value);
}
/// @notice Create `mintedAmount` tokens and send it to `target`
/// @param target Address to receive the tokens
/// @param mintedAmount the amount of tokens it will receive
function mintToken(address target, uint256 mintedAmount) onlyOwner public {
balanceOf[target] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(address(0), address(this), mintedAmount);
emit Transfer(address(this), target, mintedAmount);
}
/// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens
/// @param target Address to be frozen
/// @param freeze either to freeze it or not
function freezeAccount(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
/// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth
/// @param newSellPrice Price the users can sell to the contract
/// @param newBuyPrice Price users can buy from the contract
function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public {
sellPrice = newSellPrice;
buyPrice = newBuyPrice;
}
/// @notice Buy tokens from contract by sending ether
function buy() payable public {
uint amount = msg.value / buyPrice; // calculates the amount
_transfer(address(this), msg.sender, amount); // makes the transfers
}
/// @notice Sell `amount` tokens to contract
/// @param amount amount of tokens to be sold
function sell(uint256 amount) public {
address myAddress = address(this);
require(myAddress.balance >= amount * sellPrice); // checks if the contract has enough ether to buy
_transfer(msg.sender, address(this), amount); // makes the transfers
msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks
}
} | /******************************************/ | NatSpecMultiLine | _transfer | function _transfer(address _from, address _to, uint _value) internal {
require (_to != address(0x0)); // Prevent transfer to 0x0 address. Use burn() instead
require (balanceOf[_from] >= _value); // Check if the sender has enough
require (balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows
require(!frozenAccount[_from]); // Check if sender is frozen
require(!frozenAccount[_to]); // Check if recipient is frozen
balanceOf[_from] -= _value; // Subtract from the sender
balanceOf[_to] += _value; // Add the same to the recipient
emit Transfer(_from, _to, _value);
}
| /* Internal transfer, only can be called by this contract */ | Comment | v0.5.1+commit.c8a2cb62 | GNU GPLv3 | bzzr://5370cc40a45c16341193a25ef627624af393a02b53482ed8db4811018656360d | {
"func_code_index": [
652,
1467
]
} | 5,587 |
TokenERC20 | TokenERC20.sol | 0xeac224ec129b203bd9067db6e3df1646fd4e640a | Solidity | MyAdvancedToken | contract MyAdvancedToken is owned, TokenERC20 {
uint256 public sellPrice;
uint256 public buyPrice;
mapping (address => bool) public frozenAccount;
/* This generates a public event on the blockchain that will notify clients */
event FrozenFunds(address target, bool frozen);
/* Initializes contract with initial supply tokens to the creator of the contract */
constructor(
uint256 initialSupply,
string memory tokenName,
string memory tokenSymbol
) TokenERC20(initialSupply, tokenName, tokenSymbol) public {}
/* Internal transfer, only can be called by this contract */
function _transfer(address _from, address _to, uint _value) internal {
require (_to != address(0x0)); // Prevent transfer to 0x0 address. Use burn() instead
require (balanceOf[_from] >= _value); // Check if the sender has enough
require (balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows
require(!frozenAccount[_from]); // Check if sender is frozen
require(!frozenAccount[_to]); // Check if recipient is frozen
balanceOf[_from] -= _value; // Subtract from the sender
balanceOf[_to] += _value; // Add the same to the recipient
emit Transfer(_from, _to, _value);
}
/// @notice Create `mintedAmount` tokens and send it to `target`
/// @param target Address to receive the tokens
/// @param mintedAmount the amount of tokens it will receive
function mintToken(address target, uint256 mintedAmount) onlyOwner public {
balanceOf[target] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(address(0), address(this), mintedAmount);
emit Transfer(address(this), target, mintedAmount);
}
/// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens
/// @param target Address to be frozen
/// @param freeze either to freeze it or not
function freezeAccount(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
/// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth
/// @param newSellPrice Price the users can sell to the contract
/// @param newBuyPrice Price users can buy from the contract
function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public {
sellPrice = newSellPrice;
buyPrice = newBuyPrice;
}
/// @notice Buy tokens from contract by sending ether
function buy() payable public {
uint amount = msg.value / buyPrice; // calculates the amount
_transfer(address(this), msg.sender, amount); // makes the transfers
}
/// @notice Sell `amount` tokens to contract
/// @param amount amount of tokens to be sold
function sell(uint256 amount) public {
address myAddress = address(this);
require(myAddress.balance >= amount * sellPrice); // checks if the contract has enough ether to buy
_transfer(msg.sender, address(this), amount); // makes the transfers
msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks
}
} | /******************************************/ | NatSpecMultiLine | mintToken | function mintToken(address target, uint256 mintedAmount) onlyOwner public {
balanceOf[target] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(address(0), address(this), mintedAmount);
emit Transfer(address(this), target, mintedAmount);
}
| /// @notice Create `mintedAmount` tokens and send it to `target`
/// @param target Address to receive the tokens
/// @param mintedAmount the amount of tokens it will receive | NatSpecSingleLine | v0.5.1+commit.c8a2cb62 | GNU GPLv3 | bzzr://5370cc40a45c16341193a25ef627624af393a02b53482ed8db4811018656360d | {
"func_code_index": [
1659,
1954
]
} | 5,588 |
TokenERC20 | TokenERC20.sol | 0xeac224ec129b203bd9067db6e3df1646fd4e640a | Solidity | MyAdvancedToken | contract MyAdvancedToken is owned, TokenERC20 {
uint256 public sellPrice;
uint256 public buyPrice;
mapping (address => bool) public frozenAccount;
/* This generates a public event on the blockchain that will notify clients */
event FrozenFunds(address target, bool frozen);
/* Initializes contract with initial supply tokens to the creator of the contract */
constructor(
uint256 initialSupply,
string memory tokenName,
string memory tokenSymbol
) TokenERC20(initialSupply, tokenName, tokenSymbol) public {}
/* Internal transfer, only can be called by this contract */
function _transfer(address _from, address _to, uint _value) internal {
require (_to != address(0x0)); // Prevent transfer to 0x0 address. Use burn() instead
require (balanceOf[_from] >= _value); // Check if the sender has enough
require (balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows
require(!frozenAccount[_from]); // Check if sender is frozen
require(!frozenAccount[_to]); // Check if recipient is frozen
balanceOf[_from] -= _value; // Subtract from the sender
balanceOf[_to] += _value; // Add the same to the recipient
emit Transfer(_from, _to, _value);
}
/// @notice Create `mintedAmount` tokens and send it to `target`
/// @param target Address to receive the tokens
/// @param mintedAmount the amount of tokens it will receive
function mintToken(address target, uint256 mintedAmount) onlyOwner public {
balanceOf[target] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(address(0), address(this), mintedAmount);
emit Transfer(address(this), target, mintedAmount);
}
/// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens
/// @param target Address to be frozen
/// @param freeze either to freeze it or not
function freezeAccount(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
/// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth
/// @param newSellPrice Price the users can sell to the contract
/// @param newBuyPrice Price users can buy from the contract
function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public {
sellPrice = newSellPrice;
buyPrice = newBuyPrice;
}
/// @notice Buy tokens from contract by sending ether
function buy() payable public {
uint amount = msg.value / buyPrice; // calculates the amount
_transfer(address(this), msg.sender, amount); // makes the transfers
}
/// @notice Sell `amount` tokens to contract
/// @param amount amount of tokens to be sold
function sell(uint256 amount) public {
address myAddress = address(this);
require(myAddress.balance >= amount * sellPrice); // checks if the contract has enough ether to buy
_transfer(msg.sender, address(this), amount); // makes the transfers
msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks
}
} | /******************************************/ | NatSpecMultiLine | freezeAccount | function freezeAccount(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
| /// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens
/// @param target Address to be frozen
/// @param freeze either to freeze it or not | NatSpecSingleLine | v0.5.1+commit.c8a2cb62 | GNU GPLv3 | bzzr://5370cc40a45c16341193a25ef627624af393a02b53482ed8db4811018656360d | {
"func_code_index": [
2135,
2301
]
} | 5,589 |
TokenERC20 | TokenERC20.sol | 0xeac224ec129b203bd9067db6e3df1646fd4e640a | Solidity | MyAdvancedToken | contract MyAdvancedToken is owned, TokenERC20 {
uint256 public sellPrice;
uint256 public buyPrice;
mapping (address => bool) public frozenAccount;
/* This generates a public event on the blockchain that will notify clients */
event FrozenFunds(address target, bool frozen);
/* Initializes contract with initial supply tokens to the creator of the contract */
constructor(
uint256 initialSupply,
string memory tokenName,
string memory tokenSymbol
) TokenERC20(initialSupply, tokenName, tokenSymbol) public {}
/* Internal transfer, only can be called by this contract */
function _transfer(address _from, address _to, uint _value) internal {
require (_to != address(0x0)); // Prevent transfer to 0x0 address. Use burn() instead
require (balanceOf[_from] >= _value); // Check if the sender has enough
require (balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows
require(!frozenAccount[_from]); // Check if sender is frozen
require(!frozenAccount[_to]); // Check if recipient is frozen
balanceOf[_from] -= _value; // Subtract from the sender
balanceOf[_to] += _value; // Add the same to the recipient
emit Transfer(_from, _to, _value);
}
/// @notice Create `mintedAmount` tokens and send it to `target`
/// @param target Address to receive the tokens
/// @param mintedAmount the amount of tokens it will receive
function mintToken(address target, uint256 mintedAmount) onlyOwner public {
balanceOf[target] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(address(0), address(this), mintedAmount);
emit Transfer(address(this), target, mintedAmount);
}
/// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens
/// @param target Address to be frozen
/// @param freeze either to freeze it or not
function freezeAccount(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
/// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth
/// @param newSellPrice Price the users can sell to the contract
/// @param newBuyPrice Price users can buy from the contract
function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public {
sellPrice = newSellPrice;
buyPrice = newBuyPrice;
}
/// @notice Buy tokens from contract by sending ether
function buy() payable public {
uint amount = msg.value / buyPrice; // calculates the amount
_transfer(address(this), msg.sender, amount); // makes the transfers
}
/// @notice Sell `amount` tokens to contract
/// @param amount amount of tokens to be sold
function sell(uint256 amount) public {
address myAddress = address(this);
require(myAddress.balance >= amount * sellPrice); // checks if the contract has enough ether to buy
_transfer(msg.sender, address(this), amount); // makes the transfers
msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks
}
} | /******************************************/ | NatSpecMultiLine | setPrices | function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public {
sellPrice = newSellPrice;
buyPrice = newBuyPrice;
}
| /// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth
/// @param newSellPrice Price the users can sell to the contract
/// @param newBuyPrice Price users can buy from the contract | NatSpecSingleLine | v0.5.1+commit.c8a2cb62 | GNU GPLv3 | bzzr://5370cc40a45c16341193a25ef627624af393a02b53482ed8db4811018656360d | {
"func_code_index": [
2544,
2704
]
} | 5,590 |
TokenERC20 | TokenERC20.sol | 0xeac224ec129b203bd9067db6e3df1646fd4e640a | Solidity | MyAdvancedToken | contract MyAdvancedToken is owned, TokenERC20 {
uint256 public sellPrice;
uint256 public buyPrice;
mapping (address => bool) public frozenAccount;
/* This generates a public event on the blockchain that will notify clients */
event FrozenFunds(address target, bool frozen);
/* Initializes contract with initial supply tokens to the creator of the contract */
constructor(
uint256 initialSupply,
string memory tokenName,
string memory tokenSymbol
) TokenERC20(initialSupply, tokenName, tokenSymbol) public {}
/* Internal transfer, only can be called by this contract */
function _transfer(address _from, address _to, uint _value) internal {
require (_to != address(0x0)); // Prevent transfer to 0x0 address. Use burn() instead
require (balanceOf[_from] >= _value); // Check if the sender has enough
require (balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows
require(!frozenAccount[_from]); // Check if sender is frozen
require(!frozenAccount[_to]); // Check if recipient is frozen
balanceOf[_from] -= _value; // Subtract from the sender
balanceOf[_to] += _value; // Add the same to the recipient
emit Transfer(_from, _to, _value);
}
/// @notice Create `mintedAmount` tokens and send it to `target`
/// @param target Address to receive the tokens
/// @param mintedAmount the amount of tokens it will receive
function mintToken(address target, uint256 mintedAmount) onlyOwner public {
balanceOf[target] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(address(0), address(this), mintedAmount);
emit Transfer(address(this), target, mintedAmount);
}
/// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens
/// @param target Address to be frozen
/// @param freeze either to freeze it or not
function freezeAccount(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
/// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth
/// @param newSellPrice Price the users can sell to the contract
/// @param newBuyPrice Price users can buy from the contract
function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public {
sellPrice = newSellPrice;
buyPrice = newBuyPrice;
}
/// @notice Buy tokens from contract by sending ether
function buy() payable public {
uint amount = msg.value / buyPrice; // calculates the amount
_transfer(address(this), msg.sender, amount); // makes the transfers
}
/// @notice Sell `amount` tokens to contract
/// @param amount amount of tokens to be sold
function sell(uint256 amount) public {
address myAddress = address(this);
require(myAddress.balance >= amount * sellPrice); // checks if the contract has enough ether to buy
_transfer(msg.sender, address(this), amount); // makes the transfers
msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks
}
} | /******************************************/ | NatSpecMultiLine | buy | function buy() payable public {
uint amount = msg.value / buyPrice; // calculates the amount
_transfer(address(this), msg.sender, amount); // makes the transfers
}
| /// @notice Buy tokens from contract by sending ether | NatSpecSingleLine | v0.5.1+commit.c8a2cb62 | GNU GPLv3 | bzzr://5370cc40a45c16341193a25ef627624af393a02b53482ed8db4811018656360d | {
"func_code_index": [
2766,
2979
]
} | 5,591 |
TokenERC20 | TokenERC20.sol | 0xeac224ec129b203bd9067db6e3df1646fd4e640a | Solidity | MyAdvancedToken | contract MyAdvancedToken is owned, TokenERC20 {
uint256 public sellPrice;
uint256 public buyPrice;
mapping (address => bool) public frozenAccount;
/* This generates a public event on the blockchain that will notify clients */
event FrozenFunds(address target, bool frozen);
/* Initializes contract with initial supply tokens to the creator of the contract */
constructor(
uint256 initialSupply,
string memory tokenName,
string memory tokenSymbol
) TokenERC20(initialSupply, tokenName, tokenSymbol) public {}
/* Internal transfer, only can be called by this contract */
function _transfer(address _from, address _to, uint _value) internal {
require (_to != address(0x0)); // Prevent transfer to 0x0 address. Use burn() instead
require (balanceOf[_from] >= _value); // Check if the sender has enough
require (balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows
require(!frozenAccount[_from]); // Check if sender is frozen
require(!frozenAccount[_to]); // Check if recipient is frozen
balanceOf[_from] -= _value; // Subtract from the sender
balanceOf[_to] += _value; // Add the same to the recipient
emit Transfer(_from, _to, _value);
}
/// @notice Create `mintedAmount` tokens and send it to `target`
/// @param target Address to receive the tokens
/// @param mintedAmount the amount of tokens it will receive
function mintToken(address target, uint256 mintedAmount) onlyOwner public {
balanceOf[target] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(address(0), address(this), mintedAmount);
emit Transfer(address(this), target, mintedAmount);
}
/// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens
/// @param target Address to be frozen
/// @param freeze either to freeze it or not
function freezeAccount(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
/// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth
/// @param newSellPrice Price the users can sell to the contract
/// @param newBuyPrice Price users can buy from the contract
function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public {
sellPrice = newSellPrice;
buyPrice = newBuyPrice;
}
/// @notice Buy tokens from contract by sending ether
function buy() payable public {
uint amount = msg.value / buyPrice; // calculates the amount
_transfer(address(this), msg.sender, amount); // makes the transfers
}
/// @notice Sell `amount` tokens to contract
/// @param amount amount of tokens to be sold
function sell(uint256 amount) public {
address myAddress = address(this);
require(myAddress.balance >= amount * sellPrice); // checks if the contract has enough ether to buy
_transfer(msg.sender, address(this), amount); // makes the transfers
msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks
}
} | /******************************************/ | NatSpecMultiLine | sell | function sell(uint256 amount) public {
address myAddress = address(this);
require(myAddress.balance >= amount * sellPrice); // checks if the contract has enough ether to buy
_transfer(msg.sender, address(this), amount); // makes the transfers
msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks
}
| /// @notice Sell `amount` tokens to contract
/// @param amount amount of tokens to be sold | NatSpecSingleLine | v0.5.1+commit.c8a2cb62 | GNU GPLv3 | bzzr://5370cc40a45c16341193a25ef627624af393a02b53482ed8db4811018656360d | {
"func_code_index": [
3083,
3521
]
} | 5,592 |
FlashLiquidator | @uniswap/v3-periphery/contracts/interfaces/IPeripheryImmutableState.sol | 0x23d85060f87218bb276afe55a26bfd3b5f59914e | Solidity | IPeripheryImmutableState | interface IPeripheryImmutableState {
/// @return Returns the address of the Uniswap V3 factory
function factory() external view returns (address);
/// @return Returns the address of WETH9
function WETH9() external view returns (address);
} | /// @title Immutable state
/// @notice Functions that return immutable state of the router | NatSpecSingleLine | factory | function factory() external view returns (address);
| /// @return Returns the address of the Uniswap V3 factory | NatSpecSingleLine | v0.8.6+commit.11564f7e | {
"func_code_index": [
99,
154
]
} | 5,593 |
||
FlashLiquidator | @uniswap/v3-periphery/contracts/interfaces/IPeripheryImmutableState.sol | 0x23d85060f87218bb276afe55a26bfd3b5f59914e | Solidity | IPeripheryImmutableState | interface IPeripheryImmutableState {
/// @return Returns the address of the Uniswap V3 factory
function factory() external view returns (address);
/// @return Returns the address of WETH9
function WETH9() external view returns (address);
} | /// @title Immutable state
/// @notice Functions that return immutable state of the router | NatSpecSingleLine | WETH9 | function WETH9() external view returns (address);
| /// @return Returns the address of WETH9 | NatSpecSingleLine | v0.8.6+commit.11564f7e | {
"func_code_index": [
201,
254
]
} | 5,594 |
||
FlashLiquidator | @yield-protocol/vault-interfaces/IWitch.sol | 0x23d85060f87218bb276afe55a26bfd3b5f59914e | Solidity | IWitch | interface IWitch {
/// @dev Link to the Cauldron in the Yield Protocol
function cauldron() external returns (ICauldron);
/// @dev Link to the Ladle in the Yield Protocol
function ladle() external returns (ILadle);
/// @dev Vaults up for liquidation
function auctions(bytes12 vaultId) external returns (address owner, uint32 start);
/// @dev Auction parameters per ilk
function ilks(bytes6 ilkId) external returns (uint32 duration, uint64 initialOffer);
/// @dev Pay all debt from a vault in liquidation, getting at least `min` collateral.
function payAll(bytes12 vaultId, uint128 min) external returns (uint256 ink);
} | cauldron | function cauldron() external returns (ICauldron);
| /// @dev Link to the Cauldron in the Yield Protocol | NatSpecSingleLine | v0.8.6+commit.11564f7e | {
"func_code_index": [
75,
128
]
} | 5,595 |
||||
FlashLiquidator | @yield-protocol/vault-interfaces/IWitch.sol | 0x23d85060f87218bb276afe55a26bfd3b5f59914e | Solidity | IWitch | interface IWitch {
/// @dev Link to the Cauldron in the Yield Protocol
function cauldron() external returns (ICauldron);
/// @dev Link to the Ladle in the Yield Protocol
function ladle() external returns (ILadle);
/// @dev Vaults up for liquidation
function auctions(bytes12 vaultId) external returns (address owner, uint32 start);
/// @dev Auction parameters per ilk
function ilks(bytes6 ilkId) external returns (uint32 duration, uint64 initialOffer);
/// @dev Pay all debt from a vault in liquidation, getting at least `min` collateral.
function payAll(bytes12 vaultId, uint128 min) external returns (uint256 ink);
} | ladle | function ladle() external returns (ILadle);
| /// @dev Link to the Ladle in the Yield Protocol | NatSpecSingleLine | v0.8.6+commit.11564f7e | {
"func_code_index": [
183,
230
]
} | 5,596 |
||||
FlashLiquidator | @yield-protocol/vault-interfaces/IWitch.sol | 0x23d85060f87218bb276afe55a26bfd3b5f59914e | Solidity | IWitch | interface IWitch {
/// @dev Link to the Cauldron in the Yield Protocol
function cauldron() external returns (ICauldron);
/// @dev Link to the Ladle in the Yield Protocol
function ladle() external returns (ILadle);
/// @dev Vaults up for liquidation
function auctions(bytes12 vaultId) external returns (address owner, uint32 start);
/// @dev Auction parameters per ilk
function ilks(bytes6 ilkId) external returns (uint32 duration, uint64 initialOffer);
/// @dev Pay all debt from a vault in liquidation, getting at least `min` collateral.
function payAll(bytes12 vaultId, uint128 min) external returns (uint256 ink);
} | auctions | function auctions(bytes12 vaultId) external returns (address owner, uint32 start);
| /// @dev Vaults up for liquidation | NatSpecSingleLine | v0.8.6+commit.11564f7e | {
"func_code_index": [
271,
357
]
} | 5,597 |
||||
FlashLiquidator | @yield-protocol/vault-interfaces/IWitch.sol | 0x23d85060f87218bb276afe55a26bfd3b5f59914e | Solidity | IWitch | interface IWitch {
/// @dev Link to the Cauldron in the Yield Protocol
function cauldron() external returns (ICauldron);
/// @dev Link to the Ladle in the Yield Protocol
function ladle() external returns (ILadle);
/// @dev Vaults up for liquidation
function auctions(bytes12 vaultId) external returns (address owner, uint32 start);
/// @dev Auction parameters per ilk
function ilks(bytes6 ilkId) external returns (uint32 duration, uint64 initialOffer);
/// @dev Pay all debt from a vault in liquidation, getting at least `min` collateral.
function payAll(bytes12 vaultId, uint128 min) external returns (uint256 ink);
} | ilks | function ilks(bytes6 ilkId) external returns (uint32 duration, uint64 initialOffer);
| /// @dev Auction parameters per ilk | NatSpecSingleLine | v0.8.6+commit.11564f7e | {
"func_code_index": [
399,
487
]
} | 5,598 |
||||
FlashLiquidator | @yield-protocol/vault-interfaces/IWitch.sol | 0x23d85060f87218bb276afe55a26bfd3b5f59914e | Solidity | IWitch | interface IWitch {
/// @dev Link to the Cauldron in the Yield Protocol
function cauldron() external returns (ICauldron);
/// @dev Link to the Ladle in the Yield Protocol
function ladle() external returns (ILadle);
/// @dev Vaults up for liquidation
function auctions(bytes12 vaultId) external returns (address owner, uint32 start);
/// @dev Auction parameters per ilk
function ilks(bytes6 ilkId) external returns (uint32 duration, uint64 initialOffer);
/// @dev Pay all debt from a vault in liquidation, getting at least `min` collateral.
function payAll(bytes12 vaultId, uint128 min) external returns (uint256 ink);
} | payAll | function payAll(bytes12 vaultId, uint128 min) external returns (uint256 ink);
| /// @dev Pay all debt from a vault in liquidation, getting at least `min` collateral. | NatSpecSingleLine | v0.8.6+commit.11564f7e | {
"func_code_index": [
579,
660
]
} | 5,599 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.