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
CriptaliaRewards
CriptaliaRewards.sol
0x2c821a3ce3b5c0a471862eb63a2ef99a4d285d43
Solidity
CriptaliaRewards
contract CriptaliaRewards 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 // ------------------------------------------------------------------------ function CriptaliaRewards() public { symbol = "CRIPTRE"; name = "CRIPTALIA REWARDS"; decimals = 18; _totalSupply = 100000000000000000000000000; balances[msg.sender] = _totalSupply; Transfer(address(0), msg.sender, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); 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; 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); 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; 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.19+commit.c4cbbb05
bzzr://8aa82eb5fe2ca991432d5ab5fda049a82fadf2c17c6a727dbc5bb442ea49e4de
{ "func_code_index": [ 4944, 5003 ] }
1,207
CriptaliaRewards
CriptaliaRewards.sol
0x2c821a3ce3b5c0a471862eb63a2ef99a4d285d43
Solidity
CriptaliaRewards
contract CriptaliaRewards 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 // ------------------------------------------------------------------------ function CriptaliaRewards() public { symbol = "CRIPTRE"; name = "CRIPTALIA REWARDS"; decimals = 18; _totalSupply = 100000000000000000000000000; balances[msg.sender] = _totalSupply; Transfer(address(0), msg.sender, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); 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; 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); 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; 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.19+commit.c4cbbb05
bzzr://8aa82eb5fe2ca991432d5ab5fda049a82fadf2c17c6a727dbc5bb442ea49e4de
{ "func_code_index": [ 5236, 5425 ] }
1,208
KREEP
KREEP.sol
0xbd9c92490b7e9444951fe86af90b6e54ab95cb16
Solidity
IERC20
interface IERC20 { 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); }
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://39a71624c52ee018a303c30d9b86c3b7498d4c8dc13424b42bbf95fb353b3cea
{ "func_code_index": [ 165, 238 ] }
1,209
KREEP
KREEP.sol
0xbd9c92490b7e9444951fe86af90b6e54ab95cb16
Solidity
IERC20
interface IERC20 { 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); }
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://39a71624c52ee018a303c30d9b86c3b7498d4c8dc13424b42bbf95fb353b3cea
{ "func_code_index": [ 462, 544 ] }
1,210
KREEP
KREEP.sol
0xbd9c92490b7e9444951fe86af90b6e54ab95cb16
Solidity
IERC20
interface IERC20 { 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); }
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://39a71624c52ee018a303c30d9b86c3b7498d4c8dc13424b42bbf95fb353b3cea
{ "func_code_index": [ 823, 911 ] }
1,211
KREEP
KREEP.sol
0xbd9c92490b7e9444951fe86af90b6e54ab95cb16
Solidity
IERC20
interface IERC20 { 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); }
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://39a71624c52ee018a303c30d9b86c3b7498d4c8dc13424b42bbf95fb353b3cea
{ "func_code_index": [ 1575, 1654 ] }
1,212
KREEP
KREEP.sol
0xbd9c92490b7e9444951fe86af90b6e54ab95cb16
Solidity
IERC20
interface IERC20 { 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); }
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://39a71624c52ee018a303c30d9b86c3b7498d4c8dc13424b42bbf95fb353b3cea
{ "func_code_index": [ 1967, 2069 ] }
1,213
KREEP
KREEP.sol
0xbd9c92490b7e9444951fe86af90b6e54ab95cb16
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
/** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */
NatSpecMultiLine
add
function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; }
/** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://39a71624c52ee018a303c30d9b86c3b7498d4c8dc13424b42bbf95fb353b3cea
{ "func_code_index": [ 259, 445 ] }
1,214
KREEP
KREEP.sol
0xbd9c92490b7e9444951fe86af90b6e54ab95cb16
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
/** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */
NatSpecMultiLine
sub
function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); }
/** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://39a71624c52ee018a303c30d9b86c3b7498d4c8dc13424b42bbf95fb353b3cea
{ "func_code_index": [ 723, 864 ] }
1,215
KREEP
KREEP.sol
0xbd9c92490b7e9444951fe86af90b6e54ab95cb16
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
/** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */
NatSpecMultiLine
sub
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; }
/** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://39a71624c52ee018a303c30d9b86c3b7498d4c8dc13424b42bbf95fb353b3cea
{ "func_code_index": [ 1162, 1359 ] }
1,216
KREEP
KREEP.sol
0xbd9c92490b7e9444951fe86af90b6e54ab95cb16
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
/** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */
NatSpecMultiLine
mul
function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; }
/** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://39a71624c52ee018a303c30d9b86c3b7498d4c8dc13424b42bbf95fb353b3cea
{ "func_code_index": [ 1613, 2089 ] }
1,217
KREEP
KREEP.sol
0xbd9c92490b7e9444951fe86af90b6e54ab95cb16
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
/** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */
NatSpecMultiLine
div
function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); }
/** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://39a71624c52ee018a303c30d9b86c3b7498d4c8dc13424b42bbf95fb353b3cea
{ "func_code_index": [ 2560, 2697 ] }
1,218
KREEP
KREEP.sol
0xbd9c92490b7e9444951fe86af90b6e54ab95cb16
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
/** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */
NatSpecMultiLine
div
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; }
/** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://39a71624c52ee018a303c30d9b86c3b7498d4c8dc13424b42bbf95fb353b3cea
{ "func_code_index": [ 3188, 3471 ] }
1,219
KREEP
KREEP.sol
0xbd9c92490b7e9444951fe86af90b6e54ab95cb16
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
/** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */
NatSpecMultiLine
mod
function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); }
/** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://39a71624c52ee018a303c30d9b86c3b7498d4c8dc13424b42bbf95fb353b3cea
{ "func_code_index": [ 3931, 4066 ] }
1,220
KREEP
KREEP.sol
0xbd9c92490b7e9444951fe86af90b6e54ab95cb16
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
/** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */
NatSpecMultiLine
mod
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; }
/** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://39a71624c52ee018a303c30d9b86c3b7498d4c8dc13424b42bbf95fb353b3cea
{ "func_code_index": [ 4546, 4717 ] }
1,221
KREEP
KREEP.sol
0xbd9c92490b7e9444951fe86af90b6e54ab95cb16
Solidity
Address
library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
isContract
function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); }
/** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://39a71624c52ee018a303c30d9b86c3b7498d4c8dc13424b42bbf95fb353b3cea
{ "func_code_index": [ 606, 1230 ] }
1,222
KREEP
KREEP.sol
0xbd9c92490b7e9444951fe86af90b6e54ab95cb16
Solidity
Address
library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
sendValue
function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); }
/** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://39a71624c52ee018a303c30d9b86c3b7498d4c8dc13424b42bbf95fb353b3cea
{ "func_code_index": [ 2160, 2562 ] }
1,223
KREEP
KREEP.sol
0xbd9c92490b7e9444951fe86af90b6e54ab95cb16
Solidity
Address
library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionCall
function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); }
/** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://39a71624c52ee018a303c30d9b86c3b7498d4c8dc13424b42bbf95fb353b3cea
{ "func_code_index": [ 3318, 3496 ] }
1,224
KREEP
KREEP.sol
0xbd9c92490b7e9444951fe86af90b6e54ab95cb16
Solidity
Address
library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionCall
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); }
/** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://39a71624c52ee018a303c30d9b86c3b7498d4c8dc13424b42bbf95fb353b3cea
{ "func_code_index": [ 3721, 3922 ] }
1,225
KREEP
KREEP.sol
0xbd9c92490b7e9444951fe86af90b6e54ab95cb16
Solidity
Address
library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionCallWithValue
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); }
/** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://39a71624c52ee018a303c30d9b86c3b7498d4c8dc13424b42bbf95fb353b3cea
{ "func_code_index": [ 4292, 4523 ] }
1,226
KREEP
KREEP.sol
0xbd9c92490b7e9444951fe86af90b6e54ab95cb16
Solidity
Address
library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionCallWithValue
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); }
/** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://39a71624c52ee018a303c30d9b86c3b7498d4c8dc13424b42bbf95fb353b3cea
{ "func_code_index": [ 4774, 5095 ] }
1,227
KREEP
KREEP.sol
0xbd9c92490b7e9444951fe86af90b6e54ab95cb16
Solidity
Ownable
contract Ownable is Context { address private _owner; address private _previousOwner; uint256 private _lockTime; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = now + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(now > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } }
/** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */
NatSpecMultiLine
owner
function owner() public view returns (address) { return _owner; }
/** * @dev Returns the address of the current owner. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://39a71624c52ee018a303c30d9b86c3b7498d4c8dc13424b42bbf95fb353b3cea
{ "func_code_index": [ 566, 650 ] }
1,228
KREEP
KREEP.sol
0xbd9c92490b7e9444951fe86af90b6e54ab95cb16
Solidity
Ownable
contract Ownable is Context { address private _owner; address private _previousOwner; uint256 private _lockTime; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = now + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(now > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } }
/** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */
NatSpecMultiLine
renounceOwnership
function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); }
/** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://39a71624c52ee018a303c30d9b86c3b7498d4c8dc13424b42bbf95fb353b3cea
{ "func_code_index": [ 1209, 1362 ] }
1,229
KREEP
KREEP.sol
0xbd9c92490b7e9444951fe86af90b6e54ab95cb16
Solidity
Ownable
contract Ownable is Context { address private _owner; address private _previousOwner; uint256 private _lockTime; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = now + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(now > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } }
/** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */
NatSpecMultiLine
transferOwnership
function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; }
/** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://39a71624c52ee018a303c30d9b86c3b7498d4c8dc13424b42bbf95fb353b3cea
{ "func_code_index": [ 1512, 1761 ] }
1,230
KREEP
KREEP.sol
0xbd9c92490b7e9444951fe86af90b6e54ab95cb16
Solidity
Ownable
contract Ownable is Context { address private _owner; address private _previousOwner; uint256 private _lockTime; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = now + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(now > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } }
/** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */
NatSpecMultiLine
lock
function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = now + time; emit OwnershipTransferred(_owner, address(0)); }
//Locks the contract for owner for the amount of time provided
LineComment
v0.6.12+commit.27d51765
None
ipfs://39a71624c52ee018a303c30d9b86c3b7498d4c8dc13424b42bbf95fb353b3cea
{ "func_code_index": [ 1929, 2148 ] }
1,231
KREEP
KREEP.sol
0xbd9c92490b7e9444951fe86af90b6e54ab95cb16
Solidity
Ownable
contract Ownable is Context { address private _owner; address private _previousOwner; uint256 private _lockTime; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = now + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(now > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } }
/** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */
NatSpecMultiLine
unlock
function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(now > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; }
//Unlocks the contract for owner when _lockTime is exceeds
LineComment
v0.6.12+commit.27d51765
None
ipfs://39a71624c52ee018a303c30d9b86c3b7498d4c8dc13424b42bbf95fb353b3cea
{ "func_code_index": [ 2219, 2517 ] }
1,232
KREEP
KREEP.sol
0xbd9c92490b7e9444951fe86af90b6e54ab95cb16
Solidity
KREEP
contract KREEP is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 100000000000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "KREEP | t.me/creepHODL"; string private _symbol = "KREEP \xF0\x9F\x92\x8E"; uint8 private _decimals = 9; uint256 public _taxFee = 2; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 2; uint256 private _previousLiquidityFee = _liquidityFee; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxTxAmount = 500000000 * 10**6 * 10**9; uint256 private numTokensSellToAddToLiquidity = 50000000 * 10**6 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () public { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setTaxFeePercent(uint256 taxFee) external onlyOwner() { _taxFee = taxFee; } function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() { _liquidityFee = liquidityFee; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**2 ); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { 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); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { contractTokenBalance = numTokensSellToAddToLiquidity; //add liquidity swapAndLiquify(contractTokenBalance); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from,to,amount,takeFee); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { // split the contract balance into halves uint256 half = contractTokenBalance.div(2); uint256 otherHalf = contractTokenBalance.sub(half); // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); // add liquidity to uniswap addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } }
//to recieve ETH from uniswapV2Router when swaping
LineComment
v0.6.12+commit.27d51765
None
ipfs://39a71624c52ee018a303c30d9b86c3b7498d4c8dc13424b42bbf95fb353b3cea
{ "func_code_index": [ 8141, 8175 ] }
1,233
KREEP
KREEP.sol
0xbd9c92490b7e9444951fe86af90b6e54ab95cb16
Solidity
KREEP
contract KREEP is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 100000000000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "KREEP | t.me/creepHODL"; string private _symbol = "KREEP \xF0\x9F\x92\x8E"; uint8 private _decimals = 9; uint256 public _taxFee = 2; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 2; uint256 private _previousLiquidityFee = _liquidityFee; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxTxAmount = 500000000 * 10**6 * 10**9; uint256 private numTokensSellToAddToLiquidity = 50000000 * 10**6 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () public { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setTaxFeePercent(uint256 taxFee) external onlyOwner() { _taxFee = taxFee; } function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() { _liquidityFee = liquidityFee; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**2 ); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { 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); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { contractTokenBalance = numTokensSellToAddToLiquidity; //add liquidity swapAndLiquify(contractTokenBalance); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from,to,amount,takeFee); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { // split the contract balance into halves uint256 half = contractTokenBalance.div(2); uint256 otherHalf = contractTokenBalance.sub(half); // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); // add liquidity to uniswap addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } }
_tokenTransfer
function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); }
//this method is responsible for taking all fee, if takeFee is true
LineComment
v0.6.12+commit.27d51765
None
ipfs://39a71624c52ee018a303c30d9b86c3b7498d4c8dc13424b42bbf95fb353b3cea
{ "func_code_index": [ 15866, 16705 ] }
1,234
UniV3LiquidityAMO
contracts/Uniswap_V3/periphery/libraries/PoolAddress.sol
0xc687e65456ff664b95753e3ee02a5e5d4fdbe886
Solidity
PoolAddress
library PoolAddress { bytes32 internal constant POOL_INIT_CODE_HASH = 0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54; /// @notice The identifying key of the pool struct PoolKey { address token0; address token1; uint24 fee; } /// @notice Returns PoolKey: the ordered tokens with the matched fee levels /// @param tokenA The first token of a pool, unsorted /// @param tokenB The second token of a pool, unsorted /// @param fee The fee level of the pool /// @return Poolkey The pool details with ordered token0 and token1 assignments function getPoolKey( address tokenA, address tokenB, uint24 fee ) internal pure returns (PoolKey memory) { if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA); return PoolKey({token0: tokenA, token1: tokenB, fee: fee}); } /// @notice Deterministically computes the pool address given the factory and PoolKey /// @param factory The Uniswap V3 factory contract address /// @param key The PoolKey /// @return pool The contract address of the V3 pool function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) { require(key.token0 < key.token1); pool = address(uint160( uint256( keccak256( abi.encodePacked( hex'ff', factory, keccak256(abi.encode(key.token0, key.token1, key.fee)), POOL_INIT_CODE_HASH ) ) ) )); } }
/// @title Provides functions for deriving a pool address from the factory, tokens, and the fee
NatSpecSingleLine
getPoolKey
function getPoolKey( address tokenA, address tokenB, uint24 fee ) internal pure returns (PoolKey memory) { if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA); return PoolKey({token0: tokenA, token1: tokenB, fee: fee}); }
/// @notice Returns PoolKey: the ordered tokens with the matched fee levels /// @param tokenA The first token of a pool, unsorted /// @param tokenB The second token of a pool, unsorted /// @param fee The fee level of the pool /// @return Poolkey The pool details with ordered token0 and token1 assignments
NatSpecSingleLine
v0.8.4+commit.c7e474f2
{ "func_code_index": [ 613, 891 ] }
1,235
UniV3LiquidityAMO
contracts/Uniswap_V3/periphery/libraries/PoolAddress.sol
0xc687e65456ff664b95753e3ee02a5e5d4fdbe886
Solidity
PoolAddress
library PoolAddress { bytes32 internal constant POOL_INIT_CODE_HASH = 0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54; /// @notice The identifying key of the pool struct PoolKey { address token0; address token1; uint24 fee; } /// @notice Returns PoolKey: the ordered tokens with the matched fee levels /// @param tokenA The first token of a pool, unsorted /// @param tokenB The second token of a pool, unsorted /// @param fee The fee level of the pool /// @return Poolkey The pool details with ordered token0 and token1 assignments function getPoolKey( address tokenA, address tokenB, uint24 fee ) internal pure returns (PoolKey memory) { if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA); return PoolKey({token0: tokenA, token1: tokenB, fee: fee}); } /// @notice Deterministically computes the pool address given the factory and PoolKey /// @param factory The Uniswap V3 factory contract address /// @param key The PoolKey /// @return pool The contract address of the V3 pool function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) { require(key.token0 < key.token1); pool = address(uint160( uint256( keccak256( abi.encodePacked( hex'ff', factory, keccak256(abi.encode(key.token0, key.token1, key.fee)), POOL_INIT_CODE_HASH ) ) ) )); } }
/// @title Provides functions for deriving a pool address from the factory, tokens, and the fee
NatSpecSingleLine
computeAddress
function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) { require(key.token0 < key.token1); pool = address(uint160( uint256( keccak256( abi.encodePacked( hex'ff', factory, keccak256(abi.encode(key.token0, key.token1, key.fee)), POOL_INIT_CODE_HASH ) ) ) )); }
/// @notice Deterministically computes the pool address given the factory and PoolKey /// @param factory The Uniswap V3 factory contract address /// @param key The PoolKey /// @return pool The contract address of the V3 pool
NatSpecSingleLine
v0.8.4+commit.c7e474f2
{ "func_code_index": [ 1134, 1659 ] }
1,236
BRMP
BRMP.sol
0xea3b77d0322b427453300df08f23ee6c071aaebc
Solidity
BRMP
contract BRMP is Owned, ERC20Token { using SafeMath for uint256; string private constant standard = "201907043306"; string private constant version = "6.0663688"; string private name_ = "Borrme Points"; string private symbol_ = "BRMP"; uint8 private decimals_ = 18; uint256 private totalSupply_ = uint256(100) * uint256(10)**uint256(8) * uint256(10)**uint256(decimals_); mapping (address => uint256) private balanceP; mapping (address => mapping (address => uint256)) private allowed; mapping (address => uint256[]) private lockTime; mapping (address => uint256[]) private lockValue; mapping (address => uint256) private lockNum; uint256 private later = 0; uint256 private earlier = 0; bool private mintable_ = true; // burn token event event Burn(address indexed _from, uint256 _value); // mint token event event Mint(address indexed _to, uint256 _value); // timelock-related events event TransferLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value); event TokenUnlocked(address indexed _address, uint256 _value); // safety method-related events event WrongTokenEmptied(address indexed _token, address indexed _addr, uint256 _amount); event WrongEtherEmptied(address indexed _addr, uint256 _amount); // constructor for the ERC20 Token constructor() public { balanceP[msg.sender] = totalSupply_; } modifier validAddress(address _address) { require(_address != 0x0); _; } modifier isMintable() { require(mintable_); _; } // fast-forward the timelocks for all accounts function setUnlockEarlier(uint256 _earlier) public onlyOwner { earlier = earlier.add(_earlier); } // delay the timelocks for all accounts function setUnlockLater(uint256 _later) public onlyOwner { later = later.add(_later); } // owner may permanently disable minting function disableMint() public onlyOwner isMintable { mintable_ = false; } // show if the token is still mintable function mintable() public view returns (bool) { return mintable_; } // standard ERC20 name function function name() public view returns (string) { return name_; } // standard ERC20 symbol function function symbol() public view returns (string) { return symbol_; } // standard ERC20 decimals function function decimals() public view returns (uint8) { return decimals_; } // standard ERC20 totalSupply function function totalSupply() public view returns (uint256) { return totalSupply_; } // standard ERC20 allowance function function allowance(address _owner, address _spender) external view returns (uint256) { return allowed[_owner][_spender]; } // show unlocked balance of an account function balanceUnlocked(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) >= lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocked balance of an account function balanceLocked(address _address) public view returns (uint256 _balance) { _balance = 0; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) < lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // standard ERC20 balanceOf with timelock added function balanceOf(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocks in an account function showLockTimes(address _address) public view validAddress(_address) returns (uint256[] _times) { uint i = 0; uint256[] memory tempLockTime = new uint256[](lockNum[_address]); while (i < lockNum[_address]) { tempLockTime[i] = lockTime[_address][i].add(later).sub(earlier); i++; } return tempLockTime; } // show values locked in an account's timelocks function showLockValues(address _address) public view validAddress(_address) returns (uint256[] _values) { return lockValue[_address]; } function showLockNum(address _address) public view validAddress(_address) returns (uint256 _lockNum) { return lockNum[_address]; } // Calculate and process the timelock states of an account function calcUnlock(address _address) private { uint256 i = 0; uint256 j = 0; uint256[] memory currentLockTime; uint256[] memory currentLockValue; uint256[] memory newLockTime = new uint256[](lockNum[_address]); uint256[] memory newLockValue = new uint256[](lockNum[_address]); currentLockTime = lockTime[_address]; currentLockValue = lockValue[_address]; while (i < lockNum[_address]) { if (now.add(earlier) >= currentLockTime[i].add(later)) { balanceP[_address] = balanceP[_address].add(currentLockValue[i]); emit TokenUnlocked(_address, currentLockValue[i]); } else { newLockTime[j] = currentLockTime[i]; newLockValue[j] = currentLockValue[i]; j++; } i++; } uint256[] memory trimLockTime = new uint256[](j); uint256[] memory trimLockValue = new uint256[](j); i = 0; while (i < j) { trimLockTime[i] = newLockTime[i]; trimLockValue[i] = newLockValue[i]; i++; } lockTime[_address] = trimLockTime; lockValue[_address] = trimLockValue; lockNum[_address] = j; } // standard ERC20 transfer function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // transfer Token with timelocks function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool _success) { require(_value.length == _time.length); if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[msg.sender] >= totalValue && totalValue >= 0); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[msg.sender] = balanceP[msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(msg.sender, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(msg.sender, _to, _value[i]); i++; } return true; } // TransferFrom Token with timelocks function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public validAddress(_from) validAddress(_to) returns (bool success) { require(_value.length == _time.length); if (lockNum[_from] > 0) calcUnlock(_from); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[_from] >= totalValue && totalValue >= 0 && allowed[_from][msg.sender] >= totalValue); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[_from] = balanceP[_from].sub(_value[i]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(_from, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(_from, _to, _value[i]); i++; } return true; } // standard ERC20 transferFrom function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool _success) { if (lockNum[_from] > 0) calcUnlock(_from); require(balanceP[_from] >= _value && _value >= 0 && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balanceP[_from] = balanceP[_from].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(_from, _to, _value); return true; } // should only be called when first setting an allowed function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // increase or decrease allowed function increaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { if(_value >= allowed[msg.sender][_spender]) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_value); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // owner may burn own token function burn(uint256 _value) public onlyOwner returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } // owner may mint new token and increase total supply function mint(uint256 _value) public onlyOwner isMintable returns (bool _success) { balanceP[msg.sender] = balanceP[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); emit Mint(msg.sender, _value); return true; } // safety methods function () public payable { revert(); } function emptyWrongToken(address _addr) onlyOwner public { ERC20Token wrongToken = ERC20Token(_addr); uint256 amount = wrongToken.balanceOf(address(this)); require(amount > 0); require(wrongToken.transfer(msg.sender, amount)); emit WrongTokenEmptied(_addr, msg.sender, amount); } // shouldn't happen, just in case function emptyWrongEther() onlyOwner public { uint256 amount = address(this).balance; require(amount > 0); msg.sender.transfer(amount); emit WrongEtherEmptied(msg.sender, amount); } }
// the main ERC20-compliant multi-timelock enabled contract
LineComment
setUnlockEarlier
function setUnlockEarlier(uint256 _earlier) public onlyOwner { earlier = earlier.add(_earlier); }
// fast-forward the timelocks for all accounts
LineComment
v0.4.26+commit.4563c3fc
bzzr://0db19956575b13220b4f08b353bc03ba65f05ac41f0203c4a9f88831c40d3012
{ "func_code_index": [ 1727, 1843 ] }
1,237
BRMP
BRMP.sol
0xea3b77d0322b427453300df08f23ee6c071aaebc
Solidity
BRMP
contract BRMP is Owned, ERC20Token { using SafeMath for uint256; string private constant standard = "201907043306"; string private constant version = "6.0663688"; string private name_ = "Borrme Points"; string private symbol_ = "BRMP"; uint8 private decimals_ = 18; uint256 private totalSupply_ = uint256(100) * uint256(10)**uint256(8) * uint256(10)**uint256(decimals_); mapping (address => uint256) private balanceP; mapping (address => mapping (address => uint256)) private allowed; mapping (address => uint256[]) private lockTime; mapping (address => uint256[]) private lockValue; mapping (address => uint256) private lockNum; uint256 private later = 0; uint256 private earlier = 0; bool private mintable_ = true; // burn token event event Burn(address indexed _from, uint256 _value); // mint token event event Mint(address indexed _to, uint256 _value); // timelock-related events event TransferLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value); event TokenUnlocked(address indexed _address, uint256 _value); // safety method-related events event WrongTokenEmptied(address indexed _token, address indexed _addr, uint256 _amount); event WrongEtherEmptied(address indexed _addr, uint256 _amount); // constructor for the ERC20 Token constructor() public { balanceP[msg.sender] = totalSupply_; } modifier validAddress(address _address) { require(_address != 0x0); _; } modifier isMintable() { require(mintable_); _; } // fast-forward the timelocks for all accounts function setUnlockEarlier(uint256 _earlier) public onlyOwner { earlier = earlier.add(_earlier); } // delay the timelocks for all accounts function setUnlockLater(uint256 _later) public onlyOwner { later = later.add(_later); } // owner may permanently disable minting function disableMint() public onlyOwner isMintable { mintable_ = false; } // show if the token is still mintable function mintable() public view returns (bool) { return mintable_; } // standard ERC20 name function function name() public view returns (string) { return name_; } // standard ERC20 symbol function function symbol() public view returns (string) { return symbol_; } // standard ERC20 decimals function function decimals() public view returns (uint8) { return decimals_; } // standard ERC20 totalSupply function function totalSupply() public view returns (uint256) { return totalSupply_; } // standard ERC20 allowance function function allowance(address _owner, address _spender) external view returns (uint256) { return allowed[_owner][_spender]; } // show unlocked balance of an account function balanceUnlocked(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) >= lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocked balance of an account function balanceLocked(address _address) public view returns (uint256 _balance) { _balance = 0; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) < lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // standard ERC20 balanceOf with timelock added function balanceOf(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocks in an account function showLockTimes(address _address) public view validAddress(_address) returns (uint256[] _times) { uint i = 0; uint256[] memory tempLockTime = new uint256[](lockNum[_address]); while (i < lockNum[_address]) { tempLockTime[i] = lockTime[_address][i].add(later).sub(earlier); i++; } return tempLockTime; } // show values locked in an account's timelocks function showLockValues(address _address) public view validAddress(_address) returns (uint256[] _values) { return lockValue[_address]; } function showLockNum(address _address) public view validAddress(_address) returns (uint256 _lockNum) { return lockNum[_address]; } // Calculate and process the timelock states of an account function calcUnlock(address _address) private { uint256 i = 0; uint256 j = 0; uint256[] memory currentLockTime; uint256[] memory currentLockValue; uint256[] memory newLockTime = new uint256[](lockNum[_address]); uint256[] memory newLockValue = new uint256[](lockNum[_address]); currentLockTime = lockTime[_address]; currentLockValue = lockValue[_address]; while (i < lockNum[_address]) { if (now.add(earlier) >= currentLockTime[i].add(later)) { balanceP[_address] = balanceP[_address].add(currentLockValue[i]); emit TokenUnlocked(_address, currentLockValue[i]); } else { newLockTime[j] = currentLockTime[i]; newLockValue[j] = currentLockValue[i]; j++; } i++; } uint256[] memory trimLockTime = new uint256[](j); uint256[] memory trimLockValue = new uint256[](j); i = 0; while (i < j) { trimLockTime[i] = newLockTime[i]; trimLockValue[i] = newLockValue[i]; i++; } lockTime[_address] = trimLockTime; lockValue[_address] = trimLockValue; lockNum[_address] = j; } // standard ERC20 transfer function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // transfer Token with timelocks function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool _success) { require(_value.length == _time.length); if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[msg.sender] >= totalValue && totalValue >= 0); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[msg.sender] = balanceP[msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(msg.sender, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(msg.sender, _to, _value[i]); i++; } return true; } // TransferFrom Token with timelocks function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public validAddress(_from) validAddress(_to) returns (bool success) { require(_value.length == _time.length); if (lockNum[_from] > 0) calcUnlock(_from); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[_from] >= totalValue && totalValue >= 0 && allowed[_from][msg.sender] >= totalValue); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[_from] = balanceP[_from].sub(_value[i]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(_from, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(_from, _to, _value[i]); i++; } return true; } // standard ERC20 transferFrom function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool _success) { if (lockNum[_from] > 0) calcUnlock(_from); require(balanceP[_from] >= _value && _value >= 0 && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balanceP[_from] = balanceP[_from].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(_from, _to, _value); return true; } // should only be called when first setting an allowed function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // increase or decrease allowed function increaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { if(_value >= allowed[msg.sender][_spender]) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_value); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // owner may burn own token function burn(uint256 _value) public onlyOwner returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } // owner may mint new token and increase total supply function mint(uint256 _value) public onlyOwner isMintable returns (bool _success) { balanceP[msg.sender] = balanceP[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); emit Mint(msg.sender, _value); return true; } // safety methods function () public payable { revert(); } function emptyWrongToken(address _addr) onlyOwner public { ERC20Token wrongToken = ERC20Token(_addr); uint256 amount = wrongToken.balanceOf(address(this)); require(amount > 0); require(wrongToken.transfer(msg.sender, amount)); emit WrongTokenEmptied(_addr, msg.sender, amount); } // shouldn't happen, just in case function emptyWrongEther() onlyOwner public { uint256 amount = address(this).balance; require(amount > 0); msg.sender.transfer(amount); emit WrongEtherEmptied(msg.sender, amount); } }
// the main ERC20-compliant multi-timelock enabled contract
LineComment
setUnlockLater
function setUnlockLater(uint256 _later) public onlyOwner { later = later.add(_later); }
// delay the timelocks for all accounts
LineComment
v0.4.26+commit.4563c3fc
bzzr://0db19956575b13220b4f08b353bc03ba65f05ac41f0203c4a9f88831c40d3012
{ "func_code_index": [ 1891, 1997 ] }
1,238
BRMP
BRMP.sol
0xea3b77d0322b427453300df08f23ee6c071aaebc
Solidity
BRMP
contract BRMP is Owned, ERC20Token { using SafeMath for uint256; string private constant standard = "201907043306"; string private constant version = "6.0663688"; string private name_ = "Borrme Points"; string private symbol_ = "BRMP"; uint8 private decimals_ = 18; uint256 private totalSupply_ = uint256(100) * uint256(10)**uint256(8) * uint256(10)**uint256(decimals_); mapping (address => uint256) private balanceP; mapping (address => mapping (address => uint256)) private allowed; mapping (address => uint256[]) private lockTime; mapping (address => uint256[]) private lockValue; mapping (address => uint256) private lockNum; uint256 private later = 0; uint256 private earlier = 0; bool private mintable_ = true; // burn token event event Burn(address indexed _from, uint256 _value); // mint token event event Mint(address indexed _to, uint256 _value); // timelock-related events event TransferLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value); event TokenUnlocked(address indexed _address, uint256 _value); // safety method-related events event WrongTokenEmptied(address indexed _token, address indexed _addr, uint256 _amount); event WrongEtherEmptied(address indexed _addr, uint256 _amount); // constructor for the ERC20 Token constructor() public { balanceP[msg.sender] = totalSupply_; } modifier validAddress(address _address) { require(_address != 0x0); _; } modifier isMintable() { require(mintable_); _; } // fast-forward the timelocks for all accounts function setUnlockEarlier(uint256 _earlier) public onlyOwner { earlier = earlier.add(_earlier); } // delay the timelocks for all accounts function setUnlockLater(uint256 _later) public onlyOwner { later = later.add(_later); } // owner may permanently disable minting function disableMint() public onlyOwner isMintable { mintable_ = false; } // show if the token is still mintable function mintable() public view returns (bool) { return mintable_; } // standard ERC20 name function function name() public view returns (string) { return name_; } // standard ERC20 symbol function function symbol() public view returns (string) { return symbol_; } // standard ERC20 decimals function function decimals() public view returns (uint8) { return decimals_; } // standard ERC20 totalSupply function function totalSupply() public view returns (uint256) { return totalSupply_; } // standard ERC20 allowance function function allowance(address _owner, address _spender) external view returns (uint256) { return allowed[_owner][_spender]; } // show unlocked balance of an account function balanceUnlocked(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) >= lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocked balance of an account function balanceLocked(address _address) public view returns (uint256 _balance) { _balance = 0; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) < lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // standard ERC20 balanceOf with timelock added function balanceOf(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocks in an account function showLockTimes(address _address) public view validAddress(_address) returns (uint256[] _times) { uint i = 0; uint256[] memory tempLockTime = new uint256[](lockNum[_address]); while (i < lockNum[_address]) { tempLockTime[i] = lockTime[_address][i].add(later).sub(earlier); i++; } return tempLockTime; } // show values locked in an account's timelocks function showLockValues(address _address) public view validAddress(_address) returns (uint256[] _values) { return lockValue[_address]; } function showLockNum(address _address) public view validAddress(_address) returns (uint256 _lockNum) { return lockNum[_address]; } // Calculate and process the timelock states of an account function calcUnlock(address _address) private { uint256 i = 0; uint256 j = 0; uint256[] memory currentLockTime; uint256[] memory currentLockValue; uint256[] memory newLockTime = new uint256[](lockNum[_address]); uint256[] memory newLockValue = new uint256[](lockNum[_address]); currentLockTime = lockTime[_address]; currentLockValue = lockValue[_address]; while (i < lockNum[_address]) { if (now.add(earlier) >= currentLockTime[i].add(later)) { balanceP[_address] = balanceP[_address].add(currentLockValue[i]); emit TokenUnlocked(_address, currentLockValue[i]); } else { newLockTime[j] = currentLockTime[i]; newLockValue[j] = currentLockValue[i]; j++; } i++; } uint256[] memory trimLockTime = new uint256[](j); uint256[] memory trimLockValue = new uint256[](j); i = 0; while (i < j) { trimLockTime[i] = newLockTime[i]; trimLockValue[i] = newLockValue[i]; i++; } lockTime[_address] = trimLockTime; lockValue[_address] = trimLockValue; lockNum[_address] = j; } // standard ERC20 transfer function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // transfer Token with timelocks function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool _success) { require(_value.length == _time.length); if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[msg.sender] >= totalValue && totalValue >= 0); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[msg.sender] = balanceP[msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(msg.sender, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(msg.sender, _to, _value[i]); i++; } return true; } // TransferFrom Token with timelocks function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public validAddress(_from) validAddress(_to) returns (bool success) { require(_value.length == _time.length); if (lockNum[_from] > 0) calcUnlock(_from); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[_from] >= totalValue && totalValue >= 0 && allowed[_from][msg.sender] >= totalValue); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[_from] = balanceP[_from].sub(_value[i]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(_from, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(_from, _to, _value[i]); i++; } return true; } // standard ERC20 transferFrom function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool _success) { if (lockNum[_from] > 0) calcUnlock(_from); require(balanceP[_from] >= _value && _value >= 0 && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balanceP[_from] = balanceP[_from].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(_from, _to, _value); return true; } // should only be called when first setting an allowed function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // increase or decrease allowed function increaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { if(_value >= allowed[msg.sender][_spender]) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_value); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // owner may burn own token function burn(uint256 _value) public onlyOwner returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } // owner may mint new token and increase total supply function mint(uint256 _value) public onlyOwner isMintable returns (bool _success) { balanceP[msg.sender] = balanceP[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); emit Mint(msg.sender, _value); return true; } // safety methods function () public payable { revert(); } function emptyWrongToken(address _addr) onlyOwner public { ERC20Token wrongToken = ERC20Token(_addr); uint256 amount = wrongToken.balanceOf(address(this)); require(amount > 0); require(wrongToken.transfer(msg.sender, amount)); emit WrongTokenEmptied(_addr, msg.sender, amount); } // shouldn't happen, just in case function emptyWrongEther() onlyOwner public { uint256 amount = address(this).balance; require(amount > 0); msg.sender.transfer(amount); emit WrongEtherEmptied(msg.sender, amount); } }
// the main ERC20-compliant multi-timelock enabled contract
LineComment
disableMint
function disableMint() public onlyOwner isMintable { mintable_ = false; }
// owner may permanently disable minting
LineComment
v0.4.26+commit.4563c3fc
bzzr://0db19956575b13220b4f08b353bc03ba65f05ac41f0203c4a9f88831c40d3012
{ "func_code_index": [ 2046, 2138 ] }
1,239
BRMP
BRMP.sol
0xea3b77d0322b427453300df08f23ee6c071aaebc
Solidity
BRMP
contract BRMP is Owned, ERC20Token { using SafeMath for uint256; string private constant standard = "201907043306"; string private constant version = "6.0663688"; string private name_ = "Borrme Points"; string private symbol_ = "BRMP"; uint8 private decimals_ = 18; uint256 private totalSupply_ = uint256(100) * uint256(10)**uint256(8) * uint256(10)**uint256(decimals_); mapping (address => uint256) private balanceP; mapping (address => mapping (address => uint256)) private allowed; mapping (address => uint256[]) private lockTime; mapping (address => uint256[]) private lockValue; mapping (address => uint256) private lockNum; uint256 private later = 0; uint256 private earlier = 0; bool private mintable_ = true; // burn token event event Burn(address indexed _from, uint256 _value); // mint token event event Mint(address indexed _to, uint256 _value); // timelock-related events event TransferLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value); event TokenUnlocked(address indexed _address, uint256 _value); // safety method-related events event WrongTokenEmptied(address indexed _token, address indexed _addr, uint256 _amount); event WrongEtherEmptied(address indexed _addr, uint256 _amount); // constructor for the ERC20 Token constructor() public { balanceP[msg.sender] = totalSupply_; } modifier validAddress(address _address) { require(_address != 0x0); _; } modifier isMintable() { require(mintable_); _; } // fast-forward the timelocks for all accounts function setUnlockEarlier(uint256 _earlier) public onlyOwner { earlier = earlier.add(_earlier); } // delay the timelocks for all accounts function setUnlockLater(uint256 _later) public onlyOwner { later = later.add(_later); } // owner may permanently disable minting function disableMint() public onlyOwner isMintable { mintable_ = false; } // show if the token is still mintable function mintable() public view returns (bool) { return mintable_; } // standard ERC20 name function function name() public view returns (string) { return name_; } // standard ERC20 symbol function function symbol() public view returns (string) { return symbol_; } // standard ERC20 decimals function function decimals() public view returns (uint8) { return decimals_; } // standard ERC20 totalSupply function function totalSupply() public view returns (uint256) { return totalSupply_; } // standard ERC20 allowance function function allowance(address _owner, address _spender) external view returns (uint256) { return allowed[_owner][_spender]; } // show unlocked balance of an account function balanceUnlocked(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) >= lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocked balance of an account function balanceLocked(address _address) public view returns (uint256 _balance) { _balance = 0; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) < lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // standard ERC20 balanceOf with timelock added function balanceOf(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocks in an account function showLockTimes(address _address) public view validAddress(_address) returns (uint256[] _times) { uint i = 0; uint256[] memory tempLockTime = new uint256[](lockNum[_address]); while (i < lockNum[_address]) { tempLockTime[i] = lockTime[_address][i].add(later).sub(earlier); i++; } return tempLockTime; } // show values locked in an account's timelocks function showLockValues(address _address) public view validAddress(_address) returns (uint256[] _values) { return lockValue[_address]; } function showLockNum(address _address) public view validAddress(_address) returns (uint256 _lockNum) { return lockNum[_address]; } // Calculate and process the timelock states of an account function calcUnlock(address _address) private { uint256 i = 0; uint256 j = 0; uint256[] memory currentLockTime; uint256[] memory currentLockValue; uint256[] memory newLockTime = new uint256[](lockNum[_address]); uint256[] memory newLockValue = new uint256[](lockNum[_address]); currentLockTime = lockTime[_address]; currentLockValue = lockValue[_address]; while (i < lockNum[_address]) { if (now.add(earlier) >= currentLockTime[i].add(later)) { balanceP[_address] = balanceP[_address].add(currentLockValue[i]); emit TokenUnlocked(_address, currentLockValue[i]); } else { newLockTime[j] = currentLockTime[i]; newLockValue[j] = currentLockValue[i]; j++; } i++; } uint256[] memory trimLockTime = new uint256[](j); uint256[] memory trimLockValue = new uint256[](j); i = 0; while (i < j) { trimLockTime[i] = newLockTime[i]; trimLockValue[i] = newLockValue[i]; i++; } lockTime[_address] = trimLockTime; lockValue[_address] = trimLockValue; lockNum[_address] = j; } // standard ERC20 transfer function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // transfer Token with timelocks function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool _success) { require(_value.length == _time.length); if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[msg.sender] >= totalValue && totalValue >= 0); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[msg.sender] = balanceP[msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(msg.sender, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(msg.sender, _to, _value[i]); i++; } return true; } // TransferFrom Token with timelocks function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public validAddress(_from) validAddress(_to) returns (bool success) { require(_value.length == _time.length); if (lockNum[_from] > 0) calcUnlock(_from); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[_from] >= totalValue && totalValue >= 0 && allowed[_from][msg.sender] >= totalValue); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[_from] = balanceP[_from].sub(_value[i]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(_from, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(_from, _to, _value[i]); i++; } return true; } // standard ERC20 transferFrom function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool _success) { if (lockNum[_from] > 0) calcUnlock(_from); require(balanceP[_from] >= _value && _value >= 0 && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balanceP[_from] = balanceP[_from].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(_from, _to, _value); return true; } // should only be called when first setting an allowed function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // increase or decrease allowed function increaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { if(_value >= allowed[msg.sender][_spender]) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_value); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // owner may burn own token function burn(uint256 _value) public onlyOwner returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } // owner may mint new token and increase total supply function mint(uint256 _value) public onlyOwner isMintable returns (bool _success) { balanceP[msg.sender] = balanceP[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); emit Mint(msg.sender, _value); return true; } // safety methods function () public payable { revert(); } function emptyWrongToken(address _addr) onlyOwner public { ERC20Token wrongToken = ERC20Token(_addr); uint256 amount = wrongToken.balanceOf(address(this)); require(amount > 0); require(wrongToken.transfer(msg.sender, amount)); emit WrongTokenEmptied(_addr, msg.sender, amount); } // shouldn't happen, just in case function emptyWrongEther() onlyOwner public { uint256 amount = address(this).balance; require(amount > 0); msg.sender.transfer(amount); emit WrongEtherEmptied(msg.sender, amount); } }
// the main ERC20-compliant multi-timelock enabled contract
LineComment
mintable
function mintable() public view returns (bool) { return mintable_; }
// show if the token is still mintable
LineComment
v0.4.26+commit.4563c3fc
bzzr://0db19956575b13220b4f08b353bc03ba65f05ac41f0203c4a9f88831c40d3012
{ "func_code_index": [ 2185, 2272 ] }
1,240
BRMP
BRMP.sol
0xea3b77d0322b427453300df08f23ee6c071aaebc
Solidity
BRMP
contract BRMP is Owned, ERC20Token { using SafeMath for uint256; string private constant standard = "201907043306"; string private constant version = "6.0663688"; string private name_ = "Borrme Points"; string private symbol_ = "BRMP"; uint8 private decimals_ = 18; uint256 private totalSupply_ = uint256(100) * uint256(10)**uint256(8) * uint256(10)**uint256(decimals_); mapping (address => uint256) private balanceP; mapping (address => mapping (address => uint256)) private allowed; mapping (address => uint256[]) private lockTime; mapping (address => uint256[]) private lockValue; mapping (address => uint256) private lockNum; uint256 private later = 0; uint256 private earlier = 0; bool private mintable_ = true; // burn token event event Burn(address indexed _from, uint256 _value); // mint token event event Mint(address indexed _to, uint256 _value); // timelock-related events event TransferLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value); event TokenUnlocked(address indexed _address, uint256 _value); // safety method-related events event WrongTokenEmptied(address indexed _token, address indexed _addr, uint256 _amount); event WrongEtherEmptied(address indexed _addr, uint256 _amount); // constructor for the ERC20 Token constructor() public { balanceP[msg.sender] = totalSupply_; } modifier validAddress(address _address) { require(_address != 0x0); _; } modifier isMintable() { require(mintable_); _; } // fast-forward the timelocks for all accounts function setUnlockEarlier(uint256 _earlier) public onlyOwner { earlier = earlier.add(_earlier); } // delay the timelocks for all accounts function setUnlockLater(uint256 _later) public onlyOwner { later = later.add(_later); } // owner may permanently disable minting function disableMint() public onlyOwner isMintable { mintable_ = false; } // show if the token is still mintable function mintable() public view returns (bool) { return mintable_; } // standard ERC20 name function function name() public view returns (string) { return name_; } // standard ERC20 symbol function function symbol() public view returns (string) { return symbol_; } // standard ERC20 decimals function function decimals() public view returns (uint8) { return decimals_; } // standard ERC20 totalSupply function function totalSupply() public view returns (uint256) { return totalSupply_; } // standard ERC20 allowance function function allowance(address _owner, address _spender) external view returns (uint256) { return allowed[_owner][_spender]; } // show unlocked balance of an account function balanceUnlocked(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) >= lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocked balance of an account function balanceLocked(address _address) public view returns (uint256 _balance) { _balance = 0; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) < lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // standard ERC20 balanceOf with timelock added function balanceOf(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocks in an account function showLockTimes(address _address) public view validAddress(_address) returns (uint256[] _times) { uint i = 0; uint256[] memory tempLockTime = new uint256[](lockNum[_address]); while (i < lockNum[_address]) { tempLockTime[i] = lockTime[_address][i].add(later).sub(earlier); i++; } return tempLockTime; } // show values locked in an account's timelocks function showLockValues(address _address) public view validAddress(_address) returns (uint256[] _values) { return lockValue[_address]; } function showLockNum(address _address) public view validAddress(_address) returns (uint256 _lockNum) { return lockNum[_address]; } // Calculate and process the timelock states of an account function calcUnlock(address _address) private { uint256 i = 0; uint256 j = 0; uint256[] memory currentLockTime; uint256[] memory currentLockValue; uint256[] memory newLockTime = new uint256[](lockNum[_address]); uint256[] memory newLockValue = new uint256[](lockNum[_address]); currentLockTime = lockTime[_address]; currentLockValue = lockValue[_address]; while (i < lockNum[_address]) { if (now.add(earlier) >= currentLockTime[i].add(later)) { balanceP[_address] = balanceP[_address].add(currentLockValue[i]); emit TokenUnlocked(_address, currentLockValue[i]); } else { newLockTime[j] = currentLockTime[i]; newLockValue[j] = currentLockValue[i]; j++; } i++; } uint256[] memory trimLockTime = new uint256[](j); uint256[] memory trimLockValue = new uint256[](j); i = 0; while (i < j) { trimLockTime[i] = newLockTime[i]; trimLockValue[i] = newLockValue[i]; i++; } lockTime[_address] = trimLockTime; lockValue[_address] = trimLockValue; lockNum[_address] = j; } // standard ERC20 transfer function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // transfer Token with timelocks function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool _success) { require(_value.length == _time.length); if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[msg.sender] >= totalValue && totalValue >= 0); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[msg.sender] = balanceP[msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(msg.sender, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(msg.sender, _to, _value[i]); i++; } return true; } // TransferFrom Token with timelocks function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public validAddress(_from) validAddress(_to) returns (bool success) { require(_value.length == _time.length); if (lockNum[_from] > 0) calcUnlock(_from); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[_from] >= totalValue && totalValue >= 0 && allowed[_from][msg.sender] >= totalValue); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[_from] = balanceP[_from].sub(_value[i]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(_from, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(_from, _to, _value[i]); i++; } return true; } // standard ERC20 transferFrom function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool _success) { if (lockNum[_from] > 0) calcUnlock(_from); require(balanceP[_from] >= _value && _value >= 0 && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balanceP[_from] = balanceP[_from].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(_from, _to, _value); return true; } // should only be called when first setting an allowed function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // increase or decrease allowed function increaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { if(_value >= allowed[msg.sender][_spender]) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_value); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // owner may burn own token function burn(uint256 _value) public onlyOwner returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } // owner may mint new token and increase total supply function mint(uint256 _value) public onlyOwner isMintable returns (bool _success) { balanceP[msg.sender] = balanceP[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); emit Mint(msg.sender, _value); return true; } // safety methods function () public payable { revert(); } function emptyWrongToken(address _addr) onlyOwner public { ERC20Token wrongToken = ERC20Token(_addr); uint256 amount = wrongToken.balanceOf(address(this)); require(amount > 0); require(wrongToken.transfer(msg.sender, amount)); emit WrongTokenEmptied(_addr, msg.sender, amount); } // shouldn't happen, just in case function emptyWrongEther() onlyOwner public { uint256 amount = address(this).balance; require(amount > 0); msg.sender.transfer(amount); emit WrongEtherEmptied(msg.sender, amount); } }
// the main ERC20-compliant multi-timelock enabled contract
LineComment
name
function name() public view returns (string) { return name_; }
// standard ERC20 name function
LineComment
v0.4.26+commit.4563c3fc
bzzr://0db19956575b13220b4f08b353bc03ba65f05ac41f0203c4a9f88831c40d3012
{ "func_code_index": [ 2312, 2393 ] }
1,241
BRMP
BRMP.sol
0xea3b77d0322b427453300df08f23ee6c071aaebc
Solidity
BRMP
contract BRMP is Owned, ERC20Token { using SafeMath for uint256; string private constant standard = "201907043306"; string private constant version = "6.0663688"; string private name_ = "Borrme Points"; string private symbol_ = "BRMP"; uint8 private decimals_ = 18; uint256 private totalSupply_ = uint256(100) * uint256(10)**uint256(8) * uint256(10)**uint256(decimals_); mapping (address => uint256) private balanceP; mapping (address => mapping (address => uint256)) private allowed; mapping (address => uint256[]) private lockTime; mapping (address => uint256[]) private lockValue; mapping (address => uint256) private lockNum; uint256 private later = 0; uint256 private earlier = 0; bool private mintable_ = true; // burn token event event Burn(address indexed _from, uint256 _value); // mint token event event Mint(address indexed _to, uint256 _value); // timelock-related events event TransferLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value); event TokenUnlocked(address indexed _address, uint256 _value); // safety method-related events event WrongTokenEmptied(address indexed _token, address indexed _addr, uint256 _amount); event WrongEtherEmptied(address indexed _addr, uint256 _amount); // constructor for the ERC20 Token constructor() public { balanceP[msg.sender] = totalSupply_; } modifier validAddress(address _address) { require(_address != 0x0); _; } modifier isMintable() { require(mintable_); _; } // fast-forward the timelocks for all accounts function setUnlockEarlier(uint256 _earlier) public onlyOwner { earlier = earlier.add(_earlier); } // delay the timelocks for all accounts function setUnlockLater(uint256 _later) public onlyOwner { later = later.add(_later); } // owner may permanently disable minting function disableMint() public onlyOwner isMintable { mintable_ = false; } // show if the token is still mintable function mintable() public view returns (bool) { return mintable_; } // standard ERC20 name function function name() public view returns (string) { return name_; } // standard ERC20 symbol function function symbol() public view returns (string) { return symbol_; } // standard ERC20 decimals function function decimals() public view returns (uint8) { return decimals_; } // standard ERC20 totalSupply function function totalSupply() public view returns (uint256) { return totalSupply_; } // standard ERC20 allowance function function allowance(address _owner, address _spender) external view returns (uint256) { return allowed[_owner][_spender]; } // show unlocked balance of an account function balanceUnlocked(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) >= lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocked balance of an account function balanceLocked(address _address) public view returns (uint256 _balance) { _balance = 0; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) < lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // standard ERC20 balanceOf with timelock added function balanceOf(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocks in an account function showLockTimes(address _address) public view validAddress(_address) returns (uint256[] _times) { uint i = 0; uint256[] memory tempLockTime = new uint256[](lockNum[_address]); while (i < lockNum[_address]) { tempLockTime[i] = lockTime[_address][i].add(later).sub(earlier); i++; } return tempLockTime; } // show values locked in an account's timelocks function showLockValues(address _address) public view validAddress(_address) returns (uint256[] _values) { return lockValue[_address]; } function showLockNum(address _address) public view validAddress(_address) returns (uint256 _lockNum) { return lockNum[_address]; } // Calculate and process the timelock states of an account function calcUnlock(address _address) private { uint256 i = 0; uint256 j = 0; uint256[] memory currentLockTime; uint256[] memory currentLockValue; uint256[] memory newLockTime = new uint256[](lockNum[_address]); uint256[] memory newLockValue = new uint256[](lockNum[_address]); currentLockTime = lockTime[_address]; currentLockValue = lockValue[_address]; while (i < lockNum[_address]) { if (now.add(earlier) >= currentLockTime[i].add(later)) { balanceP[_address] = balanceP[_address].add(currentLockValue[i]); emit TokenUnlocked(_address, currentLockValue[i]); } else { newLockTime[j] = currentLockTime[i]; newLockValue[j] = currentLockValue[i]; j++; } i++; } uint256[] memory trimLockTime = new uint256[](j); uint256[] memory trimLockValue = new uint256[](j); i = 0; while (i < j) { trimLockTime[i] = newLockTime[i]; trimLockValue[i] = newLockValue[i]; i++; } lockTime[_address] = trimLockTime; lockValue[_address] = trimLockValue; lockNum[_address] = j; } // standard ERC20 transfer function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // transfer Token with timelocks function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool _success) { require(_value.length == _time.length); if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[msg.sender] >= totalValue && totalValue >= 0); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[msg.sender] = balanceP[msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(msg.sender, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(msg.sender, _to, _value[i]); i++; } return true; } // TransferFrom Token with timelocks function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public validAddress(_from) validAddress(_to) returns (bool success) { require(_value.length == _time.length); if (lockNum[_from] > 0) calcUnlock(_from); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[_from] >= totalValue && totalValue >= 0 && allowed[_from][msg.sender] >= totalValue); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[_from] = balanceP[_from].sub(_value[i]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(_from, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(_from, _to, _value[i]); i++; } return true; } // standard ERC20 transferFrom function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool _success) { if (lockNum[_from] > 0) calcUnlock(_from); require(balanceP[_from] >= _value && _value >= 0 && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balanceP[_from] = balanceP[_from].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(_from, _to, _value); return true; } // should only be called when first setting an allowed function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // increase or decrease allowed function increaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { if(_value >= allowed[msg.sender][_spender]) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_value); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // owner may burn own token function burn(uint256 _value) public onlyOwner returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } // owner may mint new token and increase total supply function mint(uint256 _value) public onlyOwner isMintable returns (bool _success) { balanceP[msg.sender] = balanceP[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); emit Mint(msg.sender, _value); return true; } // safety methods function () public payable { revert(); } function emptyWrongToken(address _addr) onlyOwner public { ERC20Token wrongToken = ERC20Token(_addr); uint256 amount = wrongToken.balanceOf(address(this)); require(amount > 0); require(wrongToken.transfer(msg.sender, amount)); emit WrongTokenEmptied(_addr, msg.sender, amount); } // shouldn't happen, just in case function emptyWrongEther() onlyOwner public { uint256 amount = address(this).balance; require(amount > 0); msg.sender.transfer(amount); emit WrongEtherEmptied(msg.sender, amount); } }
// the main ERC20-compliant multi-timelock enabled contract
LineComment
symbol
function symbol() public view returns (string) { return symbol_; }
// standard ERC20 symbol function
LineComment
v0.4.26+commit.4563c3fc
bzzr://0db19956575b13220b4f08b353bc03ba65f05ac41f0203c4a9f88831c40d3012
{ "func_code_index": [ 2435, 2520 ] }
1,242
BRMP
BRMP.sol
0xea3b77d0322b427453300df08f23ee6c071aaebc
Solidity
BRMP
contract BRMP is Owned, ERC20Token { using SafeMath for uint256; string private constant standard = "201907043306"; string private constant version = "6.0663688"; string private name_ = "Borrme Points"; string private symbol_ = "BRMP"; uint8 private decimals_ = 18; uint256 private totalSupply_ = uint256(100) * uint256(10)**uint256(8) * uint256(10)**uint256(decimals_); mapping (address => uint256) private balanceP; mapping (address => mapping (address => uint256)) private allowed; mapping (address => uint256[]) private lockTime; mapping (address => uint256[]) private lockValue; mapping (address => uint256) private lockNum; uint256 private later = 0; uint256 private earlier = 0; bool private mintable_ = true; // burn token event event Burn(address indexed _from, uint256 _value); // mint token event event Mint(address indexed _to, uint256 _value); // timelock-related events event TransferLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value); event TokenUnlocked(address indexed _address, uint256 _value); // safety method-related events event WrongTokenEmptied(address indexed _token, address indexed _addr, uint256 _amount); event WrongEtherEmptied(address indexed _addr, uint256 _amount); // constructor for the ERC20 Token constructor() public { balanceP[msg.sender] = totalSupply_; } modifier validAddress(address _address) { require(_address != 0x0); _; } modifier isMintable() { require(mintable_); _; } // fast-forward the timelocks for all accounts function setUnlockEarlier(uint256 _earlier) public onlyOwner { earlier = earlier.add(_earlier); } // delay the timelocks for all accounts function setUnlockLater(uint256 _later) public onlyOwner { later = later.add(_later); } // owner may permanently disable minting function disableMint() public onlyOwner isMintable { mintable_ = false; } // show if the token is still mintable function mintable() public view returns (bool) { return mintable_; } // standard ERC20 name function function name() public view returns (string) { return name_; } // standard ERC20 symbol function function symbol() public view returns (string) { return symbol_; } // standard ERC20 decimals function function decimals() public view returns (uint8) { return decimals_; } // standard ERC20 totalSupply function function totalSupply() public view returns (uint256) { return totalSupply_; } // standard ERC20 allowance function function allowance(address _owner, address _spender) external view returns (uint256) { return allowed[_owner][_spender]; } // show unlocked balance of an account function balanceUnlocked(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) >= lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocked balance of an account function balanceLocked(address _address) public view returns (uint256 _balance) { _balance = 0; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) < lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // standard ERC20 balanceOf with timelock added function balanceOf(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocks in an account function showLockTimes(address _address) public view validAddress(_address) returns (uint256[] _times) { uint i = 0; uint256[] memory tempLockTime = new uint256[](lockNum[_address]); while (i < lockNum[_address]) { tempLockTime[i] = lockTime[_address][i].add(later).sub(earlier); i++; } return tempLockTime; } // show values locked in an account's timelocks function showLockValues(address _address) public view validAddress(_address) returns (uint256[] _values) { return lockValue[_address]; } function showLockNum(address _address) public view validAddress(_address) returns (uint256 _lockNum) { return lockNum[_address]; } // Calculate and process the timelock states of an account function calcUnlock(address _address) private { uint256 i = 0; uint256 j = 0; uint256[] memory currentLockTime; uint256[] memory currentLockValue; uint256[] memory newLockTime = new uint256[](lockNum[_address]); uint256[] memory newLockValue = new uint256[](lockNum[_address]); currentLockTime = lockTime[_address]; currentLockValue = lockValue[_address]; while (i < lockNum[_address]) { if (now.add(earlier) >= currentLockTime[i].add(later)) { balanceP[_address] = balanceP[_address].add(currentLockValue[i]); emit TokenUnlocked(_address, currentLockValue[i]); } else { newLockTime[j] = currentLockTime[i]; newLockValue[j] = currentLockValue[i]; j++; } i++; } uint256[] memory trimLockTime = new uint256[](j); uint256[] memory trimLockValue = new uint256[](j); i = 0; while (i < j) { trimLockTime[i] = newLockTime[i]; trimLockValue[i] = newLockValue[i]; i++; } lockTime[_address] = trimLockTime; lockValue[_address] = trimLockValue; lockNum[_address] = j; } // standard ERC20 transfer function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // transfer Token with timelocks function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool _success) { require(_value.length == _time.length); if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[msg.sender] >= totalValue && totalValue >= 0); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[msg.sender] = balanceP[msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(msg.sender, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(msg.sender, _to, _value[i]); i++; } return true; } // TransferFrom Token with timelocks function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public validAddress(_from) validAddress(_to) returns (bool success) { require(_value.length == _time.length); if (lockNum[_from] > 0) calcUnlock(_from); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[_from] >= totalValue && totalValue >= 0 && allowed[_from][msg.sender] >= totalValue); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[_from] = balanceP[_from].sub(_value[i]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(_from, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(_from, _to, _value[i]); i++; } return true; } // standard ERC20 transferFrom function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool _success) { if (lockNum[_from] > 0) calcUnlock(_from); require(balanceP[_from] >= _value && _value >= 0 && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balanceP[_from] = balanceP[_from].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(_from, _to, _value); return true; } // should only be called when first setting an allowed function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // increase or decrease allowed function increaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { if(_value >= allowed[msg.sender][_spender]) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_value); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // owner may burn own token function burn(uint256 _value) public onlyOwner returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } // owner may mint new token and increase total supply function mint(uint256 _value) public onlyOwner isMintable returns (bool _success) { balanceP[msg.sender] = balanceP[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); emit Mint(msg.sender, _value); return true; } // safety methods function () public payable { revert(); } function emptyWrongToken(address _addr) onlyOwner public { ERC20Token wrongToken = ERC20Token(_addr); uint256 amount = wrongToken.balanceOf(address(this)); require(amount > 0); require(wrongToken.transfer(msg.sender, amount)); emit WrongTokenEmptied(_addr, msg.sender, amount); } // shouldn't happen, just in case function emptyWrongEther() onlyOwner public { uint256 amount = address(this).balance; require(amount > 0); msg.sender.transfer(amount); emit WrongEtherEmptied(msg.sender, amount); } }
// the main ERC20-compliant multi-timelock enabled contract
LineComment
decimals
function decimals() public view returns (uint8) { return decimals_; }
// standard ERC20 decimals function
LineComment
v0.4.26+commit.4563c3fc
bzzr://0db19956575b13220b4f08b353bc03ba65f05ac41f0203c4a9f88831c40d3012
{ "func_code_index": [ 2564, 2652 ] }
1,243
BRMP
BRMP.sol
0xea3b77d0322b427453300df08f23ee6c071aaebc
Solidity
BRMP
contract BRMP is Owned, ERC20Token { using SafeMath for uint256; string private constant standard = "201907043306"; string private constant version = "6.0663688"; string private name_ = "Borrme Points"; string private symbol_ = "BRMP"; uint8 private decimals_ = 18; uint256 private totalSupply_ = uint256(100) * uint256(10)**uint256(8) * uint256(10)**uint256(decimals_); mapping (address => uint256) private balanceP; mapping (address => mapping (address => uint256)) private allowed; mapping (address => uint256[]) private lockTime; mapping (address => uint256[]) private lockValue; mapping (address => uint256) private lockNum; uint256 private later = 0; uint256 private earlier = 0; bool private mintable_ = true; // burn token event event Burn(address indexed _from, uint256 _value); // mint token event event Mint(address indexed _to, uint256 _value); // timelock-related events event TransferLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value); event TokenUnlocked(address indexed _address, uint256 _value); // safety method-related events event WrongTokenEmptied(address indexed _token, address indexed _addr, uint256 _amount); event WrongEtherEmptied(address indexed _addr, uint256 _amount); // constructor for the ERC20 Token constructor() public { balanceP[msg.sender] = totalSupply_; } modifier validAddress(address _address) { require(_address != 0x0); _; } modifier isMintable() { require(mintable_); _; } // fast-forward the timelocks for all accounts function setUnlockEarlier(uint256 _earlier) public onlyOwner { earlier = earlier.add(_earlier); } // delay the timelocks for all accounts function setUnlockLater(uint256 _later) public onlyOwner { later = later.add(_later); } // owner may permanently disable minting function disableMint() public onlyOwner isMintable { mintable_ = false; } // show if the token is still mintable function mintable() public view returns (bool) { return mintable_; } // standard ERC20 name function function name() public view returns (string) { return name_; } // standard ERC20 symbol function function symbol() public view returns (string) { return symbol_; } // standard ERC20 decimals function function decimals() public view returns (uint8) { return decimals_; } // standard ERC20 totalSupply function function totalSupply() public view returns (uint256) { return totalSupply_; } // standard ERC20 allowance function function allowance(address _owner, address _spender) external view returns (uint256) { return allowed[_owner][_spender]; } // show unlocked balance of an account function balanceUnlocked(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) >= lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocked balance of an account function balanceLocked(address _address) public view returns (uint256 _balance) { _balance = 0; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) < lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // standard ERC20 balanceOf with timelock added function balanceOf(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocks in an account function showLockTimes(address _address) public view validAddress(_address) returns (uint256[] _times) { uint i = 0; uint256[] memory tempLockTime = new uint256[](lockNum[_address]); while (i < lockNum[_address]) { tempLockTime[i] = lockTime[_address][i].add(later).sub(earlier); i++; } return tempLockTime; } // show values locked in an account's timelocks function showLockValues(address _address) public view validAddress(_address) returns (uint256[] _values) { return lockValue[_address]; } function showLockNum(address _address) public view validAddress(_address) returns (uint256 _lockNum) { return lockNum[_address]; } // Calculate and process the timelock states of an account function calcUnlock(address _address) private { uint256 i = 0; uint256 j = 0; uint256[] memory currentLockTime; uint256[] memory currentLockValue; uint256[] memory newLockTime = new uint256[](lockNum[_address]); uint256[] memory newLockValue = new uint256[](lockNum[_address]); currentLockTime = lockTime[_address]; currentLockValue = lockValue[_address]; while (i < lockNum[_address]) { if (now.add(earlier) >= currentLockTime[i].add(later)) { balanceP[_address] = balanceP[_address].add(currentLockValue[i]); emit TokenUnlocked(_address, currentLockValue[i]); } else { newLockTime[j] = currentLockTime[i]; newLockValue[j] = currentLockValue[i]; j++; } i++; } uint256[] memory trimLockTime = new uint256[](j); uint256[] memory trimLockValue = new uint256[](j); i = 0; while (i < j) { trimLockTime[i] = newLockTime[i]; trimLockValue[i] = newLockValue[i]; i++; } lockTime[_address] = trimLockTime; lockValue[_address] = trimLockValue; lockNum[_address] = j; } // standard ERC20 transfer function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // transfer Token with timelocks function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool _success) { require(_value.length == _time.length); if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[msg.sender] >= totalValue && totalValue >= 0); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[msg.sender] = balanceP[msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(msg.sender, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(msg.sender, _to, _value[i]); i++; } return true; } // TransferFrom Token with timelocks function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public validAddress(_from) validAddress(_to) returns (bool success) { require(_value.length == _time.length); if (lockNum[_from] > 0) calcUnlock(_from); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[_from] >= totalValue && totalValue >= 0 && allowed[_from][msg.sender] >= totalValue); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[_from] = balanceP[_from].sub(_value[i]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(_from, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(_from, _to, _value[i]); i++; } return true; } // standard ERC20 transferFrom function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool _success) { if (lockNum[_from] > 0) calcUnlock(_from); require(balanceP[_from] >= _value && _value >= 0 && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balanceP[_from] = balanceP[_from].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(_from, _to, _value); return true; } // should only be called when first setting an allowed function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // increase or decrease allowed function increaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { if(_value >= allowed[msg.sender][_spender]) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_value); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // owner may burn own token function burn(uint256 _value) public onlyOwner returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } // owner may mint new token and increase total supply function mint(uint256 _value) public onlyOwner isMintable returns (bool _success) { balanceP[msg.sender] = balanceP[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); emit Mint(msg.sender, _value); return true; } // safety methods function () public payable { revert(); } function emptyWrongToken(address _addr) onlyOwner public { ERC20Token wrongToken = ERC20Token(_addr); uint256 amount = wrongToken.balanceOf(address(this)); require(amount > 0); require(wrongToken.transfer(msg.sender, amount)); emit WrongTokenEmptied(_addr, msg.sender, amount); } // shouldn't happen, just in case function emptyWrongEther() onlyOwner public { uint256 amount = address(this).balance; require(amount > 0); msg.sender.transfer(amount); emit WrongEtherEmptied(msg.sender, amount); } }
// the main ERC20-compliant multi-timelock enabled contract
LineComment
totalSupply
function totalSupply() public view returns (uint256) { return totalSupply_; }
// standard ERC20 totalSupply function
LineComment
v0.4.26+commit.4563c3fc
bzzr://0db19956575b13220b4f08b353bc03ba65f05ac41f0203c4a9f88831c40d3012
{ "func_code_index": [ 2699, 2795 ] }
1,244
BRMP
BRMP.sol
0xea3b77d0322b427453300df08f23ee6c071aaebc
Solidity
BRMP
contract BRMP is Owned, ERC20Token { using SafeMath for uint256; string private constant standard = "201907043306"; string private constant version = "6.0663688"; string private name_ = "Borrme Points"; string private symbol_ = "BRMP"; uint8 private decimals_ = 18; uint256 private totalSupply_ = uint256(100) * uint256(10)**uint256(8) * uint256(10)**uint256(decimals_); mapping (address => uint256) private balanceP; mapping (address => mapping (address => uint256)) private allowed; mapping (address => uint256[]) private lockTime; mapping (address => uint256[]) private lockValue; mapping (address => uint256) private lockNum; uint256 private later = 0; uint256 private earlier = 0; bool private mintable_ = true; // burn token event event Burn(address indexed _from, uint256 _value); // mint token event event Mint(address indexed _to, uint256 _value); // timelock-related events event TransferLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value); event TokenUnlocked(address indexed _address, uint256 _value); // safety method-related events event WrongTokenEmptied(address indexed _token, address indexed _addr, uint256 _amount); event WrongEtherEmptied(address indexed _addr, uint256 _amount); // constructor for the ERC20 Token constructor() public { balanceP[msg.sender] = totalSupply_; } modifier validAddress(address _address) { require(_address != 0x0); _; } modifier isMintable() { require(mintable_); _; } // fast-forward the timelocks for all accounts function setUnlockEarlier(uint256 _earlier) public onlyOwner { earlier = earlier.add(_earlier); } // delay the timelocks for all accounts function setUnlockLater(uint256 _later) public onlyOwner { later = later.add(_later); } // owner may permanently disable minting function disableMint() public onlyOwner isMintable { mintable_ = false; } // show if the token is still mintable function mintable() public view returns (bool) { return mintable_; } // standard ERC20 name function function name() public view returns (string) { return name_; } // standard ERC20 symbol function function symbol() public view returns (string) { return symbol_; } // standard ERC20 decimals function function decimals() public view returns (uint8) { return decimals_; } // standard ERC20 totalSupply function function totalSupply() public view returns (uint256) { return totalSupply_; } // standard ERC20 allowance function function allowance(address _owner, address _spender) external view returns (uint256) { return allowed[_owner][_spender]; } // show unlocked balance of an account function balanceUnlocked(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) >= lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocked balance of an account function balanceLocked(address _address) public view returns (uint256 _balance) { _balance = 0; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) < lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // standard ERC20 balanceOf with timelock added function balanceOf(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocks in an account function showLockTimes(address _address) public view validAddress(_address) returns (uint256[] _times) { uint i = 0; uint256[] memory tempLockTime = new uint256[](lockNum[_address]); while (i < lockNum[_address]) { tempLockTime[i] = lockTime[_address][i].add(later).sub(earlier); i++; } return tempLockTime; } // show values locked in an account's timelocks function showLockValues(address _address) public view validAddress(_address) returns (uint256[] _values) { return lockValue[_address]; } function showLockNum(address _address) public view validAddress(_address) returns (uint256 _lockNum) { return lockNum[_address]; } // Calculate and process the timelock states of an account function calcUnlock(address _address) private { uint256 i = 0; uint256 j = 0; uint256[] memory currentLockTime; uint256[] memory currentLockValue; uint256[] memory newLockTime = new uint256[](lockNum[_address]); uint256[] memory newLockValue = new uint256[](lockNum[_address]); currentLockTime = lockTime[_address]; currentLockValue = lockValue[_address]; while (i < lockNum[_address]) { if (now.add(earlier) >= currentLockTime[i].add(later)) { balanceP[_address] = balanceP[_address].add(currentLockValue[i]); emit TokenUnlocked(_address, currentLockValue[i]); } else { newLockTime[j] = currentLockTime[i]; newLockValue[j] = currentLockValue[i]; j++; } i++; } uint256[] memory trimLockTime = new uint256[](j); uint256[] memory trimLockValue = new uint256[](j); i = 0; while (i < j) { trimLockTime[i] = newLockTime[i]; trimLockValue[i] = newLockValue[i]; i++; } lockTime[_address] = trimLockTime; lockValue[_address] = trimLockValue; lockNum[_address] = j; } // standard ERC20 transfer function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // transfer Token with timelocks function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool _success) { require(_value.length == _time.length); if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[msg.sender] >= totalValue && totalValue >= 0); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[msg.sender] = balanceP[msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(msg.sender, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(msg.sender, _to, _value[i]); i++; } return true; } // TransferFrom Token with timelocks function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public validAddress(_from) validAddress(_to) returns (bool success) { require(_value.length == _time.length); if (lockNum[_from] > 0) calcUnlock(_from); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[_from] >= totalValue && totalValue >= 0 && allowed[_from][msg.sender] >= totalValue); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[_from] = balanceP[_from].sub(_value[i]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(_from, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(_from, _to, _value[i]); i++; } return true; } // standard ERC20 transferFrom function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool _success) { if (lockNum[_from] > 0) calcUnlock(_from); require(balanceP[_from] >= _value && _value >= 0 && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balanceP[_from] = balanceP[_from].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(_from, _to, _value); return true; } // should only be called when first setting an allowed function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // increase or decrease allowed function increaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { if(_value >= allowed[msg.sender][_spender]) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_value); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // owner may burn own token function burn(uint256 _value) public onlyOwner returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } // owner may mint new token and increase total supply function mint(uint256 _value) public onlyOwner isMintable returns (bool _success) { balanceP[msg.sender] = balanceP[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); emit Mint(msg.sender, _value); return true; } // safety methods function () public payable { revert(); } function emptyWrongToken(address _addr) onlyOwner public { ERC20Token wrongToken = ERC20Token(_addr); uint256 amount = wrongToken.balanceOf(address(this)); require(amount > 0); require(wrongToken.transfer(msg.sender, amount)); emit WrongTokenEmptied(_addr, msg.sender, amount); } // shouldn't happen, just in case function emptyWrongEther() onlyOwner public { uint256 amount = address(this).balance; require(amount > 0); msg.sender.transfer(amount); emit WrongEtherEmptied(msg.sender, amount); } }
// the main ERC20-compliant multi-timelock enabled contract
LineComment
allowance
function allowance(address _owner, address _spender) external view returns (uint256) { return allowed[_owner][_spender]; }
// standard ERC20 allowance function
LineComment
v0.4.26+commit.4563c3fc
bzzr://0db19956575b13220b4f08b353bc03ba65f05ac41f0203c4a9f88831c40d3012
{ "func_code_index": [ 2840, 2981 ] }
1,245
BRMP
BRMP.sol
0xea3b77d0322b427453300df08f23ee6c071aaebc
Solidity
BRMP
contract BRMP is Owned, ERC20Token { using SafeMath for uint256; string private constant standard = "201907043306"; string private constant version = "6.0663688"; string private name_ = "Borrme Points"; string private symbol_ = "BRMP"; uint8 private decimals_ = 18; uint256 private totalSupply_ = uint256(100) * uint256(10)**uint256(8) * uint256(10)**uint256(decimals_); mapping (address => uint256) private balanceP; mapping (address => mapping (address => uint256)) private allowed; mapping (address => uint256[]) private lockTime; mapping (address => uint256[]) private lockValue; mapping (address => uint256) private lockNum; uint256 private later = 0; uint256 private earlier = 0; bool private mintable_ = true; // burn token event event Burn(address indexed _from, uint256 _value); // mint token event event Mint(address indexed _to, uint256 _value); // timelock-related events event TransferLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value); event TokenUnlocked(address indexed _address, uint256 _value); // safety method-related events event WrongTokenEmptied(address indexed _token, address indexed _addr, uint256 _amount); event WrongEtherEmptied(address indexed _addr, uint256 _amount); // constructor for the ERC20 Token constructor() public { balanceP[msg.sender] = totalSupply_; } modifier validAddress(address _address) { require(_address != 0x0); _; } modifier isMintable() { require(mintable_); _; } // fast-forward the timelocks for all accounts function setUnlockEarlier(uint256 _earlier) public onlyOwner { earlier = earlier.add(_earlier); } // delay the timelocks for all accounts function setUnlockLater(uint256 _later) public onlyOwner { later = later.add(_later); } // owner may permanently disable minting function disableMint() public onlyOwner isMintable { mintable_ = false; } // show if the token is still mintable function mintable() public view returns (bool) { return mintable_; } // standard ERC20 name function function name() public view returns (string) { return name_; } // standard ERC20 symbol function function symbol() public view returns (string) { return symbol_; } // standard ERC20 decimals function function decimals() public view returns (uint8) { return decimals_; } // standard ERC20 totalSupply function function totalSupply() public view returns (uint256) { return totalSupply_; } // standard ERC20 allowance function function allowance(address _owner, address _spender) external view returns (uint256) { return allowed[_owner][_spender]; } // show unlocked balance of an account function balanceUnlocked(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) >= lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocked balance of an account function balanceLocked(address _address) public view returns (uint256 _balance) { _balance = 0; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) < lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // standard ERC20 balanceOf with timelock added function balanceOf(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocks in an account function showLockTimes(address _address) public view validAddress(_address) returns (uint256[] _times) { uint i = 0; uint256[] memory tempLockTime = new uint256[](lockNum[_address]); while (i < lockNum[_address]) { tempLockTime[i] = lockTime[_address][i].add(later).sub(earlier); i++; } return tempLockTime; } // show values locked in an account's timelocks function showLockValues(address _address) public view validAddress(_address) returns (uint256[] _values) { return lockValue[_address]; } function showLockNum(address _address) public view validAddress(_address) returns (uint256 _lockNum) { return lockNum[_address]; } // Calculate and process the timelock states of an account function calcUnlock(address _address) private { uint256 i = 0; uint256 j = 0; uint256[] memory currentLockTime; uint256[] memory currentLockValue; uint256[] memory newLockTime = new uint256[](lockNum[_address]); uint256[] memory newLockValue = new uint256[](lockNum[_address]); currentLockTime = lockTime[_address]; currentLockValue = lockValue[_address]; while (i < lockNum[_address]) { if (now.add(earlier) >= currentLockTime[i].add(later)) { balanceP[_address] = balanceP[_address].add(currentLockValue[i]); emit TokenUnlocked(_address, currentLockValue[i]); } else { newLockTime[j] = currentLockTime[i]; newLockValue[j] = currentLockValue[i]; j++; } i++; } uint256[] memory trimLockTime = new uint256[](j); uint256[] memory trimLockValue = new uint256[](j); i = 0; while (i < j) { trimLockTime[i] = newLockTime[i]; trimLockValue[i] = newLockValue[i]; i++; } lockTime[_address] = trimLockTime; lockValue[_address] = trimLockValue; lockNum[_address] = j; } // standard ERC20 transfer function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // transfer Token with timelocks function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool _success) { require(_value.length == _time.length); if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[msg.sender] >= totalValue && totalValue >= 0); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[msg.sender] = balanceP[msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(msg.sender, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(msg.sender, _to, _value[i]); i++; } return true; } // TransferFrom Token with timelocks function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public validAddress(_from) validAddress(_to) returns (bool success) { require(_value.length == _time.length); if (lockNum[_from] > 0) calcUnlock(_from); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[_from] >= totalValue && totalValue >= 0 && allowed[_from][msg.sender] >= totalValue); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[_from] = balanceP[_from].sub(_value[i]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(_from, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(_from, _to, _value[i]); i++; } return true; } // standard ERC20 transferFrom function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool _success) { if (lockNum[_from] > 0) calcUnlock(_from); require(balanceP[_from] >= _value && _value >= 0 && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balanceP[_from] = balanceP[_from].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(_from, _to, _value); return true; } // should only be called when first setting an allowed function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // increase or decrease allowed function increaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { if(_value >= allowed[msg.sender][_spender]) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_value); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // owner may burn own token function burn(uint256 _value) public onlyOwner returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } // owner may mint new token and increase total supply function mint(uint256 _value) public onlyOwner isMintable returns (bool _success) { balanceP[msg.sender] = balanceP[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); emit Mint(msg.sender, _value); return true; } // safety methods function () public payable { revert(); } function emptyWrongToken(address _addr) onlyOwner public { ERC20Token wrongToken = ERC20Token(_addr); uint256 amount = wrongToken.balanceOf(address(this)); require(amount > 0); require(wrongToken.transfer(msg.sender, amount)); emit WrongTokenEmptied(_addr, msg.sender, amount); } // shouldn't happen, just in case function emptyWrongEther() onlyOwner public { uint256 amount = address(this).balance; require(amount > 0); msg.sender.transfer(amount); emit WrongEtherEmptied(msg.sender, amount); } }
// the main ERC20-compliant multi-timelock enabled contract
LineComment
balanceUnlocked
function balanceUnlocked(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) >= lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; }
// show unlocked balance of an account
LineComment
v0.4.26+commit.4563c3fc
bzzr://0db19956575b13220b4f08b353bc03ba65f05ac41f0203c4a9f88831c40d3012
{ "func_code_index": [ 3028, 3403 ] }
1,246
BRMP
BRMP.sol
0xea3b77d0322b427453300df08f23ee6c071aaebc
Solidity
BRMP
contract BRMP is Owned, ERC20Token { using SafeMath for uint256; string private constant standard = "201907043306"; string private constant version = "6.0663688"; string private name_ = "Borrme Points"; string private symbol_ = "BRMP"; uint8 private decimals_ = 18; uint256 private totalSupply_ = uint256(100) * uint256(10)**uint256(8) * uint256(10)**uint256(decimals_); mapping (address => uint256) private balanceP; mapping (address => mapping (address => uint256)) private allowed; mapping (address => uint256[]) private lockTime; mapping (address => uint256[]) private lockValue; mapping (address => uint256) private lockNum; uint256 private later = 0; uint256 private earlier = 0; bool private mintable_ = true; // burn token event event Burn(address indexed _from, uint256 _value); // mint token event event Mint(address indexed _to, uint256 _value); // timelock-related events event TransferLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value); event TokenUnlocked(address indexed _address, uint256 _value); // safety method-related events event WrongTokenEmptied(address indexed _token, address indexed _addr, uint256 _amount); event WrongEtherEmptied(address indexed _addr, uint256 _amount); // constructor for the ERC20 Token constructor() public { balanceP[msg.sender] = totalSupply_; } modifier validAddress(address _address) { require(_address != 0x0); _; } modifier isMintable() { require(mintable_); _; } // fast-forward the timelocks for all accounts function setUnlockEarlier(uint256 _earlier) public onlyOwner { earlier = earlier.add(_earlier); } // delay the timelocks for all accounts function setUnlockLater(uint256 _later) public onlyOwner { later = later.add(_later); } // owner may permanently disable minting function disableMint() public onlyOwner isMintable { mintable_ = false; } // show if the token is still mintable function mintable() public view returns (bool) { return mintable_; } // standard ERC20 name function function name() public view returns (string) { return name_; } // standard ERC20 symbol function function symbol() public view returns (string) { return symbol_; } // standard ERC20 decimals function function decimals() public view returns (uint8) { return decimals_; } // standard ERC20 totalSupply function function totalSupply() public view returns (uint256) { return totalSupply_; } // standard ERC20 allowance function function allowance(address _owner, address _spender) external view returns (uint256) { return allowed[_owner][_spender]; } // show unlocked balance of an account function balanceUnlocked(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) >= lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocked balance of an account function balanceLocked(address _address) public view returns (uint256 _balance) { _balance = 0; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) < lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // standard ERC20 balanceOf with timelock added function balanceOf(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocks in an account function showLockTimes(address _address) public view validAddress(_address) returns (uint256[] _times) { uint i = 0; uint256[] memory tempLockTime = new uint256[](lockNum[_address]); while (i < lockNum[_address]) { tempLockTime[i] = lockTime[_address][i].add(later).sub(earlier); i++; } return tempLockTime; } // show values locked in an account's timelocks function showLockValues(address _address) public view validAddress(_address) returns (uint256[] _values) { return lockValue[_address]; } function showLockNum(address _address) public view validAddress(_address) returns (uint256 _lockNum) { return lockNum[_address]; } // Calculate and process the timelock states of an account function calcUnlock(address _address) private { uint256 i = 0; uint256 j = 0; uint256[] memory currentLockTime; uint256[] memory currentLockValue; uint256[] memory newLockTime = new uint256[](lockNum[_address]); uint256[] memory newLockValue = new uint256[](lockNum[_address]); currentLockTime = lockTime[_address]; currentLockValue = lockValue[_address]; while (i < lockNum[_address]) { if (now.add(earlier) >= currentLockTime[i].add(later)) { balanceP[_address] = balanceP[_address].add(currentLockValue[i]); emit TokenUnlocked(_address, currentLockValue[i]); } else { newLockTime[j] = currentLockTime[i]; newLockValue[j] = currentLockValue[i]; j++; } i++; } uint256[] memory trimLockTime = new uint256[](j); uint256[] memory trimLockValue = new uint256[](j); i = 0; while (i < j) { trimLockTime[i] = newLockTime[i]; trimLockValue[i] = newLockValue[i]; i++; } lockTime[_address] = trimLockTime; lockValue[_address] = trimLockValue; lockNum[_address] = j; } // standard ERC20 transfer function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // transfer Token with timelocks function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool _success) { require(_value.length == _time.length); if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[msg.sender] >= totalValue && totalValue >= 0); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[msg.sender] = balanceP[msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(msg.sender, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(msg.sender, _to, _value[i]); i++; } return true; } // TransferFrom Token with timelocks function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public validAddress(_from) validAddress(_to) returns (bool success) { require(_value.length == _time.length); if (lockNum[_from] > 0) calcUnlock(_from); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[_from] >= totalValue && totalValue >= 0 && allowed[_from][msg.sender] >= totalValue); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[_from] = balanceP[_from].sub(_value[i]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(_from, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(_from, _to, _value[i]); i++; } return true; } // standard ERC20 transferFrom function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool _success) { if (lockNum[_from] > 0) calcUnlock(_from); require(balanceP[_from] >= _value && _value >= 0 && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balanceP[_from] = balanceP[_from].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(_from, _to, _value); return true; } // should only be called when first setting an allowed function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // increase or decrease allowed function increaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { if(_value >= allowed[msg.sender][_spender]) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_value); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // owner may burn own token function burn(uint256 _value) public onlyOwner returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } // owner may mint new token and increase total supply function mint(uint256 _value) public onlyOwner isMintable returns (bool _success) { balanceP[msg.sender] = balanceP[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); emit Mint(msg.sender, _value); return true; } // safety methods function () public payable { revert(); } function emptyWrongToken(address _addr) onlyOwner public { ERC20Token wrongToken = ERC20Token(_addr); uint256 amount = wrongToken.balanceOf(address(this)); require(amount > 0); require(wrongToken.transfer(msg.sender, amount)); emit WrongTokenEmptied(_addr, msg.sender, amount); } // shouldn't happen, just in case function emptyWrongEther() onlyOwner public { uint256 amount = address(this).balance; require(amount > 0); msg.sender.transfer(amount); emit WrongEtherEmptied(msg.sender, amount); } }
// the main ERC20-compliant multi-timelock enabled contract
LineComment
balanceLocked
function balanceLocked(address _address) public view returns (uint256 _balance) { _balance = 0; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) < lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; }
// show timelocked balance of an account
LineComment
v0.4.26+commit.4563c3fc
bzzr://0db19956575b13220b4f08b353bc03ba65f05ac41f0203c4a9f88831c40d3012
{ "func_code_index": [ 3452, 3808 ] }
1,247
BRMP
BRMP.sol
0xea3b77d0322b427453300df08f23ee6c071aaebc
Solidity
BRMP
contract BRMP is Owned, ERC20Token { using SafeMath for uint256; string private constant standard = "201907043306"; string private constant version = "6.0663688"; string private name_ = "Borrme Points"; string private symbol_ = "BRMP"; uint8 private decimals_ = 18; uint256 private totalSupply_ = uint256(100) * uint256(10)**uint256(8) * uint256(10)**uint256(decimals_); mapping (address => uint256) private balanceP; mapping (address => mapping (address => uint256)) private allowed; mapping (address => uint256[]) private lockTime; mapping (address => uint256[]) private lockValue; mapping (address => uint256) private lockNum; uint256 private later = 0; uint256 private earlier = 0; bool private mintable_ = true; // burn token event event Burn(address indexed _from, uint256 _value); // mint token event event Mint(address indexed _to, uint256 _value); // timelock-related events event TransferLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value); event TokenUnlocked(address indexed _address, uint256 _value); // safety method-related events event WrongTokenEmptied(address indexed _token, address indexed _addr, uint256 _amount); event WrongEtherEmptied(address indexed _addr, uint256 _amount); // constructor for the ERC20 Token constructor() public { balanceP[msg.sender] = totalSupply_; } modifier validAddress(address _address) { require(_address != 0x0); _; } modifier isMintable() { require(mintable_); _; } // fast-forward the timelocks for all accounts function setUnlockEarlier(uint256 _earlier) public onlyOwner { earlier = earlier.add(_earlier); } // delay the timelocks for all accounts function setUnlockLater(uint256 _later) public onlyOwner { later = later.add(_later); } // owner may permanently disable minting function disableMint() public onlyOwner isMintable { mintable_ = false; } // show if the token is still mintable function mintable() public view returns (bool) { return mintable_; } // standard ERC20 name function function name() public view returns (string) { return name_; } // standard ERC20 symbol function function symbol() public view returns (string) { return symbol_; } // standard ERC20 decimals function function decimals() public view returns (uint8) { return decimals_; } // standard ERC20 totalSupply function function totalSupply() public view returns (uint256) { return totalSupply_; } // standard ERC20 allowance function function allowance(address _owner, address _spender) external view returns (uint256) { return allowed[_owner][_spender]; } // show unlocked balance of an account function balanceUnlocked(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) >= lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocked balance of an account function balanceLocked(address _address) public view returns (uint256 _balance) { _balance = 0; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) < lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // standard ERC20 balanceOf with timelock added function balanceOf(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocks in an account function showLockTimes(address _address) public view validAddress(_address) returns (uint256[] _times) { uint i = 0; uint256[] memory tempLockTime = new uint256[](lockNum[_address]); while (i < lockNum[_address]) { tempLockTime[i] = lockTime[_address][i].add(later).sub(earlier); i++; } return tempLockTime; } // show values locked in an account's timelocks function showLockValues(address _address) public view validAddress(_address) returns (uint256[] _values) { return lockValue[_address]; } function showLockNum(address _address) public view validAddress(_address) returns (uint256 _lockNum) { return lockNum[_address]; } // Calculate and process the timelock states of an account function calcUnlock(address _address) private { uint256 i = 0; uint256 j = 0; uint256[] memory currentLockTime; uint256[] memory currentLockValue; uint256[] memory newLockTime = new uint256[](lockNum[_address]); uint256[] memory newLockValue = new uint256[](lockNum[_address]); currentLockTime = lockTime[_address]; currentLockValue = lockValue[_address]; while (i < lockNum[_address]) { if (now.add(earlier) >= currentLockTime[i].add(later)) { balanceP[_address] = balanceP[_address].add(currentLockValue[i]); emit TokenUnlocked(_address, currentLockValue[i]); } else { newLockTime[j] = currentLockTime[i]; newLockValue[j] = currentLockValue[i]; j++; } i++; } uint256[] memory trimLockTime = new uint256[](j); uint256[] memory trimLockValue = new uint256[](j); i = 0; while (i < j) { trimLockTime[i] = newLockTime[i]; trimLockValue[i] = newLockValue[i]; i++; } lockTime[_address] = trimLockTime; lockValue[_address] = trimLockValue; lockNum[_address] = j; } // standard ERC20 transfer function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // transfer Token with timelocks function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool _success) { require(_value.length == _time.length); if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[msg.sender] >= totalValue && totalValue >= 0); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[msg.sender] = balanceP[msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(msg.sender, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(msg.sender, _to, _value[i]); i++; } return true; } // TransferFrom Token with timelocks function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public validAddress(_from) validAddress(_to) returns (bool success) { require(_value.length == _time.length); if (lockNum[_from] > 0) calcUnlock(_from); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[_from] >= totalValue && totalValue >= 0 && allowed[_from][msg.sender] >= totalValue); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[_from] = balanceP[_from].sub(_value[i]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(_from, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(_from, _to, _value[i]); i++; } return true; } // standard ERC20 transferFrom function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool _success) { if (lockNum[_from] > 0) calcUnlock(_from); require(balanceP[_from] >= _value && _value >= 0 && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balanceP[_from] = balanceP[_from].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(_from, _to, _value); return true; } // should only be called when first setting an allowed function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // increase or decrease allowed function increaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { if(_value >= allowed[msg.sender][_spender]) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_value); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // owner may burn own token function burn(uint256 _value) public onlyOwner returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } // owner may mint new token and increase total supply function mint(uint256 _value) public onlyOwner isMintable returns (bool _success) { balanceP[msg.sender] = balanceP[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); emit Mint(msg.sender, _value); return true; } // safety methods function () public payable { revert(); } function emptyWrongToken(address _addr) onlyOwner public { ERC20Token wrongToken = ERC20Token(_addr); uint256 amount = wrongToken.balanceOf(address(this)); require(amount > 0); require(wrongToken.transfer(msg.sender, amount)); emit WrongTokenEmptied(_addr, msg.sender, amount); } // shouldn't happen, just in case function emptyWrongEther() onlyOwner public { uint256 amount = address(this).balance; require(amount > 0); msg.sender.transfer(amount); emit WrongEtherEmptied(msg.sender, amount); } }
// the main ERC20-compliant multi-timelock enabled contract
LineComment
balanceOf
function balanceOf(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; }
// standard ERC20 balanceOf with timelock added
LineComment
v0.4.26+commit.4563c3fc
bzzr://0db19956575b13220b4f08b353bc03ba65f05ac41f0203c4a9f88831c40d3012
{ "func_code_index": [ 3864, 4175 ] }
1,248
BRMP
BRMP.sol
0xea3b77d0322b427453300df08f23ee6c071aaebc
Solidity
BRMP
contract BRMP is Owned, ERC20Token { using SafeMath for uint256; string private constant standard = "201907043306"; string private constant version = "6.0663688"; string private name_ = "Borrme Points"; string private symbol_ = "BRMP"; uint8 private decimals_ = 18; uint256 private totalSupply_ = uint256(100) * uint256(10)**uint256(8) * uint256(10)**uint256(decimals_); mapping (address => uint256) private balanceP; mapping (address => mapping (address => uint256)) private allowed; mapping (address => uint256[]) private lockTime; mapping (address => uint256[]) private lockValue; mapping (address => uint256) private lockNum; uint256 private later = 0; uint256 private earlier = 0; bool private mintable_ = true; // burn token event event Burn(address indexed _from, uint256 _value); // mint token event event Mint(address indexed _to, uint256 _value); // timelock-related events event TransferLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value); event TokenUnlocked(address indexed _address, uint256 _value); // safety method-related events event WrongTokenEmptied(address indexed _token, address indexed _addr, uint256 _amount); event WrongEtherEmptied(address indexed _addr, uint256 _amount); // constructor for the ERC20 Token constructor() public { balanceP[msg.sender] = totalSupply_; } modifier validAddress(address _address) { require(_address != 0x0); _; } modifier isMintable() { require(mintable_); _; } // fast-forward the timelocks for all accounts function setUnlockEarlier(uint256 _earlier) public onlyOwner { earlier = earlier.add(_earlier); } // delay the timelocks for all accounts function setUnlockLater(uint256 _later) public onlyOwner { later = later.add(_later); } // owner may permanently disable minting function disableMint() public onlyOwner isMintable { mintable_ = false; } // show if the token is still mintable function mintable() public view returns (bool) { return mintable_; } // standard ERC20 name function function name() public view returns (string) { return name_; } // standard ERC20 symbol function function symbol() public view returns (string) { return symbol_; } // standard ERC20 decimals function function decimals() public view returns (uint8) { return decimals_; } // standard ERC20 totalSupply function function totalSupply() public view returns (uint256) { return totalSupply_; } // standard ERC20 allowance function function allowance(address _owner, address _spender) external view returns (uint256) { return allowed[_owner][_spender]; } // show unlocked balance of an account function balanceUnlocked(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) >= lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocked balance of an account function balanceLocked(address _address) public view returns (uint256 _balance) { _balance = 0; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) < lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // standard ERC20 balanceOf with timelock added function balanceOf(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocks in an account function showLockTimes(address _address) public view validAddress(_address) returns (uint256[] _times) { uint i = 0; uint256[] memory tempLockTime = new uint256[](lockNum[_address]); while (i < lockNum[_address]) { tempLockTime[i] = lockTime[_address][i].add(later).sub(earlier); i++; } return tempLockTime; } // show values locked in an account's timelocks function showLockValues(address _address) public view validAddress(_address) returns (uint256[] _values) { return lockValue[_address]; } function showLockNum(address _address) public view validAddress(_address) returns (uint256 _lockNum) { return lockNum[_address]; } // Calculate and process the timelock states of an account function calcUnlock(address _address) private { uint256 i = 0; uint256 j = 0; uint256[] memory currentLockTime; uint256[] memory currentLockValue; uint256[] memory newLockTime = new uint256[](lockNum[_address]); uint256[] memory newLockValue = new uint256[](lockNum[_address]); currentLockTime = lockTime[_address]; currentLockValue = lockValue[_address]; while (i < lockNum[_address]) { if (now.add(earlier) >= currentLockTime[i].add(later)) { balanceP[_address] = balanceP[_address].add(currentLockValue[i]); emit TokenUnlocked(_address, currentLockValue[i]); } else { newLockTime[j] = currentLockTime[i]; newLockValue[j] = currentLockValue[i]; j++; } i++; } uint256[] memory trimLockTime = new uint256[](j); uint256[] memory trimLockValue = new uint256[](j); i = 0; while (i < j) { trimLockTime[i] = newLockTime[i]; trimLockValue[i] = newLockValue[i]; i++; } lockTime[_address] = trimLockTime; lockValue[_address] = trimLockValue; lockNum[_address] = j; } // standard ERC20 transfer function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // transfer Token with timelocks function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool _success) { require(_value.length == _time.length); if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[msg.sender] >= totalValue && totalValue >= 0); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[msg.sender] = balanceP[msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(msg.sender, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(msg.sender, _to, _value[i]); i++; } return true; } // TransferFrom Token with timelocks function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public validAddress(_from) validAddress(_to) returns (bool success) { require(_value.length == _time.length); if (lockNum[_from] > 0) calcUnlock(_from); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[_from] >= totalValue && totalValue >= 0 && allowed[_from][msg.sender] >= totalValue); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[_from] = balanceP[_from].sub(_value[i]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(_from, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(_from, _to, _value[i]); i++; } return true; } // standard ERC20 transferFrom function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool _success) { if (lockNum[_from] > 0) calcUnlock(_from); require(balanceP[_from] >= _value && _value >= 0 && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balanceP[_from] = balanceP[_from].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(_from, _to, _value); return true; } // should only be called when first setting an allowed function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // increase or decrease allowed function increaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { if(_value >= allowed[msg.sender][_spender]) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_value); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // owner may burn own token function burn(uint256 _value) public onlyOwner returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } // owner may mint new token and increase total supply function mint(uint256 _value) public onlyOwner isMintable returns (bool _success) { balanceP[msg.sender] = balanceP[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); emit Mint(msg.sender, _value); return true; } // safety methods function () public payable { revert(); } function emptyWrongToken(address _addr) onlyOwner public { ERC20Token wrongToken = ERC20Token(_addr); uint256 amount = wrongToken.balanceOf(address(this)); require(amount > 0); require(wrongToken.transfer(msg.sender, amount)); emit WrongTokenEmptied(_addr, msg.sender, amount); } // shouldn't happen, just in case function emptyWrongEther() onlyOwner public { uint256 amount = address(this).balance; require(amount > 0); msg.sender.transfer(amount); emit WrongEtherEmptied(msg.sender, amount); } }
// the main ERC20-compliant multi-timelock enabled contract
LineComment
showLockTimes
function showLockTimes(address _address) public view validAddress(_address) returns (uint256[] _times) { uint i = 0; uint256[] memory tempLockTime = new uint256[](lockNum[_address]); while (i < lockNum[_address]) { tempLockTime[i] = lockTime[_address][i].add(later).sub(earlier); i++; } return tempLockTime; }
// show timelocks in an account
LineComment
v0.4.26+commit.4563c3fc
bzzr://0db19956575b13220b4f08b353bc03ba65f05ac41f0203c4a9f88831c40d3012
{ "func_code_index": [ 4215, 4605 ] }
1,249
BRMP
BRMP.sol
0xea3b77d0322b427453300df08f23ee6c071aaebc
Solidity
BRMP
contract BRMP is Owned, ERC20Token { using SafeMath for uint256; string private constant standard = "201907043306"; string private constant version = "6.0663688"; string private name_ = "Borrme Points"; string private symbol_ = "BRMP"; uint8 private decimals_ = 18; uint256 private totalSupply_ = uint256(100) * uint256(10)**uint256(8) * uint256(10)**uint256(decimals_); mapping (address => uint256) private balanceP; mapping (address => mapping (address => uint256)) private allowed; mapping (address => uint256[]) private lockTime; mapping (address => uint256[]) private lockValue; mapping (address => uint256) private lockNum; uint256 private later = 0; uint256 private earlier = 0; bool private mintable_ = true; // burn token event event Burn(address indexed _from, uint256 _value); // mint token event event Mint(address indexed _to, uint256 _value); // timelock-related events event TransferLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value); event TokenUnlocked(address indexed _address, uint256 _value); // safety method-related events event WrongTokenEmptied(address indexed _token, address indexed _addr, uint256 _amount); event WrongEtherEmptied(address indexed _addr, uint256 _amount); // constructor for the ERC20 Token constructor() public { balanceP[msg.sender] = totalSupply_; } modifier validAddress(address _address) { require(_address != 0x0); _; } modifier isMintable() { require(mintable_); _; } // fast-forward the timelocks for all accounts function setUnlockEarlier(uint256 _earlier) public onlyOwner { earlier = earlier.add(_earlier); } // delay the timelocks for all accounts function setUnlockLater(uint256 _later) public onlyOwner { later = later.add(_later); } // owner may permanently disable minting function disableMint() public onlyOwner isMintable { mintable_ = false; } // show if the token is still mintable function mintable() public view returns (bool) { return mintable_; } // standard ERC20 name function function name() public view returns (string) { return name_; } // standard ERC20 symbol function function symbol() public view returns (string) { return symbol_; } // standard ERC20 decimals function function decimals() public view returns (uint8) { return decimals_; } // standard ERC20 totalSupply function function totalSupply() public view returns (uint256) { return totalSupply_; } // standard ERC20 allowance function function allowance(address _owner, address _spender) external view returns (uint256) { return allowed[_owner][_spender]; } // show unlocked balance of an account function balanceUnlocked(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) >= lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocked balance of an account function balanceLocked(address _address) public view returns (uint256 _balance) { _balance = 0; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) < lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // standard ERC20 balanceOf with timelock added function balanceOf(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocks in an account function showLockTimes(address _address) public view validAddress(_address) returns (uint256[] _times) { uint i = 0; uint256[] memory tempLockTime = new uint256[](lockNum[_address]); while (i < lockNum[_address]) { tempLockTime[i] = lockTime[_address][i].add(later).sub(earlier); i++; } return tempLockTime; } // show values locked in an account's timelocks function showLockValues(address _address) public view validAddress(_address) returns (uint256[] _values) { return lockValue[_address]; } function showLockNum(address _address) public view validAddress(_address) returns (uint256 _lockNum) { return lockNum[_address]; } // Calculate and process the timelock states of an account function calcUnlock(address _address) private { uint256 i = 0; uint256 j = 0; uint256[] memory currentLockTime; uint256[] memory currentLockValue; uint256[] memory newLockTime = new uint256[](lockNum[_address]); uint256[] memory newLockValue = new uint256[](lockNum[_address]); currentLockTime = lockTime[_address]; currentLockValue = lockValue[_address]; while (i < lockNum[_address]) { if (now.add(earlier) >= currentLockTime[i].add(later)) { balanceP[_address] = balanceP[_address].add(currentLockValue[i]); emit TokenUnlocked(_address, currentLockValue[i]); } else { newLockTime[j] = currentLockTime[i]; newLockValue[j] = currentLockValue[i]; j++; } i++; } uint256[] memory trimLockTime = new uint256[](j); uint256[] memory trimLockValue = new uint256[](j); i = 0; while (i < j) { trimLockTime[i] = newLockTime[i]; trimLockValue[i] = newLockValue[i]; i++; } lockTime[_address] = trimLockTime; lockValue[_address] = trimLockValue; lockNum[_address] = j; } // standard ERC20 transfer function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // transfer Token with timelocks function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool _success) { require(_value.length == _time.length); if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[msg.sender] >= totalValue && totalValue >= 0); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[msg.sender] = balanceP[msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(msg.sender, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(msg.sender, _to, _value[i]); i++; } return true; } // TransferFrom Token with timelocks function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public validAddress(_from) validAddress(_to) returns (bool success) { require(_value.length == _time.length); if (lockNum[_from] > 0) calcUnlock(_from); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[_from] >= totalValue && totalValue >= 0 && allowed[_from][msg.sender] >= totalValue); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[_from] = balanceP[_from].sub(_value[i]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(_from, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(_from, _to, _value[i]); i++; } return true; } // standard ERC20 transferFrom function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool _success) { if (lockNum[_from] > 0) calcUnlock(_from); require(balanceP[_from] >= _value && _value >= 0 && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balanceP[_from] = balanceP[_from].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(_from, _to, _value); return true; } // should only be called when first setting an allowed function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // increase or decrease allowed function increaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { if(_value >= allowed[msg.sender][_spender]) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_value); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // owner may burn own token function burn(uint256 _value) public onlyOwner returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } // owner may mint new token and increase total supply function mint(uint256 _value) public onlyOwner isMintable returns (bool _success) { balanceP[msg.sender] = balanceP[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); emit Mint(msg.sender, _value); return true; } // safety methods function () public payable { revert(); } function emptyWrongToken(address _addr) onlyOwner public { ERC20Token wrongToken = ERC20Token(_addr); uint256 amount = wrongToken.balanceOf(address(this)); require(amount > 0); require(wrongToken.transfer(msg.sender, amount)); emit WrongTokenEmptied(_addr, msg.sender, amount); } // shouldn't happen, just in case function emptyWrongEther() onlyOwner public { uint256 amount = address(this).balance; require(amount > 0); msg.sender.transfer(amount); emit WrongEtherEmptied(msg.sender, amount); } }
// the main ERC20-compliant multi-timelock enabled contract
LineComment
showLockValues
function showLockValues(address _address) public view validAddress(_address) returns (uint256[] _values) { return lockValue[_address]; }
// show values locked in an account's timelocks
LineComment
v0.4.26+commit.4563c3fc
bzzr://0db19956575b13220b4f08b353bc03ba65f05ac41f0203c4a9f88831c40d3012
{ "func_code_index": [ 4661, 4816 ] }
1,250
BRMP
BRMP.sol
0xea3b77d0322b427453300df08f23ee6c071aaebc
Solidity
BRMP
contract BRMP is Owned, ERC20Token { using SafeMath for uint256; string private constant standard = "201907043306"; string private constant version = "6.0663688"; string private name_ = "Borrme Points"; string private symbol_ = "BRMP"; uint8 private decimals_ = 18; uint256 private totalSupply_ = uint256(100) * uint256(10)**uint256(8) * uint256(10)**uint256(decimals_); mapping (address => uint256) private balanceP; mapping (address => mapping (address => uint256)) private allowed; mapping (address => uint256[]) private lockTime; mapping (address => uint256[]) private lockValue; mapping (address => uint256) private lockNum; uint256 private later = 0; uint256 private earlier = 0; bool private mintable_ = true; // burn token event event Burn(address indexed _from, uint256 _value); // mint token event event Mint(address indexed _to, uint256 _value); // timelock-related events event TransferLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value); event TokenUnlocked(address indexed _address, uint256 _value); // safety method-related events event WrongTokenEmptied(address indexed _token, address indexed _addr, uint256 _amount); event WrongEtherEmptied(address indexed _addr, uint256 _amount); // constructor for the ERC20 Token constructor() public { balanceP[msg.sender] = totalSupply_; } modifier validAddress(address _address) { require(_address != 0x0); _; } modifier isMintable() { require(mintable_); _; } // fast-forward the timelocks for all accounts function setUnlockEarlier(uint256 _earlier) public onlyOwner { earlier = earlier.add(_earlier); } // delay the timelocks for all accounts function setUnlockLater(uint256 _later) public onlyOwner { later = later.add(_later); } // owner may permanently disable minting function disableMint() public onlyOwner isMintable { mintable_ = false; } // show if the token is still mintable function mintable() public view returns (bool) { return mintable_; } // standard ERC20 name function function name() public view returns (string) { return name_; } // standard ERC20 symbol function function symbol() public view returns (string) { return symbol_; } // standard ERC20 decimals function function decimals() public view returns (uint8) { return decimals_; } // standard ERC20 totalSupply function function totalSupply() public view returns (uint256) { return totalSupply_; } // standard ERC20 allowance function function allowance(address _owner, address _spender) external view returns (uint256) { return allowed[_owner][_spender]; } // show unlocked balance of an account function balanceUnlocked(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) >= lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocked balance of an account function balanceLocked(address _address) public view returns (uint256 _balance) { _balance = 0; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) < lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // standard ERC20 balanceOf with timelock added function balanceOf(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocks in an account function showLockTimes(address _address) public view validAddress(_address) returns (uint256[] _times) { uint i = 0; uint256[] memory tempLockTime = new uint256[](lockNum[_address]); while (i < lockNum[_address]) { tempLockTime[i] = lockTime[_address][i].add(later).sub(earlier); i++; } return tempLockTime; } // show values locked in an account's timelocks function showLockValues(address _address) public view validAddress(_address) returns (uint256[] _values) { return lockValue[_address]; } function showLockNum(address _address) public view validAddress(_address) returns (uint256 _lockNum) { return lockNum[_address]; } // Calculate and process the timelock states of an account function calcUnlock(address _address) private { uint256 i = 0; uint256 j = 0; uint256[] memory currentLockTime; uint256[] memory currentLockValue; uint256[] memory newLockTime = new uint256[](lockNum[_address]); uint256[] memory newLockValue = new uint256[](lockNum[_address]); currentLockTime = lockTime[_address]; currentLockValue = lockValue[_address]; while (i < lockNum[_address]) { if (now.add(earlier) >= currentLockTime[i].add(later)) { balanceP[_address] = balanceP[_address].add(currentLockValue[i]); emit TokenUnlocked(_address, currentLockValue[i]); } else { newLockTime[j] = currentLockTime[i]; newLockValue[j] = currentLockValue[i]; j++; } i++; } uint256[] memory trimLockTime = new uint256[](j); uint256[] memory trimLockValue = new uint256[](j); i = 0; while (i < j) { trimLockTime[i] = newLockTime[i]; trimLockValue[i] = newLockValue[i]; i++; } lockTime[_address] = trimLockTime; lockValue[_address] = trimLockValue; lockNum[_address] = j; } // standard ERC20 transfer function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // transfer Token with timelocks function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool _success) { require(_value.length == _time.length); if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[msg.sender] >= totalValue && totalValue >= 0); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[msg.sender] = balanceP[msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(msg.sender, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(msg.sender, _to, _value[i]); i++; } return true; } // TransferFrom Token with timelocks function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public validAddress(_from) validAddress(_to) returns (bool success) { require(_value.length == _time.length); if (lockNum[_from] > 0) calcUnlock(_from); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[_from] >= totalValue && totalValue >= 0 && allowed[_from][msg.sender] >= totalValue); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[_from] = balanceP[_from].sub(_value[i]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(_from, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(_from, _to, _value[i]); i++; } return true; } // standard ERC20 transferFrom function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool _success) { if (lockNum[_from] > 0) calcUnlock(_from); require(balanceP[_from] >= _value && _value >= 0 && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balanceP[_from] = balanceP[_from].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(_from, _to, _value); return true; } // should only be called when first setting an allowed function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // increase or decrease allowed function increaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { if(_value >= allowed[msg.sender][_spender]) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_value); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // owner may burn own token function burn(uint256 _value) public onlyOwner returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } // owner may mint new token and increase total supply function mint(uint256 _value) public onlyOwner isMintable returns (bool _success) { balanceP[msg.sender] = balanceP[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); emit Mint(msg.sender, _value); return true; } // safety methods function () public payable { revert(); } function emptyWrongToken(address _addr) onlyOwner public { ERC20Token wrongToken = ERC20Token(_addr); uint256 amount = wrongToken.balanceOf(address(this)); require(amount > 0); require(wrongToken.transfer(msg.sender, amount)); emit WrongTokenEmptied(_addr, msg.sender, amount); } // shouldn't happen, just in case function emptyWrongEther() onlyOwner public { uint256 amount = address(this).balance; require(amount > 0); msg.sender.transfer(amount); emit WrongEtherEmptied(msg.sender, amount); } }
// the main ERC20-compliant multi-timelock enabled contract
LineComment
calcUnlock
function calcUnlock(address _address) private { uint256 i = 0; uint256 j = 0; uint256[] memory currentLockTime; uint256[] memory currentLockValue; uint256[] memory newLockTime = new uint256[](lockNum[_address]); uint256[] memory newLockValue = new uint256[](lockNum[_address]); currentLockTime = lockTime[_address]; currentLockValue = lockValue[_address]; while (i < lockNum[_address]) { if (now.add(earlier) >= currentLockTime[i].add(later)) { balanceP[_address] = balanceP[_address].add(currentLockValue[i]); emit TokenUnlocked(_address, currentLockValue[i]); } else { newLockTime[j] = currentLockTime[i]; newLockValue[j] = currentLockValue[i]; j++; } i++; } uint256[] memory trimLockTime = new uint256[](j); uint256[] memory trimLockValue = new uint256[](j); i = 0; while (i < j) { trimLockTime[i] = newLockTime[i]; trimLockValue[i] = newLockValue[i]; i++; } lockTime[_address] = trimLockTime; lockValue[_address] = trimLockValue; lockNum[_address] = j; }
// Calculate and process the timelock states of an account
LineComment
v0.4.26+commit.4563c3fc
bzzr://0db19956575b13220b4f08b353bc03ba65f05ac41f0203c4a9f88831c40d3012
{ "func_code_index": [ 5035, 6341 ] }
1,251
BRMP
BRMP.sol
0xea3b77d0322b427453300df08f23ee6c071aaebc
Solidity
BRMP
contract BRMP is Owned, ERC20Token { using SafeMath for uint256; string private constant standard = "201907043306"; string private constant version = "6.0663688"; string private name_ = "Borrme Points"; string private symbol_ = "BRMP"; uint8 private decimals_ = 18; uint256 private totalSupply_ = uint256(100) * uint256(10)**uint256(8) * uint256(10)**uint256(decimals_); mapping (address => uint256) private balanceP; mapping (address => mapping (address => uint256)) private allowed; mapping (address => uint256[]) private lockTime; mapping (address => uint256[]) private lockValue; mapping (address => uint256) private lockNum; uint256 private later = 0; uint256 private earlier = 0; bool private mintable_ = true; // burn token event event Burn(address indexed _from, uint256 _value); // mint token event event Mint(address indexed _to, uint256 _value); // timelock-related events event TransferLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value); event TokenUnlocked(address indexed _address, uint256 _value); // safety method-related events event WrongTokenEmptied(address indexed _token, address indexed _addr, uint256 _amount); event WrongEtherEmptied(address indexed _addr, uint256 _amount); // constructor for the ERC20 Token constructor() public { balanceP[msg.sender] = totalSupply_; } modifier validAddress(address _address) { require(_address != 0x0); _; } modifier isMintable() { require(mintable_); _; } // fast-forward the timelocks for all accounts function setUnlockEarlier(uint256 _earlier) public onlyOwner { earlier = earlier.add(_earlier); } // delay the timelocks for all accounts function setUnlockLater(uint256 _later) public onlyOwner { later = later.add(_later); } // owner may permanently disable minting function disableMint() public onlyOwner isMintable { mintable_ = false; } // show if the token is still mintable function mintable() public view returns (bool) { return mintable_; } // standard ERC20 name function function name() public view returns (string) { return name_; } // standard ERC20 symbol function function symbol() public view returns (string) { return symbol_; } // standard ERC20 decimals function function decimals() public view returns (uint8) { return decimals_; } // standard ERC20 totalSupply function function totalSupply() public view returns (uint256) { return totalSupply_; } // standard ERC20 allowance function function allowance(address _owner, address _spender) external view returns (uint256) { return allowed[_owner][_spender]; } // show unlocked balance of an account function balanceUnlocked(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) >= lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocked balance of an account function balanceLocked(address _address) public view returns (uint256 _balance) { _balance = 0; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) < lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // standard ERC20 balanceOf with timelock added function balanceOf(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocks in an account function showLockTimes(address _address) public view validAddress(_address) returns (uint256[] _times) { uint i = 0; uint256[] memory tempLockTime = new uint256[](lockNum[_address]); while (i < lockNum[_address]) { tempLockTime[i] = lockTime[_address][i].add(later).sub(earlier); i++; } return tempLockTime; } // show values locked in an account's timelocks function showLockValues(address _address) public view validAddress(_address) returns (uint256[] _values) { return lockValue[_address]; } function showLockNum(address _address) public view validAddress(_address) returns (uint256 _lockNum) { return lockNum[_address]; } // Calculate and process the timelock states of an account function calcUnlock(address _address) private { uint256 i = 0; uint256 j = 0; uint256[] memory currentLockTime; uint256[] memory currentLockValue; uint256[] memory newLockTime = new uint256[](lockNum[_address]); uint256[] memory newLockValue = new uint256[](lockNum[_address]); currentLockTime = lockTime[_address]; currentLockValue = lockValue[_address]; while (i < lockNum[_address]) { if (now.add(earlier) >= currentLockTime[i].add(later)) { balanceP[_address] = balanceP[_address].add(currentLockValue[i]); emit TokenUnlocked(_address, currentLockValue[i]); } else { newLockTime[j] = currentLockTime[i]; newLockValue[j] = currentLockValue[i]; j++; } i++; } uint256[] memory trimLockTime = new uint256[](j); uint256[] memory trimLockValue = new uint256[](j); i = 0; while (i < j) { trimLockTime[i] = newLockTime[i]; trimLockValue[i] = newLockValue[i]; i++; } lockTime[_address] = trimLockTime; lockValue[_address] = trimLockValue; lockNum[_address] = j; } // standard ERC20 transfer function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // transfer Token with timelocks function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool _success) { require(_value.length == _time.length); if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[msg.sender] >= totalValue && totalValue >= 0); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[msg.sender] = balanceP[msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(msg.sender, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(msg.sender, _to, _value[i]); i++; } return true; } // TransferFrom Token with timelocks function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public validAddress(_from) validAddress(_to) returns (bool success) { require(_value.length == _time.length); if (lockNum[_from] > 0) calcUnlock(_from); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[_from] >= totalValue && totalValue >= 0 && allowed[_from][msg.sender] >= totalValue); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[_from] = balanceP[_from].sub(_value[i]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(_from, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(_from, _to, _value[i]); i++; } return true; } // standard ERC20 transferFrom function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool _success) { if (lockNum[_from] > 0) calcUnlock(_from); require(balanceP[_from] >= _value && _value >= 0 && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balanceP[_from] = balanceP[_from].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(_from, _to, _value); return true; } // should only be called when first setting an allowed function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // increase or decrease allowed function increaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { if(_value >= allowed[msg.sender][_spender]) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_value); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // owner may burn own token function burn(uint256 _value) public onlyOwner returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } // owner may mint new token and increase total supply function mint(uint256 _value) public onlyOwner isMintable returns (bool _success) { balanceP[msg.sender] = balanceP[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); emit Mint(msg.sender, _value); return true; } // safety methods function () public payable { revert(); } function emptyWrongToken(address _addr) onlyOwner public { ERC20Token wrongToken = ERC20Token(_addr); uint256 amount = wrongToken.balanceOf(address(this)); require(amount > 0); require(wrongToken.transfer(msg.sender, amount)); emit WrongTokenEmptied(_addr, msg.sender, amount); } // shouldn't happen, just in case function emptyWrongEther() onlyOwner public { uint256 amount = address(this).balance; require(amount > 0); msg.sender.transfer(amount); emit WrongEtherEmptied(msg.sender, amount); } }
// the main ERC20-compliant multi-timelock enabled contract
LineComment
transfer
function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; }
// standard ERC20 transfer
LineComment
v0.4.26+commit.4563c3fc
bzzr://0db19956575b13220b4f08b353bc03ba65f05ac41f0203c4a9f88831c40d3012
{ "func_code_index": [ 6376, 6801 ] }
1,252
BRMP
BRMP.sol
0xea3b77d0322b427453300df08f23ee6c071aaebc
Solidity
BRMP
contract BRMP is Owned, ERC20Token { using SafeMath for uint256; string private constant standard = "201907043306"; string private constant version = "6.0663688"; string private name_ = "Borrme Points"; string private symbol_ = "BRMP"; uint8 private decimals_ = 18; uint256 private totalSupply_ = uint256(100) * uint256(10)**uint256(8) * uint256(10)**uint256(decimals_); mapping (address => uint256) private balanceP; mapping (address => mapping (address => uint256)) private allowed; mapping (address => uint256[]) private lockTime; mapping (address => uint256[]) private lockValue; mapping (address => uint256) private lockNum; uint256 private later = 0; uint256 private earlier = 0; bool private mintable_ = true; // burn token event event Burn(address indexed _from, uint256 _value); // mint token event event Mint(address indexed _to, uint256 _value); // timelock-related events event TransferLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value); event TokenUnlocked(address indexed _address, uint256 _value); // safety method-related events event WrongTokenEmptied(address indexed _token, address indexed _addr, uint256 _amount); event WrongEtherEmptied(address indexed _addr, uint256 _amount); // constructor for the ERC20 Token constructor() public { balanceP[msg.sender] = totalSupply_; } modifier validAddress(address _address) { require(_address != 0x0); _; } modifier isMintable() { require(mintable_); _; } // fast-forward the timelocks for all accounts function setUnlockEarlier(uint256 _earlier) public onlyOwner { earlier = earlier.add(_earlier); } // delay the timelocks for all accounts function setUnlockLater(uint256 _later) public onlyOwner { later = later.add(_later); } // owner may permanently disable minting function disableMint() public onlyOwner isMintable { mintable_ = false; } // show if the token is still mintable function mintable() public view returns (bool) { return mintable_; } // standard ERC20 name function function name() public view returns (string) { return name_; } // standard ERC20 symbol function function symbol() public view returns (string) { return symbol_; } // standard ERC20 decimals function function decimals() public view returns (uint8) { return decimals_; } // standard ERC20 totalSupply function function totalSupply() public view returns (uint256) { return totalSupply_; } // standard ERC20 allowance function function allowance(address _owner, address _spender) external view returns (uint256) { return allowed[_owner][_spender]; } // show unlocked balance of an account function balanceUnlocked(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) >= lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocked balance of an account function balanceLocked(address _address) public view returns (uint256 _balance) { _balance = 0; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) < lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // standard ERC20 balanceOf with timelock added function balanceOf(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocks in an account function showLockTimes(address _address) public view validAddress(_address) returns (uint256[] _times) { uint i = 0; uint256[] memory tempLockTime = new uint256[](lockNum[_address]); while (i < lockNum[_address]) { tempLockTime[i] = lockTime[_address][i].add(later).sub(earlier); i++; } return tempLockTime; } // show values locked in an account's timelocks function showLockValues(address _address) public view validAddress(_address) returns (uint256[] _values) { return lockValue[_address]; } function showLockNum(address _address) public view validAddress(_address) returns (uint256 _lockNum) { return lockNum[_address]; } // Calculate and process the timelock states of an account function calcUnlock(address _address) private { uint256 i = 0; uint256 j = 0; uint256[] memory currentLockTime; uint256[] memory currentLockValue; uint256[] memory newLockTime = new uint256[](lockNum[_address]); uint256[] memory newLockValue = new uint256[](lockNum[_address]); currentLockTime = lockTime[_address]; currentLockValue = lockValue[_address]; while (i < lockNum[_address]) { if (now.add(earlier) >= currentLockTime[i].add(later)) { balanceP[_address] = balanceP[_address].add(currentLockValue[i]); emit TokenUnlocked(_address, currentLockValue[i]); } else { newLockTime[j] = currentLockTime[i]; newLockValue[j] = currentLockValue[i]; j++; } i++; } uint256[] memory trimLockTime = new uint256[](j); uint256[] memory trimLockValue = new uint256[](j); i = 0; while (i < j) { trimLockTime[i] = newLockTime[i]; trimLockValue[i] = newLockValue[i]; i++; } lockTime[_address] = trimLockTime; lockValue[_address] = trimLockValue; lockNum[_address] = j; } // standard ERC20 transfer function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // transfer Token with timelocks function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool _success) { require(_value.length == _time.length); if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[msg.sender] >= totalValue && totalValue >= 0); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[msg.sender] = balanceP[msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(msg.sender, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(msg.sender, _to, _value[i]); i++; } return true; } // TransferFrom Token with timelocks function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public validAddress(_from) validAddress(_to) returns (bool success) { require(_value.length == _time.length); if (lockNum[_from] > 0) calcUnlock(_from); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[_from] >= totalValue && totalValue >= 0 && allowed[_from][msg.sender] >= totalValue); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[_from] = balanceP[_from].sub(_value[i]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(_from, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(_from, _to, _value[i]); i++; } return true; } // standard ERC20 transferFrom function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool _success) { if (lockNum[_from] > 0) calcUnlock(_from); require(balanceP[_from] >= _value && _value >= 0 && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balanceP[_from] = balanceP[_from].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(_from, _to, _value); return true; } // should only be called when first setting an allowed function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // increase or decrease allowed function increaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { if(_value >= allowed[msg.sender][_spender]) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_value); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // owner may burn own token function burn(uint256 _value) public onlyOwner returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } // owner may mint new token and increase total supply function mint(uint256 _value) public onlyOwner isMintable returns (bool _success) { balanceP[msg.sender] = balanceP[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); emit Mint(msg.sender, _value); return true; } // safety methods function () public payable { revert(); } function emptyWrongToken(address _addr) onlyOwner public { ERC20Token wrongToken = ERC20Token(_addr); uint256 amount = wrongToken.balanceOf(address(this)); require(amount > 0); require(wrongToken.transfer(msg.sender, amount)); emit WrongTokenEmptied(_addr, msg.sender, amount); } // shouldn't happen, just in case function emptyWrongEther() onlyOwner public { uint256 amount = address(this).balance; require(amount > 0); msg.sender.transfer(amount); emit WrongEtherEmptied(msg.sender, amount); } }
// the main ERC20-compliant multi-timelock enabled contract
LineComment
transferLocked
function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool _success) { require(_value.length == _time.length); if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[msg.sender] >= totalValue && totalValue >= 0); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[msg.sender] = balanceP[msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(msg.sender, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(msg.sender, _to, _value[i]); i++; } return true; }
// transfer Token with timelocks
LineComment
v0.4.26+commit.4563c3fc
bzzr://0db19956575b13220b4f08b353bc03ba65f05ac41f0203c4a9f88831c40d3012
{ "func_code_index": [ 6842, 8158 ] }
1,253
BRMP
BRMP.sol
0xea3b77d0322b427453300df08f23ee6c071aaebc
Solidity
BRMP
contract BRMP is Owned, ERC20Token { using SafeMath for uint256; string private constant standard = "201907043306"; string private constant version = "6.0663688"; string private name_ = "Borrme Points"; string private symbol_ = "BRMP"; uint8 private decimals_ = 18; uint256 private totalSupply_ = uint256(100) * uint256(10)**uint256(8) * uint256(10)**uint256(decimals_); mapping (address => uint256) private balanceP; mapping (address => mapping (address => uint256)) private allowed; mapping (address => uint256[]) private lockTime; mapping (address => uint256[]) private lockValue; mapping (address => uint256) private lockNum; uint256 private later = 0; uint256 private earlier = 0; bool private mintable_ = true; // burn token event event Burn(address indexed _from, uint256 _value); // mint token event event Mint(address indexed _to, uint256 _value); // timelock-related events event TransferLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value); event TokenUnlocked(address indexed _address, uint256 _value); // safety method-related events event WrongTokenEmptied(address indexed _token, address indexed _addr, uint256 _amount); event WrongEtherEmptied(address indexed _addr, uint256 _amount); // constructor for the ERC20 Token constructor() public { balanceP[msg.sender] = totalSupply_; } modifier validAddress(address _address) { require(_address != 0x0); _; } modifier isMintable() { require(mintable_); _; } // fast-forward the timelocks for all accounts function setUnlockEarlier(uint256 _earlier) public onlyOwner { earlier = earlier.add(_earlier); } // delay the timelocks for all accounts function setUnlockLater(uint256 _later) public onlyOwner { later = later.add(_later); } // owner may permanently disable minting function disableMint() public onlyOwner isMintable { mintable_ = false; } // show if the token is still mintable function mintable() public view returns (bool) { return mintable_; } // standard ERC20 name function function name() public view returns (string) { return name_; } // standard ERC20 symbol function function symbol() public view returns (string) { return symbol_; } // standard ERC20 decimals function function decimals() public view returns (uint8) { return decimals_; } // standard ERC20 totalSupply function function totalSupply() public view returns (uint256) { return totalSupply_; } // standard ERC20 allowance function function allowance(address _owner, address _spender) external view returns (uint256) { return allowed[_owner][_spender]; } // show unlocked balance of an account function balanceUnlocked(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) >= lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocked balance of an account function balanceLocked(address _address) public view returns (uint256 _balance) { _balance = 0; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) < lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // standard ERC20 balanceOf with timelock added function balanceOf(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocks in an account function showLockTimes(address _address) public view validAddress(_address) returns (uint256[] _times) { uint i = 0; uint256[] memory tempLockTime = new uint256[](lockNum[_address]); while (i < lockNum[_address]) { tempLockTime[i] = lockTime[_address][i].add(later).sub(earlier); i++; } return tempLockTime; } // show values locked in an account's timelocks function showLockValues(address _address) public view validAddress(_address) returns (uint256[] _values) { return lockValue[_address]; } function showLockNum(address _address) public view validAddress(_address) returns (uint256 _lockNum) { return lockNum[_address]; } // Calculate and process the timelock states of an account function calcUnlock(address _address) private { uint256 i = 0; uint256 j = 0; uint256[] memory currentLockTime; uint256[] memory currentLockValue; uint256[] memory newLockTime = new uint256[](lockNum[_address]); uint256[] memory newLockValue = new uint256[](lockNum[_address]); currentLockTime = lockTime[_address]; currentLockValue = lockValue[_address]; while (i < lockNum[_address]) { if (now.add(earlier) >= currentLockTime[i].add(later)) { balanceP[_address] = balanceP[_address].add(currentLockValue[i]); emit TokenUnlocked(_address, currentLockValue[i]); } else { newLockTime[j] = currentLockTime[i]; newLockValue[j] = currentLockValue[i]; j++; } i++; } uint256[] memory trimLockTime = new uint256[](j); uint256[] memory trimLockValue = new uint256[](j); i = 0; while (i < j) { trimLockTime[i] = newLockTime[i]; trimLockValue[i] = newLockValue[i]; i++; } lockTime[_address] = trimLockTime; lockValue[_address] = trimLockValue; lockNum[_address] = j; } // standard ERC20 transfer function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // transfer Token with timelocks function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool _success) { require(_value.length == _time.length); if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[msg.sender] >= totalValue && totalValue >= 0); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[msg.sender] = balanceP[msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(msg.sender, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(msg.sender, _to, _value[i]); i++; } return true; } // TransferFrom Token with timelocks function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public validAddress(_from) validAddress(_to) returns (bool success) { require(_value.length == _time.length); if (lockNum[_from] > 0) calcUnlock(_from); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[_from] >= totalValue && totalValue >= 0 && allowed[_from][msg.sender] >= totalValue); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[_from] = balanceP[_from].sub(_value[i]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(_from, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(_from, _to, _value[i]); i++; } return true; } // standard ERC20 transferFrom function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool _success) { if (lockNum[_from] > 0) calcUnlock(_from); require(balanceP[_from] >= _value && _value >= 0 && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balanceP[_from] = balanceP[_from].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(_from, _to, _value); return true; } // should only be called when first setting an allowed function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // increase or decrease allowed function increaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { if(_value >= allowed[msg.sender][_spender]) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_value); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // owner may burn own token function burn(uint256 _value) public onlyOwner returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } // owner may mint new token and increase total supply function mint(uint256 _value) public onlyOwner isMintable returns (bool _success) { balanceP[msg.sender] = balanceP[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); emit Mint(msg.sender, _value); return true; } // safety methods function () public payable { revert(); } function emptyWrongToken(address _addr) onlyOwner public { ERC20Token wrongToken = ERC20Token(_addr); uint256 amount = wrongToken.balanceOf(address(this)); require(amount > 0); require(wrongToken.transfer(msg.sender, amount)); emit WrongTokenEmptied(_addr, msg.sender, amount); } // shouldn't happen, just in case function emptyWrongEther() onlyOwner public { uint256 amount = address(this).balance; require(amount > 0); msg.sender.transfer(amount); emit WrongEtherEmptied(msg.sender, amount); } }
// the main ERC20-compliant multi-timelock enabled contract
LineComment
transferLockedFrom
function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public validAddress(_from) validAddress(_to) returns (bool success) { require(_value.length == _time.length); if (lockNum[_from] > 0) calcUnlock(_from); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[_from] >= totalValue && totalValue >= 0 && allowed[_from][msg.sender] >= totalValue); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[_from] = balanceP[_from].sub(_value[i]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(_from, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(_from, _to, _value[i]); i++; } return true; }
// TransferFrom Token with timelocks
LineComment
v0.4.26+commit.4563c3fc
bzzr://0db19956575b13220b4f08b353bc03ba65f05ac41f0203c4a9f88831c40d3012
{ "func_code_index": [ 8203, 9661 ] }
1,254
BRMP
BRMP.sol
0xea3b77d0322b427453300df08f23ee6c071aaebc
Solidity
BRMP
contract BRMP is Owned, ERC20Token { using SafeMath for uint256; string private constant standard = "201907043306"; string private constant version = "6.0663688"; string private name_ = "Borrme Points"; string private symbol_ = "BRMP"; uint8 private decimals_ = 18; uint256 private totalSupply_ = uint256(100) * uint256(10)**uint256(8) * uint256(10)**uint256(decimals_); mapping (address => uint256) private balanceP; mapping (address => mapping (address => uint256)) private allowed; mapping (address => uint256[]) private lockTime; mapping (address => uint256[]) private lockValue; mapping (address => uint256) private lockNum; uint256 private later = 0; uint256 private earlier = 0; bool private mintable_ = true; // burn token event event Burn(address indexed _from, uint256 _value); // mint token event event Mint(address indexed _to, uint256 _value); // timelock-related events event TransferLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value); event TokenUnlocked(address indexed _address, uint256 _value); // safety method-related events event WrongTokenEmptied(address indexed _token, address indexed _addr, uint256 _amount); event WrongEtherEmptied(address indexed _addr, uint256 _amount); // constructor for the ERC20 Token constructor() public { balanceP[msg.sender] = totalSupply_; } modifier validAddress(address _address) { require(_address != 0x0); _; } modifier isMintable() { require(mintable_); _; } // fast-forward the timelocks for all accounts function setUnlockEarlier(uint256 _earlier) public onlyOwner { earlier = earlier.add(_earlier); } // delay the timelocks for all accounts function setUnlockLater(uint256 _later) public onlyOwner { later = later.add(_later); } // owner may permanently disable minting function disableMint() public onlyOwner isMintable { mintable_ = false; } // show if the token is still mintable function mintable() public view returns (bool) { return mintable_; } // standard ERC20 name function function name() public view returns (string) { return name_; } // standard ERC20 symbol function function symbol() public view returns (string) { return symbol_; } // standard ERC20 decimals function function decimals() public view returns (uint8) { return decimals_; } // standard ERC20 totalSupply function function totalSupply() public view returns (uint256) { return totalSupply_; } // standard ERC20 allowance function function allowance(address _owner, address _spender) external view returns (uint256) { return allowed[_owner][_spender]; } // show unlocked balance of an account function balanceUnlocked(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) >= lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocked balance of an account function balanceLocked(address _address) public view returns (uint256 _balance) { _balance = 0; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) < lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // standard ERC20 balanceOf with timelock added function balanceOf(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocks in an account function showLockTimes(address _address) public view validAddress(_address) returns (uint256[] _times) { uint i = 0; uint256[] memory tempLockTime = new uint256[](lockNum[_address]); while (i < lockNum[_address]) { tempLockTime[i] = lockTime[_address][i].add(later).sub(earlier); i++; } return tempLockTime; } // show values locked in an account's timelocks function showLockValues(address _address) public view validAddress(_address) returns (uint256[] _values) { return lockValue[_address]; } function showLockNum(address _address) public view validAddress(_address) returns (uint256 _lockNum) { return lockNum[_address]; } // Calculate and process the timelock states of an account function calcUnlock(address _address) private { uint256 i = 0; uint256 j = 0; uint256[] memory currentLockTime; uint256[] memory currentLockValue; uint256[] memory newLockTime = new uint256[](lockNum[_address]); uint256[] memory newLockValue = new uint256[](lockNum[_address]); currentLockTime = lockTime[_address]; currentLockValue = lockValue[_address]; while (i < lockNum[_address]) { if (now.add(earlier) >= currentLockTime[i].add(later)) { balanceP[_address] = balanceP[_address].add(currentLockValue[i]); emit TokenUnlocked(_address, currentLockValue[i]); } else { newLockTime[j] = currentLockTime[i]; newLockValue[j] = currentLockValue[i]; j++; } i++; } uint256[] memory trimLockTime = new uint256[](j); uint256[] memory trimLockValue = new uint256[](j); i = 0; while (i < j) { trimLockTime[i] = newLockTime[i]; trimLockValue[i] = newLockValue[i]; i++; } lockTime[_address] = trimLockTime; lockValue[_address] = trimLockValue; lockNum[_address] = j; } // standard ERC20 transfer function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // transfer Token with timelocks function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool _success) { require(_value.length == _time.length); if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[msg.sender] >= totalValue && totalValue >= 0); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[msg.sender] = balanceP[msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(msg.sender, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(msg.sender, _to, _value[i]); i++; } return true; } // TransferFrom Token with timelocks function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public validAddress(_from) validAddress(_to) returns (bool success) { require(_value.length == _time.length); if (lockNum[_from] > 0) calcUnlock(_from); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[_from] >= totalValue && totalValue >= 0 && allowed[_from][msg.sender] >= totalValue); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[_from] = balanceP[_from].sub(_value[i]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(_from, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(_from, _to, _value[i]); i++; } return true; } // standard ERC20 transferFrom function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool _success) { if (lockNum[_from] > 0) calcUnlock(_from); require(balanceP[_from] >= _value && _value >= 0 && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balanceP[_from] = balanceP[_from].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(_from, _to, _value); return true; } // should only be called when first setting an allowed function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // increase or decrease allowed function increaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { if(_value >= allowed[msg.sender][_spender]) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_value); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // owner may burn own token function burn(uint256 _value) public onlyOwner returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } // owner may mint new token and increase total supply function mint(uint256 _value) public onlyOwner isMintable returns (bool _success) { balanceP[msg.sender] = balanceP[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); emit Mint(msg.sender, _value); return true; } // safety methods function () public payable { revert(); } function emptyWrongToken(address _addr) onlyOwner public { ERC20Token wrongToken = ERC20Token(_addr); uint256 amount = wrongToken.balanceOf(address(this)); require(amount > 0); require(wrongToken.transfer(msg.sender, amount)); emit WrongTokenEmptied(_addr, msg.sender, amount); } // shouldn't happen, just in case function emptyWrongEther() onlyOwner public { uint256 amount = address(this).balance; require(amount > 0); msg.sender.transfer(amount); emit WrongEtherEmptied(msg.sender, amount); } }
// the main ERC20-compliant multi-timelock enabled contract
LineComment
transferFrom
function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool _success) { if (lockNum[_from] > 0) calcUnlock(_from); require(balanceP[_from] >= _value && _value >= 0 && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balanceP[_from] = balanceP[_from].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(_from, _to, _value); return true; }
// standard ERC20 transferFrom
LineComment
v0.4.26+commit.4563c3fc
bzzr://0db19956575b13220b4f08b353bc03ba65f05ac41f0203c4a9f88831c40d3012
{ "func_code_index": [ 9700, 10252 ] }
1,255
BRMP
BRMP.sol
0xea3b77d0322b427453300df08f23ee6c071aaebc
Solidity
BRMP
contract BRMP is Owned, ERC20Token { using SafeMath for uint256; string private constant standard = "201907043306"; string private constant version = "6.0663688"; string private name_ = "Borrme Points"; string private symbol_ = "BRMP"; uint8 private decimals_ = 18; uint256 private totalSupply_ = uint256(100) * uint256(10)**uint256(8) * uint256(10)**uint256(decimals_); mapping (address => uint256) private balanceP; mapping (address => mapping (address => uint256)) private allowed; mapping (address => uint256[]) private lockTime; mapping (address => uint256[]) private lockValue; mapping (address => uint256) private lockNum; uint256 private later = 0; uint256 private earlier = 0; bool private mintable_ = true; // burn token event event Burn(address indexed _from, uint256 _value); // mint token event event Mint(address indexed _to, uint256 _value); // timelock-related events event TransferLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value); event TokenUnlocked(address indexed _address, uint256 _value); // safety method-related events event WrongTokenEmptied(address indexed _token, address indexed _addr, uint256 _amount); event WrongEtherEmptied(address indexed _addr, uint256 _amount); // constructor for the ERC20 Token constructor() public { balanceP[msg.sender] = totalSupply_; } modifier validAddress(address _address) { require(_address != 0x0); _; } modifier isMintable() { require(mintable_); _; } // fast-forward the timelocks for all accounts function setUnlockEarlier(uint256 _earlier) public onlyOwner { earlier = earlier.add(_earlier); } // delay the timelocks for all accounts function setUnlockLater(uint256 _later) public onlyOwner { later = later.add(_later); } // owner may permanently disable minting function disableMint() public onlyOwner isMintable { mintable_ = false; } // show if the token is still mintable function mintable() public view returns (bool) { return mintable_; } // standard ERC20 name function function name() public view returns (string) { return name_; } // standard ERC20 symbol function function symbol() public view returns (string) { return symbol_; } // standard ERC20 decimals function function decimals() public view returns (uint8) { return decimals_; } // standard ERC20 totalSupply function function totalSupply() public view returns (uint256) { return totalSupply_; } // standard ERC20 allowance function function allowance(address _owner, address _spender) external view returns (uint256) { return allowed[_owner][_spender]; } // show unlocked balance of an account function balanceUnlocked(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) >= lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocked balance of an account function balanceLocked(address _address) public view returns (uint256 _balance) { _balance = 0; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) < lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // standard ERC20 balanceOf with timelock added function balanceOf(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocks in an account function showLockTimes(address _address) public view validAddress(_address) returns (uint256[] _times) { uint i = 0; uint256[] memory tempLockTime = new uint256[](lockNum[_address]); while (i < lockNum[_address]) { tempLockTime[i] = lockTime[_address][i].add(later).sub(earlier); i++; } return tempLockTime; } // show values locked in an account's timelocks function showLockValues(address _address) public view validAddress(_address) returns (uint256[] _values) { return lockValue[_address]; } function showLockNum(address _address) public view validAddress(_address) returns (uint256 _lockNum) { return lockNum[_address]; } // Calculate and process the timelock states of an account function calcUnlock(address _address) private { uint256 i = 0; uint256 j = 0; uint256[] memory currentLockTime; uint256[] memory currentLockValue; uint256[] memory newLockTime = new uint256[](lockNum[_address]); uint256[] memory newLockValue = new uint256[](lockNum[_address]); currentLockTime = lockTime[_address]; currentLockValue = lockValue[_address]; while (i < lockNum[_address]) { if (now.add(earlier) >= currentLockTime[i].add(later)) { balanceP[_address] = balanceP[_address].add(currentLockValue[i]); emit TokenUnlocked(_address, currentLockValue[i]); } else { newLockTime[j] = currentLockTime[i]; newLockValue[j] = currentLockValue[i]; j++; } i++; } uint256[] memory trimLockTime = new uint256[](j); uint256[] memory trimLockValue = new uint256[](j); i = 0; while (i < j) { trimLockTime[i] = newLockTime[i]; trimLockValue[i] = newLockValue[i]; i++; } lockTime[_address] = trimLockTime; lockValue[_address] = trimLockValue; lockNum[_address] = j; } // standard ERC20 transfer function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // transfer Token with timelocks function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool _success) { require(_value.length == _time.length); if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[msg.sender] >= totalValue && totalValue >= 0); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[msg.sender] = balanceP[msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(msg.sender, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(msg.sender, _to, _value[i]); i++; } return true; } // TransferFrom Token with timelocks function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public validAddress(_from) validAddress(_to) returns (bool success) { require(_value.length == _time.length); if (lockNum[_from] > 0) calcUnlock(_from); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[_from] >= totalValue && totalValue >= 0 && allowed[_from][msg.sender] >= totalValue); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[_from] = balanceP[_from].sub(_value[i]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(_from, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(_from, _to, _value[i]); i++; } return true; } // standard ERC20 transferFrom function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool _success) { if (lockNum[_from] > 0) calcUnlock(_from); require(balanceP[_from] >= _value && _value >= 0 && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balanceP[_from] = balanceP[_from].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(_from, _to, _value); return true; } // should only be called when first setting an allowed function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // increase or decrease allowed function increaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { if(_value >= allowed[msg.sender][_spender]) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_value); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // owner may burn own token function burn(uint256 _value) public onlyOwner returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } // owner may mint new token and increase total supply function mint(uint256 _value) public onlyOwner isMintable returns (bool _success) { balanceP[msg.sender] = balanceP[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); emit Mint(msg.sender, _value); return true; } // safety methods function () public payable { revert(); } function emptyWrongToken(address _addr) onlyOwner public { ERC20Token wrongToken = ERC20Token(_addr); uint256 amount = wrongToken.balanceOf(address(this)); require(amount > 0); require(wrongToken.transfer(msg.sender, amount)); emit WrongTokenEmptied(_addr, msg.sender, amount); } // shouldn't happen, just in case function emptyWrongEther() onlyOwner public { uint256 amount = address(this).balance; require(amount > 0); msg.sender.transfer(amount); emit WrongEtherEmptied(msg.sender, amount); } }
// the main ERC20-compliant multi-timelock enabled contract
LineComment
approve
function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; }
// should only be called when first setting an allowed
LineComment
v0.4.26+commit.4563c3fc
bzzr://0db19956575b13220b4f08b353bc03ba65f05ac41f0203c4a9f88831c40d3012
{ "func_code_index": [ 10315, 10620 ] }
1,256
BRMP
BRMP.sol
0xea3b77d0322b427453300df08f23ee6c071aaebc
Solidity
BRMP
contract BRMP is Owned, ERC20Token { using SafeMath for uint256; string private constant standard = "201907043306"; string private constant version = "6.0663688"; string private name_ = "Borrme Points"; string private symbol_ = "BRMP"; uint8 private decimals_ = 18; uint256 private totalSupply_ = uint256(100) * uint256(10)**uint256(8) * uint256(10)**uint256(decimals_); mapping (address => uint256) private balanceP; mapping (address => mapping (address => uint256)) private allowed; mapping (address => uint256[]) private lockTime; mapping (address => uint256[]) private lockValue; mapping (address => uint256) private lockNum; uint256 private later = 0; uint256 private earlier = 0; bool private mintable_ = true; // burn token event event Burn(address indexed _from, uint256 _value); // mint token event event Mint(address indexed _to, uint256 _value); // timelock-related events event TransferLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value); event TokenUnlocked(address indexed _address, uint256 _value); // safety method-related events event WrongTokenEmptied(address indexed _token, address indexed _addr, uint256 _amount); event WrongEtherEmptied(address indexed _addr, uint256 _amount); // constructor for the ERC20 Token constructor() public { balanceP[msg.sender] = totalSupply_; } modifier validAddress(address _address) { require(_address != 0x0); _; } modifier isMintable() { require(mintable_); _; } // fast-forward the timelocks for all accounts function setUnlockEarlier(uint256 _earlier) public onlyOwner { earlier = earlier.add(_earlier); } // delay the timelocks for all accounts function setUnlockLater(uint256 _later) public onlyOwner { later = later.add(_later); } // owner may permanently disable minting function disableMint() public onlyOwner isMintable { mintable_ = false; } // show if the token is still mintable function mintable() public view returns (bool) { return mintable_; } // standard ERC20 name function function name() public view returns (string) { return name_; } // standard ERC20 symbol function function symbol() public view returns (string) { return symbol_; } // standard ERC20 decimals function function decimals() public view returns (uint8) { return decimals_; } // standard ERC20 totalSupply function function totalSupply() public view returns (uint256) { return totalSupply_; } // standard ERC20 allowance function function allowance(address _owner, address _spender) external view returns (uint256) { return allowed[_owner][_spender]; } // show unlocked balance of an account function balanceUnlocked(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) >= lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocked balance of an account function balanceLocked(address _address) public view returns (uint256 _balance) { _balance = 0; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) < lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // standard ERC20 balanceOf with timelock added function balanceOf(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocks in an account function showLockTimes(address _address) public view validAddress(_address) returns (uint256[] _times) { uint i = 0; uint256[] memory tempLockTime = new uint256[](lockNum[_address]); while (i < lockNum[_address]) { tempLockTime[i] = lockTime[_address][i].add(later).sub(earlier); i++; } return tempLockTime; } // show values locked in an account's timelocks function showLockValues(address _address) public view validAddress(_address) returns (uint256[] _values) { return lockValue[_address]; } function showLockNum(address _address) public view validAddress(_address) returns (uint256 _lockNum) { return lockNum[_address]; } // Calculate and process the timelock states of an account function calcUnlock(address _address) private { uint256 i = 0; uint256 j = 0; uint256[] memory currentLockTime; uint256[] memory currentLockValue; uint256[] memory newLockTime = new uint256[](lockNum[_address]); uint256[] memory newLockValue = new uint256[](lockNum[_address]); currentLockTime = lockTime[_address]; currentLockValue = lockValue[_address]; while (i < lockNum[_address]) { if (now.add(earlier) >= currentLockTime[i].add(later)) { balanceP[_address] = balanceP[_address].add(currentLockValue[i]); emit TokenUnlocked(_address, currentLockValue[i]); } else { newLockTime[j] = currentLockTime[i]; newLockValue[j] = currentLockValue[i]; j++; } i++; } uint256[] memory trimLockTime = new uint256[](j); uint256[] memory trimLockValue = new uint256[](j); i = 0; while (i < j) { trimLockTime[i] = newLockTime[i]; trimLockValue[i] = newLockValue[i]; i++; } lockTime[_address] = trimLockTime; lockValue[_address] = trimLockValue; lockNum[_address] = j; } // standard ERC20 transfer function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // transfer Token with timelocks function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool _success) { require(_value.length == _time.length); if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[msg.sender] >= totalValue && totalValue >= 0); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[msg.sender] = balanceP[msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(msg.sender, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(msg.sender, _to, _value[i]); i++; } return true; } // TransferFrom Token with timelocks function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public validAddress(_from) validAddress(_to) returns (bool success) { require(_value.length == _time.length); if (lockNum[_from] > 0) calcUnlock(_from); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[_from] >= totalValue && totalValue >= 0 && allowed[_from][msg.sender] >= totalValue); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[_from] = balanceP[_from].sub(_value[i]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(_from, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(_from, _to, _value[i]); i++; } return true; } // standard ERC20 transferFrom function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool _success) { if (lockNum[_from] > 0) calcUnlock(_from); require(balanceP[_from] >= _value && _value >= 0 && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balanceP[_from] = balanceP[_from].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(_from, _to, _value); return true; } // should only be called when first setting an allowed function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // increase or decrease allowed function increaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { if(_value >= allowed[msg.sender][_spender]) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_value); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // owner may burn own token function burn(uint256 _value) public onlyOwner returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } // owner may mint new token and increase total supply function mint(uint256 _value) public onlyOwner isMintable returns (bool _success) { balanceP[msg.sender] = balanceP[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); emit Mint(msg.sender, _value); return true; } // safety methods function () public payable { revert(); } function emptyWrongToken(address _addr) onlyOwner public { ERC20Token wrongToken = ERC20Token(_addr); uint256 amount = wrongToken.balanceOf(address(this)); require(amount > 0); require(wrongToken.transfer(msg.sender, amount)); emit WrongTokenEmptied(_addr, msg.sender, amount); } // shouldn't happen, just in case function emptyWrongEther() onlyOwner public { uint256 amount = address(this).balance; require(amount > 0); msg.sender.transfer(amount); emit WrongEtherEmptied(msg.sender, amount); } }
// the main ERC20-compliant multi-timelock enabled contract
LineComment
increaseApproval
function increaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; }
// increase or decrease allowed
LineComment
v0.4.26+commit.4563c3fc
bzzr://0db19956575b13220b4f08b353bc03ba65f05ac41f0203c4a9f88831c40d3012
{ "func_code_index": [ 10660, 10967 ] }
1,257
BRMP
BRMP.sol
0xea3b77d0322b427453300df08f23ee6c071aaebc
Solidity
BRMP
contract BRMP is Owned, ERC20Token { using SafeMath for uint256; string private constant standard = "201907043306"; string private constant version = "6.0663688"; string private name_ = "Borrme Points"; string private symbol_ = "BRMP"; uint8 private decimals_ = 18; uint256 private totalSupply_ = uint256(100) * uint256(10)**uint256(8) * uint256(10)**uint256(decimals_); mapping (address => uint256) private balanceP; mapping (address => mapping (address => uint256)) private allowed; mapping (address => uint256[]) private lockTime; mapping (address => uint256[]) private lockValue; mapping (address => uint256) private lockNum; uint256 private later = 0; uint256 private earlier = 0; bool private mintable_ = true; // burn token event event Burn(address indexed _from, uint256 _value); // mint token event event Mint(address indexed _to, uint256 _value); // timelock-related events event TransferLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value); event TokenUnlocked(address indexed _address, uint256 _value); // safety method-related events event WrongTokenEmptied(address indexed _token, address indexed _addr, uint256 _amount); event WrongEtherEmptied(address indexed _addr, uint256 _amount); // constructor for the ERC20 Token constructor() public { balanceP[msg.sender] = totalSupply_; } modifier validAddress(address _address) { require(_address != 0x0); _; } modifier isMintable() { require(mintable_); _; } // fast-forward the timelocks for all accounts function setUnlockEarlier(uint256 _earlier) public onlyOwner { earlier = earlier.add(_earlier); } // delay the timelocks for all accounts function setUnlockLater(uint256 _later) public onlyOwner { later = later.add(_later); } // owner may permanently disable minting function disableMint() public onlyOwner isMintable { mintable_ = false; } // show if the token is still mintable function mintable() public view returns (bool) { return mintable_; } // standard ERC20 name function function name() public view returns (string) { return name_; } // standard ERC20 symbol function function symbol() public view returns (string) { return symbol_; } // standard ERC20 decimals function function decimals() public view returns (uint8) { return decimals_; } // standard ERC20 totalSupply function function totalSupply() public view returns (uint256) { return totalSupply_; } // standard ERC20 allowance function function allowance(address _owner, address _spender) external view returns (uint256) { return allowed[_owner][_spender]; } // show unlocked balance of an account function balanceUnlocked(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) >= lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocked balance of an account function balanceLocked(address _address) public view returns (uint256 _balance) { _balance = 0; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) < lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // standard ERC20 balanceOf with timelock added function balanceOf(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocks in an account function showLockTimes(address _address) public view validAddress(_address) returns (uint256[] _times) { uint i = 0; uint256[] memory tempLockTime = new uint256[](lockNum[_address]); while (i < lockNum[_address]) { tempLockTime[i] = lockTime[_address][i].add(later).sub(earlier); i++; } return tempLockTime; } // show values locked in an account's timelocks function showLockValues(address _address) public view validAddress(_address) returns (uint256[] _values) { return lockValue[_address]; } function showLockNum(address _address) public view validAddress(_address) returns (uint256 _lockNum) { return lockNum[_address]; } // Calculate and process the timelock states of an account function calcUnlock(address _address) private { uint256 i = 0; uint256 j = 0; uint256[] memory currentLockTime; uint256[] memory currentLockValue; uint256[] memory newLockTime = new uint256[](lockNum[_address]); uint256[] memory newLockValue = new uint256[](lockNum[_address]); currentLockTime = lockTime[_address]; currentLockValue = lockValue[_address]; while (i < lockNum[_address]) { if (now.add(earlier) >= currentLockTime[i].add(later)) { balanceP[_address] = balanceP[_address].add(currentLockValue[i]); emit TokenUnlocked(_address, currentLockValue[i]); } else { newLockTime[j] = currentLockTime[i]; newLockValue[j] = currentLockValue[i]; j++; } i++; } uint256[] memory trimLockTime = new uint256[](j); uint256[] memory trimLockValue = new uint256[](j); i = 0; while (i < j) { trimLockTime[i] = newLockTime[i]; trimLockValue[i] = newLockValue[i]; i++; } lockTime[_address] = trimLockTime; lockValue[_address] = trimLockValue; lockNum[_address] = j; } // standard ERC20 transfer function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // transfer Token with timelocks function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool _success) { require(_value.length == _time.length); if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[msg.sender] >= totalValue && totalValue >= 0); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[msg.sender] = balanceP[msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(msg.sender, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(msg.sender, _to, _value[i]); i++; } return true; } // TransferFrom Token with timelocks function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public validAddress(_from) validAddress(_to) returns (bool success) { require(_value.length == _time.length); if (lockNum[_from] > 0) calcUnlock(_from); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[_from] >= totalValue && totalValue >= 0 && allowed[_from][msg.sender] >= totalValue); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[_from] = balanceP[_from].sub(_value[i]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(_from, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(_from, _to, _value[i]); i++; } return true; } // standard ERC20 transferFrom function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool _success) { if (lockNum[_from] > 0) calcUnlock(_from); require(balanceP[_from] >= _value && _value >= 0 && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balanceP[_from] = balanceP[_from].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(_from, _to, _value); return true; } // should only be called when first setting an allowed function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // increase or decrease allowed function increaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { if(_value >= allowed[msg.sender][_spender]) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_value); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // owner may burn own token function burn(uint256 _value) public onlyOwner returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } // owner may mint new token and increase total supply function mint(uint256 _value) public onlyOwner isMintable returns (bool _success) { balanceP[msg.sender] = balanceP[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); emit Mint(msg.sender, _value); return true; } // safety methods function () public payable { revert(); } function emptyWrongToken(address _addr) onlyOwner public { ERC20Token wrongToken = ERC20Token(_addr); uint256 amount = wrongToken.balanceOf(address(this)); require(amount > 0); require(wrongToken.transfer(msg.sender, amount)); emit WrongTokenEmptied(_addr, msg.sender, amount); } // shouldn't happen, just in case function emptyWrongEther() onlyOwner public { uint256 amount = address(this).balance; require(amount > 0); msg.sender.transfer(amount); emit WrongEtherEmptied(msg.sender, amount); } }
// the main ERC20-compliant multi-timelock enabled contract
LineComment
burn
function burn(uint256 _value) public onlyOwner returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; }
// owner may burn own token
LineComment
v0.4.26+commit.4563c3fc
bzzr://0db19956575b13220b4f08b353bc03ba65f05ac41f0203c4a9f88831c40d3012
{ "func_code_index": [ 11449, 11838 ] }
1,258
BRMP
BRMP.sol
0xea3b77d0322b427453300df08f23ee6c071aaebc
Solidity
BRMP
contract BRMP is Owned, ERC20Token { using SafeMath for uint256; string private constant standard = "201907043306"; string private constant version = "6.0663688"; string private name_ = "Borrme Points"; string private symbol_ = "BRMP"; uint8 private decimals_ = 18; uint256 private totalSupply_ = uint256(100) * uint256(10)**uint256(8) * uint256(10)**uint256(decimals_); mapping (address => uint256) private balanceP; mapping (address => mapping (address => uint256)) private allowed; mapping (address => uint256[]) private lockTime; mapping (address => uint256[]) private lockValue; mapping (address => uint256) private lockNum; uint256 private later = 0; uint256 private earlier = 0; bool private mintable_ = true; // burn token event event Burn(address indexed _from, uint256 _value); // mint token event event Mint(address indexed _to, uint256 _value); // timelock-related events event TransferLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value); event TokenUnlocked(address indexed _address, uint256 _value); // safety method-related events event WrongTokenEmptied(address indexed _token, address indexed _addr, uint256 _amount); event WrongEtherEmptied(address indexed _addr, uint256 _amount); // constructor for the ERC20 Token constructor() public { balanceP[msg.sender] = totalSupply_; } modifier validAddress(address _address) { require(_address != 0x0); _; } modifier isMintable() { require(mintable_); _; } // fast-forward the timelocks for all accounts function setUnlockEarlier(uint256 _earlier) public onlyOwner { earlier = earlier.add(_earlier); } // delay the timelocks for all accounts function setUnlockLater(uint256 _later) public onlyOwner { later = later.add(_later); } // owner may permanently disable minting function disableMint() public onlyOwner isMintable { mintable_ = false; } // show if the token is still mintable function mintable() public view returns (bool) { return mintable_; } // standard ERC20 name function function name() public view returns (string) { return name_; } // standard ERC20 symbol function function symbol() public view returns (string) { return symbol_; } // standard ERC20 decimals function function decimals() public view returns (uint8) { return decimals_; } // standard ERC20 totalSupply function function totalSupply() public view returns (uint256) { return totalSupply_; } // standard ERC20 allowance function function allowance(address _owner, address _spender) external view returns (uint256) { return allowed[_owner][_spender]; } // show unlocked balance of an account function balanceUnlocked(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) >= lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocked balance of an account function balanceLocked(address _address) public view returns (uint256 _balance) { _balance = 0; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) < lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // standard ERC20 balanceOf with timelock added function balanceOf(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocks in an account function showLockTimes(address _address) public view validAddress(_address) returns (uint256[] _times) { uint i = 0; uint256[] memory tempLockTime = new uint256[](lockNum[_address]); while (i < lockNum[_address]) { tempLockTime[i] = lockTime[_address][i].add(later).sub(earlier); i++; } return tempLockTime; } // show values locked in an account's timelocks function showLockValues(address _address) public view validAddress(_address) returns (uint256[] _values) { return lockValue[_address]; } function showLockNum(address _address) public view validAddress(_address) returns (uint256 _lockNum) { return lockNum[_address]; } // Calculate and process the timelock states of an account function calcUnlock(address _address) private { uint256 i = 0; uint256 j = 0; uint256[] memory currentLockTime; uint256[] memory currentLockValue; uint256[] memory newLockTime = new uint256[](lockNum[_address]); uint256[] memory newLockValue = new uint256[](lockNum[_address]); currentLockTime = lockTime[_address]; currentLockValue = lockValue[_address]; while (i < lockNum[_address]) { if (now.add(earlier) >= currentLockTime[i].add(later)) { balanceP[_address] = balanceP[_address].add(currentLockValue[i]); emit TokenUnlocked(_address, currentLockValue[i]); } else { newLockTime[j] = currentLockTime[i]; newLockValue[j] = currentLockValue[i]; j++; } i++; } uint256[] memory trimLockTime = new uint256[](j); uint256[] memory trimLockValue = new uint256[](j); i = 0; while (i < j) { trimLockTime[i] = newLockTime[i]; trimLockValue[i] = newLockValue[i]; i++; } lockTime[_address] = trimLockTime; lockValue[_address] = trimLockValue; lockNum[_address] = j; } // standard ERC20 transfer function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // transfer Token with timelocks function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool _success) { require(_value.length == _time.length); if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[msg.sender] >= totalValue && totalValue >= 0); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[msg.sender] = balanceP[msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(msg.sender, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(msg.sender, _to, _value[i]); i++; } return true; } // TransferFrom Token with timelocks function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public validAddress(_from) validAddress(_to) returns (bool success) { require(_value.length == _time.length); if (lockNum[_from] > 0) calcUnlock(_from); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[_from] >= totalValue && totalValue >= 0 && allowed[_from][msg.sender] >= totalValue); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[_from] = balanceP[_from].sub(_value[i]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(_from, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(_from, _to, _value[i]); i++; } return true; } // standard ERC20 transferFrom function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool _success) { if (lockNum[_from] > 0) calcUnlock(_from); require(balanceP[_from] >= _value && _value >= 0 && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balanceP[_from] = balanceP[_from].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(_from, _to, _value); return true; } // should only be called when first setting an allowed function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // increase or decrease allowed function increaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { if(_value >= allowed[msg.sender][_spender]) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_value); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // owner may burn own token function burn(uint256 _value) public onlyOwner returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } // owner may mint new token and increase total supply function mint(uint256 _value) public onlyOwner isMintable returns (bool _success) { balanceP[msg.sender] = balanceP[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); emit Mint(msg.sender, _value); return true; } // safety methods function () public payable { revert(); } function emptyWrongToken(address _addr) onlyOwner public { ERC20Token wrongToken = ERC20Token(_addr); uint256 amount = wrongToken.balanceOf(address(this)); require(amount > 0); require(wrongToken.transfer(msg.sender, amount)); emit WrongTokenEmptied(_addr, msg.sender, amount); } // shouldn't happen, just in case function emptyWrongEther() onlyOwner public { uint256 amount = address(this).balance; require(amount > 0); msg.sender.transfer(amount); emit WrongEtherEmptied(msg.sender, amount); } }
// the main ERC20-compliant multi-timelock enabled contract
LineComment
mint
function mint(uint256 _value) public onlyOwner isMintable returns (bool _success) { balanceP[msg.sender] = balanceP[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); emit Mint(msg.sender, _value); return true; }
// owner may mint new token and increase total supply
LineComment
v0.4.26+commit.4563c3fc
bzzr://0db19956575b13220b4f08b353bc03ba65f05ac41f0203c4a9f88831c40d3012
{ "func_code_index": [ 11900, 12173 ] }
1,259
BRMP
BRMP.sol
0xea3b77d0322b427453300df08f23ee6c071aaebc
Solidity
BRMP
contract BRMP is Owned, ERC20Token { using SafeMath for uint256; string private constant standard = "201907043306"; string private constant version = "6.0663688"; string private name_ = "Borrme Points"; string private symbol_ = "BRMP"; uint8 private decimals_ = 18; uint256 private totalSupply_ = uint256(100) * uint256(10)**uint256(8) * uint256(10)**uint256(decimals_); mapping (address => uint256) private balanceP; mapping (address => mapping (address => uint256)) private allowed; mapping (address => uint256[]) private lockTime; mapping (address => uint256[]) private lockValue; mapping (address => uint256) private lockNum; uint256 private later = 0; uint256 private earlier = 0; bool private mintable_ = true; // burn token event event Burn(address indexed _from, uint256 _value); // mint token event event Mint(address indexed _to, uint256 _value); // timelock-related events event TransferLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value); event TokenUnlocked(address indexed _address, uint256 _value); // safety method-related events event WrongTokenEmptied(address indexed _token, address indexed _addr, uint256 _amount); event WrongEtherEmptied(address indexed _addr, uint256 _amount); // constructor for the ERC20 Token constructor() public { balanceP[msg.sender] = totalSupply_; } modifier validAddress(address _address) { require(_address != 0x0); _; } modifier isMintable() { require(mintable_); _; } // fast-forward the timelocks for all accounts function setUnlockEarlier(uint256 _earlier) public onlyOwner { earlier = earlier.add(_earlier); } // delay the timelocks for all accounts function setUnlockLater(uint256 _later) public onlyOwner { later = later.add(_later); } // owner may permanently disable minting function disableMint() public onlyOwner isMintable { mintable_ = false; } // show if the token is still mintable function mintable() public view returns (bool) { return mintable_; } // standard ERC20 name function function name() public view returns (string) { return name_; } // standard ERC20 symbol function function symbol() public view returns (string) { return symbol_; } // standard ERC20 decimals function function decimals() public view returns (uint8) { return decimals_; } // standard ERC20 totalSupply function function totalSupply() public view returns (uint256) { return totalSupply_; } // standard ERC20 allowance function function allowance(address _owner, address _spender) external view returns (uint256) { return allowed[_owner][_spender]; } // show unlocked balance of an account function balanceUnlocked(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) >= lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocked balance of an account function balanceLocked(address _address) public view returns (uint256 _balance) { _balance = 0; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) < lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // standard ERC20 balanceOf with timelock added function balanceOf(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocks in an account function showLockTimes(address _address) public view validAddress(_address) returns (uint256[] _times) { uint i = 0; uint256[] memory tempLockTime = new uint256[](lockNum[_address]); while (i < lockNum[_address]) { tempLockTime[i] = lockTime[_address][i].add(later).sub(earlier); i++; } return tempLockTime; } // show values locked in an account's timelocks function showLockValues(address _address) public view validAddress(_address) returns (uint256[] _values) { return lockValue[_address]; } function showLockNum(address _address) public view validAddress(_address) returns (uint256 _lockNum) { return lockNum[_address]; } // Calculate and process the timelock states of an account function calcUnlock(address _address) private { uint256 i = 0; uint256 j = 0; uint256[] memory currentLockTime; uint256[] memory currentLockValue; uint256[] memory newLockTime = new uint256[](lockNum[_address]); uint256[] memory newLockValue = new uint256[](lockNum[_address]); currentLockTime = lockTime[_address]; currentLockValue = lockValue[_address]; while (i < lockNum[_address]) { if (now.add(earlier) >= currentLockTime[i].add(later)) { balanceP[_address] = balanceP[_address].add(currentLockValue[i]); emit TokenUnlocked(_address, currentLockValue[i]); } else { newLockTime[j] = currentLockTime[i]; newLockValue[j] = currentLockValue[i]; j++; } i++; } uint256[] memory trimLockTime = new uint256[](j); uint256[] memory trimLockValue = new uint256[](j); i = 0; while (i < j) { trimLockTime[i] = newLockTime[i]; trimLockValue[i] = newLockValue[i]; i++; } lockTime[_address] = trimLockTime; lockValue[_address] = trimLockValue; lockNum[_address] = j; } // standard ERC20 transfer function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // transfer Token with timelocks function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool _success) { require(_value.length == _time.length); if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[msg.sender] >= totalValue && totalValue >= 0); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[msg.sender] = balanceP[msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(msg.sender, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(msg.sender, _to, _value[i]); i++; } return true; } // TransferFrom Token with timelocks function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public validAddress(_from) validAddress(_to) returns (bool success) { require(_value.length == _time.length); if (lockNum[_from] > 0) calcUnlock(_from); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[_from] >= totalValue && totalValue >= 0 && allowed[_from][msg.sender] >= totalValue); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[_from] = balanceP[_from].sub(_value[i]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(_from, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(_from, _to, _value[i]); i++; } return true; } // standard ERC20 transferFrom function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool _success) { if (lockNum[_from] > 0) calcUnlock(_from); require(balanceP[_from] >= _value && _value >= 0 && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balanceP[_from] = balanceP[_from].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(_from, _to, _value); return true; } // should only be called when first setting an allowed function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // increase or decrease allowed function increaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { if(_value >= allowed[msg.sender][_spender]) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_value); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // owner may burn own token function burn(uint256 _value) public onlyOwner returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } // owner may mint new token and increase total supply function mint(uint256 _value) public onlyOwner isMintable returns (bool _success) { balanceP[msg.sender] = balanceP[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); emit Mint(msg.sender, _value); return true; } // safety methods function () public payable { revert(); } function emptyWrongToken(address _addr) onlyOwner public { ERC20Token wrongToken = ERC20Token(_addr); uint256 amount = wrongToken.balanceOf(address(this)); require(amount > 0); require(wrongToken.transfer(msg.sender, amount)); emit WrongTokenEmptied(_addr, msg.sender, amount); } // shouldn't happen, just in case function emptyWrongEther() onlyOwner public { uint256 amount = address(this).balance; require(amount > 0); msg.sender.transfer(amount); emit WrongEtherEmptied(msg.sender, amount); } }
// the main ERC20-compliant multi-timelock enabled contract
LineComment
function () public payable { revert(); }
// safety methods
LineComment
v0.4.26+commit.4563c3fc
bzzr://0db19956575b13220b4f08b353bc03ba65f05ac41f0203c4a9f88831c40d3012
{ "func_code_index": [ 12199, 12258 ] }
1,260
BRMP
BRMP.sol
0xea3b77d0322b427453300df08f23ee6c071aaebc
Solidity
BRMP
contract BRMP is Owned, ERC20Token { using SafeMath for uint256; string private constant standard = "201907043306"; string private constant version = "6.0663688"; string private name_ = "Borrme Points"; string private symbol_ = "BRMP"; uint8 private decimals_ = 18; uint256 private totalSupply_ = uint256(100) * uint256(10)**uint256(8) * uint256(10)**uint256(decimals_); mapping (address => uint256) private balanceP; mapping (address => mapping (address => uint256)) private allowed; mapping (address => uint256[]) private lockTime; mapping (address => uint256[]) private lockValue; mapping (address => uint256) private lockNum; uint256 private later = 0; uint256 private earlier = 0; bool private mintable_ = true; // burn token event event Burn(address indexed _from, uint256 _value); // mint token event event Mint(address indexed _to, uint256 _value); // timelock-related events event TransferLocked(address indexed _from, address indexed _to, uint256 _time, uint256 _value); event TokenUnlocked(address indexed _address, uint256 _value); // safety method-related events event WrongTokenEmptied(address indexed _token, address indexed _addr, uint256 _amount); event WrongEtherEmptied(address indexed _addr, uint256 _amount); // constructor for the ERC20 Token constructor() public { balanceP[msg.sender] = totalSupply_; } modifier validAddress(address _address) { require(_address != 0x0); _; } modifier isMintable() { require(mintable_); _; } // fast-forward the timelocks for all accounts function setUnlockEarlier(uint256 _earlier) public onlyOwner { earlier = earlier.add(_earlier); } // delay the timelocks for all accounts function setUnlockLater(uint256 _later) public onlyOwner { later = later.add(_later); } // owner may permanently disable minting function disableMint() public onlyOwner isMintable { mintable_ = false; } // show if the token is still mintable function mintable() public view returns (bool) { return mintable_; } // standard ERC20 name function function name() public view returns (string) { return name_; } // standard ERC20 symbol function function symbol() public view returns (string) { return symbol_; } // standard ERC20 decimals function function decimals() public view returns (uint8) { return decimals_; } // standard ERC20 totalSupply function function totalSupply() public view returns (uint256) { return totalSupply_; } // standard ERC20 allowance function function allowance(address _owner, address _spender) external view returns (uint256) { return allowed[_owner][_spender]; } // show unlocked balance of an account function balanceUnlocked(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) >= lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocked balance of an account function balanceLocked(address _address) public view returns (uint256 _balance) { _balance = 0; uint256 i = 0; while (i < lockNum[_address]) { if (now.add(earlier) < lockTime[_address][i].add(later)) _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // standard ERC20 balanceOf with timelock added function balanceOf(address _address) public view returns (uint256 _balance) { _balance = balanceP[_address]; uint256 i = 0; while (i < lockNum[_address]) { _balance = _balance.add(lockValue[_address][i]); i++; } return _balance; } // show timelocks in an account function showLockTimes(address _address) public view validAddress(_address) returns (uint256[] _times) { uint i = 0; uint256[] memory tempLockTime = new uint256[](lockNum[_address]); while (i < lockNum[_address]) { tempLockTime[i] = lockTime[_address][i].add(later).sub(earlier); i++; } return tempLockTime; } // show values locked in an account's timelocks function showLockValues(address _address) public view validAddress(_address) returns (uint256[] _values) { return lockValue[_address]; } function showLockNum(address _address) public view validAddress(_address) returns (uint256 _lockNum) { return lockNum[_address]; } // Calculate and process the timelock states of an account function calcUnlock(address _address) private { uint256 i = 0; uint256 j = 0; uint256[] memory currentLockTime; uint256[] memory currentLockValue; uint256[] memory newLockTime = new uint256[](lockNum[_address]); uint256[] memory newLockValue = new uint256[](lockNum[_address]); currentLockTime = lockTime[_address]; currentLockValue = lockValue[_address]; while (i < lockNum[_address]) { if (now.add(earlier) >= currentLockTime[i].add(later)) { balanceP[_address] = balanceP[_address].add(currentLockValue[i]); emit TokenUnlocked(_address, currentLockValue[i]); } else { newLockTime[j] = currentLockTime[i]; newLockValue[j] = currentLockValue[i]; j++; } i++; } uint256[] memory trimLockTime = new uint256[](j); uint256[] memory trimLockValue = new uint256[](j); i = 0; while (i < j) { trimLockTime[i] = newLockTime[i]; trimLockValue[i] = newLockValue[i]; i++; } lockTime[_address] = trimLockTime; lockValue[_address] = trimLockValue; lockNum[_address] = j; } // standard ERC20 transfer function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } // transfer Token with timelocks function transferLocked(address _to, uint256[] _time, uint256[] _value) public validAddress(_to) returns (bool _success) { require(_value.length == _time.length); if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[msg.sender] >= totalValue && totalValue >= 0); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[msg.sender] = balanceP[msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(msg.sender, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(msg.sender, _to, _value[i]); i++; } return true; } // TransferFrom Token with timelocks function transferLockedFrom(address _from, address _to, uint256[] _time, uint256[] _value) public validAddress(_from) validAddress(_to) returns (bool success) { require(_value.length == _time.length); if (lockNum[_from] > 0) calcUnlock(_from); uint256 i = 0; uint256 totalValue = 0; while (i < _value.length) { totalValue = totalValue.add(_value[i]); i++; } require(balanceP[_from] >= totalValue && totalValue >= 0 && allowed[_from][msg.sender] >= totalValue); require(lockNum[_to].add(_time.length) <= 42); i = 0; while (i < _time.length) { if (_value[i] > 0) { balanceP[_from] = balanceP[_from].sub(_value[i]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value[i]); lockTime[_to].length = lockNum[_to]+1; lockValue[_to].length = lockNum[_to]+1; lockTime[_to][lockNum[_to]] = now.add(_time[i]).add(earlier).sub(later); lockValue[_to][lockNum[_to]] = _value[i]; lockNum[_to]++; } // emit custom TransferLocked event emit TransferLocked(_from, _to, _time[i], _value[i]); // emit standard Transfer event for wallets emit Transfer(_from, _to, _value[i]); i++; } return true; } // standard ERC20 transferFrom function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool _success) { if (lockNum[_from] > 0) calcUnlock(_from); require(balanceP[_from] >= _value && _value >= 0 && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balanceP[_from] = balanceP[_from].sub(_value); balanceP[_to] = balanceP[_to].add(_value); emit Transfer(_from, _to, _value); return true; } // should only be called when first setting an allowed function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } // increase or decrease allowed function increaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _value) public validAddress(_spender) returns (bool _success) { if(_value >= allowed[msg.sender][_spender]) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_value); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // owner may burn own token function burn(uint256 _value) public onlyOwner returns (bool _success) { if (lockNum[msg.sender] > 0) calcUnlock(msg.sender); require(balanceP[msg.sender] >= _value && _value >= 0); balanceP[msg.sender] = balanceP[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } // owner may mint new token and increase total supply function mint(uint256 _value) public onlyOwner isMintable returns (bool _success) { balanceP[msg.sender] = balanceP[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); emit Mint(msg.sender, _value); return true; } // safety methods function () public payable { revert(); } function emptyWrongToken(address _addr) onlyOwner public { ERC20Token wrongToken = ERC20Token(_addr); uint256 amount = wrongToken.balanceOf(address(this)); require(amount > 0); require(wrongToken.transfer(msg.sender, amount)); emit WrongTokenEmptied(_addr, msg.sender, amount); } // shouldn't happen, just in case function emptyWrongEther() onlyOwner public { uint256 amount = address(this).balance; require(amount > 0); msg.sender.transfer(amount); emit WrongEtherEmptied(msg.sender, amount); } }
// the main ERC20-compliant multi-timelock enabled contract
LineComment
emptyWrongEther
function emptyWrongEther() onlyOwner public { uint256 amount = address(this).balance; require(amount > 0); msg.sender.transfer(amount); emit WrongEtherEmptied(msg.sender, amount); }
// shouldn't happen, just in case
LineComment
v0.4.26+commit.4563c3fc
bzzr://0db19956575b13220b4f08b353bc03ba65f05ac41f0203c4a9f88831c40d3012
{ "func_code_index": [ 12639, 12868 ] }
1,261
MetaJoseon
contracts/Gravel.sol
0x6350358a3671e54358404d87f3edd73155ec8473
Solidity
MetaJoseon
contract MetaJoseon is ERC721Enumerable, Ownable { using Strings for uint256; string public baseURI; string public baseExtension = ".json"; uint256 public saleState = 1; string public notRevealedUri; uint256 public ogMaxSupply = 250; uint256 public wlMaxSupply = 3250; uint256 public pMaxSupply = 8941; bool public revealed = false; address[] public ogWhitelistedAddresses; address[] public wlWhitelistedAddresses; uint256 public ogCost = 0 ether; uint256 public wlCost = 0.06 ether; uint256 public pCost = 0.08 ether; uint256 public ogNftPerAddressLimit = 1; uint256 public wlNftPerAddressLimit = 3; uint256 public pNftPerAddressLimit = 5; mapping(address => uint256) public addressMintedBalance; constructor( string memory _name, string memory _symbol, string memory _initBaseURI, string memory _initNotRevealedUri, address[] memory _ogWhitelistedAddresses, address[] memory _wlWhitelistedAddresses ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); setNotRevealedURI(_initNotRevealedUri); _setOgwhitelistUsers(_ogWhitelistedAddresses); _setWlwhitelistUsers(_wlWhitelistedAddresses); } // internal function _setOgwhitelistUsers(address[] memory _users) private onlyOwner { delete ogWhitelistedAddresses; ogWhitelistedAddresses = _users; } function _setWlwhitelistUsers(address[] memory _users) private onlyOwner { delete wlWhitelistedAddresses; wlWhitelistedAddresses = _users; } function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(uint256 _mintAmount) public payable { uint256 supply = totalSupply(); uint256 ownerMintedCount = addressMintedBalance[msg.sender]; require(_mintAmount > 0, "need to mint at least 1 NFT"); if(msg.sender != owner()){ //Stop require(saleState != 0, "the contract is paused"); //og if(saleState == 1){ require(isOgWhitelisted(msg.sender), "user is not whitelisted"); require(ownerMintedCount + _mintAmount <= ogNftPerAddressLimit, "max NFT per address exceeded"); require(msg.value >= ogCost * _mintAmount, "insufficient funds"); require(supply + _mintAmount <= ogMaxSupply, "max NFT limit exceeded"); //wl }else if(saleState == 2){ if(isOgWhitelisted(msg.sender)){ require(ownerMintedCount + _mintAmount <= ogNftPerAddressLimit + wlNftPerAddressLimit, "max NFT per address exceeded"); }else{ require(isWlWhitelisted(msg.sender), "user is not whitelisted"); require(ownerMintedCount + _mintAmount <= wlNftPerAddressLimit, "max NFT per address exceeded"); } require(msg.value >= wlCost * _mintAmount, "insufficient funds"); require(supply + _mintAmount <= wlMaxSupply, "max NFT limit exceeded"); //public }else if(saleState == 3){ if(isOgWhitelisted(msg.sender)){ require(ownerMintedCount + _mintAmount <= ogNftPerAddressLimit + wlNftPerAddressLimit + pNftPerAddressLimit, "max NFT per address exceeded"); }else if(isWlWhitelisted(msg.sender)){ require(ownerMintedCount + _mintAmount <= wlNftPerAddressLimit + pNftPerAddressLimit, "max NFT per address exceeded"); }else{ require(ownerMintedCount + _mintAmount <= pNftPerAddressLimit, "max NFT per address exceeded"); } require(msg.value >= pCost * _mintAmount, "insufficient funds"); require(supply + _mintAmount <= pMaxSupply, "max NFT limit exceeded"); } } for (uint256 i = 1; i <= _mintAmount; i++) { addressMintedBalance[msg.sender]++; _safeMint(msg.sender, supply + i); } } function isOgWhitelisted(address _user) public view returns (bool) { for (uint i = 0; i < ogWhitelistedAddresses.length; i++) { if (ogWhitelistedAddresses[i] == _user) { return true; } } return false; } function isWlWhitelisted(address _user) public view returns (bool) { for (uint i = 0; i < wlWhitelistedAddresses.length; i++) { if (wlWhitelistedAddresses[i] == _user) { return true; } } return false; } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); if(revealed == false) { return notRevealedUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } //only owner function reveal() public onlyOwner { revealed = true; } function setOgwhitelistUsers(address[] calldata _users) public onlyOwner { delete ogWhitelistedAddresses; ogWhitelistedAddresses = _users; } function setWlwhitelistUsers(address[] calldata _users) public onlyOwner { delete wlWhitelistedAddresses; wlWhitelistedAddresses = _users; } function setOgCost(uint256 _newCost) public onlyOwner { ogCost = _newCost; } function setWlCost(uint256 _newCost) public onlyOwner { wlCost = _newCost; } function setPCost(uint256 _newCost) public onlyOwner { pCost = _newCost; } function setOgNftPerAddressLimit(uint256 _limit) public onlyOwner { ogNftPerAddressLimit = _limit; } function setWlNftPerAddressLimit(uint256 _limit) public onlyOwner { wlNftPerAddressLimit = _limit; } function setPNftPerAddressLimit(uint256 _limit) public onlyOwner { pNftPerAddressLimit = _limit; } function setSaleState(uint256 _state) public onlyOwner { saleState = _state; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } function withdraw() public payable onlyOwner { (bool os, ) = payable(owner()).call{value: address(this).balance}(""); require(os); } }
_setOgwhitelistUsers
function _setOgwhitelistUsers(address[] memory _users) private onlyOwner { delete ogWhitelistedAddresses; ogWhitelistedAddresses = _users; }
// internal
LineComment
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://f85091aa61000a5162ee30fc3b2a80064bdc3a0052ea298af5d6775accad2533
{ "func_code_index": [ 1225, 1381 ] }
1,262
MetaJoseon
contracts/Gravel.sol
0x6350358a3671e54358404d87f3edd73155ec8473
Solidity
MetaJoseon
contract MetaJoseon is ERC721Enumerable, Ownable { using Strings for uint256; string public baseURI; string public baseExtension = ".json"; uint256 public saleState = 1; string public notRevealedUri; uint256 public ogMaxSupply = 250; uint256 public wlMaxSupply = 3250; uint256 public pMaxSupply = 8941; bool public revealed = false; address[] public ogWhitelistedAddresses; address[] public wlWhitelistedAddresses; uint256 public ogCost = 0 ether; uint256 public wlCost = 0.06 ether; uint256 public pCost = 0.08 ether; uint256 public ogNftPerAddressLimit = 1; uint256 public wlNftPerAddressLimit = 3; uint256 public pNftPerAddressLimit = 5; mapping(address => uint256) public addressMintedBalance; constructor( string memory _name, string memory _symbol, string memory _initBaseURI, string memory _initNotRevealedUri, address[] memory _ogWhitelistedAddresses, address[] memory _wlWhitelistedAddresses ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); setNotRevealedURI(_initNotRevealedUri); _setOgwhitelistUsers(_ogWhitelistedAddresses); _setWlwhitelistUsers(_wlWhitelistedAddresses); } // internal function _setOgwhitelistUsers(address[] memory _users) private onlyOwner { delete ogWhitelistedAddresses; ogWhitelistedAddresses = _users; } function _setWlwhitelistUsers(address[] memory _users) private onlyOwner { delete wlWhitelistedAddresses; wlWhitelistedAddresses = _users; } function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(uint256 _mintAmount) public payable { uint256 supply = totalSupply(); uint256 ownerMintedCount = addressMintedBalance[msg.sender]; require(_mintAmount > 0, "need to mint at least 1 NFT"); if(msg.sender != owner()){ //Stop require(saleState != 0, "the contract is paused"); //og if(saleState == 1){ require(isOgWhitelisted(msg.sender), "user is not whitelisted"); require(ownerMintedCount + _mintAmount <= ogNftPerAddressLimit, "max NFT per address exceeded"); require(msg.value >= ogCost * _mintAmount, "insufficient funds"); require(supply + _mintAmount <= ogMaxSupply, "max NFT limit exceeded"); //wl }else if(saleState == 2){ if(isOgWhitelisted(msg.sender)){ require(ownerMintedCount + _mintAmount <= ogNftPerAddressLimit + wlNftPerAddressLimit, "max NFT per address exceeded"); }else{ require(isWlWhitelisted(msg.sender), "user is not whitelisted"); require(ownerMintedCount + _mintAmount <= wlNftPerAddressLimit, "max NFT per address exceeded"); } require(msg.value >= wlCost * _mintAmount, "insufficient funds"); require(supply + _mintAmount <= wlMaxSupply, "max NFT limit exceeded"); //public }else if(saleState == 3){ if(isOgWhitelisted(msg.sender)){ require(ownerMintedCount + _mintAmount <= ogNftPerAddressLimit + wlNftPerAddressLimit + pNftPerAddressLimit, "max NFT per address exceeded"); }else if(isWlWhitelisted(msg.sender)){ require(ownerMintedCount + _mintAmount <= wlNftPerAddressLimit + pNftPerAddressLimit, "max NFT per address exceeded"); }else{ require(ownerMintedCount + _mintAmount <= pNftPerAddressLimit, "max NFT per address exceeded"); } require(msg.value >= pCost * _mintAmount, "insufficient funds"); require(supply + _mintAmount <= pMaxSupply, "max NFT limit exceeded"); } } for (uint256 i = 1; i <= _mintAmount; i++) { addressMintedBalance[msg.sender]++; _safeMint(msg.sender, supply + i); } } function isOgWhitelisted(address _user) public view returns (bool) { for (uint i = 0; i < ogWhitelistedAddresses.length; i++) { if (ogWhitelistedAddresses[i] == _user) { return true; } } return false; } function isWlWhitelisted(address _user) public view returns (bool) { for (uint i = 0; i < wlWhitelistedAddresses.length; i++) { if (wlWhitelistedAddresses[i] == _user) { return true; } } return false; } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); if(revealed == false) { return notRevealedUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } //only owner function reveal() public onlyOwner { revealed = true; } function setOgwhitelistUsers(address[] calldata _users) public onlyOwner { delete ogWhitelistedAddresses; ogWhitelistedAddresses = _users; } function setWlwhitelistUsers(address[] calldata _users) public onlyOwner { delete wlWhitelistedAddresses; wlWhitelistedAddresses = _users; } function setOgCost(uint256 _newCost) public onlyOwner { ogCost = _newCost; } function setWlCost(uint256 _newCost) public onlyOwner { wlCost = _newCost; } function setPCost(uint256 _newCost) public onlyOwner { pCost = _newCost; } function setOgNftPerAddressLimit(uint256 _limit) public onlyOwner { ogNftPerAddressLimit = _limit; } function setWlNftPerAddressLimit(uint256 _limit) public onlyOwner { wlNftPerAddressLimit = _limit; } function setPNftPerAddressLimit(uint256 _limit) public onlyOwner { pNftPerAddressLimit = _limit; } function setSaleState(uint256 _state) public onlyOwner { saleState = _state; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } function withdraw() public payable onlyOwner { (bool os, ) = payable(owner()).call{value: address(this).balance}(""); require(os); } }
mint
function mint(uint256 _mintAmount) public payable { uint256 supply = totalSupply(); uint256 ownerMintedCount = addressMintedBalance[msg.sender]; require(_mintAmount > 0, "need to mint at least 1 NFT"); if(msg.sender != owner()){ //Stop require(saleState != 0, "the contract is paused"); //og if(saleState == 1){ require(isOgWhitelisted(msg.sender), "user is not whitelisted"); require(ownerMintedCount + _mintAmount <= ogNftPerAddressLimit, "max NFT per address exceeded"); require(msg.value >= ogCost * _mintAmount, "insufficient funds"); require(supply + _mintAmount <= ogMaxSupply, "max NFT limit exceeded"); //wl }else if(saleState == 2){ if(isOgWhitelisted(msg.sender)){ require(ownerMintedCount + _mintAmount <= ogNftPerAddressLimit + wlNftPerAddressLimit, "max NFT per address exceeded"); }else{ require(isWlWhitelisted(msg.sender), "user is not whitelisted"); require(ownerMintedCount + _mintAmount <= wlNftPerAddressLimit, "max NFT per address exceeded"); } require(msg.value >= wlCost * _mintAmount, "insufficient funds"); require(supply + _mintAmount <= wlMaxSupply, "max NFT limit exceeded"); //public }else if(saleState == 3){ if(isOgWhitelisted(msg.sender)){ require(ownerMintedCount + _mintAmount <= ogNftPerAddressLimit + wlNftPerAddressLimit + pNftPerAddressLimit, "max NFT per address exceeded"); }else if(isWlWhitelisted(msg.sender)){ require(ownerMintedCount + _mintAmount <= wlNftPerAddressLimit + pNftPerAddressLimit, "max NFT per address exceeded"); }else{ require(ownerMintedCount + _mintAmount <= pNftPerAddressLimit, "max NFT per address exceeded"); } require(msg.value >= pCost * _mintAmount, "insufficient funds"); require(supply + _mintAmount <= pMaxSupply, "max NFT limit exceeded"); } } for (uint256 i = 1; i <= _mintAmount; i++) { addressMintedBalance[msg.sender]++; _safeMint(msg.sender, supply + i); } }
// public
LineComment
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://f85091aa61000a5162ee30fc3b2a80064bdc3a0052ea298af5d6775accad2533
{ "func_code_index": [ 1667, 3861 ] }
1,263
MetaJoseon
contracts/Gravel.sol
0x6350358a3671e54358404d87f3edd73155ec8473
Solidity
MetaJoseon
contract MetaJoseon is ERC721Enumerable, Ownable { using Strings for uint256; string public baseURI; string public baseExtension = ".json"; uint256 public saleState = 1; string public notRevealedUri; uint256 public ogMaxSupply = 250; uint256 public wlMaxSupply = 3250; uint256 public pMaxSupply = 8941; bool public revealed = false; address[] public ogWhitelistedAddresses; address[] public wlWhitelistedAddresses; uint256 public ogCost = 0 ether; uint256 public wlCost = 0.06 ether; uint256 public pCost = 0.08 ether; uint256 public ogNftPerAddressLimit = 1; uint256 public wlNftPerAddressLimit = 3; uint256 public pNftPerAddressLimit = 5; mapping(address => uint256) public addressMintedBalance; constructor( string memory _name, string memory _symbol, string memory _initBaseURI, string memory _initNotRevealedUri, address[] memory _ogWhitelistedAddresses, address[] memory _wlWhitelistedAddresses ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); setNotRevealedURI(_initNotRevealedUri); _setOgwhitelistUsers(_ogWhitelistedAddresses); _setWlwhitelistUsers(_wlWhitelistedAddresses); } // internal function _setOgwhitelistUsers(address[] memory _users) private onlyOwner { delete ogWhitelistedAddresses; ogWhitelistedAddresses = _users; } function _setWlwhitelistUsers(address[] memory _users) private onlyOwner { delete wlWhitelistedAddresses; wlWhitelistedAddresses = _users; } function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(uint256 _mintAmount) public payable { uint256 supply = totalSupply(); uint256 ownerMintedCount = addressMintedBalance[msg.sender]; require(_mintAmount > 0, "need to mint at least 1 NFT"); if(msg.sender != owner()){ //Stop require(saleState != 0, "the contract is paused"); //og if(saleState == 1){ require(isOgWhitelisted(msg.sender), "user is not whitelisted"); require(ownerMintedCount + _mintAmount <= ogNftPerAddressLimit, "max NFT per address exceeded"); require(msg.value >= ogCost * _mintAmount, "insufficient funds"); require(supply + _mintAmount <= ogMaxSupply, "max NFT limit exceeded"); //wl }else if(saleState == 2){ if(isOgWhitelisted(msg.sender)){ require(ownerMintedCount + _mintAmount <= ogNftPerAddressLimit + wlNftPerAddressLimit, "max NFT per address exceeded"); }else{ require(isWlWhitelisted(msg.sender), "user is not whitelisted"); require(ownerMintedCount + _mintAmount <= wlNftPerAddressLimit, "max NFT per address exceeded"); } require(msg.value >= wlCost * _mintAmount, "insufficient funds"); require(supply + _mintAmount <= wlMaxSupply, "max NFT limit exceeded"); //public }else if(saleState == 3){ if(isOgWhitelisted(msg.sender)){ require(ownerMintedCount + _mintAmount <= ogNftPerAddressLimit + wlNftPerAddressLimit + pNftPerAddressLimit, "max NFT per address exceeded"); }else if(isWlWhitelisted(msg.sender)){ require(ownerMintedCount + _mintAmount <= wlNftPerAddressLimit + pNftPerAddressLimit, "max NFT per address exceeded"); }else{ require(ownerMintedCount + _mintAmount <= pNftPerAddressLimit, "max NFT per address exceeded"); } require(msg.value >= pCost * _mintAmount, "insufficient funds"); require(supply + _mintAmount <= pMaxSupply, "max NFT limit exceeded"); } } for (uint256 i = 1; i <= _mintAmount; i++) { addressMintedBalance[msg.sender]++; _safeMint(msg.sender, supply + i); } } function isOgWhitelisted(address _user) public view returns (bool) { for (uint i = 0; i < ogWhitelistedAddresses.length; i++) { if (ogWhitelistedAddresses[i] == _user) { return true; } } return false; } function isWlWhitelisted(address _user) public view returns (bool) { for (uint i = 0; i < wlWhitelistedAddresses.length; i++) { if (wlWhitelistedAddresses[i] == _user) { return true; } } return false; } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); if(revealed == false) { return notRevealedUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } //only owner function reveal() public onlyOwner { revealed = true; } function setOgwhitelistUsers(address[] calldata _users) public onlyOwner { delete ogWhitelistedAddresses; ogWhitelistedAddresses = _users; } function setWlwhitelistUsers(address[] calldata _users) public onlyOwner { delete wlWhitelistedAddresses; wlWhitelistedAddresses = _users; } function setOgCost(uint256 _newCost) public onlyOwner { ogCost = _newCost; } function setWlCost(uint256 _newCost) public onlyOwner { wlCost = _newCost; } function setPCost(uint256 _newCost) public onlyOwner { pCost = _newCost; } function setOgNftPerAddressLimit(uint256 _limit) public onlyOwner { ogNftPerAddressLimit = _limit; } function setWlNftPerAddressLimit(uint256 _limit) public onlyOwner { wlNftPerAddressLimit = _limit; } function setPNftPerAddressLimit(uint256 _limit) public onlyOwner { pNftPerAddressLimit = _limit; } function setSaleState(uint256 _state) public onlyOwner { saleState = _state; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } function withdraw() public payable onlyOwner { (bool os, ) = payable(owner()).call{value: address(this).balance}(""); require(os); } }
reveal
function reveal() public onlyOwner { revealed = true; }
//only owner
LineComment
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://f85091aa61000a5162ee30fc3b2a80064bdc3a0052ea298af5d6775accad2533
{ "func_code_index": [ 5241, 5309 ] }
1,264
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
Context
contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
_msgSender
function _msgSender() internal view returns (address payable) { return msg.sender; }
// solhint-disable-previous-line no-empty-blocks
LineComment
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 265, 368 ] }
1,265
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
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); }
totalSupply
function totalSupply() external view returns (uint256);
/** * @dev Returns the amount of tokens in existence. */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 94, 154 ] }
1,266
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
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); }
balanceOf
function balanceOf(address account) external view returns (uint256);
/** * @dev Returns the amount of tokens owned by `account`. */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 237, 310 ] }
1,267
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
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); }
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.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 534, 616 ] }
1,268
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
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); }
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.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 895, 983 ] }
1,269
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
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); }
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.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 1647, 1726 ] }
1,270
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
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); }
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.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 2039, 2141 ] }
1,271
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
add
function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; }
/** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 251, 437 ] }
1,272
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
sub
function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); }
/** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 707, 848 ] }
1,273
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
sub
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; }
/** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 1180, 1377 ] }
1,274
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
mul
function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; }
/** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 1623, 2099 ] }
1,275
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
div
function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); }
/** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 2562, 2699 ] }
1,276
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
div
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; }
/** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 3224, 3574 ] }
1,277
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
mod
function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); }
/** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 4026, 4161 ] }
1,278
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
mod
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; }
/** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 4675, 4846 ] }
1,279
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view 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 returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public 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 returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { 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"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _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 { 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 Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
totalSupply
function totalSupply() public view returns (uint256) { return _totalSupply; }
/** * @dev See {IERC20-totalSupply}. */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 299, 395 ] }
1,280
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view 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 returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public 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 returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { 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"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _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 { 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 Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
balanceOf
function balanceOf(address account) public view returns (uint256) { return _balances[account]; }
/** * @dev See {IERC20-balanceOf}. */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 453, 568 ] }
1,281
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view 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 returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public 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 returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { 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"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _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 { 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 Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
transfer
function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(_msgSender(), recipient, amount); return true; }
/** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 776, 939 ] }
1,282
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view 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 returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public 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 returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { 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"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _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 { 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 Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
allowance
function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; }
/** * @dev See {IERC20-allowance}. */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 997, 1136 ] }
1,283
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view 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 returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public 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 returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { 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"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _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 { 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 Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
approve
function approve(address spender, uint256 amount) public returns (bool) { _approve(_msgSender(), spender, amount); return true; }
/** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 1278, 1435 ] }
1,284
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view 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 returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public 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 returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { 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"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _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 { 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 Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
transferFrom
function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; }
/** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 1902, 2211 ] }
1,285
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view 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 returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public 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 returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { 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"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _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 { 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 Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
increaseAllowance
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; }
/** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 2615, 2830 ] }
1,286
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view 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 returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public 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 returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { 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"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _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 { 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 Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
decreaseAllowance
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; }
/** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 3328, 3594 ] }
1,287
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view 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 returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public 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 returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { 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"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _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 { 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 Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
_transfer
function _transfer(address sender, address recipient, uint256 amount) internal { 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"); _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.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 4079, 4555 ] }
1,288
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view 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 returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public 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 returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { 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"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _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 { 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 Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
_mint
function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); }
/** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 4831, 5144 ] }
1,289
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view 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 returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public 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 returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { 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"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _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 { 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 Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
_burn
function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _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.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 5471, 5824 ] }
1,290
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view 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 returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public 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 returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { 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"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _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 { 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 Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
_approve
function _approve(address owner, address spender, uint256 amount) internal { 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.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 6259, 6602 ] }
1,291
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view 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 returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public 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 returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { 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"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _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 { 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 Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
_burnFrom
function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); }
/** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 6783, 7020 ] }
1,292
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
Roles
library Roles { struct Role { mapping (address => bool) bearer; } /** * @dev Give an account access to this role. */ function add(Role storage role, address account) internal { require(!has(role, account), "Roles: account already has role"); role.bearer[account] = true; } /** * @dev Remove an account's access to this role. */ function remove(Role storage role, address account) internal { require(has(role, account), "Roles: account does not have role"); role.bearer[account] = false; } /** * @dev Check if an account has this role. * @return bool */ function has(Role storage role, address account) internal view returns (bool) { require(account != address(0), "Roles: account is the zero address"); return role.bearer[account]; } }
add
function add(Role storage role, address account) internal { require(!has(role, account), "Roles: account already has role"); role.bearer[account] = true; }
/** * @dev Give an account access to this role. */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 156, 339 ] }
1,293
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
Roles
library Roles { struct Role { mapping (address => bool) bearer; } /** * @dev Give an account access to this role. */ function add(Role storage role, address account) internal { require(!has(role, account), "Roles: account already has role"); role.bearer[account] = true; } /** * @dev Remove an account's access to this role. */ function remove(Role storage role, address account) internal { require(has(role, account), "Roles: account does not have role"); role.bearer[account] = false; } /** * @dev Check if an account has this role. * @return bool */ function has(Role storage role, address account) internal view returns (bool) { require(account != address(0), "Roles: account is the zero address"); return role.bearer[account]; } }
remove
function remove(Role storage role, address account) internal { require(has(role, account), "Roles: account does not have role"); role.bearer[account] = false; }
/** * @dev Remove an account's access to this role. */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 414, 602 ] }
1,294
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
Roles
library Roles { struct Role { mapping (address => bool) bearer; } /** * @dev Give an account access to this role. */ function add(Role storage role, address account) internal { require(!has(role, account), "Roles: account already has role"); role.bearer[account] = true; } /** * @dev Remove an account's access to this role. */ function remove(Role storage role, address account) internal { require(has(role, account), "Roles: account does not have role"); role.bearer[account] = false; } /** * @dev Check if an account has this role. * @return bool */ function has(Role storage role, address account) internal view returns (bool) { require(account != address(0), "Roles: account is the zero address"); return role.bearer[account]; } }
has
function has(Role storage role, address account) internal view returns (bool) { require(account != address(0), "Roles: account is the zero address"); return role.bearer[account]; }
/** * @dev Check if an account has this role. * @return bool */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 692, 900 ] }
1,295
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
ERC20Mintable
contract ERC20Mintable is ERC20, MinterRole { /** * @dev See {ERC20-_mint}. * * Requirements: * * - the caller must have the {MinterRole}. */ function mint(address account, uint256 amount) public onlyMinter returns (bool) { _mint(account, amount); return true; } }
mint
function mint(address account, uint256 amount) public onlyMinter returns (bool) { _mint(account, amount); return true; }
/** * @dev See {ERC20-_mint}. * * Requirements: * * - the caller must have the {MinterRole}. */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 184, 332 ] }
1,296
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
ERC20Capped
contract ERC20Capped is ERC20Mintable { uint256 private _cap; /** * @dev Sets the value of the `cap`. This value is immutable, it can only be * set once during construction. */ constructor (uint256 cap) public { require(cap > 0, "ERC20Capped: cap is 0"); _cap = cap; } /** * @dev Returns the cap on the token's total supply. */ function cap() public view returns (uint256) { return _cap; } /** * @dev See {ERC20Mintable-mint}. * * Requirements: * * - `value` must not cause the total supply to go over the cap. */ function _mint(address account, uint256 value) internal { require(totalSupply().add(value) <= _cap, "ERC20Capped: cap exceeded"); super._mint(account, value); } }
cap
function cap() public view returns (uint256) { return _cap; }
/** * @dev Returns the cap on the token's total supply. */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 406, 486 ] }
1,297
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
ERC20Capped
contract ERC20Capped is ERC20Mintable { uint256 private _cap; /** * @dev Sets the value of the `cap`. This value is immutable, it can only be * set once during construction. */ constructor (uint256 cap) public { require(cap > 0, "ERC20Capped: cap is 0"); _cap = cap; } /** * @dev Returns the cap on the token's total supply. */ function cap() public view returns (uint256) { return _cap; } /** * @dev See {ERC20Mintable-mint}. * * Requirements: * * - `value` must not cause the total supply to go over the cap. */ function _mint(address account, uint256 value) internal { require(totalSupply().add(value) <= _cap, "ERC20Capped: cap exceeded"); super._mint(account, value); } }
_mint
function _mint(address account, uint256 value) internal { require(totalSupply().add(value) <= _cap, "ERC20Capped: cap exceeded"); super._mint(account, value); }
/** * @dev See {ERC20Mintable-mint}. * * Requirements: * * - `value` must not cause the total supply to go over the cap. */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 654, 842 ] }
1,298
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
ERC20Detailed
contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of * these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @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. * * 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; } }
name
function name() public view returns (string memory) { return _name; }
/** * @dev Returns the name of the token. */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 550, 638 ] }
1,299
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
ERC20Detailed
contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of * these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @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. * * 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; } }
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.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 752, 844 ] }
1,300
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
ERC20Detailed
contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of * these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @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. * * 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; } }
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. * * 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.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 1402, 1490 ] }
1,301
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
Pausable
contract Pausable is Context, PauserRole { /** * @dev Emitted when the pause is triggered by a pauser (`account`). */ event Paused(address account); /** * @dev Emitted when the pause is lifted by a pauser (`account`). */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. Assigns the Pauser role * to the deployer. */ constructor () internal { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!_paused, "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(_paused, "Pausable: not paused"); _; } /** * @dev Called by a pauser to pause, triggers stopped state. */ function pause() public onlyPauser whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Called by a pauser to unpause, returns to normal state. */ function unpause() public onlyPauser whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
paused
function paused() public view returns (bool) { return _paused; }
/** * @dev Returns true if the contract is paused, and false otherwise. */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 614, 697 ] }
1,302
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
Pausable
contract Pausable is Context, PauserRole { /** * @dev Emitted when the pause is triggered by a pauser (`account`). */ event Paused(address account); /** * @dev Emitted when the pause is lifted by a pauser (`account`). */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. Assigns the Pauser role * to the deployer. */ constructor () internal { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!_paused, "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(_paused, "Pausable: not paused"); _; } /** * @dev Called by a pauser to pause, triggers stopped state. */ function pause() public onlyPauser whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Called by a pauser to unpause, returns to normal state. */ function unpause() public onlyPauser whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
pause
function pause() public onlyPauser whenNotPaused { _paused = true; emit Paused(_msgSender()); }
/** * @dev Called by a pauser to pause, triggers stopped state. */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 1194, 1317 ] }
1,303
MEDIKOIN
MEDIKOIN.sol
0xe7aa03ec676f531167454b1104001b7e8c9f41b5
Solidity
Pausable
contract Pausable is Context, PauserRole { /** * @dev Emitted when the pause is triggered by a pauser (`account`). */ event Paused(address account); /** * @dev Emitted when the pause is lifted by a pauser (`account`). */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. Assigns the Pauser role * to the deployer. */ constructor () internal { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!_paused, "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(_paused, "Pausable: not paused"); _; } /** * @dev Called by a pauser to pause, triggers stopped state. */ function pause() public onlyPauser whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Called by a pauser to unpause, returns to normal state. */ function unpause() public onlyPauser whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
unpause
function unpause() public onlyPauser whenPaused { _paused = false; emit Unpaused(_msgSender()); }
/** * @dev Called by a pauser to unpause, returns to normal state. */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
MIT
bzzr://9b0e9ada8cd87e561ce9b3b8c72cc270faf6229f66ed9efcb4b514977d1a3002
{ "func_code_index": [ 1407, 1532 ] }
1,304
UniswapZAP
contracts/UniswapZAP.sol
0x4c72653b2f0916ced776c6514926112f289f4484
Solidity
UniswapZAP
contract UniswapZAP { using SafeMath for uint256; address public _token; address public _tokenWETHPair; IWETH public _WETH; bool private initialized; function initUniswapZAP(address token, address WETH, address tokenWethPair) public { require(!initialized); _token = token; _WETH = IWETH(WETH); _tokenWETHPair = tokenWethPair; initialized = true; } fallback() external payable { if(msg.sender != address(_WETH)){ addLiquidityETHOnly(msg.sender); } } function zapETH() external payable { require(msg.value > 0, "ETH amount must be greater than 0"); addLiquidityETHOnly(msg.sender); } function zapTokens(uint amount) external { require(amount > 0, "Token amount must be greater than 0"); addLiquidityTokensOnly(msg.sender, msg.sender, amount); } function unzap() external returns (uint amountToken, uint amountETH) { uint256 liquidity = IERC20(_tokenWETHPair).balanceOf(msg.sender); (amountToken, amountETH) = removeLiquidity( _token,address(_WETH),liquidity,msg.sender); } function unzapToETH() external returns (uint amount) { uint256 liquidity = IERC20(_tokenWETHPair).balanceOf(msg.sender); amount = removeLiquidityETHOnly(msg.sender, liquidity); } function unzapToTokens() external returns (uint amount) { uint256 liquidity = IERC20(_tokenWETHPair).balanceOf(msg.sender); amount = removeLiquidityTokenOnly(msg.sender, liquidity); } /// @dev Add liquidity functions function addLiquidityTokensOnly(address from, address payable to, uint amount) public { require(to != address(0), "Invalid address"); uint256 buyAmount = amount.div(2); require(buyAmount > 0, "Insufficient Token amount"); (uint256 reserveWeth, uint256 reserveTokens) = getPairReserves(); uint256 outETH = UniswapV2Library.getAmountOut(buyAmount, reserveTokens, reserveWeth); safeTransferFrom(_token, from, address(this), amount); safeTransfer(_token, _tokenWETHPair, buyAmount); (address token0, address token1) = UniswapV2Library.sortTokens(address(_WETH), _token); IUniswapV2Pair(_tokenWETHPair).swap(address(_WETH) == token0 ? outETH : 0, address(_WETH) == token1 ? outETH : 0, address(this), ""); _addLiquidity( buyAmount, outETH, to); } function addLiquidityETHOnly(address payable to) public payable { require(to != address(0), "Invalid address"); uint256 buyAmount = msg.value.div(2); require(buyAmount > 0, "Insufficient ETH amount"); _WETH.deposit{value : msg.value}(); (uint256 reserveWeth, uint256 reserveTokens) = getPairReserves(); uint256 outTokens = UniswapV2Library.getAmountOut(buyAmount, reserveWeth, reserveTokens); _WETH.transfer(_tokenWETHPair, buyAmount); (address token0, address token1) = UniswapV2Library.sortTokens(address(_WETH), _token); IUniswapV2Pair(_tokenWETHPair).swap(_token == token0 ? outTokens : 0, _token == token1 ? outTokens : 0, address(this), ""); _addLiquidity(outTokens, buyAmount, to); } function _addLiquidity(uint256 tokenAmount, uint256 wethAmount, address payable to) internal { (uint256 wethReserve, uint256 tokenReserve) = getPairReserves(); uint256 optimalTokenAmount = UniswapV2Library.quote(wethAmount, wethReserve, tokenReserve); uint256 optimalWETHAmount; if (optimalTokenAmount > tokenAmount) { optimalWETHAmount = UniswapV2Library.quote(tokenAmount, tokenReserve, wethReserve); optimalTokenAmount = tokenAmount; } else optimalWETHAmount = wethAmount; assert(_WETH.transfer(_tokenWETHPair, optimalWETHAmount)); assert(IERC20(_token).transfer(_tokenWETHPair, optimalTokenAmount)); IUniswapV2Pair(_tokenWETHPair).mint(to); //refund dust if (tokenAmount > optimalTokenAmount) IERC20(_token).transfer(to, tokenAmount.sub(optimalTokenAmount)); if (wethAmount > optimalWETHAmount) { uint256 withdrawAmount = wethAmount.sub(optimalWETHAmount); _WETH.withdraw(withdrawAmount); to.transfer(withdrawAmount); } } function removeLiquidity( address tokenA, address tokenB, uint liquidity, address to ) public returns (uint amountA, uint amountB) { IUniswapV2Pair(_tokenWETHPair).transferFrom(msg.sender, _tokenWETHPair, liquidity); // send liquidity to pair (uint amount0, uint amount1) = IUniswapV2Pair(_tokenWETHPair).burn(to); (address token0,) = UniswapV2Library.sortTokens(tokenA, tokenB); (amountA, amountB) = tokenA == token0 ? (amount0, amount1) : (amount1, amount0); } function removeLiquidityETHOnly(address payable to, uint256 liquidity) public returns (uint amountOut){ require(to != address(0), "Invalid address"); (uint amountToken, uint amountETH) = removeLiquidity( _token,address(_WETH),liquidity,address(this)); (uint256 reserveWeth, uint256 reserveTokens) = getPairReserves(); uint256 outETH = UniswapV2Library.getAmountOut(amountToken, reserveTokens, reserveWeth); safeTransfer(_token, _tokenWETHPair, amountToken); (address token0, address token1) = UniswapV2Library.sortTokens(address(_WETH), _token); IUniswapV2Pair(_tokenWETHPair).swap(address(_WETH) == token0 ? outETH : 0, address(_WETH) == token1 ? outETH : 0, address(this), ""); amountOut = IERC20(address(_WETH)).balanceOf(address(this)); _WETH.withdraw(amountOut); safeTransferETH(to, amountOut); } function removeAllLiquidityETHOnly(address payable to) public returns (uint amount) { uint256 liquidity = IERC20(_tokenWETHPair).balanceOf(msg.sender); amount = removeLiquidityETHOnly(to, liquidity); } function removeLiquidityTokenOnly(address to, uint256 liquidity) public returns (uint amount){ require(to != address(0), "Invalid address"); (uint amountToken, uint amountETH) = removeLiquidity( _token,address(_WETH),liquidity,address(this)); (uint256 reserveWeth, uint256 reserveTokens) = getPairReserves(); uint256 outTokens = UniswapV2Library.getAmountOut(amountETH, reserveWeth, reserveTokens); _WETH.transfer(_tokenWETHPair, amountETH); (address token0, address token1) = UniswapV2Library.sortTokens(address(_WETH), _token); IUniswapV2Pair(_tokenWETHPair).swap(_token == token0 ? outTokens : 0, _token == token1 ? outTokens : 0, address(this), ""); amount = IERC20(_token).balanceOf(address(this)); safeTransfer(_token, to, amount); } function removeAllLiquidityTokenOnly(address payable to) public returns (uint amount) { uint256 liquidity = IERC20(_tokenWETHPair).balanceOf(msg.sender); amount = removeLiquidityTokenOnly(to, liquidity); } function getLPTokenPerEthUnit(uint ethAmt) public view returns (uint liquidity){ (uint256 reserveWeth, uint256 reserveTokens) = getPairReserves(); uint256 outTokens = UniswapV2Library.getAmountOut(ethAmt.div(2), reserveWeth, reserveTokens); uint _totalSupply = IUniswapV2Pair(_tokenWETHPair).totalSupply(); (address token0, ) = UniswapV2Library.sortTokens(address(_WETH), _token); (uint256 amount0, uint256 amount1) = token0 == _token ? (outTokens, ethAmt.div(2)) : (ethAmt.div(2), outTokens); (uint256 _reserve0, uint256 _reserve1) = token0 == _token ? (reserveTokens, reserveWeth) : (reserveWeth, reserveTokens); liquidity = SafeMath.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1); } function getPairReserves() internal view returns (uint256 wethReserves, uint256 tokenReserves) { (address token0,) = UniswapV2Library.sortTokens(address(_WETH), _token); (uint256 reserve0, uint reserve1,) = IUniswapV2Pair(_tokenWETHPair).getReserves(); (wethReserves, tokenReserves) = token0 == _token ? (reserve1, reserve0) : (reserve0, reserve1); } /// @dev Transfer helper from UniswapV2 Router function safeApprove(address token, address to, uint value) internal { // bytes4(keccak256(bytes('approve(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED'); } function safeTransfer(address token, address to, uint value) internal { // bytes4(keccak256(bytes('transfer(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FAILED'); } function safeTransferFrom(address token, address from, address to, uint value) internal { // bytes4(keccak256(bytes('transferFrom(address,address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FROM_FAILED'); } function safeTransferETH(address to, uint value) internal { (bool success,) = to.call{value:value}(new bytes(0)); require(success, 'TransferHelper: ETH_TRANSFER_FAILED'); } }
// ---------------------------------------------------------------------
LineComment
addLiquidityTokensOnly
function addLiquidityTokensOnly(address from, address payable to, uint amount) public { require(to != address(0), "Invalid address"); uint256 buyAmount = amount.div(2); require(buyAmount > 0, "Insufficient Token amount"); (uint256 reserveWeth, uint256 reserveTokens) = getPairReserves(); uint256 outETH = UniswapV2Library.getAmountOut(buyAmount, reserveTokens, reserveWeth); safeTransferFrom(_token, from, address(this), amount); safeTransfer(_token, _tokenWETHPair, buyAmount); (address token0, address token1) = UniswapV2Library.sortTokens(address(_WETH), _token); IUniswapV2Pair(_tokenWETHPair).swap(address(_WETH) == token0 ? outETH : 0, address(_WETH) == token1 ? outETH : 0, address(this), ""); _addLiquidity( buyAmount, outETH, to); }
/// @dev Add liquidity functions
NatSpecSingleLine
v0.6.12+commit.27d51765
GNU GPLv3
ipfs://5fb53e5c71bd6136fc00a0d29e9342d2965b11229f23c3eabfbda699263fb011
{ "func_code_index": [ 1663, 2524 ] }
1,305
UniswapZAP
contracts/UniswapZAP.sol
0x4c72653b2f0916ced776c6514926112f289f4484
Solidity
UniswapZAP
contract UniswapZAP { using SafeMath for uint256; address public _token; address public _tokenWETHPair; IWETH public _WETH; bool private initialized; function initUniswapZAP(address token, address WETH, address tokenWethPair) public { require(!initialized); _token = token; _WETH = IWETH(WETH); _tokenWETHPair = tokenWethPair; initialized = true; } fallback() external payable { if(msg.sender != address(_WETH)){ addLiquidityETHOnly(msg.sender); } } function zapETH() external payable { require(msg.value > 0, "ETH amount must be greater than 0"); addLiquidityETHOnly(msg.sender); } function zapTokens(uint amount) external { require(amount > 0, "Token amount must be greater than 0"); addLiquidityTokensOnly(msg.sender, msg.sender, amount); } function unzap() external returns (uint amountToken, uint amountETH) { uint256 liquidity = IERC20(_tokenWETHPair).balanceOf(msg.sender); (amountToken, amountETH) = removeLiquidity( _token,address(_WETH),liquidity,msg.sender); } function unzapToETH() external returns (uint amount) { uint256 liquidity = IERC20(_tokenWETHPair).balanceOf(msg.sender); amount = removeLiquidityETHOnly(msg.sender, liquidity); } function unzapToTokens() external returns (uint amount) { uint256 liquidity = IERC20(_tokenWETHPair).balanceOf(msg.sender); amount = removeLiquidityTokenOnly(msg.sender, liquidity); } /// @dev Add liquidity functions function addLiquidityTokensOnly(address from, address payable to, uint amount) public { require(to != address(0), "Invalid address"); uint256 buyAmount = amount.div(2); require(buyAmount > 0, "Insufficient Token amount"); (uint256 reserveWeth, uint256 reserveTokens) = getPairReserves(); uint256 outETH = UniswapV2Library.getAmountOut(buyAmount, reserveTokens, reserveWeth); safeTransferFrom(_token, from, address(this), amount); safeTransfer(_token, _tokenWETHPair, buyAmount); (address token0, address token1) = UniswapV2Library.sortTokens(address(_WETH), _token); IUniswapV2Pair(_tokenWETHPair).swap(address(_WETH) == token0 ? outETH : 0, address(_WETH) == token1 ? outETH : 0, address(this), ""); _addLiquidity( buyAmount, outETH, to); } function addLiquidityETHOnly(address payable to) public payable { require(to != address(0), "Invalid address"); uint256 buyAmount = msg.value.div(2); require(buyAmount > 0, "Insufficient ETH amount"); _WETH.deposit{value : msg.value}(); (uint256 reserveWeth, uint256 reserveTokens) = getPairReserves(); uint256 outTokens = UniswapV2Library.getAmountOut(buyAmount, reserveWeth, reserveTokens); _WETH.transfer(_tokenWETHPair, buyAmount); (address token0, address token1) = UniswapV2Library.sortTokens(address(_WETH), _token); IUniswapV2Pair(_tokenWETHPair).swap(_token == token0 ? outTokens : 0, _token == token1 ? outTokens : 0, address(this), ""); _addLiquidity(outTokens, buyAmount, to); } function _addLiquidity(uint256 tokenAmount, uint256 wethAmount, address payable to) internal { (uint256 wethReserve, uint256 tokenReserve) = getPairReserves(); uint256 optimalTokenAmount = UniswapV2Library.quote(wethAmount, wethReserve, tokenReserve); uint256 optimalWETHAmount; if (optimalTokenAmount > tokenAmount) { optimalWETHAmount = UniswapV2Library.quote(tokenAmount, tokenReserve, wethReserve); optimalTokenAmount = tokenAmount; } else optimalWETHAmount = wethAmount; assert(_WETH.transfer(_tokenWETHPair, optimalWETHAmount)); assert(IERC20(_token).transfer(_tokenWETHPair, optimalTokenAmount)); IUniswapV2Pair(_tokenWETHPair).mint(to); //refund dust if (tokenAmount > optimalTokenAmount) IERC20(_token).transfer(to, tokenAmount.sub(optimalTokenAmount)); if (wethAmount > optimalWETHAmount) { uint256 withdrawAmount = wethAmount.sub(optimalWETHAmount); _WETH.withdraw(withdrawAmount); to.transfer(withdrawAmount); } } function removeLiquidity( address tokenA, address tokenB, uint liquidity, address to ) public returns (uint amountA, uint amountB) { IUniswapV2Pair(_tokenWETHPair).transferFrom(msg.sender, _tokenWETHPair, liquidity); // send liquidity to pair (uint amount0, uint amount1) = IUniswapV2Pair(_tokenWETHPair).burn(to); (address token0,) = UniswapV2Library.sortTokens(tokenA, tokenB); (amountA, amountB) = tokenA == token0 ? (amount0, amount1) : (amount1, amount0); } function removeLiquidityETHOnly(address payable to, uint256 liquidity) public returns (uint amountOut){ require(to != address(0), "Invalid address"); (uint amountToken, uint amountETH) = removeLiquidity( _token,address(_WETH),liquidity,address(this)); (uint256 reserveWeth, uint256 reserveTokens) = getPairReserves(); uint256 outETH = UniswapV2Library.getAmountOut(amountToken, reserveTokens, reserveWeth); safeTransfer(_token, _tokenWETHPair, amountToken); (address token0, address token1) = UniswapV2Library.sortTokens(address(_WETH), _token); IUniswapV2Pair(_tokenWETHPair).swap(address(_WETH) == token0 ? outETH : 0, address(_WETH) == token1 ? outETH : 0, address(this), ""); amountOut = IERC20(address(_WETH)).balanceOf(address(this)); _WETH.withdraw(amountOut); safeTransferETH(to, amountOut); } function removeAllLiquidityETHOnly(address payable to) public returns (uint amount) { uint256 liquidity = IERC20(_tokenWETHPair).balanceOf(msg.sender); amount = removeLiquidityETHOnly(to, liquidity); } function removeLiquidityTokenOnly(address to, uint256 liquidity) public returns (uint amount){ require(to != address(0), "Invalid address"); (uint amountToken, uint amountETH) = removeLiquidity( _token,address(_WETH),liquidity,address(this)); (uint256 reserveWeth, uint256 reserveTokens) = getPairReserves(); uint256 outTokens = UniswapV2Library.getAmountOut(amountETH, reserveWeth, reserveTokens); _WETH.transfer(_tokenWETHPair, amountETH); (address token0, address token1) = UniswapV2Library.sortTokens(address(_WETH), _token); IUniswapV2Pair(_tokenWETHPair).swap(_token == token0 ? outTokens : 0, _token == token1 ? outTokens : 0, address(this), ""); amount = IERC20(_token).balanceOf(address(this)); safeTransfer(_token, to, amount); } function removeAllLiquidityTokenOnly(address payable to) public returns (uint amount) { uint256 liquidity = IERC20(_tokenWETHPair).balanceOf(msg.sender); amount = removeLiquidityTokenOnly(to, liquidity); } function getLPTokenPerEthUnit(uint ethAmt) public view returns (uint liquidity){ (uint256 reserveWeth, uint256 reserveTokens) = getPairReserves(); uint256 outTokens = UniswapV2Library.getAmountOut(ethAmt.div(2), reserveWeth, reserveTokens); uint _totalSupply = IUniswapV2Pair(_tokenWETHPair).totalSupply(); (address token0, ) = UniswapV2Library.sortTokens(address(_WETH), _token); (uint256 amount0, uint256 amount1) = token0 == _token ? (outTokens, ethAmt.div(2)) : (ethAmt.div(2), outTokens); (uint256 _reserve0, uint256 _reserve1) = token0 == _token ? (reserveTokens, reserveWeth) : (reserveWeth, reserveTokens); liquidity = SafeMath.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1); } function getPairReserves() internal view returns (uint256 wethReserves, uint256 tokenReserves) { (address token0,) = UniswapV2Library.sortTokens(address(_WETH), _token); (uint256 reserve0, uint reserve1,) = IUniswapV2Pair(_tokenWETHPair).getReserves(); (wethReserves, tokenReserves) = token0 == _token ? (reserve1, reserve0) : (reserve0, reserve1); } /// @dev Transfer helper from UniswapV2 Router function safeApprove(address token, address to, uint value) internal { // bytes4(keccak256(bytes('approve(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED'); } function safeTransfer(address token, address to, uint value) internal { // bytes4(keccak256(bytes('transfer(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FAILED'); } function safeTransferFrom(address token, address from, address to, uint value) internal { // bytes4(keccak256(bytes('transferFrom(address,address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FROM_FAILED'); } function safeTransferETH(address to, uint value) internal { (bool success,) = to.call{value:value}(new bytes(0)); require(success, 'TransferHelper: ETH_TRANSFER_FAILED'); } }
// ---------------------------------------------------------------------
LineComment
safeApprove
function safeApprove(address token, address to, uint value) internal { // bytes4(keccak256(bytes('approve(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED'); }
/// @dev Transfer helper from UniswapV2 Router
NatSpecSingleLine
v0.6.12+commit.27d51765
GNU GPLv3
ipfs://5fb53e5c71bd6136fc00a0d29e9342d2965b11229f23c3eabfbda699263fb011
{ "func_code_index": [ 8540, 8903 ] }
1,306