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
PAaveIntegration
contracts/masset/peripheral/AaveV2Integration.sol
0x4094aec22f40f11c29941d144c3dc887b33f5504
Solidity
AaveV2Integration
contract AaveV2Integration is AbstractIntegration { using SafeERC20 for IERC20; // Core address for the given platform */ address public immutable platformAddress; address public immutable rewardToken; event RewardTokenApproved(address rewardToken, address account); /** * @param _nexus Address of the Nexus * @param _lp Address of LP * @param _platformAddress Generic platform address * @param _rewardToken Reward token, if any */ constructor( address _nexus, address _lp, address _platformAddress, address _rewardToken ) AbstractIntegration(_nexus, _lp) { require(_platformAddress != address(0), "Invalid platform address"); platformAddress = _platformAddress; rewardToken = _rewardToken; } /*************************************** ADMIN ****************************************/ /** * @dev Approves Liquidator to spend reward tokens */ function approveRewardToken() external onlyGovernor { address liquidator = nexus.getModule(keccak256("Liquidator")); require(liquidator != address(0), "Liquidator address cannot be zero"); MassetHelpers.safeInfiniteApprove(rewardToken, liquidator); emit RewardTokenApproved(rewardToken, liquidator); } /*************************************** CORE ****************************************/ /** * @dev Deposit a quantity of bAsset into the platform. Credited aTokens * remain here in the vault. Can only be called by whitelisted addresses * (mAsset and corresponding BasketManager) * @param _bAsset Address for the bAsset * @param _amount Units of bAsset to deposit * @param _hasTxFee Is the bAsset known to have a tx fee? * @return quantityDeposited Quantity of bAsset that entered the platform */ function deposit( address _bAsset, uint256 _amount, bool _hasTxFee ) external override onlyLP nonReentrant returns (uint256 quantityDeposited) { require(_amount > 0, "Must deposit something"); IAaveATokenV2 aToken = _getATokenFor(_bAsset); quantityDeposited = _amount; if (_hasTxFee) { // If we charge a fee, account for it uint256 prevBal = _checkBalance(aToken); _getLendingPool().deposit(_bAsset, _amount, address(this), 36); uint256 newBal = _checkBalance(aToken); quantityDeposited = _min(quantityDeposited, newBal - prevBal); } else { _getLendingPool().deposit(_bAsset, _amount, address(this), 36); } emit Deposit(_bAsset, address(aToken), quantityDeposited); } /** * @dev Withdraw a quantity of bAsset from the platform * @param _receiver Address to which the bAsset should be sent * @param _bAsset Address of the bAsset * @param _amount Units of bAsset to withdraw * @param _hasTxFee Is the bAsset known to have a tx fee? */ function withdraw( address _receiver, address _bAsset, uint256 _amount, bool _hasTxFee ) external override onlyLP nonReentrant { _withdraw(_receiver, _bAsset, _amount, _amount, _hasTxFee); } /** * @dev Withdraw a quantity of bAsset from the platform * @param _receiver Address to which the bAsset should be sent * @param _bAsset Address of the bAsset * @param _amount Units of bAsset to send to recipient * @param _totalAmount Total units to pull from lending platform * @param _hasTxFee Is the bAsset known to have a tx fee? */ function withdraw( address _receiver, address _bAsset, uint256 _amount, uint256 _totalAmount, bool _hasTxFee ) external override onlyLP nonReentrant { _withdraw(_receiver, _bAsset, _amount, _totalAmount, _hasTxFee); } /** @dev Withdraws _totalAmount from the lending pool, sending _amount to user */ function _withdraw( address _receiver, address _bAsset, uint256 _amount, uint256 _totalAmount, bool _hasTxFee ) internal { require(_totalAmount > 0, "Must withdraw something"); IAaveATokenV2 aToken = _getATokenFor(_bAsset); if (_hasTxFee) { require(_amount == _totalAmount, "Cache inactive for assets with fee"); _getLendingPool().withdraw(_bAsset, _amount, _receiver); } else { _getLendingPool().withdraw(_bAsset, _totalAmount, address(this)); // Send redeemed bAsset to the receiver IERC20(_bAsset).safeTransfer(_receiver, _amount); } emit PlatformWithdrawal(_bAsset, address(aToken), _totalAmount, _amount); } /** * @dev Withdraw a quantity of bAsset from the cache. * @param _receiver Address to which the bAsset should be sent * @param _bAsset Address of the bAsset * @param _amount Units of bAsset to withdraw */ function withdrawRaw( address _receiver, address _bAsset, uint256 _amount ) external override onlyLP nonReentrant { require(_amount > 0, "Must withdraw something"); require(_receiver != address(0), "Must specify recipient"); IERC20(_bAsset).safeTransfer(_receiver, _amount); emit Withdrawal(_bAsset, address(0), _amount); } /** * @dev Get the total bAsset value held in the platform * This includes any interest that was generated since depositing * Aave gradually increases the balances of all aToken holders, as the interest grows * @param _bAsset Address of the bAsset * @return balance Total value of the bAsset in the platform */ function checkBalance(address _bAsset) external view override returns (uint256 balance) { // balance is always with token aToken decimals IAaveATokenV2 aToken = _getATokenFor(_bAsset); return _checkBalance(aToken); } /*************************************** APPROVALS ****************************************/ /** * @dev Internal method to respond to the addition of new bAsset / pTokens * We need to approve the Aave lending pool core conrtact and give it permission * to spend the bAsset * @param _bAsset Address of the bAsset to approve */ function _abstractSetPToken( address _bAsset, address /*_pToken*/ ) internal override { address lendingPool = address(_getLendingPool()); // approve the pool to spend the bAsset MassetHelpers.safeInfiniteApprove(_bAsset, lendingPool); } /*************************************** HELPERS ****************************************/ /** * @dev Get the current address of the Aave lending pool, which is the gateway to * depositing. * @return Current lending pool implementation */ function _getLendingPool() internal view returns (IAaveLendingPoolV2) { address lendingPool = ILendingPoolAddressesProviderV2(platformAddress).getLendingPool(); require(lendingPool != address(0), "Lending pool does not exist"); return IAaveLendingPoolV2(lendingPool); } /** * @dev Get the pToken wrapped in the IAaveAToken interface for this bAsset, to use * for withdrawing or balance checking. Fails if the pToken doesn't exist in our mappings. * @param _bAsset Address of the bAsset * @return aToken Corresponding to this bAsset */ function _getATokenFor(address _bAsset) internal view returns (IAaveATokenV2) { address aToken = bAssetToPToken[_bAsset]; require(aToken != address(0), "aToken does not exist"); return IAaveATokenV2(aToken); } /** * @dev Get the total bAsset value held in the platform * @param _aToken aToken for which to check balance * @return balance Total value of the bAsset in the platform */ function _checkBalance(IAaveATokenV2 _aToken) internal view returns (uint256 balance) { return _aToken.balanceOf(address(this)); } }
/** * @title AaveV2Integration * @author mStable * @notice A simple connection to deposit and withdraw bAssets from Aave * @dev VERSION: 1.0 * DATE: 2020-16-11 */
NatSpecMultiLine
_checkBalance
function _checkBalance(IAaveATokenV2 _aToken) internal view returns (uint256 balance) { return _aToken.balanceOf(address(this)); }
/** * @dev Get the total bAsset value held in the platform * @param _aToken aToken for which to check balance * @return balance Total value of the bAsset in the platform */
NatSpecMultiLine
v0.8.6+commit.11564f7e
{ "func_code_index": [ 8229, 8375 ] }
2,700
Token
Token.sol
0xa62621a592bf8ec23718e5593c2d668327381648
Solidity
ERC20Base
contract ERC20Base is ERC20Interface { using SafeMath for uint256; string public symbol; string public name; uint8 public decimals; uint public totalSupply_; address public owner; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /** * @dev Constructor */ constructor(address _owner) public { symbol = "DTC"; name = "Delta Coin"; decimals = 18; totalSupply_ = 272 * (10 ** 8) * (10 ** 18); owner = _owner; balances[owner] = totalSupply_; emit Transfer(address(0), owner, totalSupply_); } /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint _value) public returns (bool success) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Destoys `amount` tokens, reducing the total supply. * @param _value must have at least `amount` tokens. */ function burn(uint256 _value) public { address account = msg.sender; totalSupply_ = totalSupply_.sub(_value); balances[account] = balances[account].sub(_value); emit Transfer(account, address(0), _value); } }
totalSupply
function totalSupply() public view returns (uint256) { return totalSupply_; }
/** * @dev total number of tokens in existence */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://3ba331a200d1c272e4d4a16ee63afef52d0e08e05f0b087031343bfc0112e90f
{ "func_code_index": [ 730, 826 ] }
2,701
Token
Token.sol
0xa62621a592bf8ec23718e5593c2d668327381648
Solidity
ERC20Base
contract ERC20Base is ERC20Interface { using SafeMath for uint256; string public symbol; string public name; uint8 public decimals; uint public totalSupply_; address public owner; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /** * @dev Constructor */ constructor(address _owner) public { symbol = "DTC"; name = "Delta Coin"; decimals = 18; totalSupply_ = 272 * (10 ** 8) * (10 ** 18); owner = _owner; balances[owner] = totalSupply_; emit Transfer(address(0), owner, totalSupply_); } /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint _value) public returns (bool success) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Destoys `amount` tokens, reducing the total supply. * @param _value must have at least `amount` tokens. */ function burn(uint256 _value) public { address account = msg.sender; totalSupply_ = totalSupply_.sub(_value); balances[account] = balances[account].sub(_value); emit Transfer(account, address(0), _value); } }
balanceOf
function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; }
/** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://3ba331a200d1c272e4d4a16ee63afef52d0e08e05f0b087031343bfc0112e90f
{ "func_code_index": [ 1042, 1162 ] }
2,702
Token
Token.sol
0xa62621a592bf8ec23718e5593c2d668327381648
Solidity
ERC20Base
contract ERC20Base is ERC20Interface { using SafeMath for uint256; string public symbol; string public name; uint8 public decimals; uint public totalSupply_; address public owner; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /** * @dev Constructor */ constructor(address _owner) public { symbol = "DTC"; name = "Delta Coin"; decimals = 18; totalSupply_ = 272 * (10 ** 8) * (10 ** 18); owner = _owner; balances[owner] = totalSupply_; emit Transfer(address(0), owner, totalSupply_); } /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint _value) public returns (bool success) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Destoys `amount` tokens, reducing the total supply. * @param _value must have at least `amount` tokens. */ function burn(uint256 _value) public { address account = msg.sender; totalSupply_ = totalSupply_.sub(_value); balances[account] = balances[account].sub(_value); emit Transfer(account, address(0), _value); } }
transfer
function transfer(address _to, uint _value) public returns (bool success) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; }
/** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://3ba331a200d1c272e4d4a16ee63afef52d0e08e05f0b087031343bfc0112e90f
{ "func_code_index": [ 1330, 1695 ] }
2,703
Token
Token.sol
0xa62621a592bf8ec23718e5593c2d668327381648
Solidity
ERC20Base
contract ERC20Base is ERC20Interface { using SafeMath for uint256; string public symbol; string public name; uint8 public decimals; uint public totalSupply_; address public owner; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /** * @dev Constructor */ constructor(address _owner) public { symbol = "DTC"; name = "Delta Coin"; decimals = 18; totalSupply_ = 272 * (10 ** 8) * (10 ** 18); owner = _owner; balances[owner] = totalSupply_; emit Transfer(address(0), owner, totalSupply_); } /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint _value) public returns (bool success) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Destoys `amount` tokens, reducing the total supply. * @param _value must have at least `amount` tokens. */ function burn(uint256 _value) public { address account = msg.sender; totalSupply_ = totalSupply_.sub(_value); balances[account] = balances[account].sub(_value); emit Transfer(account, address(0), _value); } }
approve
function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; }
/** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://3ba331a200d1c272e4d4a16ee63afef52d0e08e05f0b087031343bfc0112e90f
{ "func_code_index": [ 1937, 2148 ] }
2,704
Token
Token.sol
0xa62621a592bf8ec23718e5593c2d668327381648
Solidity
ERC20Base
contract ERC20Base is ERC20Interface { using SafeMath for uint256; string public symbol; string public name; uint8 public decimals; uint public totalSupply_; address public owner; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /** * @dev Constructor */ constructor(address _owner) public { symbol = "DTC"; name = "Delta Coin"; decimals = 18; totalSupply_ = 272 * (10 ** 8) * (10 ** 18); owner = _owner; balances[owner] = totalSupply_; emit Transfer(address(0), owner, totalSupply_); } /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint _value) public returns (bool success) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Destoys `amount` tokens, reducing the total supply. * @param _value must have at least `amount` tokens. */ function burn(uint256 _value) public { address account = msg.sender; totalSupply_ = totalSupply_.sub(_value); balances[account] = balances[account].sub(_value); emit Transfer(account, address(0), _value); } }
transferFrom
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; }
/** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://3ba331a200d1c272e4d4a16ee63afef52d0e08e05f0b087031343bfc0112e90f
{ "func_code_index": [ 2435, 2928 ] }
2,705
Token
Token.sol
0xa62621a592bf8ec23718e5593c2d668327381648
Solidity
ERC20Base
contract ERC20Base is ERC20Interface { using SafeMath for uint256; string public symbol; string public name; uint8 public decimals; uint public totalSupply_; address public owner; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /** * @dev Constructor */ constructor(address _owner) public { symbol = "DTC"; name = "Delta Coin"; decimals = 18; totalSupply_ = 272 * (10 ** 8) * (10 ** 18); owner = _owner; balances[owner] = totalSupply_; emit Transfer(address(0), owner, totalSupply_); } /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint _value) public returns (bool success) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Destoys `amount` tokens, reducing the total supply. * @param _value must have at least `amount` tokens. */ function burn(uint256 _value) public { address account = msg.sender; totalSupply_ = totalSupply_.sub(_value); balances[account] = balances[account].sub(_value); emit Transfer(account, address(0), _value); } }
allowance
function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; }
/** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://3ba331a200d1c272e4d4a16ee63afef52d0e08e05f0b087031343bfc0112e90f
{ "func_code_index": [ 3259, 3398 ] }
2,706
Token
Token.sol
0xa62621a592bf8ec23718e5593c2d668327381648
Solidity
ERC20Base
contract ERC20Base is ERC20Interface { using SafeMath for uint256; string public symbol; string public name; uint8 public decimals; uint public totalSupply_; address public owner; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /** * @dev Constructor */ constructor(address _owner) public { symbol = "DTC"; name = "Delta Coin"; decimals = 18; totalSupply_ = 272 * (10 ** 8) * (10 ** 18); owner = _owner; balances[owner] = totalSupply_; emit Transfer(address(0), owner, totalSupply_); } /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint _value) public returns (bool success) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Destoys `amount` tokens, reducing the total supply. * @param _value must have at least `amount` tokens. */ function burn(uint256 _value) public { address account = msg.sender; totalSupply_ = totalSupply_.sub(_value); balances[account] = balances[account].sub(_value); emit Transfer(account, address(0), _value); } }
burn
function burn(uint256 _value) public { address account = msg.sender; totalSupply_ = totalSupply_.sub(_value); balances[account] = balances[account].sub(_value); emit Transfer(account, address(0), _value); }
/** * @dev Destoys `amount` tokens, reducing the total supply. * @param _value must have at least `amount` tokens. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://3ba331a200d1c272e4d4a16ee63afef52d0e08e05f0b087031343bfc0112e90f
{ "func_code_index": [ 3542, 3804 ] }
2,707
TeamVesting
contracts/TeamVesting.sol
0x13d0526c393de67399f262b9ae19c77d067ec344
Solidity
TeamVesting
contract TeamVesting is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; event InvestorsAdded(address[] investors, uint256[] tokenAllocations, address caller); event InvestorAdded(address indexed investor, address indexed caller, uint256 allocation); event InvestorRemoved(address indexed investor, address indexed caller, uint256 allocation); event WithdrawnTokens(address indexed investor, uint256 value); event DepositInvestment(address indexed investor, uint256 value); event TransferInvestment(address indexed owner, uint256 value); event RecoverToken(address indexed token, uint256 indexed amount); uint256 private _totalAllocatedAmount; uint256 private _initialTimestamp; IERC20 private _priviToken; address[] public investors; struct Investor { bool exists; uint256 withdrawnTokens; uint256 tokensAllotment; } uint256[] teamVesting = [ 2777777777777780000, 5555555555777780000, 8333333333777780000, 11111111111777800000, 13888888889777800000, 16666666667777800000, 19444444445777800000, 22222222223777800000, 25000000001777800000, 27777777779777800000, 30555555557777800000, 33333333335777800000, 36111111113777800000, 38888888891777800000, 41666666669777800000, 44444444447777800000, 47222222225777800000, 50000000003777800000, 52777777781777800000, 55555555559777800000, 58333333337777800000, 61111111115777800000, 63888888893777800000, 66666666671777800000, 69444444449777800000, 72222222227777800000, 75000000005777800000, 77777777783777800000, 80555555561777800000, 83333333339777800000, 86111111117777800000, 88888888895777800000, 91666666673777800000, 94444444451777800000, 97222222229777800000, 100000000000000000000 ]; mapping(address => Investor) public investorsInfo; /// @dev Boolean variable that indicates whether the contract was initialized. bool public isInitialized = false; /// @dev Boolean variable that indicates whether the investors set was finalized. bool public isFinalized = false; /// @dev Checks that the contract is initialized. modifier initialized() { require(isInitialized, "not initialized"); _; } /// @dev Checks that the contract is initialized. modifier notInitialized() { require(!isInitialized, "initialized"); _; } modifier onlyInvestor() { require(investorsInfo[_msgSender()].exists, "Only investors allowed"); _; } constructor(address _token) { _priviToken = IERC20(_token); } function getInitialTimestamp() public view returns (uint256 timestamp) { return _initialTimestamp; } /// @dev release tokens to all the investors function releaseTokens() external onlyOwner initialized() { for (uint8 i = 0; i < investors.length; i++) { uint256 availableTokens = withdrawableTokens(investors[i]); _priviToken.safeTransfer(investors[i], availableTokens); } } /// @dev Adds investors. This function doesn't limit max gas consumption, /// so adding too many investors can cause it to reach the out-of-gas error. /// @param _investors The addresses of new investors. /// @param _tokenAllocations The amounts of the tokens that belong to each investor. function addInvestors(address[] calldata _investors, uint256[] calldata _tokenAllocations) external onlyOwner { require(_investors.length == _tokenAllocations.length, "different arrays sizes"); for (uint256 i = 0; i < _investors.length; i++) { _addInvestor(_investors[i], _tokenAllocations[i]); } emit InvestorsAdded(_investors, _tokenAllocations, msg.sender); } function withdrawTokens() external onlyInvestor() initialized() { Investor storage investor = investorsInfo[_msgSender()]; uint256 tokensAvailable = withdrawableTokens(_msgSender()); require(tokensAvailable > 0, "no tokens available for withdrawl"); investor.withdrawnTokens = investor.withdrawnTokens.add(tokensAvailable); _priviToken.safeTransfer(_msgSender(), tokensAvailable); emit WithdrawnTokens(_msgSender(), tokensAvailable); } /// @dev The starting time of TGE /// @param _timestamp The initial timestamp, this timestap should be used for vesting function setInitialTimestamp(uint256 _timestamp) external onlyOwner() notInitialized() { isInitialized = true; _initialTimestamp = _timestamp; } /// @dev withdrawble tokens for an address /// @param _investor whitelisted investor address function withdrawableTokens(address _investor) public view returns (uint256 tokens) { Investor storage investor = investorsInfo[_investor]; uint256 availablePercentage = _calculateAvailablePercentage(); uint256 noOfTokens = _calculatePercentage(investor.tokensAllotment, availablePercentage); uint256 tokensAvailable = noOfTokens.sub(investor.withdrawnTokens); return tokensAvailable; } /// @dev Adds investor. This function doesn't limit max gas consumption, /// so adding too many investors can cause it to reach the out-of-gas error. /// @param _investor The addresses of new investors. /// @param _tokensAllotment The amounts of the tokens that belong to each investor. function _addInvestor(address _investor, uint256 _tokensAllotment) internal onlyOwner { require(_investor != address(0), "Invalid address"); require(_tokensAllotment > 0, "the investor allocation must be more than 0"); Investor storage investor = investorsInfo[_investor]; require(investor.tokensAllotment == 0, "investor already added"); investor.tokensAllotment = _tokensAllotment; investor.exists = true; investors.push(_investor); _totalAllocatedAmount = _totalAllocatedAmount.add(_tokensAllotment); emit InvestorAdded(_investor, _msgSender(), _tokensAllotment); } /// @dev calculate percentage value from amount /// @param _amount amount input to find the percentage /// @param _percentage percentage for an amount function _calculatePercentage(uint256 _amount, uint256 _percentage) private pure returns (uint256 percentage) { return _amount.mul(_percentage).div(100).div(1e18); } function _calculateAvailablePercentage() private view returns (uint256 availablePercentage) { uint256 currentTimeStamp = block.timestamp; uint256 noOfMonths = BokkyPooBahsDateTimeLibrary.diffMonths(_initialTimestamp, currentTimeStamp); return teamVesting[noOfMonths]; } function recoverToken(address _token, uint256 amount) external onlyOwner { IERC20(_token).safeTransfer(_msgSender(), amount); emit RecoverToken(_token, amount); } }
releaseTokens
function releaseTokens() external onlyOwner initialized() { for (uint8 i = 0; i < investors.length; i++) { uint256 availableTokens = withdrawableTokens(investors[i]); _priviToken.safeTransfer(investors[i], availableTokens); } }
/// @dev release tokens to all the investors
NatSpecSingleLine
v0.8.0+commit.c7dfd78e
{ "func_code_index": [ 3024, 3299 ] }
2,708
TeamVesting
contracts/TeamVesting.sol
0x13d0526c393de67399f262b9ae19c77d067ec344
Solidity
TeamVesting
contract TeamVesting is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; event InvestorsAdded(address[] investors, uint256[] tokenAllocations, address caller); event InvestorAdded(address indexed investor, address indexed caller, uint256 allocation); event InvestorRemoved(address indexed investor, address indexed caller, uint256 allocation); event WithdrawnTokens(address indexed investor, uint256 value); event DepositInvestment(address indexed investor, uint256 value); event TransferInvestment(address indexed owner, uint256 value); event RecoverToken(address indexed token, uint256 indexed amount); uint256 private _totalAllocatedAmount; uint256 private _initialTimestamp; IERC20 private _priviToken; address[] public investors; struct Investor { bool exists; uint256 withdrawnTokens; uint256 tokensAllotment; } uint256[] teamVesting = [ 2777777777777780000, 5555555555777780000, 8333333333777780000, 11111111111777800000, 13888888889777800000, 16666666667777800000, 19444444445777800000, 22222222223777800000, 25000000001777800000, 27777777779777800000, 30555555557777800000, 33333333335777800000, 36111111113777800000, 38888888891777800000, 41666666669777800000, 44444444447777800000, 47222222225777800000, 50000000003777800000, 52777777781777800000, 55555555559777800000, 58333333337777800000, 61111111115777800000, 63888888893777800000, 66666666671777800000, 69444444449777800000, 72222222227777800000, 75000000005777800000, 77777777783777800000, 80555555561777800000, 83333333339777800000, 86111111117777800000, 88888888895777800000, 91666666673777800000, 94444444451777800000, 97222222229777800000, 100000000000000000000 ]; mapping(address => Investor) public investorsInfo; /// @dev Boolean variable that indicates whether the contract was initialized. bool public isInitialized = false; /// @dev Boolean variable that indicates whether the investors set was finalized. bool public isFinalized = false; /// @dev Checks that the contract is initialized. modifier initialized() { require(isInitialized, "not initialized"); _; } /// @dev Checks that the contract is initialized. modifier notInitialized() { require(!isInitialized, "initialized"); _; } modifier onlyInvestor() { require(investorsInfo[_msgSender()].exists, "Only investors allowed"); _; } constructor(address _token) { _priviToken = IERC20(_token); } function getInitialTimestamp() public view returns (uint256 timestamp) { return _initialTimestamp; } /// @dev release tokens to all the investors function releaseTokens() external onlyOwner initialized() { for (uint8 i = 0; i < investors.length; i++) { uint256 availableTokens = withdrawableTokens(investors[i]); _priviToken.safeTransfer(investors[i], availableTokens); } } /// @dev Adds investors. This function doesn't limit max gas consumption, /// so adding too many investors can cause it to reach the out-of-gas error. /// @param _investors The addresses of new investors. /// @param _tokenAllocations The amounts of the tokens that belong to each investor. function addInvestors(address[] calldata _investors, uint256[] calldata _tokenAllocations) external onlyOwner { require(_investors.length == _tokenAllocations.length, "different arrays sizes"); for (uint256 i = 0; i < _investors.length; i++) { _addInvestor(_investors[i], _tokenAllocations[i]); } emit InvestorsAdded(_investors, _tokenAllocations, msg.sender); } function withdrawTokens() external onlyInvestor() initialized() { Investor storage investor = investorsInfo[_msgSender()]; uint256 tokensAvailable = withdrawableTokens(_msgSender()); require(tokensAvailable > 0, "no tokens available for withdrawl"); investor.withdrawnTokens = investor.withdrawnTokens.add(tokensAvailable); _priviToken.safeTransfer(_msgSender(), tokensAvailable); emit WithdrawnTokens(_msgSender(), tokensAvailable); } /// @dev The starting time of TGE /// @param _timestamp The initial timestamp, this timestap should be used for vesting function setInitialTimestamp(uint256 _timestamp) external onlyOwner() notInitialized() { isInitialized = true; _initialTimestamp = _timestamp; } /// @dev withdrawble tokens for an address /// @param _investor whitelisted investor address function withdrawableTokens(address _investor) public view returns (uint256 tokens) { Investor storage investor = investorsInfo[_investor]; uint256 availablePercentage = _calculateAvailablePercentage(); uint256 noOfTokens = _calculatePercentage(investor.tokensAllotment, availablePercentage); uint256 tokensAvailable = noOfTokens.sub(investor.withdrawnTokens); return tokensAvailable; } /// @dev Adds investor. This function doesn't limit max gas consumption, /// so adding too many investors can cause it to reach the out-of-gas error. /// @param _investor The addresses of new investors. /// @param _tokensAllotment The amounts of the tokens that belong to each investor. function _addInvestor(address _investor, uint256 _tokensAllotment) internal onlyOwner { require(_investor != address(0), "Invalid address"); require(_tokensAllotment > 0, "the investor allocation must be more than 0"); Investor storage investor = investorsInfo[_investor]; require(investor.tokensAllotment == 0, "investor already added"); investor.tokensAllotment = _tokensAllotment; investor.exists = true; investors.push(_investor); _totalAllocatedAmount = _totalAllocatedAmount.add(_tokensAllotment); emit InvestorAdded(_investor, _msgSender(), _tokensAllotment); } /// @dev calculate percentage value from amount /// @param _amount amount input to find the percentage /// @param _percentage percentage for an amount function _calculatePercentage(uint256 _amount, uint256 _percentage) private pure returns (uint256 percentage) { return _amount.mul(_percentage).div(100).div(1e18); } function _calculateAvailablePercentage() private view returns (uint256 availablePercentage) { uint256 currentTimeStamp = block.timestamp; uint256 noOfMonths = BokkyPooBahsDateTimeLibrary.diffMonths(_initialTimestamp, currentTimeStamp); return teamVesting[noOfMonths]; } function recoverToken(address _token, uint256 amount) external onlyOwner { IERC20(_token).safeTransfer(_msgSender(), amount); emit RecoverToken(_token, amount); } }
addInvestors
function addInvestors(address[] calldata _investors, uint256[] calldata _tokenAllocations) external onlyOwner { require(_investors.length == _tokenAllocations.length, "different arrays sizes"); for (uint256 i = 0; i < _investors.length; i++) { _addInvestor(_investors[i], _tokenAllocations[i]); } emit InvestorsAdded(_investors, _tokenAllocations, msg.sender); }
/// @dev Adds investors. This function doesn't limit max gas consumption, /// so adding too many investors can cause it to reach the out-of-gas error. /// @param _investors The addresses of new investors. /// @param _tokenAllocations The amounts of the tokens that belong to each investor.
NatSpecSingleLine
v0.8.0+commit.c7dfd78e
{ "func_code_index": [ 3607, 4021 ] }
2,709
TeamVesting
contracts/TeamVesting.sol
0x13d0526c393de67399f262b9ae19c77d067ec344
Solidity
TeamVesting
contract TeamVesting is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; event InvestorsAdded(address[] investors, uint256[] tokenAllocations, address caller); event InvestorAdded(address indexed investor, address indexed caller, uint256 allocation); event InvestorRemoved(address indexed investor, address indexed caller, uint256 allocation); event WithdrawnTokens(address indexed investor, uint256 value); event DepositInvestment(address indexed investor, uint256 value); event TransferInvestment(address indexed owner, uint256 value); event RecoverToken(address indexed token, uint256 indexed amount); uint256 private _totalAllocatedAmount; uint256 private _initialTimestamp; IERC20 private _priviToken; address[] public investors; struct Investor { bool exists; uint256 withdrawnTokens; uint256 tokensAllotment; } uint256[] teamVesting = [ 2777777777777780000, 5555555555777780000, 8333333333777780000, 11111111111777800000, 13888888889777800000, 16666666667777800000, 19444444445777800000, 22222222223777800000, 25000000001777800000, 27777777779777800000, 30555555557777800000, 33333333335777800000, 36111111113777800000, 38888888891777800000, 41666666669777800000, 44444444447777800000, 47222222225777800000, 50000000003777800000, 52777777781777800000, 55555555559777800000, 58333333337777800000, 61111111115777800000, 63888888893777800000, 66666666671777800000, 69444444449777800000, 72222222227777800000, 75000000005777800000, 77777777783777800000, 80555555561777800000, 83333333339777800000, 86111111117777800000, 88888888895777800000, 91666666673777800000, 94444444451777800000, 97222222229777800000, 100000000000000000000 ]; mapping(address => Investor) public investorsInfo; /// @dev Boolean variable that indicates whether the contract was initialized. bool public isInitialized = false; /// @dev Boolean variable that indicates whether the investors set was finalized. bool public isFinalized = false; /// @dev Checks that the contract is initialized. modifier initialized() { require(isInitialized, "not initialized"); _; } /// @dev Checks that the contract is initialized. modifier notInitialized() { require(!isInitialized, "initialized"); _; } modifier onlyInvestor() { require(investorsInfo[_msgSender()].exists, "Only investors allowed"); _; } constructor(address _token) { _priviToken = IERC20(_token); } function getInitialTimestamp() public view returns (uint256 timestamp) { return _initialTimestamp; } /// @dev release tokens to all the investors function releaseTokens() external onlyOwner initialized() { for (uint8 i = 0; i < investors.length; i++) { uint256 availableTokens = withdrawableTokens(investors[i]); _priviToken.safeTransfer(investors[i], availableTokens); } } /// @dev Adds investors. This function doesn't limit max gas consumption, /// so adding too many investors can cause it to reach the out-of-gas error. /// @param _investors The addresses of new investors. /// @param _tokenAllocations The amounts of the tokens that belong to each investor. function addInvestors(address[] calldata _investors, uint256[] calldata _tokenAllocations) external onlyOwner { require(_investors.length == _tokenAllocations.length, "different arrays sizes"); for (uint256 i = 0; i < _investors.length; i++) { _addInvestor(_investors[i], _tokenAllocations[i]); } emit InvestorsAdded(_investors, _tokenAllocations, msg.sender); } function withdrawTokens() external onlyInvestor() initialized() { Investor storage investor = investorsInfo[_msgSender()]; uint256 tokensAvailable = withdrawableTokens(_msgSender()); require(tokensAvailable > 0, "no tokens available for withdrawl"); investor.withdrawnTokens = investor.withdrawnTokens.add(tokensAvailable); _priviToken.safeTransfer(_msgSender(), tokensAvailable); emit WithdrawnTokens(_msgSender(), tokensAvailable); } /// @dev The starting time of TGE /// @param _timestamp The initial timestamp, this timestap should be used for vesting function setInitialTimestamp(uint256 _timestamp) external onlyOwner() notInitialized() { isInitialized = true; _initialTimestamp = _timestamp; } /// @dev withdrawble tokens for an address /// @param _investor whitelisted investor address function withdrawableTokens(address _investor) public view returns (uint256 tokens) { Investor storage investor = investorsInfo[_investor]; uint256 availablePercentage = _calculateAvailablePercentage(); uint256 noOfTokens = _calculatePercentage(investor.tokensAllotment, availablePercentage); uint256 tokensAvailable = noOfTokens.sub(investor.withdrawnTokens); return tokensAvailable; } /// @dev Adds investor. This function doesn't limit max gas consumption, /// so adding too many investors can cause it to reach the out-of-gas error. /// @param _investor The addresses of new investors. /// @param _tokensAllotment The amounts of the tokens that belong to each investor. function _addInvestor(address _investor, uint256 _tokensAllotment) internal onlyOwner { require(_investor != address(0), "Invalid address"); require(_tokensAllotment > 0, "the investor allocation must be more than 0"); Investor storage investor = investorsInfo[_investor]; require(investor.tokensAllotment == 0, "investor already added"); investor.tokensAllotment = _tokensAllotment; investor.exists = true; investors.push(_investor); _totalAllocatedAmount = _totalAllocatedAmount.add(_tokensAllotment); emit InvestorAdded(_investor, _msgSender(), _tokensAllotment); } /// @dev calculate percentage value from amount /// @param _amount amount input to find the percentage /// @param _percentage percentage for an amount function _calculatePercentage(uint256 _amount, uint256 _percentage) private pure returns (uint256 percentage) { return _amount.mul(_percentage).div(100).div(1e18); } function _calculateAvailablePercentage() private view returns (uint256 availablePercentage) { uint256 currentTimeStamp = block.timestamp; uint256 noOfMonths = BokkyPooBahsDateTimeLibrary.diffMonths(_initialTimestamp, currentTimeStamp); return teamVesting[noOfMonths]; } function recoverToken(address _token, uint256 amount) external onlyOwner { IERC20(_token).safeTransfer(_msgSender(), amount); emit RecoverToken(_token, amount); } }
setInitialTimestamp
function setInitialTimestamp(uint256 _timestamp) external onlyOwner() notInitialized() { isInitialized = true; _initialTimestamp = _timestamp; }
/// @dev The starting time of TGE /// @param _timestamp The initial timestamp, this timestap should be used for vesting
NatSpecSingleLine
v0.8.0+commit.c7dfd78e
{ "func_code_index": [ 4648, 4816 ] }
2,710
TeamVesting
contracts/TeamVesting.sol
0x13d0526c393de67399f262b9ae19c77d067ec344
Solidity
TeamVesting
contract TeamVesting is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; event InvestorsAdded(address[] investors, uint256[] tokenAllocations, address caller); event InvestorAdded(address indexed investor, address indexed caller, uint256 allocation); event InvestorRemoved(address indexed investor, address indexed caller, uint256 allocation); event WithdrawnTokens(address indexed investor, uint256 value); event DepositInvestment(address indexed investor, uint256 value); event TransferInvestment(address indexed owner, uint256 value); event RecoverToken(address indexed token, uint256 indexed amount); uint256 private _totalAllocatedAmount; uint256 private _initialTimestamp; IERC20 private _priviToken; address[] public investors; struct Investor { bool exists; uint256 withdrawnTokens; uint256 tokensAllotment; } uint256[] teamVesting = [ 2777777777777780000, 5555555555777780000, 8333333333777780000, 11111111111777800000, 13888888889777800000, 16666666667777800000, 19444444445777800000, 22222222223777800000, 25000000001777800000, 27777777779777800000, 30555555557777800000, 33333333335777800000, 36111111113777800000, 38888888891777800000, 41666666669777800000, 44444444447777800000, 47222222225777800000, 50000000003777800000, 52777777781777800000, 55555555559777800000, 58333333337777800000, 61111111115777800000, 63888888893777800000, 66666666671777800000, 69444444449777800000, 72222222227777800000, 75000000005777800000, 77777777783777800000, 80555555561777800000, 83333333339777800000, 86111111117777800000, 88888888895777800000, 91666666673777800000, 94444444451777800000, 97222222229777800000, 100000000000000000000 ]; mapping(address => Investor) public investorsInfo; /// @dev Boolean variable that indicates whether the contract was initialized. bool public isInitialized = false; /// @dev Boolean variable that indicates whether the investors set was finalized. bool public isFinalized = false; /// @dev Checks that the contract is initialized. modifier initialized() { require(isInitialized, "not initialized"); _; } /// @dev Checks that the contract is initialized. modifier notInitialized() { require(!isInitialized, "initialized"); _; } modifier onlyInvestor() { require(investorsInfo[_msgSender()].exists, "Only investors allowed"); _; } constructor(address _token) { _priviToken = IERC20(_token); } function getInitialTimestamp() public view returns (uint256 timestamp) { return _initialTimestamp; } /// @dev release tokens to all the investors function releaseTokens() external onlyOwner initialized() { for (uint8 i = 0; i < investors.length; i++) { uint256 availableTokens = withdrawableTokens(investors[i]); _priviToken.safeTransfer(investors[i], availableTokens); } } /// @dev Adds investors. This function doesn't limit max gas consumption, /// so adding too many investors can cause it to reach the out-of-gas error. /// @param _investors The addresses of new investors. /// @param _tokenAllocations The amounts of the tokens that belong to each investor. function addInvestors(address[] calldata _investors, uint256[] calldata _tokenAllocations) external onlyOwner { require(_investors.length == _tokenAllocations.length, "different arrays sizes"); for (uint256 i = 0; i < _investors.length; i++) { _addInvestor(_investors[i], _tokenAllocations[i]); } emit InvestorsAdded(_investors, _tokenAllocations, msg.sender); } function withdrawTokens() external onlyInvestor() initialized() { Investor storage investor = investorsInfo[_msgSender()]; uint256 tokensAvailable = withdrawableTokens(_msgSender()); require(tokensAvailable > 0, "no tokens available for withdrawl"); investor.withdrawnTokens = investor.withdrawnTokens.add(tokensAvailable); _priviToken.safeTransfer(_msgSender(), tokensAvailable); emit WithdrawnTokens(_msgSender(), tokensAvailable); } /// @dev The starting time of TGE /// @param _timestamp The initial timestamp, this timestap should be used for vesting function setInitialTimestamp(uint256 _timestamp) external onlyOwner() notInitialized() { isInitialized = true; _initialTimestamp = _timestamp; } /// @dev withdrawble tokens for an address /// @param _investor whitelisted investor address function withdrawableTokens(address _investor) public view returns (uint256 tokens) { Investor storage investor = investorsInfo[_investor]; uint256 availablePercentage = _calculateAvailablePercentage(); uint256 noOfTokens = _calculatePercentage(investor.tokensAllotment, availablePercentage); uint256 tokensAvailable = noOfTokens.sub(investor.withdrawnTokens); return tokensAvailable; } /// @dev Adds investor. This function doesn't limit max gas consumption, /// so adding too many investors can cause it to reach the out-of-gas error. /// @param _investor The addresses of new investors. /// @param _tokensAllotment The amounts of the tokens that belong to each investor. function _addInvestor(address _investor, uint256 _tokensAllotment) internal onlyOwner { require(_investor != address(0), "Invalid address"); require(_tokensAllotment > 0, "the investor allocation must be more than 0"); Investor storage investor = investorsInfo[_investor]; require(investor.tokensAllotment == 0, "investor already added"); investor.tokensAllotment = _tokensAllotment; investor.exists = true; investors.push(_investor); _totalAllocatedAmount = _totalAllocatedAmount.add(_tokensAllotment); emit InvestorAdded(_investor, _msgSender(), _tokensAllotment); } /// @dev calculate percentage value from amount /// @param _amount amount input to find the percentage /// @param _percentage percentage for an amount function _calculatePercentage(uint256 _amount, uint256 _percentage) private pure returns (uint256 percentage) { return _amount.mul(_percentage).div(100).div(1e18); } function _calculateAvailablePercentage() private view returns (uint256 availablePercentage) { uint256 currentTimeStamp = block.timestamp; uint256 noOfMonths = BokkyPooBahsDateTimeLibrary.diffMonths(_initialTimestamp, currentTimeStamp); return teamVesting[noOfMonths]; } function recoverToken(address _token, uint256 amount) external onlyOwner { IERC20(_token).safeTransfer(_msgSender(), amount); emit RecoverToken(_token, amount); } }
withdrawableTokens
function withdrawableTokens(address _investor) public view returns (uint256 tokens) { Investor storage investor = investorsInfo[_investor]; uint256 availablePercentage = _calculateAvailablePercentage(); uint256 noOfTokens = _calculatePercentage(investor.tokensAllotment, availablePercentage); uint256 tokensAvailable = noOfTokens.sub(investor.withdrawnTokens); return tokensAvailable; }
/// @dev withdrawble tokens for an address /// @param _investor whitelisted investor address
NatSpecSingleLine
v0.8.0+commit.c7dfd78e
{ "func_code_index": [ 4919, 5354 ] }
2,711
TeamVesting
contracts/TeamVesting.sol
0x13d0526c393de67399f262b9ae19c77d067ec344
Solidity
TeamVesting
contract TeamVesting is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; event InvestorsAdded(address[] investors, uint256[] tokenAllocations, address caller); event InvestorAdded(address indexed investor, address indexed caller, uint256 allocation); event InvestorRemoved(address indexed investor, address indexed caller, uint256 allocation); event WithdrawnTokens(address indexed investor, uint256 value); event DepositInvestment(address indexed investor, uint256 value); event TransferInvestment(address indexed owner, uint256 value); event RecoverToken(address indexed token, uint256 indexed amount); uint256 private _totalAllocatedAmount; uint256 private _initialTimestamp; IERC20 private _priviToken; address[] public investors; struct Investor { bool exists; uint256 withdrawnTokens; uint256 tokensAllotment; } uint256[] teamVesting = [ 2777777777777780000, 5555555555777780000, 8333333333777780000, 11111111111777800000, 13888888889777800000, 16666666667777800000, 19444444445777800000, 22222222223777800000, 25000000001777800000, 27777777779777800000, 30555555557777800000, 33333333335777800000, 36111111113777800000, 38888888891777800000, 41666666669777800000, 44444444447777800000, 47222222225777800000, 50000000003777800000, 52777777781777800000, 55555555559777800000, 58333333337777800000, 61111111115777800000, 63888888893777800000, 66666666671777800000, 69444444449777800000, 72222222227777800000, 75000000005777800000, 77777777783777800000, 80555555561777800000, 83333333339777800000, 86111111117777800000, 88888888895777800000, 91666666673777800000, 94444444451777800000, 97222222229777800000, 100000000000000000000 ]; mapping(address => Investor) public investorsInfo; /// @dev Boolean variable that indicates whether the contract was initialized. bool public isInitialized = false; /// @dev Boolean variable that indicates whether the investors set was finalized. bool public isFinalized = false; /// @dev Checks that the contract is initialized. modifier initialized() { require(isInitialized, "not initialized"); _; } /// @dev Checks that the contract is initialized. modifier notInitialized() { require(!isInitialized, "initialized"); _; } modifier onlyInvestor() { require(investorsInfo[_msgSender()].exists, "Only investors allowed"); _; } constructor(address _token) { _priviToken = IERC20(_token); } function getInitialTimestamp() public view returns (uint256 timestamp) { return _initialTimestamp; } /// @dev release tokens to all the investors function releaseTokens() external onlyOwner initialized() { for (uint8 i = 0; i < investors.length; i++) { uint256 availableTokens = withdrawableTokens(investors[i]); _priviToken.safeTransfer(investors[i], availableTokens); } } /// @dev Adds investors. This function doesn't limit max gas consumption, /// so adding too many investors can cause it to reach the out-of-gas error. /// @param _investors The addresses of new investors. /// @param _tokenAllocations The amounts of the tokens that belong to each investor. function addInvestors(address[] calldata _investors, uint256[] calldata _tokenAllocations) external onlyOwner { require(_investors.length == _tokenAllocations.length, "different arrays sizes"); for (uint256 i = 0; i < _investors.length; i++) { _addInvestor(_investors[i], _tokenAllocations[i]); } emit InvestorsAdded(_investors, _tokenAllocations, msg.sender); } function withdrawTokens() external onlyInvestor() initialized() { Investor storage investor = investorsInfo[_msgSender()]; uint256 tokensAvailable = withdrawableTokens(_msgSender()); require(tokensAvailable > 0, "no tokens available for withdrawl"); investor.withdrawnTokens = investor.withdrawnTokens.add(tokensAvailable); _priviToken.safeTransfer(_msgSender(), tokensAvailable); emit WithdrawnTokens(_msgSender(), tokensAvailable); } /// @dev The starting time of TGE /// @param _timestamp The initial timestamp, this timestap should be used for vesting function setInitialTimestamp(uint256 _timestamp) external onlyOwner() notInitialized() { isInitialized = true; _initialTimestamp = _timestamp; } /// @dev withdrawble tokens for an address /// @param _investor whitelisted investor address function withdrawableTokens(address _investor) public view returns (uint256 tokens) { Investor storage investor = investorsInfo[_investor]; uint256 availablePercentage = _calculateAvailablePercentage(); uint256 noOfTokens = _calculatePercentage(investor.tokensAllotment, availablePercentage); uint256 tokensAvailable = noOfTokens.sub(investor.withdrawnTokens); return tokensAvailable; } /// @dev Adds investor. This function doesn't limit max gas consumption, /// so adding too many investors can cause it to reach the out-of-gas error. /// @param _investor The addresses of new investors. /// @param _tokensAllotment The amounts of the tokens that belong to each investor. function _addInvestor(address _investor, uint256 _tokensAllotment) internal onlyOwner { require(_investor != address(0), "Invalid address"); require(_tokensAllotment > 0, "the investor allocation must be more than 0"); Investor storage investor = investorsInfo[_investor]; require(investor.tokensAllotment == 0, "investor already added"); investor.tokensAllotment = _tokensAllotment; investor.exists = true; investors.push(_investor); _totalAllocatedAmount = _totalAllocatedAmount.add(_tokensAllotment); emit InvestorAdded(_investor, _msgSender(), _tokensAllotment); } /// @dev calculate percentage value from amount /// @param _amount amount input to find the percentage /// @param _percentage percentage for an amount function _calculatePercentage(uint256 _amount, uint256 _percentage) private pure returns (uint256 percentage) { return _amount.mul(_percentage).div(100).div(1e18); } function _calculateAvailablePercentage() private view returns (uint256 availablePercentage) { uint256 currentTimeStamp = block.timestamp; uint256 noOfMonths = BokkyPooBahsDateTimeLibrary.diffMonths(_initialTimestamp, currentTimeStamp); return teamVesting[noOfMonths]; } function recoverToken(address _token, uint256 amount) external onlyOwner { IERC20(_token).safeTransfer(_msgSender(), amount); emit RecoverToken(_token, amount); } }
_addInvestor
function _addInvestor(address _investor, uint256 _tokensAllotment) internal onlyOwner { require(_investor != address(0), "Invalid address"); require(_tokensAllotment > 0, "the investor allocation must be more than 0"); Investor storage investor = investorsInfo[_investor]; require(investor.tokensAllotment == 0, "investor already added"); investor.tokensAllotment = _tokensAllotment; investor.exists = true; investors.push(_investor); _totalAllocatedAmount = _totalAllocatedAmount.add(_tokensAllotment); emit InvestorAdded(_investor, _msgSender(), _tokensAllotment); }
/// @dev Adds investor. This function doesn't limit max gas consumption, /// so adding too many investors can cause it to reach the out-of-gas error. /// @param _investor The addresses of new investors. /// @param _tokensAllotment The amounts of the tokens that belong to each investor.
NatSpecSingleLine
v0.8.0+commit.c7dfd78e
{ "func_code_index": [ 5660, 6310 ] }
2,712
TeamVesting
contracts/TeamVesting.sol
0x13d0526c393de67399f262b9ae19c77d067ec344
Solidity
TeamVesting
contract TeamVesting is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; event InvestorsAdded(address[] investors, uint256[] tokenAllocations, address caller); event InvestorAdded(address indexed investor, address indexed caller, uint256 allocation); event InvestorRemoved(address indexed investor, address indexed caller, uint256 allocation); event WithdrawnTokens(address indexed investor, uint256 value); event DepositInvestment(address indexed investor, uint256 value); event TransferInvestment(address indexed owner, uint256 value); event RecoverToken(address indexed token, uint256 indexed amount); uint256 private _totalAllocatedAmount; uint256 private _initialTimestamp; IERC20 private _priviToken; address[] public investors; struct Investor { bool exists; uint256 withdrawnTokens; uint256 tokensAllotment; } uint256[] teamVesting = [ 2777777777777780000, 5555555555777780000, 8333333333777780000, 11111111111777800000, 13888888889777800000, 16666666667777800000, 19444444445777800000, 22222222223777800000, 25000000001777800000, 27777777779777800000, 30555555557777800000, 33333333335777800000, 36111111113777800000, 38888888891777800000, 41666666669777800000, 44444444447777800000, 47222222225777800000, 50000000003777800000, 52777777781777800000, 55555555559777800000, 58333333337777800000, 61111111115777800000, 63888888893777800000, 66666666671777800000, 69444444449777800000, 72222222227777800000, 75000000005777800000, 77777777783777800000, 80555555561777800000, 83333333339777800000, 86111111117777800000, 88888888895777800000, 91666666673777800000, 94444444451777800000, 97222222229777800000, 100000000000000000000 ]; mapping(address => Investor) public investorsInfo; /// @dev Boolean variable that indicates whether the contract was initialized. bool public isInitialized = false; /// @dev Boolean variable that indicates whether the investors set was finalized. bool public isFinalized = false; /// @dev Checks that the contract is initialized. modifier initialized() { require(isInitialized, "not initialized"); _; } /// @dev Checks that the contract is initialized. modifier notInitialized() { require(!isInitialized, "initialized"); _; } modifier onlyInvestor() { require(investorsInfo[_msgSender()].exists, "Only investors allowed"); _; } constructor(address _token) { _priviToken = IERC20(_token); } function getInitialTimestamp() public view returns (uint256 timestamp) { return _initialTimestamp; } /// @dev release tokens to all the investors function releaseTokens() external onlyOwner initialized() { for (uint8 i = 0; i < investors.length; i++) { uint256 availableTokens = withdrawableTokens(investors[i]); _priviToken.safeTransfer(investors[i], availableTokens); } } /// @dev Adds investors. This function doesn't limit max gas consumption, /// so adding too many investors can cause it to reach the out-of-gas error. /// @param _investors The addresses of new investors. /// @param _tokenAllocations The amounts of the tokens that belong to each investor. function addInvestors(address[] calldata _investors, uint256[] calldata _tokenAllocations) external onlyOwner { require(_investors.length == _tokenAllocations.length, "different arrays sizes"); for (uint256 i = 0; i < _investors.length; i++) { _addInvestor(_investors[i], _tokenAllocations[i]); } emit InvestorsAdded(_investors, _tokenAllocations, msg.sender); } function withdrawTokens() external onlyInvestor() initialized() { Investor storage investor = investorsInfo[_msgSender()]; uint256 tokensAvailable = withdrawableTokens(_msgSender()); require(tokensAvailable > 0, "no tokens available for withdrawl"); investor.withdrawnTokens = investor.withdrawnTokens.add(tokensAvailable); _priviToken.safeTransfer(_msgSender(), tokensAvailable); emit WithdrawnTokens(_msgSender(), tokensAvailable); } /// @dev The starting time of TGE /// @param _timestamp The initial timestamp, this timestap should be used for vesting function setInitialTimestamp(uint256 _timestamp) external onlyOwner() notInitialized() { isInitialized = true; _initialTimestamp = _timestamp; } /// @dev withdrawble tokens for an address /// @param _investor whitelisted investor address function withdrawableTokens(address _investor) public view returns (uint256 tokens) { Investor storage investor = investorsInfo[_investor]; uint256 availablePercentage = _calculateAvailablePercentage(); uint256 noOfTokens = _calculatePercentage(investor.tokensAllotment, availablePercentage); uint256 tokensAvailable = noOfTokens.sub(investor.withdrawnTokens); return tokensAvailable; } /// @dev Adds investor. This function doesn't limit max gas consumption, /// so adding too many investors can cause it to reach the out-of-gas error. /// @param _investor The addresses of new investors. /// @param _tokensAllotment The amounts of the tokens that belong to each investor. function _addInvestor(address _investor, uint256 _tokensAllotment) internal onlyOwner { require(_investor != address(0), "Invalid address"); require(_tokensAllotment > 0, "the investor allocation must be more than 0"); Investor storage investor = investorsInfo[_investor]; require(investor.tokensAllotment == 0, "investor already added"); investor.tokensAllotment = _tokensAllotment; investor.exists = true; investors.push(_investor); _totalAllocatedAmount = _totalAllocatedAmount.add(_tokensAllotment); emit InvestorAdded(_investor, _msgSender(), _tokensAllotment); } /// @dev calculate percentage value from amount /// @param _amount amount input to find the percentage /// @param _percentage percentage for an amount function _calculatePercentage(uint256 _amount, uint256 _percentage) private pure returns (uint256 percentage) { return _amount.mul(_percentage).div(100).div(1e18); } function _calculateAvailablePercentage() private view returns (uint256 availablePercentage) { uint256 currentTimeStamp = block.timestamp; uint256 noOfMonths = BokkyPooBahsDateTimeLibrary.diffMonths(_initialTimestamp, currentTimeStamp); return teamVesting[noOfMonths]; } function recoverToken(address _token, uint256 amount) external onlyOwner { IERC20(_token).safeTransfer(_msgSender(), amount); emit RecoverToken(_token, amount); } }
_calculatePercentage
function _calculatePercentage(uint256 _amount, uint256 _percentage) private pure returns (uint256 percentage) { return _amount.mul(_percentage).div(100).div(1e18); }
/// @dev calculate percentage value from amount /// @param _amount amount input to find the percentage /// @param _percentage percentage for an amount
NatSpecSingleLine
v0.8.0+commit.c7dfd78e
{ "func_code_index": [ 6475, 6656 ] }
2,713
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
Solidity
IERC20
interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
/** * @dev Interface of the ERC20 standard as defined in the EIP. */
NatSpecMultiLine
totalSupply
function totalSupply() external view returns (uint256);
/** * @dev Returns the amount of tokens in existence. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 94, 154 ] }
2,714
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
Solidity
IERC20
interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
/** * @dev Interface of the ERC20 standard as defined in the EIP. */
NatSpecMultiLine
balanceOf
function balanceOf(address account) external view returns (uint256);
/** * @dev Returns the amount of tokens owned by `account`. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 237, 310 ] }
2,715
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
Solidity
IERC20
interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
/** * @dev Interface of the ERC20 standard as defined in the EIP. */
NatSpecMultiLine
transfer
function transfer(address recipient, uint256 amount) external returns (bool);
/** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 534, 616 ] }
2,716
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
Solidity
IERC20
interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
/** * @dev Interface of the ERC20 standard as defined in the EIP. */
NatSpecMultiLine
allowance
function allowance(address owner, address spender) external view returns (uint256);
/** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 895, 983 ] }
2,717
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
Solidity
IERC20
interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
/** * @dev Interface of the ERC20 standard as defined in the EIP. */
NatSpecMultiLine
approve
function approve(address spender, uint256 amount) external returns (bool);
/** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 1647, 1726 ] }
2,718
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
Solidity
IERC20
interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
/** * @dev Interface of the ERC20 standard as defined in the EIP. */
NatSpecMultiLine
transferFrom
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 2039, 2141 ] }
2,719
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
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
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 259, 445 ] }
2,720
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
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
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 723, 864 ] }
2,721
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
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
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 1162, 1359 ] }
2,722
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
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
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 1613, 2089 ] }
2,723
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
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
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 2560, 2697 ] }
2,724
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
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
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 3188, 3471 ] }
2,725
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
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
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 3931, 4066 ] }
2,726
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
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
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 4546, 4717 ] }
2,727
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
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
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 606, 1230 ] }
2,728
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
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
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 2160, 2562 ] }
2,729
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
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
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 3318, 3496 ] }
2,730
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
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
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 3721, 3922 ] }
2,731
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
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
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 4292, 4523 ] }
2,732
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
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
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 4774, 5095 ] }
2,733
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
name
function name() public view returns (string memory) { return _name; }
/** * @dev Returns the name of the token. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 902, 990 ] }
2,734
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
symbol
function symbol() public view returns (string memory) { return _symbol; }
/** * @dev Returns the symbol of the token, usually a shorter version of the * name. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 1104, 1196 ] }
2,735
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
decimals
function decimals() public view returns (uint8) { return _decimals; }
/** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 1829, 1917 ] }
2,736
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
totalSupply
function totalSupply() public view override returns (uint256) { return _totalSupply; }
/** * @dev See {IERC20-totalSupply}. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 1977, 2082 ] }
2,737
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
balanceOf
function balanceOf(address account) public view override returns (uint256) { return _balances[account]; }
/** * @dev See {IERC20-balanceOf}. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 2140, 2264 ] }
2,738
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
transfer
function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; }
/** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 2472, 2652 ] }
2,739
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
allowance
function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; }
/** * @dev See {IERC20-allowance}. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 2710, 2866 ] }
2,740
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
approve
function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; }
/** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 3008, 3182 ] }
2,741
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
transferFrom
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; }
/** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 3651, 3977 ] }
2,742
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
increaseAllowance
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; }
/** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 4381, 4604 ] }
2,743
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
decreaseAllowance
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; }
/** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 5102, 5376 ] }
2,744
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_transfer
function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); }
/** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 5861, 6405 ] }
2,745
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_mint
function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); }
/** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 6681, 7064 ] }
2,746
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_burn
function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); }
/** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 7391, 7814 ] }
2,747
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_approve
function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); }
/** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 8249, 8600 ] }
2,748
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_setupDecimals
function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; }
/** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 8927, 9022 ] }
2,749
ZksToken
ZksToken.sol
0xe4815ae53b124e7263f08dcdbbb757d41ed658c6
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_beforeTokenTransfer
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
/** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://05ecae0876fbfd0f1dead05d79e1a49610e0721c2d872be1d631451c3d8f8d8e
{ "func_code_index": [ 9620, 9717 ] }
2,750
Subrosa
Subrosa.sol
0x1b85440d66a5903deabb24807d739019ff1741e6
Solidity
Subrosa
contract Subrosa { using SafeMath for uint256; /* This smart contract allows to collect ether in a wallet and allow only the owner to withdraw it. Initialize the wallet with owners address while deploying. */ // Events // Deposit Event from the address event Deposit(address _from, uint256 _amount); // Withdraw Event event WithDraw(address _to, uint256 _amount); // The owner of the address address public owner; // Contract address address public contractAddress; // Modifier for only onlyOwner modifier onlyOwner() { require (msg.sender == owner); _; } // Default constructor function Subrosa() public{ owner = 0x193129A669A6Fd24Fc261028570023e91F123573; contractAddress = this; } // Send the ether to current address // The fall back function to which the ether is sent function () public payable { emit Deposit(msg.sender, msg.value); } // WithDraw all the ether only owner can withdraw function withDraw() public onlyOwner () { owner.transfer(contractAddress.balance); emit WithDraw(owner, contractAddress.balance); } // WithDraw a specific amount in wei // @param amount the amount to be withdrawn function withDrawAmount(uint256 amount) public onlyOwner{ require(amount <= contractAddress.balance); owner.transfer(amount); emit WithDraw(owner, amount); } // Check the current balance of the contract // @returns balance returns the current balance of wallet function getBalance() public constant returns(uint256 balance){ return contractAddress.balance; } }
Subrosa
function Subrosa() public{ owner = 0x193129A669A6Fd24Fc261028570023e91F123573; contractAddress = this; }
// Default constructor
LineComment
v0.4.22+commit.4cb486ee
bzzr://f0834b5524f29bbb73b0ffd9abe4f22c47063c15a5035b19c5adc5482fbb4ed3
{ "func_code_index": [ 713, 845 ] }
2,751
Subrosa
Subrosa.sol
0x1b85440d66a5903deabb24807d739019ff1741e6
Solidity
Subrosa
contract Subrosa { using SafeMath for uint256; /* This smart contract allows to collect ether in a wallet and allow only the owner to withdraw it. Initialize the wallet with owners address while deploying. */ // Events // Deposit Event from the address event Deposit(address _from, uint256 _amount); // Withdraw Event event WithDraw(address _to, uint256 _amount); // The owner of the address address public owner; // Contract address address public contractAddress; // Modifier for only onlyOwner modifier onlyOwner() { require (msg.sender == owner); _; } // Default constructor function Subrosa() public{ owner = 0x193129A669A6Fd24Fc261028570023e91F123573; contractAddress = this; } // Send the ether to current address // The fall back function to which the ether is sent function () public payable { emit Deposit(msg.sender, msg.value); } // WithDraw all the ether only owner can withdraw function withDraw() public onlyOwner () { owner.transfer(contractAddress.balance); emit WithDraw(owner, contractAddress.balance); } // WithDraw a specific amount in wei // @param amount the amount to be withdrawn function withDrawAmount(uint256 amount) public onlyOwner{ require(amount <= contractAddress.balance); owner.transfer(amount); emit WithDraw(owner, amount); } // Check the current balance of the contract // @returns balance returns the current balance of wallet function getBalance() public constant returns(uint256 balance){ return contractAddress.balance; } }
function () public payable { emit Deposit(msg.sender, msg.value); }
// Send the ether to current address // The fall back function to which the ether is sent
LineComment
v0.4.22+commit.4cb486ee
bzzr://f0834b5524f29bbb73b0ffd9abe4f22c47063c15a5035b19c5adc5482fbb4ed3
{ "func_code_index": [ 948, 1034 ] }
2,752
Subrosa
Subrosa.sol
0x1b85440d66a5903deabb24807d739019ff1741e6
Solidity
Subrosa
contract Subrosa { using SafeMath for uint256; /* This smart contract allows to collect ether in a wallet and allow only the owner to withdraw it. Initialize the wallet with owners address while deploying. */ // Events // Deposit Event from the address event Deposit(address _from, uint256 _amount); // Withdraw Event event WithDraw(address _to, uint256 _amount); // The owner of the address address public owner; // Contract address address public contractAddress; // Modifier for only onlyOwner modifier onlyOwner() { require (msg.sender == owner); _; } // Default constructor function Subrosa() public{ owner = 0x193129A669A6Fd24Fc261028570023e91F123573; contractAddress = this; } // Send the ether to current address // The fall back function to which the ether is sent function () public payable { emit Deposit(msg.sender, msg.value); } // WithDraw all the ether only owner can withdraw function withDraw() public onlyOwner () { owner.transfer(contractAddress.balance); emit WithDraw(owner, contractAddress.balance); } // WithDraw a specific amount in wei // @param amount the amount to be withdrawn function withDrawAmount(uint256 amount) public onlyOwner{ require(amount <= contractAddress.balance); owner.transfer(amount); emit WithDraw(owner, amount); } // Check the current balance of the contract // @returns balance returns the current balance of wallet function getBalance() public constant returns(uint256 balance){ return contractAddress.balance; } }
withDraw
function withDraw() public onlyOwner () { owner.transfer(contractAddress.balance); emit WithDraw(owner, contractAddress.balance); }
// WithDraw all the ether only owner can withdraw
LineComment
v0.4.22+commit.4cb486ee
bzzr://f0834b5524f29bbb73b0ffd9abe4f22c47063c15a5035b19c5adc5482fbb4ed3
{ "func_code_index": [ 1092, 1251 ] }
2,753
Subrosa
Subrosa.sol
0x1b85440d66a5903deabb24807d739019ff1741e6
Solidity
Subrosa
contract Subrosa { using SafeMath for uint256; /* This smart contract allows to collect ether in a wallet and allow only the owner to withdraw it. Initialize the wallet with owners address while deploying. */ // Events // Deposit Event from the address event Deposit(address _from, uint256 _amount); // Withdraw Event event WithDraw(address _to, uint256 _amount); // The owner of the address address public owner; // Contract address address public contractAddress; // Modifier for only onlyOwner modifier onlyOwner() { require (msg.sender == owner); _; } // Default constructor function Subrosa() public{ owner = 0x193129A669A6Fd24Fc261028570023e91F123573; contractAddress = this; } // Send the ether to current address // The fall back function to which the ether is sent function () public payable { emit Deposit(msg.sender, msg.value); } // WithDraw all the ether only owner can withdraw function withDraw() public onlyOwner () { owner.transfer(contractAddress.balance); emit WithDraw(owner, contractAddress.balance); } // WithDraw a specific amount in wei // @param amount the amount to be withdrawn function withDrawAmount(uint256 amount) public onlyOwner{ require(amount <= contractAddress.balance); owner.transfer(amount); emit WithDraw(owner, amount); } // Check the current balance of the contract // @returns balance returns the current balance of wallet function getBalance() public constant returns(uint256 balance){ return contractAddress.balance; } }
withDrawAmount
function withDrawAmount(uint256 amount) public onlyOwner{ require(amount <= contractAddress.balance); owner.transfer(amount); emit WithDraw(owner, amount); }
// WithDraw a specific amount in wei // @param amount the amount to be withdrawn
LineComment
v0.4.22+commit.4cb486ee
bzzr://f0834b5524f29bbb73b0ffd9abe4f22c47063c15a5035b19c5adc5482fbb4ed3
{ "func_code_index": [ 1345, 1539 ] }
2,754
Subrosa
Subrosa.sol
0x1b85440d66a5903deabb24807d739019ff1741e6
Solidity
Subrosa
contract Subrosa { using SafeMath for uint256; /* This smart contract allows to collect ether in a wallet and allow only the owner to withdraw it. Initialize the wallet with owners address while deploying. */ // Events // Deposit Event from the address event Deposit(address _from, uint256 _amount); // Withdraw Event event WithDraw(address _to, uint256 _amount); // The owner of the address address public owner; // Contract address address public contractAddress; // Modifier for only onlyOwner modifier onlyOwner() { require (msg.sender == owner); _; } // Default constructor function Subrosa() public{ owner = 0x193129A669A6Fd24Fc261028570023e91F123573; contractAddress = this; } // Send the ether to current address // The fall back function to which the ether is sent function () public payable { emit Deposit(msg.sender, msg.value); } // WithDraw all the ether only owner can withdraw function withDraw() public onlyOwner () { owner.transfer(contractAddress.balance); emit WithDraw(owner, contractAddress.balance); } // WithDraw a specific amount in wei // @param amount the amount to be withdrawn function withDrawAmount(uint256 amount) public onlyOwner{ require(amount <= contractAddress.balance); owner.transfer(amount); emit WithDraw(owner, amount); } // Check the current balance of the contract // @returns balance returns the current balance of wallet function getBalance() public constant returns(uint256 balance){ return contractAddress.balance; } }
getBalance
function getBalance() public constant returns(uint256 balance){ return contractAddress.balance; }
// Check the current balance of the contract // @returns balance returns the current balance of wallet
LineComment
v0.4.22+commit.4cb486ee
bzzr://f0834b5524f29bbb73b0ffd9abe4f22c47063c15a5035b19c5adc5482fbb4ed3
{ "func_code_index": [ 1655, 1771 ] }
2,755
DebitumToken
DebitumToken.sol
0x151202c9c18e495656f372281f493eb7698961d5
Solidity
Ownable
contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } }
Ownable
function Ownable() public { owner = msg.sender; }
/** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://17a8528c91e34bd0e06d8187306573c7a476a20d07c9ce914f43c9b87cfbe5c1
{ "func_code_index": [ 261, 321 ] }
2,756
DebitumToken
DebitumToken.sol
0x151202c9c18e495656f372281f493eb7698961d5
Solidity
Ownable
contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } }
transferOwnership
function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; }
/** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://17a8528c91e34bd0e06d8187306573c7a476a20d07c9ce914f43c9b87cfbe5c1
{ "func_code_index": [ 644, 820 ] }
2,757
DebitumToken
DebitumToken.sol
0x151202c9c18e495656f372281f493eb7698961d5
Solidity
iERC20Token
contract iERC20Token { uint256 public totalSupply = 0; /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) public view returns (uint256 balance); /// @notice send `_value` token to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transfer(address _to, uint256 _value) public returns (bool success); /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); /// @notice `msg.sender` approves `_spender` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of tokens to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _value) public returns (bool success); /// @param _owner The address of the account owning tokens /// @param _spender The address of the account able to transfer the tokens /// @return Amount of remaining tokens allowed to spent function allowance(address _owner, address _spender) public view returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); }
balanceOf
function balanceOf(address _owner) public view returns (uint256 balance);
/// @param _owner The address from which the balance will be retrieved /// @return The balance
NatSpecSingleLine
v0.4.18+commit.9cf6e910
bzzr://17a8528c91e34bd0e06d8187306573c7a476a20d07c9ce914f43c9b87cfbe5c1
{ "func_code_index": [ 166, 244 ] }
2,758
DebitumToken
DebitumToken.sol
0x151202c9c18e495656f372281f493eb7698961d5
Solidity
iERC20Token
contract iERC20Token { uint256 public totalSupply = 0; /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) public view returns (uint256 balance); /// @notice send `_value` token to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transfer(address _to, uint256 _value) public returns (bool success); /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); /// @notice `msg.sender` approves `_spender` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of tokens to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _value) public returns (bool success); /// @param _owner The address of the account owning tokens /// @param _spender The address of the account able to transfer the tokens /// @return Amount of remaining tokens allowed to spent function allowance(address _owner, address _spender) public view returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); }
transfer
function transfer(address _to, uint256 _value) public returns (bool success);
/// @notice send `_value` token to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not
NatSpecSingleLine
v0.4.18+commit.9cf6e910
bzzr://17a8528c91e34bd0e06d8187306573c7a476a20d07c9ce914f43c9b87cfbe5c1
{ "func_code_index": [ 481, 563 ] }
2,759
DebitumToken
DebitumToken.sol
0x151202c9c18e495656f372281f493eb7698961d5
Solidity
iERC20Token
contract iERC20Token { uint256 public totalSupply = 0; /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) public view returns (uint256 balance); /// @notice send `_value` token to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transfer(address _to, uint256 _value) public returns (bool success); /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); /// @notice `msg.sender` approves `_spender` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of tokens to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _value) public returns (bool success); /// @param _owner The address of the account owning tokens /// @param _spender The address of the account able to transfer the tokens /// @return Amount of remaining tokens allowed to spent function allowance(address _owner, address _spender) public view returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); }
transferFrom
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not
NatSpecSingleLine
v0.4.18+commit.9cf6e910
bzzr://17a8528c91e34bd0e06d8187306573c7a476a20d07c9ce914f43c9b87cfbe5c1
{ "func_code_index": [ 886, 987 ] }
2,760
DebitumToken
DebitumToken.sol
0x151202c9c18e495656f372281f493eb7698961d5
Solidity
iERC20Token
contract iERC20Token { uint256 public totalSupply = 0; /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) public view returns (uint256 balance); /// @notice send `_value` token to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transfer(address _to, uint256 _value) public returns (bool success); /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); /// @notice `msg.sender` approves `_spender` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of tokens to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _value) public returns (bool success); /// @param _owner The address of the account owning tokens /// @param _spender The address of the account able to transfer the tokens /// @return Amount of remaining tokens allowed to spent function allowance(address _owner, address _spender) public view returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); }
approve
function approve(address _spender, uint256 _value) public returns (bool success);
/// @notice `msg.sender` approves `_spender` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of tokens to be approved for transfer /// @return Whether the approval was successful or not
NatSpecSingleLine
v0.4.18+commit.9cf6e910
bzzr://17a8528c91e34bd0e06d8187306573c7a476a20d07c9ce914f43c9b87cfbe5c1
{ "func_code_index": [ 1277, 1363 ] }
2,761
DebitumToken
DebitumToken.sol
0x151202c9c18e495656f372281f493eb7698961d5
Solidity
iERC20Token
contract iERC20Token { uint256 public totalSupply = 0; /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) public view returns (uint256 balance); /// @notice send `_value` token to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transfer(address _to, uint256 _value) public returns (bool success); /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); /// @notice `msg.sender` approves `_spender` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of tokens to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _value) public returns (bool success); /// @param _owner The address of the account owning tokens /// @param _spender The address of the account able to transfer the tokens /// @return Amount of remaining tokens allowed to spent function allowance(address _owner, address _spender) public view returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); }
allowance
function allowance(address _owner, address _spender) public view returns (uint256 remaining);
/// @param _owner The address of the account owning tokens /// @param _spender The address of the account able to transfer the tokens /// @return Amount of remaining tokens allowed to spent
NatSpecSingleLine
v0.4.18+commit.9cf6e910
bzzr://17a8528c91e34bd0e06d8187306573c7a476a20d07c9ce914f43c9b87cfbe5c1
{ "func_code_index": [ 1571, 1669 ] }
2,762
DebitumToken
DebitumToken.sol
0x151202c9c18e495656f372281f493eb7698961d5
Solidity
StandardToken
contract StandardToken is iERC20Token { using SafeMath for uint256; mapping(address => uint) balances; mapping (address => mapping (address => uint)) allowed; function transfer(address _to, uint _value) public returns (bool success) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint _value) public returns (bool success) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint balance) { return balances[_owner]; } function approve(address _spender, uint _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint remaining) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval (address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval (address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
increaseApproval
function increaseApproval (address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; }
/** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */
NatSpecMultiLine
v0.4.18+commit.9cf6e910
bzzr://17a8528c91e34bd0e06d8187306573c7a476a20d07c9ce914f43c9b87cfbe5c1
{ "func_code_index": [ 1832, 2121 ] }
2,763
DebitumToken
DebitumToken.sol
0x151202c9c18e495656f372281f493eb7698961d5
Solidity
FreezableToken
contract FreezableToken is iERC223Token, StandardToken, Ownable { event ContractTransfer(address indexed _from, address indexed _to, uint _value, bytes _data); bool public freezed; modifier canTransfer(address _transferer) { require(owner == _transferer || !freezed); _; } function FreezableToken() public { freezed = true; } function transfer(address _to, uint _value, bytes _data) canTransfer(msg.sender) public canTransfer(msg.sender) returns (bool success) { //filtering if the target is a contract with bytecode inside it require(super.transfer(_to, _value)); // do a normal token transfer if (isContract(_to)) { require(contractFallback(msg.sender, _to, _value, _data)); } return true; } function transferFrom(address _from, address _to, uint _value, bytes _data) public canTransfer(msg.sender) returns (bool success) { require(super.transferFrom(_from, _to, _value)); // do a normal token transfer if (isContract(_to)) { require(contractFallback(_from, _to, _value, _data)); } return true; } function transfer(address _to, uint _value) canTransfer(msg.sender) public canTransfer(msg.sender) returns (bool success) { return transfer(_to, _value, new bytes(0)); } function transferFrom(address _from, address _to, uint _value) public canTransfer(msg.sender) returns (bool success) { return transferFrom(_from, _to, _value, new bytes(0)); } //function that is called when transaction target is a contract function contractFallback(address _origin, address _to, uint _value, bytes _data) private returns (bool) { ContractTransfer(_origin, _to, _value, _data); ERC223Receiver reciever = ERC223Receiver(_to); require(reciever.tokenFallback(_origin, _value, _data)); return true; } //assemble the given address bytecode. If bytecode exists then the _addr is a contract. function isContract(address _addr) private view returns (bool is_contract) { uint length; assembly { length := extcodesize(_addr) } return length > 0; } function unfreeze() public onlyOwner returns (bool){ freezed = false; return true; } }
contractFallback
function contractFallback(address _origin, address _to, uint _value, bytes _data) private returns (bool) { ContractTransfer(_origin, _to, _value, _data); ERC223Receiver reciever = ERC223Receiver(_to); require(reciever.tokenFallback(_origin, _value, _data)); return true; }
//function that is called when transaction target is a contract
LineComment
v0.4.18+commit.9cf6e910
bzzr://17a8528c91e34bd0e06d8187306573c7a476a20d07c9ce914f43c9b87cfbe5c1
{ "func_code_index": [ 1682, 2000 ] }
2,764
DebitumToken
DebitumToken.sol
0x151202c9c18e495656f372281f493eb7698961d5
Solidity
FreezableToken
contract FreezableToken is iERC223Token, StandardToken, Ownable { event ContractTransfer(address indexed _from, address indexed _to, uint _value, bytes _data); bool public freezed; modifier canTransfer(address _transferer) { require(owner == _transferer || !freezed); _; } function FreezableToken() public { freezed = true; } function transfer(address _to, uint _value, bytes _data) canTransfer(msg.sender) public canTransfer(msg.sender) returns (bool success) { //filtering if the target is a contract with bytecode inside it require(super.transfer(_to, _value)); // do a normal token transfer if (isContract(_to)) { require(contractFallback(msg.sender, _to, _value, _data)); } return true; } function transferFrom(address _from, address _to, uint _value, bytes _data) public canTransfer(msg.sender) returns (bool success) { require(super.transferFrom(_from, _to, _value)); // do a normal token transfer if (isContract(_to)) { require(contractFallback(_from, _to, _value, _data)); } return true; } function transfer(address _to, uint _value) canTransfer(msg.sender) public canTransfer(msg.sender) returns (bool success) { return transfer(_to, _value, new bytes(0)); } function transferFrom(address _from, address _to, uint _value) public canTransfer(msg.sender) returns (bool success) { return transferFrom(_from, _to, _value, new bytes(0)); } //function that is called when transaction target is a contract function contractFallback(address _origin, address _to, uint _value, bytes _data) private returns (bool) { ContractTransfer(_origin, _to, _value, _data); ERC223Receiver reciever = ERC223Receiver(_to); require(reciever.tokenFallback(_origin, _value, _data)); return true; } //assemble the given address bytecode. If bytecode exists then the _addr is a contract. function isContract(address _addr) private view returns (bool is_contract) { uint length; assembly { length := extcodesize(_addr) } return length > 0; } function unfreeze() public onlyOwner returns (bool){ freezed = false; return true; } }
isContract
function isContract(address _addr) private view returns (bool is_contract) { uint length; assembly { length := extcodesize(_addr) } return length > 0; }
//assemble the given address bytecode. If bytecode exists then the _addr is a contract.
LineComment
v0.4.18+commit.9cf6e910
bzzr://17a8528c91e34bd0e06d8187306573c7a476a20d07c9ce914f43c9b87cfbe5c1
{ "func_code_index": [ 2096, 2285 ] }
2,765
UniqGenerator
./contracts/UniqGenerator2.sol
0xb1e9cff95de0681adc3d658df462052512c6dedb
Solidity
UniqGenerator
contract UniqGenerator is ERC721Tradable{ // ----- VARIABLES ----- // uint256 internal _verificationPrice; address internal _tokenForPaying; string public METADATA_PROVENANCE_HASH; uint256 public immutable ROYALTY_FEE; string internal _token_uri; mapping(bytes32 => bool) internal _isItemMinted; mapping(uint256 => bytes32) internal _hashOf; mapping(bytes32 => address) internal _verificationRequester; uint256 internal _tokenNumber; address internal _claimingAddress; // ----- MODIFIERS ----- // modifier notZeroAddress(address a) { require(a != address(0), "ZERO address can not be used"); _; } constructor( address _proxyRegistryAddress, string memory _name, string memory _symbol, uint256 _verfifyPrice, address _tokenERC20, string memory _ttokenUri ) notZeroAddress(_proxyRegistryAddress) ERC721Tradable(_name, _symbol, _proxyRegistryAddress) { ROYALTY_FEE = 750000; //7.5% _verificationPrice = _verfifyPrice; _tokenForPaying = _tokenERC20; _token_uri = _ttokenUri; } function getMessageHash(address _requester, bytes32 _itemHash) public pure returns (bytes32) { return keccak256(abi.encodePacked(_requester, _itemHash)); } function burn(uint256 _tokenId) external { if (msg.sender != _claimingAddress) { require( _isApprovedOrOwner(msg.sender, _tokenId), "Ownership or approval required" ); } _burn(_tokenId); } function getEthSignedMessageHash(bytes32 _messageHash) internal pure returns (bytes32) { return keccak256( abi.encodePacked( "\x19Ethereum Signed Message:\n32", _messageHash ) ); } function verifySignature( address _requester, bytes32 _itemHash, bytes memory _signature ) internal view returns (bool) { bytes32 messageHash = getMessageHash(_requester, _itemHash); bytes32 ethSignedMessageHash = getEthSignedMessageHash(messageHash); return recoverSigner(ethSignedMessageHash, _signature) == owner(); } function recoverSigner( bytes32 _ethSignedMessageHash, bytes memory _signature ) internal pure returns (address) { require(_signature.length == 65, "invalid signature length"); bytes32 r; bytes32 s; uint8 v; assembly { r := mload(add(_signature, 32)) s := mload(add(_signature, 64)) v := byte(0, mload(add(_signature, 96))) } return ecrecover(_ethSignedMessageHash, v, r, s); } function isMintedForHash(bytes32 _itemHash) external view returns (bool) { return _isItemMinted[_itemHash]; } function hashOf(uint256 _id) external view returns (bytes32) { return _hashOf[_id]; } function royaltyInfo(uint256) external view returns (address receiver, uint256 amount) { return (owner(), ROYALTY_FEE); } function tokensOfOwner(address _owner) external view returns (uint256[] memory) { uint256 tokenCount = balanceOf(_owner); if (tokenCount == 0) { // Return an empty array return new uint256[](0); } else { uint256[] memory result = new uint256[](tokenCount); uint256 index; for (index = 0; index < tokenCount; index++) { result[index] = tokenOfOwnerByIndex(_owner, index); } return result; } } function verificationRequester(bytes32 _itemHash) external view returns (address) { return _verificationRequester[_itemHash]; } function getClaimerAddress() external view returns (address) { return _claimingAddress; } function getVerificationPrice() external view returns (uint256) { return _verificationPrice; } function baseTokenURI() override public view returns (string memory) { return _token_uri; } function contractURI() public pure returns (string memory) { return "https://uniqly.com/api/nft-generator/"; } // ----- PUBLIC METHODS ----- // function payForVerification(bytes32 _itemHash) external { require(!_isItemMinted[_itemHash], "Already minted"); require( _verificationRequester[_itemHash] == address(0), "Verification already requested" ); require( IERC20(_tokenForPaying).transferFrom( msg.sender, address(this), _verificationPrice ) ); _verificationRequester[_itemHash] = msg.sender; } function mintVerified(bytes32 _itemHash, bytes memory _signature) external { require( _verificationRequester[_itemHash] == msg.sender, "Verification Requester mismatch" ); require(!_isItemMinted[_itemHash], "Already minted"); require( verifySignature(msg.sender, _itemHash, _signature), "Signature mismatch" ); _isItemMinted[_itemHash] = true; _safeMint(msg.sender, _tokenNumber); _hashOf[_tokenNumber] = _itemHash; _tokenNumber++; } // ----- OWNERS METHODS ----- // function setProvenanceHash(string memory _hash) external onlyOwner { METADATA_PROVENANCE_HASH = _hash; } function editTokenUri(string memory _ttokenUri) external onlyOwner{ _token_uri = _ttokenUri; } function setTokenAddress(address _newAddress) external onlyOwner { _tokenForPaying = _newAddress; } function editVireficationPrice(uint256 _newPrice) external onlyOwner { _verificationPrice = _newPrice; } function editClaimingAdress(address _newAddress) external onlyOwner { _claimingAddress = _newAddress; } function recoverERC20(address token) external onlyOwner { uint256 val = IERC20(token).balanceOf(address(this)); require(val > 0, "Nothing to recover"); // use interface that not return value (USDT case) Ierc20(token).transfer(owner(), val); } function receivedRoyalties( address, address _buyer, uint256 _tokenId, address _tokenPaid, uint256 _amount ) external { emit ReceivedRoyalties(owner(), _buyer, _tokenId, _tokenPaid, _amount); } event ReceivedRoyalties( address indexed _royaltyRecipient, address indexed _buyer, uint256 indexed _tokenId, address _tokenPaid, uint256 _amount ); }
payForVerification
function payForVerification(bytes32 _itemHash) external { require(!_isItemMinted[_itemHash], "Already minted"); require( _verificationRequester[_itemHash] == address(0), "Verification already requested" ); require( IERC20(_tokenForPaying).transferFrom( msg.sender, address(this), _verificationPrice ) ); _verificationRequester[_itemHash] = msg.sender; }
// ----- PUBLIC METHODS ----- //
LineComment
v0.8.6+commit.11564f7e
None
ipfs://8684d54a22c734896df6299361d52ced1d6d29a3d3f98e0413f94190e5a256b7
{ "func_code_index": [ 4466, 4971 ] }
2,766
UniqGenerator
./contracts/UniqGenerator2.sol
0xb1e9cff95de0681adc3d658df462052512c6dedb
Solidity
UniqGenerator
contract UniqGenerator is ERC721Tradable{ // ----- VARIABLES ----- // uint256 internal _verificationPrice; address internal _tokenForPaying; string public METADATA_PROVENANCE_HASH; uint256 public immutable ROYALTY_FEE; string internal _token_uri; mapping(bytes32 => bool) internal _isItemMinted; mapping(uint256 => bytes32) internal _hashOf; mapping(bytes32 => address) internal _verificationRequester; uint256 internal _tokenNumber; address internal _claimingAddress; // ----- MODIFIERS ----- // modifier notZeroAddress(address a) { require(a != address(0), "ZERO address can not be used"); _; } constructor( address _proxyRegistryAddress, string memory _name, string memory _symbol, uint256 _verfifyPrice, address _tokenERC20, string memory _ttokenUri ) notZeroAddress(_proxyRegistryAddress) ERC721Tradable(_name, _symbol, _proxyRegistryAddress) { ROYALTY_FEE = 750000; //7.5% _verificationPrice = _verfifyPrice; _tokenForPaying = _tokenERC20; _token_uri = _ttokenUri; } function getMessageHash(address _requester, bytes32 _itemHash) public pure returns (bytes32) { return keccak256(abi.encodePacked(_requester, _itemHash)); } function burn(uint256 _tokenId) external { if (msg.sender != _claimingAddress) { require( _isApprovedOrOwner(msg.sender, _tokenId), "Ownership or approval required" ); } _burn(_tokenId); } function getEthSignedMessageHash(bytes32 _messageHash) internal pure returns (bytes32) { return keccak256( abi.encodePacked( "\x19Ethereum Signed Message:\n32", _messageHash ) ); } function verifySignature( address _requester, bytes32 _itemHash, bytes memory _signature ) internal view returns (bool) { bytes32 messageHash = getMessageHash(_requester, _itemHash); bytes32 ethSignedMessageHash = getEthSignedMessageHash(messageHash); return recoverSigner(ethSignedMessageHash, _signature) == owner(); } function recoverSigner( bytes32 _ethSignedMessageHash, bytes memory _signature ) internal pure returns (address) { require(_signature.length == 65, "invalid signature length"); bytes32 r; bytes32 s; uint8 v; assembly { r := mload(add(_signature, 32)) s := mload(add(_signature, 64)) v := byte(0, mload(add(_signature, 96))) } return ecrecover(_ethSignedMessageHash, v, r, s); } function isMintedForHash(bytes32 _itemHash) external view returns (bool) { return _isItemMinted[_itemHash]; } function hashOf(uint256 _id) external view returns (bytes32) { return _hashOf[_id]; } function royaltyInfo(uint256) external view returns (address receiver, uint256 amount) { return (owner(), ROYALTY_FEE); } function tokensOfOwner(address _owner) external view returns (uint256[] memory) { uint256 tokenCount = balanceOf(_owner); if (tokenCount == 0) { // Return an empty array return new uint256[](0); } else { uint256[] memory result = new uint256[](tokenCount); uint256 index; for (index = 0; index < tokenCount; index++) { result[index] = tokenOfOwnerByIndex(_owner, index); } return result; } } function verificationRequester(bytes32 _itemHash) external view returns (address) { return _verificationRequester[_itemHash]; } function getClaimerAddress() external view returns (address) { return _claimingAddress; } function getVerificationPrice() external view returns (uint256) { return _verificationPrice; } function baseTokenURI() override public view returns (string memory) { return _token_uri; } function contractURI() public pure returns (string memory) { return "https://uniqly.com/api/nft-generator/"; } // ----- PUBLIC METHODS ----- // function payForVerification(bytes32 _itemHash) external { require(!_isItemMinted[_itemHash], "Already minted"); require( _verificationRequester[_itemHash] == address(0), "Verification already requested" ); require( IERC20(_tokenForPaying).transferFrom( msg.sender, address(this), _verificationPrice ) ); _verificationRequester[_itemHash] = msg.sender; } function mintVerified(bytes32 _itemHash, bytes memory _signature) external { require( _verificationRequester[_itemHash] == msg.sender, "Verification Requester mismatch" ); require(!_isItemMinted[_itemHash], "Already minted"); require( verifySignature(msg.sender, _itemHash, _signature), "Signature mismatch" ); _isItemMinted[_itemHash] = true; _safeMint(msg.sender, _tokenNumber); _hashOf[_tokenNumber] = _itemHash; _tokenNumber++; } // ----- OWNERS METHODS ----- // function setProvenanceHash(string memory _hash) external onlyOwner { METADATA_PROVENANCE_HASH = _hash; } function editTokenUri(string memory _ttokenUri) external onlyOwner{ _token_uri = _ttokenUri; } function setTokenAddress(address _newAddress) external onlyOwner { _tokenForPaying = _newAddress; } function editVireficationPrice(uint256 _newPrice) external onlyOwner { _verificationPrice = _newPrice; } function editClaimingAdress(address _newAddress) external onlyOwner { _claimingAddress = _newAddress; } function recoverERC20(address token) external onlyOwner { uint256 val = IERC20(token).balanceOf(address(this)); require(val > 0, "Nothing to recover"); // use interface that not return value (USDT case) Ierc20(token).transfer(owner(), val); } function receivedRoyalties( address, address _buyer, uint256 _tokenId, address _tokenPaid, uint256 _amount ) external { emit ReceivedRoyalties(owner(), _buyer, _tokenId, _tokenPaid, _amount); } event ReceivedRoyalties( address indexed _royaltyRecipient, address indexed _buyer, uint256 indexed _tokenId, address _tokenPaid, uint256 _amount ); }
setProvenanceHash
function setProvenanceHash(string memory _hash) external onlyOwner { METADATA_PROVENANCE_HASH = _hash; }
// ----- OWNERS METHODS ----- //
LineComment
v0.8.6+commit.11564f7e
None
ipfs://8684d54a22c734896df6299361d52ced1d6d29a3d3f98e0413f94190e5a256b7
{ "func_code_index": [ 5573, 5693 ] }
2,767
_goatgauds
contracts/goadgauds.sol
0x5cebe5cde01ab154fb46b7984d6354da367bcbaf
Solidity
_goatgauds
contract _goatgauds is Delegated, ERC721EnumerableLite, PaymentSplitterMod { using Strings for uint; uint public MAX_ORDER = 2; uint public MAX_SUPPLY = 2222; uint public MAINSALE_PRICE = 0.125 ether; uint public PRESALE_PRICE = 0.1 ether; bool public isMintActive = false; bool public isPresaleActive = false; mapping(address=>uint) public accessList; string private _tokenURIPrefix = ''; string private _tokenURISuffix = ''; address[] private addressList = [ 0xF5c774b504C1D82fb59e3B826555D67033A13b01, 0x7Cf39e8D6F6f9F25E925Dad7EB371276231780d7, 0xC02Dd50b25364e747410730A1df9B72A92C3C68B, 0x286777D6ad08EbE395C377078a17a32c21564a8a, 0x00eCb19318d98ff57173Ac8EdFb7a5D90ba2005d, 0x2E169A7c3D8EBeC11D5b43Dade06Ac29FEf59cb3, 0x693B22BB92727Fb2a9a4D7e1b1D65B3E8168B774 ]; uint[] private shareList = [ 5, 5, 5, 5, 30, 25, 25 ]; constructor() Delegated() ERC721B("Goat Gauds", "GG", 0) PaymentSplitterMod( addressList, shareList ){ } //public view fallback() external payable {} function tokenURI(uint tokenId) external view override returns (string memory) { require(_exists(tokenId), "Query for nonexistent token"); return string(abi.encodePacked(_tokenURIPrefix, tokenId.toString(), _tokenURISuffix)); } //public payable function presale( uint quantity ) external payable { require( isPresaleActive, "Presale is not active" ); require( quantity <= MAX_ORDER, "Order too big" ); require( msg.value >= PRESALE_PRICE * quantity, "Ether sent is not correct" ); require( accessList[msg.sender] > 0, "Not authorized" ); uint supply = totalSupply(); require( supply + quantity <= MAX_SUPPLY, "Mint/order exceeds supply" ); accessList[msg.sender] -= quantity; for(uint i; i < quantity; ++i){ _mint( msg.sender, supply++ ); } } function mint( uint quantity ) external payable { require( isMintActive, "Sale is not active" ); require( quantity <= MAX_ORDER, "Order too big" ); require( msg.value >= MAINSALE_PRICE * quantity, "Ether sent is not correct" ); uint supply = totalSupply(); require( supply + quantity <= MAX_SUPPLY, "Mint/order exceeds supply" ); for(uint i; i < quantity; ++i){ _mint( msg.sender, supply++ ); } } //delegated payable function burnFrom( address owner, uint[] calldata tokenIds ) external payable onlyDelegates{ for(uint i; i < tokenIds.length; ++i ){ require( _exists( tokenIds[i] ), "Burn for nonexistent token" ); require( _owners[ tokenIds[i] ] == owner, "Owner mismatch" ); _burn( tokenIds[i] ); } } function mintTo(uint[] calldata quantity, address[] calldata recipient) external payable onlyDelegates{ require(quantity.length == recipient.length, "Must provide equal quantities and recipients" ); uint totalQuantity; uint supply = totalSupply(); for(uint i; i < quantity.length; ++i){ totalQuantity += quantity[i]; } require( supply + totalQuantity <= MAX_SUPPLY, "Mint/order exceeds supply" ); for(uint i; i < recipient.length; ++i){ for(uint j; j < quantity[i]; ++j){ _mint( recipient[i], supply++ ); } } } //delegated nonpayable function resurrect( uint[] calldata tokenIds, address[] calldata recipients ) external onlyDelegates{ require(tokenIds.length == recipients.length, "Must provide equal tokenIds and recipients" ); address to; uint tokenId; address zero = address(0); for(uint i; i < tokenIds.length; ++i ){ to = recipients[i]; require(recipients[i] != address(0), "resurrect to the zero address" ); tokenId = tokenIds[i]; require( !_exists( tokenId ), "can't resurrect existing token" ); _owners[tokenId] = to; // Clear approvals _approve(zero, tokenId); emit Transfer(zero, to, tokenId); } } function setAccessList(address[] calldata accounts, uint[] calldata quantities) external onlyDelegates{ require(accounts.length == quantities.length, "Must provide equal accounts and quantities" ); for(uint i; i < accounts.length; ++i){ accessList[ accounts[i] ] = quantities[i]; } } function setActive(bool isPresaleActive_, bool isMintActive_) external onlyDelegates{ require( isPresaleActive != isPresaleActive_ || isMintActive != isMintActive_, "New value matches old" ); isPresaleActive = isPresaleActive_; isMintActive = isMintActive_; } function setBaseURI(string calldata newPrefix, string calldata newSuffix) external onlyDelegates{ _tokenURIPrefix = newPrefix; _tokenURISuffix = newSuffix; } function setMax(uint maxOrder, uint maxSupply) external onlyDelegates{ require( MAX_ORDER != maxOrder || MAX_SUPPLY != maxSupply, "New value matches old" ); require(maxSupply >= totalSupply(), "Specified supply is lower than current balance" ); MAX_ORDER = maxOrder; MAX_SUPPLY = maxSupply; } function setPrice(uint presalePrice, uint mainsalePrice ) external onlyDelegates{ require( PRESALE_PRICE != presalePrice || MAINSALE_PRICE != mainsalePrice, "New value matches old" ); PRESALE_PRICE = presalePrice; MAINSALE_PRICE = mainsalePrice; } //owner function addPayee(address account, uint256 shares_) external onlyOwner { _addPayee(account, shares_); } function setPayee( uint index, address account, uint newShares ) external onlyOwner { _setPayee(index, account, newShares); } //internal function _burn(uint tokenId) internal override { address curOwner = ERC721B.ownerOf(tokenId); // Clear approvals _approve(owner(), tokenId); _owners[tokenId] = address(0); emit Transfer(curOwner, address(0), tokenId); } function _mint(address to, uint tokenId) internal override { _owners.push(to); emit Transfer(address(0), to, tokenId); } }
//public view
LineComment
v0.8.7+commit.e28d00a7
MIT
ipfs://efc6e995f9113dd9e7553b8bfdbd720d3ba65ba918ce8660b957b3e9434d2079
{ "func_code_index": [ 1110, 1143 ] }
2,768
_goatgauds
contracts/goadgauds.sol
0x5cebe5cde01ab154fb46b7984d6354da367bcbaf
Solidity
_goatgauds
contract _goatgauds is Delegated, ERC721EnumerableLite, PaymentSplitterMod { using Strings for uint; uint public MAX_ORDER = 2; uint public MAX_SUPPLY = 2222; uint public MAINSALE_PRICE = 0.125 ether; uint public PRESALE_PRICE = 0.1 ether; bool public isMintActive = false; bool public isPresaleActive = false; mapping(address=>uint) public accessList; string private _tokenURIPrefix = ''; string private _tokenURISuffix = ''; address[] private addressList = [ 0xF5c774b504C1D82fb59e3B826555D67033A13b01, 0x7Cf39e8D6F6f9F25E925Dad7EB371276231780d7, 0xC02Dd50b25364e747410730A1df9B72A92C3C68B, 0x286777D6ad08EbE395C377078a17a32c21564a8a, 0x00eCb19318d98ff57173Ac8EdFb7a5D90ba2005d, 0x2E169A7c3D8EBeC11D5b43Dade06Ac29FEf59cb3, 0x693B22BB92727Fb2a9a4D7e1b1D65B3E8168B774 ]; uint[] private shareList = [ 5, 5, 5, 5, 30, 25, 25 ]; constructor() Delegated() ERC721B("Goat Gauds", "GG", 0) PaymentSplitterMod( addressList, shareList ){ } //public view fallback() external payable {} function tokenURI(uint tokenId) external view override returns (string memory) { require(_exists(tokenId), "Query for nonexistent token"); return string(abi.encodePacked(_tokenURIPrefix, tokenId.toString(), _tokenURISuffix)); } //public payable function presale( uint quantity ) external payable { require( isPresaleActive, "Presale is not active" ); require( quantity <= MAX_ORDER, "Order too big" ); require( msg.value >= PRESALE_PRICE * quantity, "Ether sent is not correct" ); require( accessList[msg.sender] > 0, "Not authorized" ); uint supply = totalSupply(); require( supply + quantity <= MAX_SUPPLY, "Mint/order exceeds supply" ); accessList[msg.sender] -= quantity; for(uint i; i < quantity; ++i){ _mint( msg.sender, supply++ ); } } function mint( uint quantity ) external payable { require( isMintActive, "Sale is not active" ); require( quantity <= MAX_ORDER, "Order too big" ); require( msg.value >= MAINSALE_PRICE * quantity, "Ether sent is not correct" ); uint supply = totalSupply(); require( supply + quantity <= MAX_SUPPLY, "Mint/order exceeds supply" ); for(uint i; i < quantity; ++i){ _mint( msg.sender, supply++ ); } } //delegated payable function burnFrom( address owner, uint[] calldata tokenIds ) external payable onlyDelegates{ for(uint i; i < tokenIds.length; ++i ){ require( _exists( tokenIds[i] ), "Burn for nonexistent token" ); require( _owners[ tokenIds[i] ] == owner, "Owner mismatch" ); _burn( tokenIds[i] ); } } function mintTo(uint[] calldata quantity, address[] calldata recipient) external payable onlyDelegates{ require(quantity.length == recipient.length, "Must provide equal quantities and recipients" ); uint totalQuantity; uint supply = totalSupply(); for(uint i; i < quantity.length; ++i){ totalQuantity += quantity[i]; } require( supply + totalQuantity <= MAX_SUPPLY, "Mint/order exceeds supply" ); for(uint i; i < recipient.length; ++i){ for(uint j; j < quantity[i]; ++j){ _mint( recipient[i], supply++ ); } } } //delegated nonpayable function resurrect( uint[] calldata tokenIds, address[] calldata recipients ) external onlyDelegates{ require(tokenIds.length == recipients.length, "Must provide equal tokenIds and recipients" ); address to; uint tokenId; address zero = address(0); for(uint i; i < tokenIds.length; ++i ){ to = recipients[i]; require(recipients[i] != address(0), "resurrect to the zero address" ); tokenId = tokenIds[i]; require( !_exists( tokenId ), "can't resurrect existing token" ); _owners[tokenId] = to; // Clear approvals _approve(zero, tokenId); emit Transfer(zero, to, tokenId); } } function setAccessList(address[] calldata accounts, uint[] calldata quantities) external onlyDelegates{ require(accounts.length == quantities.length, "Must provide equal accounts and quantities" ); for(uint i; i < accounts.length; ++i){ accessList[ accounts[i] ] = quantities[i]; } } function setActive(bool isPresaleActive_, bool isMintActive_) external onlyDelegates{ require( isPresaleActive != isPresaleActive_ || isMintActive != isMintActive_, "New value matches old" ); isPresaleActive = isPresaleActive_; isMintActive = isMintActive_; } function setBaseURI(string calldata newPrefix, string calldata newSuffix) external onlyDelegates{ _tokenURIPrefix = newPrefix; _tokenURISuffix = newSuffix; } function setMax(uint maxOrder, uint maxSupply) external onlyDelegates{ require( MAX_ORDER != maxOrder || MAX_SUPPLY != maxSupply, "New value matches old" ); require(maxSupply >= totalSupply(), "Specified supply is lower than current balance" ); MAX_ORDER = maxOrder; MAX_SUPPLY = maxSupply; } function setPrice(uint presalePrice, uint mainsalePrice ) external onlyDelegates{ require( PRESALE_PRICE != presalePrice || MAINSALE_PRICE != mainsalePrice, "New value matches old" ); PRESALE_PRICE = presalePrice; MAINSALE_PRICE = mainsalePrice; } //owner function addPayee(address account, uint256 shares_) external onlyOwner { _addPayee(account, shares_); } function setPayee( uint index, address account, uint newShares ) external onlyOwner { _setPayee(index, account, newShares); } //internal function _burn(uint tokenId) internal override { address curOwner = ERC721B.ownerOf(tokenId); // Clear approvals _approve(owner(), tokenId); _owners[tokenId] = address(0); emit Transfer(curOwner, address(0), tokenId); } function _mint(address to, uint tokenId) internal override { _owners.push(to); emit Transfer(address(0), to, tokenId); } }
presale
function presale( uint quantity ) external payable { require( isPresaleActive, "Presale is not active" ); require( quantity <= MAX_ORDER, "Order too big" ); require( msg.value >= PRESALE_PRICE * quantity, "Ether sent is not correct" ); require( accessList[msg.sender] > 0, "Not authorized" ); uint supply = totalSupply(); require( supply + quantity <= MAX_SUPPLY, "Mint/order exceeds supply" ); accessList[msg.sender] -= quantity; for(uint i; i < quantity; ++i){ _mint( msg.sender, supply++ ); } }
//public payable
LineComment
v0.8.7+commit.e28d00a7
MIT
ipfs://efc6e995f9113dd9e7553b8bfdbd720d3ba65ba918ce8660b957b3e9434d2079
{ "func_code_index": [ 1414, 2025 ] }
2,769
_goatgauds
contracts/goadgauds.sol
0x5cebe5cde01ab154fb46b7984d6354da367bcbaf
Solidity
_goatgauds
contract _goatgauds is Delegated, ERC721EnumerableLite, PaymentSplitterMod { using Strings for uint; uint public MAX_ORDER = 2; uint public MAX_SUPPLY = 2222; uint public MAINSALE_PRICE = 0.125 ether; uint public PRESALE_PRICE = 0.1 ether; bool public isMintActive = false; bool public isPresaleActive = false; mapping(address=>uint) public accessList; string private _tokenURIPrefix = ''; string private _tokenURISuffix = ''; address[] private addressList = [ 0xF5c774b504C1D82fb59e3B826555D67033A13b01, 0x7Cf39e8D6F6f9F25E925Dad7EB371276231780d7, 0xC02Dd50b25364e747410730A1df9B72A92C3C68B, 0x286777D6ad08EbE395C377078a17a32c21564a8a, 0x00eCb19318d98ff57173Ac8EdFb7a5D90ba2005d, 0x2E169A7c3D8EBeC11D5b43Dade06Ac29FEf59cb3, 0x693B22BB92727Fb2a9a4D7e1b1D65B3E8168B774 ]; uint[] private shareList = [ 5, 5, 5, 5, 30, 25, 25 ]; constructor() Delegated() ERC721B("Goat Gauds", "GG", 0) PaymentSplitterMod( addressList, shareList ){ } //public view fallback() external payable {} function tokenURI(uint tokenId) external view override returns (string memory) { require(_exists(tokenId), "Query for nonexistent token"); return string(abi.encodePacked(_tokenURIPrefix, tokenId.toString(), _tokenURISuffix)); } //public payable function presale( uint quantity ) external payable { require( isPresaleActive, "Presale is not active" ); require( quantity <= MAX_ORDER, "Order too big" ); require( msg.value >= PRESALE_PRICE * quantity, "Ether sent is not correct" ); require( accessList[msg.sender] > 0, "Not authorized" ); uint supply = totalSupply(); require( supply + quantity <= MAX_SUPPLY, "Mint/order exceeds supply" ); accessList[msg.sender] -= quantity; for(uint i; i < quantity; ++i){ _mint( msg.sender, supply++ ); } } function mint( uint quantity ) external payable { require( isMintActive, "Sale is not active" ); require( quantity <= MAX_ORDER, "Order too big" ); require( msg.value >= MAINSALE_PRICE * quantity, "Ether sent is not correct" ); uint supply = totalSupply(); require( supply + quantity <= MAX_SUPPLY, "Mint/order exceeds supply" ); for(uint i; i < quantity; ++i){ _mint( msg.sender, supply++ ); } } //delegated payable function burnFrom( address owner, uint[] calldata tokenIds ) external payable onlyDelegates{ for(uint i; i < tokenIds.length; ++i ){ require( _exists( tokenIds[i] ), "Burn for nonexistent token" ); require( _owners[ tokenIds[i] ] == owner, "Owner mismatch" ); _burn( tokenIds[i] ); } } function mintTo(uint[] calldata quantity, address[] calldata recipient) external payable onlyDelegates{ require(quantity.length == recipient.length, "Must provide equal quantities and recipients" ); uint totalQuantity; uint supply = totalSupply(); for(uint i; i < quantity.length; ++i){ totalQuantity += quantity[i]; } require( supply + totalQuantity <= MAX_SUPPLY, "Mint/order exceeds supply" ); for(uint i; i < recipient.length; ++i){ for(uint j; j < quantity[i]; ++j){ _mint( recipient[i], supply++ ); } } } //delegated nonpayable function resurrect( uint[] calldata tokenIds, address[] calldata recipients ) external onlyDelegates{ require(tokenIds.length == recipients.length, "Must provide equal tokenIds and recipients" ); address to; uint tokenId; address zero = address(0); for(uint i; i < tokenIds.length; ++i ){ to = recipients[i]; require(recipients[i] != address(0), "resurrect to the zero address" ); tokenId = tokenIds[i]; require( !_exists( tokenId ), "can't resurrect existing token" ); _owners[tokenId] = to; // Clear approvals _approve(zero, tokenId); emit Transfer(zero, to, tokenId); } } function setAccessList(address[] calldata accounts, uint[] calldata quantities) external onlyDelegates{ require(accounts.length == quantities.length, "Must provide equal accounts and quantities" ); for(uint i; i < accounts.length; ++i){ accessList[ accounts[i] ] = quantities[i]; } } function setActive(bool isPresaleActive_, bool isMintActive_) external onlyDelegates{ require( isPresaleActive != isPresaleActive_ || isMintActive != isMintActive_, "New value matches old" ); isPresaleActive = isPresaleActive_; isMintActive = isMintActive_; } function setBaseURI(string calldata newPrefix, string calldata newSuffix) external onlyDelegates{ _tokenURIPrefix = newPrefix; _tokenURISuffix = newSuffix; } function setMax(uint maxOrder, uint maxSupply) external onlyDelegates{ require( MAX_ORDER != maxOrder || MAX_SUPPLY != maxSupply, "New value matches old" ); require(maxSupply >= totalSupply(), "Specified supply is lower than current balance" ); MAX_ORDER = maxOrder; MAX_SUPPLY = maxSupply; } function setPrice(uint presalePrice, uint mainsalePrice ) external onlyDelegates{ require( PRESALE_PRICE != presalePrice || MAINSALE_PRICE != mainsalePrice, "New value matches old" ); PRESALE_PRICE = presalePrice; MAINSALE_PRICE = mainsalePrice; } //owner function addPayee(address account, uint256 shares_) external onlyOwner { _addPayee(account, shares_); } function setPayee( uint index, address account, uint newShares ) external onlyOwner { _setPayee(index, account, newShares); } //internal function _burn(uint tokenId) internal override { address curOwner = ERC721B.ownerOf(tokenId); // Clear approvals _approve(owner(), tokenId); _owners[tokenId] = address(0); emit Transfer(curOwner, address(0), tokenId); } function _mint(address to, uint tokenId) internal override { _owners.push(to); emit Transfer(address(0), to, tokenId); } }
burnFrom
function burnFrom( address owner, uint[] calldata tokenIds ) external payable onlyDelegates{ for(uint i; i < tokenIds.length; ++i ){ require( _exists( tokenIds[i] ), "Burn for nonexistent token" ); require( _owners[ tokenIds[i] ] == owner, "Owner mismatch" ); _burn( tokenIds[i] ); } }
//delegated payable
LineComment
v0.8.7+commit.e28d00a7
MIT
ipfs://efc6e995f9113dd9e7553b8bfdbd720d3ba65ba918ce8660b957b3e9434d2079
{ "func_code_index": [ 2546, 2868 ] }
2,770
_goatgauds
contracts/goadgauds.sol
0x5cebe5cde01ab154fb46b7984d6354da367bcbaf
Solidity
_goatgauds
contract _goatgauds is Delegated, ERC721EnumerableLite, PaymentSplitterMod { using Strings for uint; uint public MAX_ORDER = 2; uint public MAX_SUPPLY = 2222; uint public MAINSALE_PRICE = 0.125 ether; uint public PRESALE_PRICE = 0.1 ether; bool public isMintActive = false; bool public isPresaleActive = false; mapping(address=>uint) public accessList; string private _tokenURIPrefix = ''; string private _tokenURISuffix = ''; address[] private addressList = [ 0xF5c774b504C1D82fb59e3B826555D67033A13b01, 0x7Cf39e8D6F6f9F25E925Dad7EB371276231780d7, 0xC02Dd50b25364e747410730A1df9B72A92C3C68B, 0x286777D6ad08EbE395C377078a17a32c21564a8a, 0x00eCb19318d98ff57173Ac8EdFb7a5D90ba2005d, 0x2E169A7c3D8EBeC11D5b43Dade06Ac29FEf59cb3, 0x693B22BB92727Fb2a9a4D7e1b1D65B3E8168B774 ]; uint[] private shareList = [ 5, 5, 5, 5, 30, 25, 25 ]; constructor() Delegated() ERC721B("Goat Gauds", "GG", 0) PaymentSplitterMod( addressList, shareList ){ } //public view fallback() external payable {} function tokenURI(uint tokenId) external view override returns (string memory) { require(_exists(tokenId), "Query for nonexistent token"); return string(abi.encodePacked(_tokenURIPrefix, tokenId.toString(), _tokenURISuffix)); } //public payable function presale( uint quantity ) external payable { require( isPresaleActive, "Presale is not active" ); require( quantity <= MAX_ORDER, "Order too big" ); require( msg.value >= PRESALE_PRICE * quantity, "Ether sent is not correct" ); require( accessList[msg.sender] > 0, "Not authorized" ); uint supply = totalSupply(); require( supply + quantity <= MAX_SUPPLY, "Mint/order exceeds supply" ); accessList[msg.sender] -= quantity; for(uint i; i < quantity; ++i){ _mint( msg.sender, supply++ ); } } function mint( uint quantity ) external payable { require( isMintActive, "Sale is not active" ); require( quantity <= MAX_ORDER, "Order too big" ); require( msg.value >= MAINSALE_PRICE * quantity, "Ether sent is not correct" ); uint supply = totalSupply(); require( supply + quantity <= MAX_SUPPLY, "Mint/order exceeds supply" ); for(uint i; i < quantity; ++i){ _mint( msg.sender, supply++ ); } } //delegated payable function burnFrom( address owner, uint[] calldata tokenIds ) external payable onlyDelegates{ for(uint i; i < tokenIds.length; ++i ){ require( _exists( tokenIds[i] ), "Burn for nonexistent token" ); require( _owners[ tokenIds[i] ] == owner, "Owner mismatch" ); _burn( tokenIds[i] ); } } function mintTo(uint[] calldata quantity, address[] calldata recipient) external payable onlyDelegates{ require(quantity.length == recipient.length, "Must provide equal quantities and recipients" ); uint totalQuantity; uint supply = totalSupply(); for(uint i; i < quantity.length; ++i){ totalQuantity += quantity[i]; } require( supply + totalQuantity <= MAX_SUPPLY, "Mint/order exceeds supply" ); for(uint i; i < recipient.length; ++i){ for(uint j; j < quantity[i]; ++j){ _mint( recipient[i], supply++ ); } } } //delegated nonpayable function resurrect( uint[] calldata tokenIds, address[] calldata recipients ) external onlyDelegates{ require(tokenIds.length == recipients.length, "Must provide equal tokenIds and recipients" ); address to; uint tokenId; address zero = address(0); for(uint i; i < tokenIds.length; ++i ){ to = recipients[i]; require(recipients[i] != address(0), "resurrect to the zero address" ); tokenId = tokenIds[i]; require( !_exists( tokenId ), "can't resurrect existing token" ); _owners[tokenId] = to; // Clear approvals _approve(zero, tokenId); emit Transfer(zero, to, tokenId); } } function setAccessList(address[] calldata accounts, uint[] calldata quantities) external onlyDelegates{ require(accounts.length == quantities.length, "Must provide equal accounts and quantities" ); for(uint i; i < accounts.length; ++i){ accessList[ accounts[i] ] = quantities[i]; } } function setActive(bool isPresaleActive_, bool isMintActive_) external onlyDelegates{ require( isPresaleActive != isPresaleActive_ || isMintActive != isMintActive_, "New value matches old" ); isPresaleActive = isPresaleActive_; isMintActive = isMintActive_; } function setBaseURI(string calldata newPrefix, string calldata newSuffix) external onlyDelegates{ _tokenURIPrefix = newPrefix; _tokenURISuffix = newSuffix; } function setMax(uint maxOrder, uint maxSupply) external onlyDelegates{ require( MAX_ORDER != maxOrder || MAX_SUPPLY != maxSupply, "New value matches old" ); require(maxSupply >= totalSupply(), "Specified supply is lower than current balance" ); MAX_ORDER = maxOrder; MAX_SUPPLY = maxSupply; } function setPrice(uint presalePrice, uint mainsalePrice ) external onlyDelegates{ require( PRESALE_PRICE != presalePrice || MAINSALE_PRICE != mainsalePrice, "New value matches old" ); PRESALE_PRICE = presalePrice; MAINSALE_PRICE = mainsalePrice; } //owner function addPayee(address account, uint256 shares_) external onlyOwner { _addPayee(account, shares_); } function setPayee( uint index, address account, uint newShares ) external onlyOwner { _setPayee(index, account, newShares); } //internal function _burn(uint tokenId) internal override { address curOwner = ERC721B.ownerOf(tokenId); // Clear approvals _approve(owner(), tokenId); _owners[tokenId] = address(0); emit Transfer(curOwner, address(0), tokenId); } function _mint(address to, uint tokenId) internal override { _owners.push(to); emit Transfer(address(0), to, tokenId); } }
resurrect
function resurrect( uint[] calldata tokenIds, address[] calldata recipients ) external onlyDelegates{ require(tokenIds.length == recipients.length, "Must provide equal tokenIds and recipients" ); address to; uint tokenId; address zero = address(0); for(uint i; i < tokenIds.length; ++i ){ to = recipients[i]; require(recipients[i] != address(0), "resurrect to the zero address" ); tokenId = tokenIds[i]; require( !_exists( tokenId ), "can't resurrect existing token" ); _owners[tokenId] = to; // Clear approvals _approve(zero, tokenId); emit Transfer(zero, to, tokenId); } }
//delegated nonpayable
LineComment
v0.8.7+commit.e28d00a7
MIT
ipfs://efc6e995f9113dd9e7553b8bfdbd720d3ba65ba918ce8660b957b3e9434d2079
{ "func_code_index": [ 3492, 4174 ] }
2,771
_goatgauds
contracts/goadgauds.sol
0x5cebe5cde01ab154fb46b7984d6354da367bcbaf
Solidity
_goatgauds
contract _goatgauds is Delegated, ERC721EnumerableLite, PaymentSplitterMod { using Strings for uint; uint public MAX_ORDER = 2; uint public MAX_SUPPLY = 2222; uint public MAINSALE_PRICE = 0.125 ether; uint public PRESALE_PRICE = 0.1 ether; bool public isMintActive = false; bool public isPresaleActive = false; mapping(address=>uint) public accessList; string private _tokenURIPrefix = ''; string private _tokenURISuffix = ''; address[] private addressList = [ 0xF5c774b504C1D82fb59e3B826555D67033A13b01, 0x7Cf39e8D6F6f9F25E925Dad7EB371276231780d7, 0xC02Dd50b25364e747410730A1df9B72A92C3C68B, 0x286777D6ad08EbE395C377078a17a32c21564a8a, 0x00eCb19318d98ff57173Ac8EdFb7a5D90ba2005d, 0x2E169A7c3D8EBeC11D5b43Dade06Ac29FEf59cb3, 0x693B22BB92727Fb2a9a4D7e1b1D65B3E8168B774 ]; uint[] private shareList = [ 5, 5, 5, 5, 30, 25, 25 ]; constructor() Delegated() ERC721B("Goat Gauds", "GG", 0) PaymentSplitterMod( addressList, shareList ){ } //public view fallback() external payable {} function tokenURI(uint tokenId) external view override returns (string memory) { require(_exists(tokenId), "Query for nonexistent token"); return string(abi.encodePacked(_tokenURIPrefix, tokenId.toString(), _tokenURISuffix)); } //public payable function presale( uint quantity ) external payable { require( isPresaleActive, "Presale is not active" ); require( quantity <= MAX_ORDER, "Order too big" ); require( msg.value >= PRESALE_PRICE * quantity, "Ether sent is not correct" ); require( accessList[msg.sender] > 0, "Not authorized" ); uint supply = totalSupply(); require( supply + quantity <= MAX_SUPPLY, "Mint/order exceeds supply" ); accessList[msg.sender] -= quantity; for(uint i; i < quantity; ++i){ _mint( msg.sender, supply++ ); } } function mint( uint quantity ) external payable { require( isMintActive, "Sale is not active" ); require( quantity <= MAX_ORDER, "Order too big" ); require( msg.value >= MAINSALE_PRICE * quantity, "Ether sent is not correct" ); uint supply = totalSupply(); require( supply + quantity <= MAX_SUPPLY, "Mint/order exceeds supply" ); for(uint i; i < quantity; ++i){ _mint( msg.sender, supply++ ); } } //delegated payable function burnFrom( address owner, uint[] calldata tokenIds ) external payable onlyDelegates{ for(uint i; i < tokenIds.length; ++i ){ require( _exists( tokenIds[i] ), "Burn for nonexistent token" ); require( _owners[ tokenIds[i] ] == owner, "Owner mismatch" ); _burn( tokenIds[i] ); } } function mintTo(uint[] calldata quantity, address[] calldata recipient) external payable onlyDelegates{ require(quantity.length == recipient.length, "Must provide equal quantities and recipients" ); uint totalQuantity; uint supply = totalSupply(); for(uint i; i < quantity.length; ++i){ totalQuantity += quantity[i]; } require( supply + totalQuantity <= MAX_SUPPLY, "Mint/order exceeds supply" ); for(uint i; i < recipient.length; ++i){ for(uint j; j < quantity[i]; ++j){ _mint( recipient[i], supply++ ); } } } //delegated nonpayable function resurrect( uint[] calldata tokenIds, address[] calldata recipients ) external onlyDelegates{ require(tokenIds.length == recipients.length, "Must provide equal tokenIds and recipients" ); address to; uint tokenId; address zero = address(0); for(uint i; i < tokenIds.length; ++i ){ to = recipients[i]; require(recipients[i] != address(0), "resurrect to the zero address" ); tokenId = tokenIds[i]; require( !_exists( tokenId ), "can't resurrect existing token" ); _owners[tokenId] = to; // Clear approvals _approve(zero, tokenId); emit Transfer(zero, to, tokenId); } } function setAccessList(address[] calldata accounts, uint[] calldata quantities) external onlyDelegates{ require(accounts.length == quantities.length, "Must provide equal accounts and quantities" ); for(uint i; i < accounts.length; ++i){ accessList[ accounts[i] ] = quantities[i]; } } function setActive(bool isPresaleActive_, bool isMintActive_) external onlyDelegates{ require( isPresaleActive != isPresaleActive_ || isMintActive != isMintActive_, "New value matches old" ); isPresaleActive = isPresaleActive_; isMintActive = isMintActive_; } function setBaseURI(string calldata newPrefix, string calldata newSuffix) external onlyDelegates{ _tokenURIPrefix = newPrefix; _tokenURISuffix = newSuffix; } function setMax(uint maxOrder, uint maxSupply) external onlyDelegates{ require( MAX_ORDER != maxOrder || MAX_SUPPLY != maxSupply, "New value matches old" ); require(maxSupply >= totalSupply(), "Specified supply is lower than current balance" ); MAX_ORDER = maxOrder; MAX_SUPPLY = maxSupply; } function setPrice(uint presalePrice, uint mainsalePrice ) external onlyDelegates{ require( PRESALE_PRICE != presalePrice || MAINSALE_PRICE != mainsalePrice, "New value matches old" ); PRESALE_PRICE = presalePrice; MAINSALE_PRICE = mainsalePrice; } //owner function addPayee(address account, uint256 shares_) external onlyOwner { _addPayee(account, shares_); } function setPayee( uint index, address account, uint newShares ) external onlyOwner { _setPayee(index, account, newShares); } //internal function _burn(uint tokenId) internal override { address curOwner = ERC721B.ownerOf(tokenId); // Clear approvals _approve(owner(), tokenId); _owners[tokenId] = address(0); emit Transfer(curOwner, address(0), tokenId); } function _mint(address to, uint tokenId) internal override { _owners.push(to); emit Transfer(address(0), to, tokenId); } }
addPayee
function addPayee(address account, uint256 shares_) external onlyOwner { _addPayee(account, shares_); }
//owner
LineComment
v0.8.7+commit.e28d00a7
MIT
ipfs://efc6e995f9113dd9e7553b8bfdbd720d3ba65ba918ce8660b957b3e9434d2079
{ "func_code_index": [ 5555, 5669 ] }
2,772
_goatgauds
contracts/goadgauds.sol
0x5cebe5cde01ab154fb46b7984d6354da367bcbaf
Solidity
_goatgauds
contract _goatgauds is Delegated, ERC721EnumerableLite, PaymentSplitterMod { using Strings for uint; uint public MAX_ORDER = 2; uint public MAX_SUPPLY = 2222; uint public MAINSALE_PRICE = 0.125 ether; uint public PRESALE_PRICE = 0.1 ether; bool public isMintActive = false; bool public isPresaleActive = false; mapping(address=>uint) public accessList; string private _tokenURIPrefix = ''; string private _tokenURISuffix = ''; address[] private addressList = [ 0xF5c774b504C1D82fb59e3B826555D67033A13b01, 0x7Cf39e8D6F6f9F25E925Dad7EB371276231780d7, 0xC02Dd50b25364e747410730A1df9B72A92C3C68B, 0x286777D6ad08EbE395C377078a17a32c21564a8a, 0x00eCb19318d98ff57173Ac8EdFb7a5D90ba2005d, 0x2E169A7c3D8EBeC11D5b43Dade06Ac29FEf59cb3, 0x693B22BB92727Fb2a9a4D7e1b1D65B3E8168B774 ]; uint[] private shareList = [ 5, 5, 5, 5, 30, 25, 25 ]; constructor() Delegated() ERC721B("Goat Gauds", "GG", 0) PaymentSplitterMod( addressList, shareList ){ } //public view fallback() external payable {} function tokenURI(uint tokenId) external view override returns (string memory) { require(_exists(tokenId), "Query for nonexistent token"); return string(abi.encodePacked(_tokenURIPrefix, tokenId.toString(), _tokenURISuffix)); } //public payable function presale( uint quantity ) external payable { require( isPresaleActive, "Presale is not active" ); require( quantity <= MAX_ORDER, "Order too big" ); require( msg.value >= PRESALE_PRICE * quantity, "Ether sent is not correct" ); require( accessList[msg.sender] > 0, "Not authorized" ); uint supply = totalSupply(); require( supply + quantity <= MAX_SUPPLY, "Mint/order exceeds supply" ); accessList[msg.sender] -= quantity; for(uint i; i < quantity; ++i){ _mint( msg.sender, supply++ ); } } function mint( uint quantity ) external payable { require( isMintActive, "Sale is not active" ); require( quantity <= MAX_ORDER, "Order too big" ); require( msg.value >= MAINSALE_PRICE * quantity, "Ether sent is not correct" ); uint supply = totalSupply(); require( supply + quantity <= MAX_SUPPLY, "Mint/order exceeds supply" ); for(uint i; i < quantity; ++i){ _mint( msg.sender, supply++ ); } } //delegated payable function burnFrom( address owner, uint[] calldata tokenIds ) external payable onlyDelegates{ for(uint i; i < tokenIds.length; ++i ){ require( _exists( tokenIds[i] ), "Burn for nonexistent token" ); require( _owners[ tokenIds[i] ] == owner, "Owner mismatch" ); _burn( tokenIds[i] ); } } function mintTo(uint[] calldata quantity, address[] calldata recipient) external payable onlyDelegates{ require(quantity.length == recipient.length, "Must provide equal quantities and recipients" ); uint totalQuantity; uint supply = totalSupply(); for(uint i; i < quantity.length; ++i){ totalQuantity += quantity[i]; } require( supply + totalQuantity <= MAX_SUPPLY, "Mint/order exceeds supply" ); for(uint i; i < recipient.length; ++i){ for(uint j; j < quantity[i]; ++j){ _mint( recipient[i], supply++ ); } } } //delegated nonpayable function resurrect( uint[] calldata tokenIds, address[] calldata recipients ) external onlyDelegates{ require(tokenIds.length == recipients.length, "Must provide equal tokenIds and recipients" ); address to; uint tokenId; address zero = address(0); for(uint i; i < tokenIds.length; ++i ){ to = recipients[i]; require(recipients[i] != address(0), "resurrect to the zero address" ); tokenId = tokenIds[i]; require( !_exists( tokenId ), "can't resurrect existing token" ); _owners[tokenId] = to; // Clear approvals _approve(zero, tokenId); emit Transfer(zero, to, tokenId); } } function setAccessList(address[] calldata accounts, uint[] calldata quantities) external onlyDelegates{ require(accounts.length == quantities.length, "Must provide equal accounts and quantities" ); for(uint i; i < accounts.length; ++i){ accessList[ accounts[i] ] = quantities[i]; } } function setActive(bool isPresaleActive_, bool isMintActive_) external onlyDelegates{ require( isPresaleActive != isPresaleActive_ || isMintActive != isMintActive_, "New value matches old" ); isPresaleActive = isPresaleActive_; isMintActive = isMintActive_; } function setBaseURI(string calldata newPrefix, string calldata newSuffix) external onlyDelegates{ _tokenURIPrefix = newPrefix; _tokenURISuffix = newSuffix; } function setMax(uint maxOrder, uint maxSupply) external onlyDelegates{ require( MAX_ORDER != maxOrder || MAX_SUPPLY != maxSupply, "New value matches old" ); require(maxSupply >= totalSupply(), "Specified supply is lower than current balance" ); MAX_ORDER = maxOrder; MAX_SUPPLY = maxSupply; } function setPrice(uint presalePrice, uint mainsalePrice ) external onlyDelegates{ require( PRESALE_PRICE != presalePrice || MAINSALE_PRICE != mainsalePrice, "New value matches old" ); PRESALE_PRICE = presalePrice; MAINSALE_PRICE = mainsalePrice; } //owner function addPayee(address account, uint256 shares_) external onlyOwner { _addPayee(account, shares_); } function setPayee( uint index, address account, uint newShares ) external onlyOwner { _setPayee(index, account, newShares); } //internal function _burn(uint tokenId) internal override { address curOwner = ERC721B.ownerOf(tokenId); // Clear approvals _approve(owner(), tokenId); _owners[tokenId] = address(0); emit Transfer(curOwner, address(0), tokenId); } function _mint(address to, uint tokenId) internal override { _owners.push(to); emit Transfer(address(0), to, tokenId); } }
_burn
function _burn(uint tokenId) internal override { address curOwner = ERC721B.ownerOf(tokenId); // Clear approvals _approve(owner(), tokenId); _owners[tokenId] = address(0); emit Transfer(curOwner, address(0), tokenId); }
//internal
LineComment
v0.8.7+commit.e28d00a7
MIT
ipfs://efc6e995f9113dd9e7553b8bfdbd720d3ba65ba918ce8660b957b3e9434d2079
{ "func_code_index": [ 5827, 6079 ] }
2,773
Crowdsale
Crowdsale.sol
0x3c047c238fd1dc6cb23317f5e533f35c57059ee6
Solidity
Crowdsale
contract Crowdsale { using SafeMath for uint256; // uint256 durationInMinutes; // address where funds are collected address public wallet; // token address address public addressOfTokenUsedAsReward; uint256 public price = 1818; token tokenReward; // mapping (address => uint) public contributions; // start and end timestamps where investments are allowed (both inclusive) // uint256 public startTime; // uint256 public endTime; // amount of raised money in wei uint256 public weiRaised; /** * event for token purchase logging * @param purchaser who paid for the tokens * @param beneficiary who got the tokens * @param value weis paid for purchase * @param amount amount of tokens purchased */ event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); function Crowdsale() { //You will change this to your wallet where you need the ETH wallet = 0x5d467Dfc5e3FcA3ea4bd6C312275ca930d2f3E19; // durationInMinutes = _durationInMinutes; //Here will come the checksum address we got addressOfTokenUsedAsReward = 0xB6eC8C3a347f66a3d7C4F39D6DD68A422E69E81d ; tokenReward = token(addressOfTokenUsedAsReward); } bool public started = true; function startSale(){ if (msg.sender != wallet) throw; started = true; } function stopSale(){ if(msg.sender != wallet) throw; started = false; } function setPrice(uint256 _price){ if(msg.sender != wallet) throw; price = _price; } function changeWallet(address _wallet){ if(msg.sender != wallet) throw; wallet = _wallet; } function changeTokenReward(address _token){ if(msg.sender!=wallet) throw; tokenReward = token(_token); addressOfTokenUsedAsReward = _token; } // fallback function can be used to buy tokens function () payable { buyTokens(msg.sender,""); } // low level token purchase function function buyTokens(address beneficiary, bytes32 promoCode) payable { require(beneficiary != 0x0); require(validPurchase()); uint256 weiAmount = msg.value; // if(weiAmount < 10**16) throw; // if(weiAmount > 50*10**18) throw; // calculate token amount to be sent uint256 tokens = (weiAmount) * price;//weiamount * price if (promoCode == "ILOVEICOBUFFER") tokens = weiAmount * 2015; // uint256 tokens = (weiAmount/10**(18-decimals)) * price;//weiamount * price // update state weiRaised = weiRaised.add(weiAmount); // if(contributions[msg.sender].add(weiAmount)>10*10**18) throw; // contributions[msg.sender] = contributions[msg.sender].add(weiAmount); tokenReward.transfer(beneficiary, tokens); TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); forwardFunds(); } // send ether to the fund collection wallet // override to create custom fund forwarding mechanisms function forwardFunds() internal { // wallet.transfer(msg.value); if (!wallet.send(msg.value)) { throw; } } // @return true if the transaction can buy tokens function validPurchase() internal constant returns (bool) { bool withinPeriod = started; bool nonZeroPurchase = msg.value != 0; return withinPeriod && nonZeroPurchase; } function withdrawTokens(uint256 _amount) { if(msg.sender!=wallet) throw; tokenReward.transfer(wallet,_amount); } }
function () payable { buyTokens(msg.sender,""); }
// fallback function can be used to buy tokens
LineComment
v0.4.23+commit.124ca40d
bzzr://0a86b02a41be51d27c341dd592d389da93eabf168d279edbf725d4aa32af6de1
{ "func_code_index": [ 1929, 1989 ] }
2,774
Crowdsale
Crowdsale.sol
0x3c047c238fd1dc6cb23317f5e533f35c57059ee6
Solidity
Crowdsale
contract Crowdsale { using SafeMath for uint256; // uint256 durationInMinutes; // address where funds are collected address public wallet; // token address address public addressOfTokenUsedAsReward; uint256 public price = 1818; token tokenReward; // mapping (address => uint) public contributions; // start and end timestamps where investments are allowed (both inclusive) // uint256 public startTime; // uint256 public endTime; // amount of raised money in wei uint256 public weiRaised; /** * event for token purchase logging * @param purchaser who paid for the tokens * @param beneficiary who got the tokens * @param value weis paid for purchase * @param amount amount of tokens purchased */ event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); function Crowdsale() { //You will change this to your wallet where you need the ETH wallet = 0x5d467Dfc5e3FcA3ea4bd6C312275ca930d2f3E19; // durationInMinutes = _durationInMinutes; //Here will come the checksum address we got addressOfTokenUsedAsReward = 0xB6eC8C3a347f66a3d7C4F39D6DD68A422E69E81d ; tokenReward = token(addressOfTokenUsedAsReward); } bool public started = true; function startSale(){ if (msg.sender != wallet) throw; started = true; } function stopSale(){ if(msg.sender != wallet) throw; started = false; } function setPrice(uint256 _price){ if(msg.sender != wallet) throw; price = _price; } function changeWallet(address _wallet){ if(msg.sender != wallet) throw; wallet = _wallet; } function changeTokenReward(address _token){ if(msg.sender!=wallet) throw; tokenReward = token(_token); addressOfTokenUsedAsReward = _token; } // fallback function can be used to buy tokens function () payable { buyTokens(msg.sender,""); } // low level token purchase function function buyTokens(address beneficiary, bytes32 promoCode) payable { require(beneficiary != 0x0); require(validPurchase()); uint256 weiAmount = msg.value; // if(weiAmount < 10**16) throw; // if(weiAmount > 50*10**18) throw; // calculate token amount to be sent uint256 tokens = (weiAmount) * price;//weiamount * price if (promoCode == "ILOVEICOBUFFER") tokens = weiAmount * 2015; // uint256 tokens = (weiAmount/10**(18-decimals)) * price;//weiamount * price // update state weiRaised = weiRaised.add(weiAmount); // if(contributions[msg.sender].add(weiAmount)>10*10**18) throw; // contributions[msg.sender] = contributions[msg.sender].add(weiAmount); tokenReward.transfer(beneficiary, tokens); TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); forwardFunds(); } // send ether to the fund collection wallet // override to create custom fund forwarding mechanisms function forwardFunds() internal { // wallet.transfer(msg.value); if (!wallet.send(msg.value)) { throw; } } // @return true if the transaction can buy tokens function validPurchase() internal constant returns (bool) { bool withinPeriod = started; bool nonZeroPurchase = msg.value != 0; return withinPeriod && nonZeroPurchase; } function withdrawTokens(uint256 _amount) { if(msg.sender!=wallet) throw; tokenReward.transfer(wallet,_amount); } }
buyTokens
function buyTokens(address beneficiary, bytes32 promoCode) payable { require(beneficiary != 0x0); require(validPurchase()); uint256 weiAmount = msg.value; // if(weiAmount < 10**16) throw; // if(weiAmount > 50*10**18) throw; // calculate token amount to be sent uint256 tokens = (weiAmount) * price;//weiamount * price if (promoCode == "ILOVEICOBUFFER") tokens = weiAmount * 2015; // uint256 tokens = (weiAmount/10**(18-decimals)) * price;//weiamount * price // update state weiRaised = weiRaised.add(weiAmount); // if(contributions[msg.sender].add(weiAmount)>10*10**18) throw; // contributions[msg.sender] = contributions[msg.sender].add(weiAmount); tokenReward.transfer(beneficiary, tokens); TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); forwardFunds(); }
// low level token purchase function
LineComment
v0.4.23+commit.124ca40d
bzzr://0a86b02a41be51d27c341dd592d389da93eabf168d279edbf725d4aa32af6de1
{ "func_code_index": [ 2032, 2920 ] }
2,775
Crowdsale
Crowdsale.sol
0x3c047c238fd1dc6cb23317f5e533f35c57059ee6
Solidity
Crowdsale
contract Crowdsale { using SafeMath for uint256; // uint256 durationInMinutes; // address where funds are collected address public wallet; // token address address public addressOfTokenUsedAsReward; uint256 public price = 1818; token tokenReward; // mapping (address => uint) public contributions; // start and end timestamps where investments are allowed (both inclusive) // uint256 public startTime; // uint256 public endTime; // amount of raised money in wei uint256 public weiRaised; /** * event for token purchase logging * @param purchaser who paid for the tokens * @param beneficiary who got the tokens * @param value weis paid for purchase * @param amount amount of tokens purchased */ event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); function Crowdsale() { //You will change this to your wallet where you need the ETH wallet = 0x5d467Dfc5e3FcA3ea4bd6C312275ca930d2f3E19; // durationInMinutes = _durationInMinutes; //Here will come the checksum address we got addressOfTokenUsedAsReward = 0xB6eC8C3a347f66a3d7C4F39D6DD68A422E69E81d ; tokenReward = token(addressOfTokenUsedAsReward); } bool public started = true; function startSale(){ if (msg.sender != wallet) throw; started = true; } function stopSale(){ if(msg.sender != wallet) throw; started = false; } function setPrice(uint256 _price){ if(msg.sender != wallet) throw; price = _price; } function changeWallet(address _wallet){ if(msg.sender != wallet) throw; wallet = _wallet; } function changeTokenReward(address _token){ if(msg.sender!=wallet) throw; tokenReward = token(_token); addressOfTokenUsedAsReward = _token; } // fallback function can be used to buy tokens function () payable { buyTokens(msg.sender,""); } // low level token purchase function function buyTokens(address beneficiary, bytes32 promoCode) payable { require(beneficiary != 0x0); require(validPurchase()); uint256 weiAmount = msg.value; // if(weiAmount < 10**16) throw; // if(weiAmount > 50*10**18) throw; // calculate token amount to be sent uint256 tokens = (weiAmount) * price;//weiamount * price if (promoCode == "ILOVEICOBUFFER") tokens = weiAmount * 2015; // uint256 tokens = (weiAmount/10**(18-decimals)) * price;//weiamount * price // update state weiRaised = weiRaised.add(weiAmount); // if(contributions[msg.sender].add(weiAmount)>10*10**18) throw; // contributions[msg.sender] = contributions[msg.sender].add(weiAmount); tokenReward.transfer(beneficiary, tokens); TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); forwardFunds(); } // send ether to the fund collection wallet // override to create custom fund forwarding mechanisms function forwardFunds() internal { // wallet.transfer(msg.value); if (!wallet.send(msg.value)) { throw; } } // @return true if the transaction can buy tokens function validPurchase() internal constant returns (bool) { bool withinPeriod = started; bool nonZeroPurchase = msg.value != 0; return withinPeriod && nonZeroPurchase; } function withdrawTokens(uint256 _amount) { if(msg.sender!=wallet) throw; tokenReward.transfer(wallet,_amount); } }
forwardFunds
function forwardFunds() internal { // wallet.transfer(msg.value); if (!wallet.send(msg.value)) { throw; } }
// send ether to the fund collection wallet // override to create custom fund forwarding mechanisms
LineComment
v0.4.23+commit.124ca40d
bzzr://0a86b02a41be51d27c341dd592d389da93eabf168d279edbf725d4aa32af6de1
{ "func_code_index": [ 3029, 3164 ] }
2,776
Crowdsale
Crowdsale.sol
0x3c047c238fd1dc6cb23317f5e533f35c57059ee6
Solidity
Crowdsale
contract Crowdsale { using SafeMath for uint256; // uint256 durationInMinutes; // address where funds are collected address public wallet; // token address address public addressOfTokenUsedAsReward; uint256 public price = 1818; token tokenReward; // mapping (address => uint) public contributions; // start and end timestamps where investments are allowed (both inclusive) // uint256 public startTime; // uint256 public endTime; // amount of raised money in wei uint256 public weiRaised; /** * event for token purchase logging * @param purchaser who paid for the tokens * @param beneficiary who got the tokens * @param value weis paid for purchase * @param amount amount of tokens purchased */ event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); function Crowdsale() { //You will change this to your wallet where you need the ETH wallet = 0x5d467Dfc5e3FcA3ea4bd6C312275ca930d2f3E19; // durationInMinutes = _durationInMinutes; //Here will come the checksum address we got addressOfTokenUsedAsReward = 0xB6eC8C3a347f66a3d7C4F39D6DD68A422E69E81d ; tokenReward = token(addressOfTokenUsedAsReward); } bool public started = true; function startSale(){ if (msg.sender != wallet) throw; started = true; } function stopSale(){ if(msg.sender != wallet) throw; started = false; } function setPrice(uint256 _price){ if(msg.sender != wallet) throw; price = _price; } function changeWallet(address _wallet){ if(msg.sender != wallet) throw; wallet = _wallet; } function changeTokenReward(address _token){ if(msg.sender!=wallet) throw; tokenReward = token(_token); addressOfTokenUsedAsReward = _token; } // fallback function can be used to buy tokens function () payable { buyTokens(msg.sender,""); } // low level token purchase function function buyTokens(address beneficiary, bytes32 promoCode) payable { require(beneficiary != 0x0); require(validPurchase()); uint256 weiAmount = msg.value; // if(weiAmount < 10**16) throw; // if(weiAmount > 50*10**18) throw; // calculate token amount to be sent uint256 tokens = (weiAmount) * price;//weiamount * price if (promoCode == "ILOVEICOBUFFER") tokens = weiAmount * 2015; // uint256 tokens = (weiAmount/10**(18-decimals)) * price;//weiamount * price // update state weiRaised = weiRaised.add(weiAmount); // if(contributions[msg.sender].add(weiAmount)>10*10**18) throw; // contributions[msg.sender] = contributions[msg.sender].add(weiAmount); tokenReward.transfer(beneficiary, tokens); TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); forwardFunds(); } // send ether to the fund collection wallet // override to create custom fund forwarding mechanisms function forwardFunds() internal { // wallet.transfer(msg.value); if (!wallet.send(msg.value)) { throw; } } // @return true if the transaction can buy tokens function validPurchase() internal constant returns (bool) { bool withinPeriod = started; bool nonZeroPurchase = msg.value != 0; return withinPeriod && nonZeroPurchase; } function withdrawTokens(uint256 _amount) { if(msg.sender!=wallet) throw; tokenReward.transfer(wallet,_amount); } }
validPurchase
function validPurchase() internal constant returns (bool) { bool withinPeriod = started; bool nonZeroPurchase = msg.value != 0; return withinPeriod && nonZeroPurchase; }
// @return true if the transaction can buy tokens
LineComment
v0.4.23+commit.124ca40d
bzzr://0a86b02a41be51d27c341dd592d389da93eabf168d279edbf725d4aa32af6de1
{ "func_code_index": [ 3220, 3410 ] }
2,777
Account
Account.sol
0x2ed747ed395cfd40ff750fdfa351b229d67c8c01
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, reverts on 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-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); // Solidity only automatically asserts when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } /** * @dev Adds two numbers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } /** * @dev Returns ceil(a / b). */ function ceil(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; if(a % b == 0) { return c; } else { return c + 1; } } }
/** * @title SafeMath * @dev Math operations with safety checks that throw on error */
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-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; }
/** * @dev Multiplies two numbers, reverts on overflow. */
NatSpecMultiLine
v0.5.4+commit.9549d8ff
GNU GPLv3
bzzr://325ab23acf652cf963ee273c31a40feb195010aef23c1acf8f2f424fa1bd1a26
{ "func_code_index": [ 96, 534 ] }
2,778
Account
Account.sol
0x2ed747ed395cfd40ff750fdfa351b229d67c8c01
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, reverts on 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-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); // Solidity only automatically asserts when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } /** * @dev Adds two numbers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } /** * @dev Returns ceil(a / b). */ function ceil(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; if(a % b == 0) { return c; } else { return c + 1; } } }
/** * @title SafeMath * @dev Math operations with safety checks that throw on error */
NatSpecMultiLine
div
function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); // Solidity only automatically asserts when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; }
/** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */
NatSpecMultiLine
v0.5.4+commit.9549d8ff
GNU GPLv3
bzzr://325ab23acf652cf963ee273c31a40feb195010aef23c1acf8f2f424fa1bd1a26
{ "func_code_index": [ 652, 951 ] }
2,779
Account
Account.sol
0x2ed747ed395cfd40ff750fdfa351b229d67c8c01
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, reverts on 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-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); // Solidity only automatically asserts when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } /** * @dev Adds two numbers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } /** * @dev Returns ceil(a / b). */ function ceil(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; if(a % b == 0) { return c; } else { return c + 1; } } }
/** * @title SafeMath * @dev Math operations with safety checks that throw on error */
NatSpecMultiLine
sub
function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; }
/** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */
NatSpecMultiLine
v0.5.4+commit.9549d8ff
GNU GPLv3
bzzr://325ab23acf652cf963ee273c31a40feb195010aef23c1acf8f2f424fa1bd1a26
{ "func_code_index": [ 1072, 1227 ] }
2,780
Account
Account.sol
0x2ed747ed395cfd40ff750fdfa351b229d67c8c01
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, reverts on 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-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); // Solidity only automatically asserts when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } /** * @dev Adds two numbers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } /** * @dev Returns ceil(a / b). */ function ceil(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; if(a % b == 0) { return c; } else { return c + 1; } } }
/** * @title SafeMath * @dev Math operations with safety checks that throw on error */
NatSpecMultiLine
add
function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; }
/** * @dev Adds two numbers, reverts on overflow. */
NatSpecMultiLine
v0.5.4+commit.9549d8ff
GNU GPLv3
bzzr://325ab23acf652cf963ee273c31a40feb195010aef23c1acf8f2f424fa1bd1a26
{ "func_code_index": [ 1298, 1453 ] }
2,781
Account
Account.sol
0x2ed747ed395cfd40ff750fdfa351b229d67c8c01
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, reverts on 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-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); // Solidity only automatically asserts when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } /** * @dev Adds two numbers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } /** * @dev Returns ceil(a / b). */ function ceil(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; if(a % b == 0) { return c; } else { return c + 1; } } }
/** * @title SafeMath * @dev Math operations with safety checks that throw on error */
NatSpecMultiLine
mod
function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; }
/** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */
NatSpecMultiLine
v0.5.4+commit.9549d8ff
GNU GPLv3
bzzr://325ab23acf652cf963ee273c31a40feb195010aef23c1acf8f2f424fa1bd1a26
{ "func_code_index": [ 1596, 1725 ] }
2,782
Account
Account.sol
0x2ed747ed395cfd40ff750fdfa351b229d67c8c01
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, reverts on 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-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); // Solidity only automatically asserts when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } /** * @dev Adds two numbers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } /** * @dev Returns ceil(a / b). */ function ceil(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; if(a % b == 0) { return c; } else { return c + 1; } } }
/** * @title SafeMath * @dev Math operations with safety checks that throw on error */
NatSpecMultiLine
ceil
function ceil(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; if(a % b == 0) { return c; } else { return c + 1; } }
/** * @dev Returns ceil(a / b). */
NatSpecMultiLine
v0.5.4+commit.9549d8ff
GNU GPLv3
bzzr://325ab23acf652cf963ee273c31a40feb195010aef23c1acf8f2f424fa1bd1a26
{ "func_code_index": [ 1778, 2001 ] }
2,783
Account
Account.sol
0x2ed747ed395cfd40ff750fdfa351b229d67c8c01
Solidity
BaseLogic
contract BaseLogic { bytes constant internal SIGN_HASH_PREFIX = "\x19Ethereum Signed Message:\n32"; mapping (address => uint256) keyNonce; AccountStorage public accountStorage; modifier allowSelfCallsOnly() { require (msg.sender == address(this), "only internal call is allowed"); _; } modifier allowAccountCallsOnly(Account _account) { require(msg.sender == address(_account), "caller must be account"); _; } event LogicInitialised(address wallet); // *************** Constructor ********************** // constructor(AccountStorage _accountStorage) public { accountStorage = _accountStorage; } // *************** Initialization ********************* // function initAccount(Account _account) external allowAccountCallsOnly(_account){ emit LogicInitialised(address(_account)); } // *************** Getter ********************** // function getKeyNonce(address _key) external view returns(uint256) { return keyNonce[_key]; } // *************** Signature ********************** // function getSignHash(bytes memory _data, uint256 _nonce) internal view returns(bytes32) { // use EIP 191 // 0x1900 + this logic address + data + nonce of signing key bytes32 msgHash = keccak256(abi.encodePacked(byte(0x19), byte(0), address(this), _data, _nonce)); bytes32 prefixedHash = keccak256(abi.encodePacked(SIGN_HASH_PREFIX, msgHash)); return prefixedHash; } function verifySig(address _signingKey, bytes memory _signature, bytes32 _signHash) internal pure { require(_signingKey != address(0), "invalid signing key"); address recoveredAddr = recover(_signHash, _signature); require(recoveredAddr == _signingKey, "signature verification failed"); } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * NOTE: This call _does not revert_ if the signature is invalid, or * if the signer is otherwise unable to be retrieved. In those scenarios, * the zero address is returned. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise) * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { // Check the signature length if (signature.length != 65) { return (address(0)); } // Divide the signature in r, s and v variables bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. // solhint-disable-next-line no-inline-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return address(0); } if (v != 27 && v != 28) { return address(0); } // If the signature is valid (and not malleable), return the signer address return ecrecover(hash, v, r, s); } /* get signer address from data * @dev Gets an address encoded as the first argument in transaction data * @param b The byte array that should have an address as first argument * @returns a The address retrieved from the array */ function getSignerAddress(bytes memory _b) internal pure returns (address _a) { require(_b.length >= 36, "invalid bytes"); // solium-disable-next-line security/no-inline-assembly assembly { let mask := 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF _a := and(mask, mload(add(_b, 36))) // b = {length:32}{method sig:4}{address:32}{...} // 36 is the offset of the first parameter of the data, if encoded properly. // 32 bytes for the length of the bytes array, and the first 4 bytes for the function signature. // 32 bytes is the length of the bytes array!!!! } } // get method id, first 4 bytes of data function getMethodId(bytes memory _b) internal pure returns (bytes4 _a) { require(_b.length >= 4, "invalid data"); // solium-disable-next-line security/no-inline-assembly assembly { // 32 bytes is the length of the bytes array _a := mload(add(_b, 32)) } } function checkKeyStatus(address _account, uint256 _index) internal { // check operation key status if (_index > 0) { require(accountStorage.getKeyStatus(_account, _index) != 1, "frozen key"); } } // _nonce is timestamp in microsecond(1/1000000 second) function checkAndUpdateNonce(address _key, uint256 _nonce) internal { require(_nonce > keyNonce[_key], "nonce too small"); require(SafeMath.div(_nonce, 1000000) <= now + 86400, "nonce too big"); // 86400=24*3600 seconds keyNonce[_key] = _nonce; } }
initAccount
function initAccount(Account _account) external allowAccountCallsOnly(_account){ emit LogicInitialised(address(_account)); }
// *************** Initialization ********************* //
LineComment
v0.5.4+commit.9549d8ff
GNU GPLv3
bzzr://325ab23acf652cf963ee273c31a40feb195010aef23c1acf8f2f424fa1bd1a26
{ "func_code_index": [ 779, 922 ] }
2,784
Account
Account.sol
0x2ed747ed395cfd40ff750fdfa351b229d67c8c01
Solidity
BaseLogic
contract BaseLogic { bytes constant internal SIGN_HASH_PREFIX = "\x19Ethereum Signed Message:\n32"; mapping (address => uint256) keyNonce; AccountStorage public accountStorage; modifier allowSelfCallsOnly() { require (msg.sender == address(this), "only internal call is allowed"); _; } modifier allowAccountCallsOnly(Account _account) { require(msg.sender == address(_account), "caller must be account"); _; } event LogicInitialised(address wallet); // *************** Constructor ********************** // constructor(AccountStorage _accountStorage) public { accountStorage = _accountStorage; } // *************** Initialization ********************* // function initAccount(Account _account) external allowAccountCallsOnly(_account){ emit LogicInitialised(address(_account)); } // *************** Getter ********************** // function getKeyNonce(address _key) external view returns(uint256) { return keyNonce[_key]; } // *************** Signature ********************** // function getSignHash(bytes memory _data, uint256 _nonce) internal view returns(bytes32) { // use EIP 191 // 0x1900 + this logic address + data + nonce of signing key bytes32 msgHash = keccak256(abi.encodePacked(byte(0x19), byte(0), address(this), _data, _nonce)); bytes32 prefixedHash = keccak256(abi.encodePacked(SIGN_HASH_PREFIX, msgHash)); return prefixedHash; } function verifySig(address _signingKey, bytes memory _signature, bytes32 _signHash) internal pure { require(_signingKey != address(0), "invalid signing key"); address recoveredAddr = recover(_signHash, _signature); require(recoveredAddr == _signingKey, "signature verification failed"); } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * NOTE: This call _does not revert_ if the signature is invalid, or * if the signer is otherwise unable to be retrieved. In those scenarios, * the zero address is returned. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise) * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { // Check the signature length if (signature.length != 65) { return (address(0)); } // Divide the signature in r, s and v variables bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. // solhint-disable-next-line no-inline-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return address(0); } if (v != 27 && v != 28) { return address(0); } // If the signature is valid (and not malleable), return the signer address return ecrecover(hash, v, r, s); } /* get signer address from data * @dev Gets an address encoded as the first argument in transaction data * @param b The byte array that should have an address as first argument * @returns a The address retrieved from the array */ function getSignerAddress(bytes memory _b) internal pure returns (address _a) { require(_b.length >= 36, "invalid bytes"); // solium-disable-next-line security/no-inline-assembly assembly { let mask := 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF _a := and(mask, mload(add(_b, 36))) // b = {length:32}{method sig:4}{address:32}{...} // 36 is the offset of the first parameter of the data, if encoded properly. // 32 bytes for the length of the bytes array, and the first 4 bytes for the function signature. // 32 bytes is the length of the bytes array!!!! } } // get method id, first 4 bytes of data function getMethodId(bytes memory _b) internal pure returns (bytes4 _a) { require(_b.length >= 4, "invalid data"); // solium-disable-next-line security/no-inline-assembly assembly { // 32 bytes is the length of the bytes array _a := mload(add(_b, 32)) } } function checkKeyStatus(address _account, uint256 _index) internal { // check operation key status if (_index > 0) { require(accountStorage.getKeyStatus(_account, _index) != 1, "frozen key"); } } // _nonce is timestamp in microsecond(1/1000000 second) function checkAndUpdateNonce(address _key, uint256 _nonce) internal { require(_nonce > keyNonce[_key], "nonce too small"); require(SafeMath.div(_nonce, 1000000) <= now + 86400, "nonce too big"); // 86400=24*3600 seconds keyNonce[_key] = _nonce; } }
getKeyNonce
function getKeyNonce(address _key) external view returns(uint256) { return keyNonce[_key]; }
// *************** Getter ********************** //
LineComment
v0.5.4+commit.9549d8ff
GNU GPLv3
bzzr://325ab23acf652cf963ee273c31a40feb195010aef23c1acf8f2f424fa1bd1a26
{ "func_code_index": [ 984, 1095 ] }
2,785
Account
Account.sol
0x2ed747ed395cfd40ff750fdfa351b229d67c8c01
Solidity
BaseLogic
contract BaseLogic { bytes constant internal SIGN_HASH_PREFIX = "\x19Ethereum Signed Message:\n32"; mapping (address => uint256) keyNonce; AccountStorage public accountStorage; modifier allowSelfCallsOnly() { require (msg.sender == address(this), "only internal call is allowed"); _; } modifier allowAccountCallsOnly(Account _account) { require(msg.sender == address(_account), "caller must be account"); _; } event LogicInitialised(address wallet); // *************** Constructor ********************** // constructor(AccountStorage _accountStorage) public { accountStorage = _accountStorage; } // *************** Initialization ********************* // function initAccount(Account _account) external allowAccountCallsOnly(_account){ emit LogicInitialised(address(_account)); } // *************** Getter ********************** // function getKeyNonce(address _key) external view returns(uint256) { return keyNonce[_key]; } // *************** Signature ********************** // function getSignHash(bytes memory _data, uint256 _nonce) internal view returns(bytes32) { // use EIP 191 // 0x1900 + this logic address + data + nonce of signing key bytes32 msgHash = keccak256(abi.encodePacked(byte(0x19), byte(0), address(this), _data, _nonce)); bytes32 prefixedHash = keccak256(abi.encodePacked(SIGN_HASH_PREFIX, msgHash)); return prefixedHash; } function verifySig(address _signingKey, bytes memory _signature, bytes32 _signHash) internal pure { require(_signingKey != address(0), "invalid signing key"); address recoveredAddr = recover(_signHash, _signature); require(recoveredAddr == _signingKey, "signature verification failed"); } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * NOTE: This call _does not revert_ if the signature is invalid, or * if the signer is otherwise unable to be retrieved. In those scenarios, * the zero address is returned. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise) * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { // Check the signature length if (signature.length != 65) { return (address(0)); } // Divide the signature in r, s and v variables bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. // solhint-disable-next-line no-inline-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return address(0); } if (v != 27 && v != 28) { return address(0); } // If the signature is valid (and not malleable), return the signer address return ecrecover(hash, v, r, s); } /* get signer address from data * @dev Gets an address encoded as the first argument in transaction data * @param b The byte array that should have an address as first argument * @returns a The address retrieved from the array */ function getSignerAddress(bytes memory _b) internal pure returns (address _a) { require(_b.length >= 36, "invalid bytes"); // solium-disable-next-line security/no-inline-assembly assembly { let mask := 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF _a := and(mask, mload(add(_b, 36))) // b = {length:32}{method sig:4}{address:32}{...} // 36 is the offset of the first parameter of the data, if encoded properly. // 32 bytes for the length of the bytes array, and the first 4 bytes for the function signature. // 32 bytes is the length of the bytes array!!!! } } // get method id, first 4 bytes of data function getMethodId(bytes memory _b) internal pure returns (bytes4 _a) { require(_b.length >= 4, "invalid data"); // solium-disable-next-line security/no-inline-assembly assembly { // 32 bytes is the length of the bytes array _a := mload(add(_b, 32)) } } function checkKeyStatus(address _account, uint256 _index) internal { // check operation key status if (_index > 0) { require(accountStorage.getKeyStatus(_account, _index) != 1, "frozen key"); } } // _nonce is timestamp in microsecond(1/1000000 second) function checkAndUpdateNonce(address _key, uint256 _nonce) internal { require(_nonce > keyNonce[_key], "nonce too small"); require(SafeMath.div(_nonce, 1000000) <= now + 86400, "nonce too big"); // 86400=24*3600 seconds keyNonce[_key] = _nonce; } }
getSignHash
function getSignHash(bytes memory _data, uint256 _nonce) internal view returns(bytes32) { // use EIP 191 // 0x1900 + this logic address + data + nonce of signing key bytes32 msgHash = keccak256(abi.encodePacked(byte(0x19), byte(0), address(this), _data, _nonce)); bytes32 prefixedHash = keccak256(abi.encodePacked(SIGN_HASH_PREFIX, msgHash)); return prefixedHash; }
// *************** Signature ********************** //
LineComment
v0.5.4+commit.9549d8ff
GNU GPLv3
bzzr://325ab23acf652cf963ee273c31a40feb195010aef23c1acf8f2f424fa1bd1a26
{ "func_code_index": [ 1160, 1580 ] }
2,786
Account
Account.sol
0x2ed747ed395cfd40ff750fdfa351b229d67c8c01
Solidity
BaseLogic
contract BaseLogic { bytes constant internal SIGN_HASH_PREFIX = "\x19Ethereum Signed Message:\n32"; mapping (address => uint256) keyNonce; AccountStorage public accountStorage; modifier allowSelfCallsOnly() { require (msg.sender == address(this), "only internal call is allowed"); _; } modifier allowAccountCallsOnly(Account _account) { require(msg.sender == address(_account), "caller must be account"); _; } event LogicInitialised(address wallet); // *************** Constructor ********************** // constructor(AccountStorage _accountStorage) public { accountStorage = _accountStorage; } // *************** Initialization ********************* // function initAccount(Account _account) external allowAccountCallsOnly(_account){ emit LogicInitialised(address(_account)); } // *************** Getter ********************** // function getKeyNonce(address _key) external view returns(uint256) { return keyNonce[_key]; } // *************** Signature ********************** // function getSignHash(bytes memory _data, uint256 _nonce) internal view returns(bytes32) { // use EIP 191 // 0x1900 + this logic address + data + nonce of signing key bytes32 msgHash = keccak256(abi.encodePacked(byte(0x19), byte(0), address(this), _data, _nonce)); bytes32 prefixedHash = keccak256(abi.encodePacked(SIGN_HASH_PREFIX, msgHash)); return prefixedHash; } function verifySig(address _signingKey, bytes memory _signature, bytes32 _signHash) internal pure { require(_signingKey != address(0), "invalid signing key"); address recoveredAddr = recover(_signHash, _signature); require(recoveredAddr == _signingKey, "signature verification failed"); } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * NOTE: This call _does not revert_ if the signature is invalid, or * if the signer is otherwise unable to be retrieved. In those scenarios, * the zero address is returned. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise) * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { // Check the signature length if (signature.length != 65) { return (address(0)); } // Divide the signature in r, s and v variables bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. // solhint-disable-next-line no-inline-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return address(0); } if (v != 27 && v != 28) { return address(0); } // If the signature is valid (and not malleable), return the signer address return ecrecover(hash, v, r, s); } /* get signer address from data * @dev Gets an address encoded as the first argument in transaction data * @param b The byte array that should have an address as first argument * @returns a The address retrieved from the array */ function getSignerAddress(bytes memory _b) internal pure returns (address _a) { require(_b.length >= 36, "invalid bytes"); // solium-disable-next-line security/no-inline-assembly assembly { let mask := 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF _a := and(mask, mload(add(_b, 36))) // b = {length:32}{method sig:4}{address:32}{...} // 36 is the offset of the first parameter of the data, if encoded properly. // 32 bytes for the length of the bytes array, and the first 4 bytes for the function signature. // 32 bytes is the length of the bytes array!!!! } } // get method id, first 4 bytes of data function getMethodId(bytes memory _b) internal pure returns (bytes4 _a) { require(_b.length >= 4, "invalid data"); // solium-disable-next-line security/no-inline-assembly assembly { // 32 bytes is the length of the bytes array _a := mload(add(_b, 32)) } } function checkKeyStatus(address _account, uint256 _index) internal { // check operation key status if (_index > 0) { require(accountStorage.getKeyStatus(_account, _index) != 1, "frozen key"); } } // _nonce is timestamp in microsecond(1/1000000 second) function checkAndUpdateNonce(address _key, uint256 _nonce) internal { require(_nonce > keyNonce[_key], "nonce too small"); require(SafeMath.div(_nonce, 1000000) <= now + 86400, "nonce too big"); // 86400=24*3600 seconds keyNonce[_key] = _nonce; } }
recover
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { // Check the signature length if (signature.length != 65) { return (address(0)); } // Divide the signature in r, s and v variables bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. // solhint-disable-next-line no-inline-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return address(0); } if (v != 27 && v != 28) { return address(0); } // If the signature is valid (and not malleable), return the signer address return ecrecover(hash, v, r, s); }
/** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * NOTE: This call _does not revert_ if the signature is invalid, or * if the signer is otherwise unable to be retrieved. In those scenarios, * the zero address is returned. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise) * be too long), and then calling {toEthSignedMessageHash} on it. */
NatSpecMultiLine
v0.5.4+commit.9549d8ff
GNU GPLv3
bzzr://325ab23acf652cf963ee273c31a40feb195010aef23c1acf8f2f424fa1bd1a26
{ "func_code_index": [ 2905, 4837 ] }
2,787
Account
Account.sol
0x2ed747ed395cfd40ff750fdfa351b229d67c8c01
Solidity
BaseLogic
contract BaseLogic { bytes constant internal SIGN_HASH_PREFIX = "\x19Ethereum Signed Message:\n32"; mapping (address => uint256) keyNonce; AccountStorage public accountStorage; modifier allowSelfCallsOnly() { require (msg.sender == address(this), "only internal call is allowed"); _; } modifier allowAccountCallsOnly(Account _account) { require(msg.sender == address(_account), "caller must be account"); _; } event LogicInitialised(address wallet); // *************** Constructor ********************** // constructor(AccountStorage _accountStorage) public { accountStorage = _accountStorage; } // *************** Initialization ********************* // function initAccount(Account _account) external allowAccountCallsOnly(_account){ emit LogicInitialised(address(_account)); } // *************** Getter ********************** // function getKeyNonce(address _key) external view returns(uint256) { return keyNonce[_key]; } // *************** Signature ********************** // function getSignHash(bytes memory _data, uint256 _nonce) internal view returns(bytes32) { // use EIP 191 // 0x1900 + this logic address + data + nonce of signing key bytes32 msgHash = keccak256(abi.encodePacked(byte(0x19), byte(0), address(this), _data, _nonce)); bytes32 prefixedHash = keccak256(abi.encodePacked(SIGN_HASH_PREFIX, msgHash)); return prefixedHash; } function verifySig(address _signingKey, bytes memory _signature, bytes32 _signHash) internal pure { require(_signingKey != address(0), "invalid signing key"); address recoveredAddr = recover(_signHash, _signature); require(recoveredAddr == _signingKey, "signature verification failed"); } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * NOTE: This call _does not revert_ if the signature is invalid, or * if the signer is otherwise unable to be retrieved. In those scenarios, * the zero address is returned. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise) * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { // Check the signature length if (signature.length != 65) { return (address(0)); } // Divide the signature in r, s and v variables bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. // solhint-disable-next-line no-inline-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return address(0); } if (v != 27 && v != 28) { return address(0); } // If the signature is valid (and not malleable), return the signer address return ecrecover(hash, v, r, s); } /* get signer address from data * @dev Gets an address encoded as the first argument in transaction data * @param b The byte array that should have an address as first argument * @returns a The address retrieved from the array */ function getSignerAddress(bytes memory _b) internal pure returns (address _a) { require(_b.length >= 36, "invalid bytes"); // solium-disable-next-line security/no-inline-assembly assembly { let mask := 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF _a := and(mask, mload(add(_b, 36))) // b = {length:32}{method sig:4}{address:32}{...} // 36 is the offset of the first parameter of the data, if encoded properly. // 32 bytes for the length of the bytes array, and the first 4 bytes for the function signature. // 32 bytes is the length of the bytes array!!!! } } // get method id, first 4 bytes of data function getMethodId(bytes memory _b) internal pure returns (bytes4 _a) { require(_b.length >= 4, "invalid data"); // solium-disable-next-line security/no-inline-assembly assembly { // 32 bytes is the length of the bytes array _a := mload(add(_b, 32)) } } function checkKeyStatus(address _account, uint256 _index) internal { // check operation key status if (_index > 0) { require(accountStorage.getKeyStatus(_account, _index) != 1, "frozen key"); } } // _nonce is timestamp in microsecond(1/1000000 second) function checkAndUpdateNonce(address _key, uint256 _nonce) internal { require(_nonce > keyNonce[_key], "nonce too small"); require(SafeMath.div(_nonce, 1000000) <= now + 86400, "nonce too big"); // 86400=24*3600 seconds keyNonce[_key] = _nonce; } }
getSignerAddress
function getSignerAddress(bytes memory _b) internal pure returns (address _a) { require(_b.length >= 36, "invalid bytes"); // solium-disable-next-line security/no-inline-assembly assembly { let mask := 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF _a := and(mask, mload(add(_b, 36))) // b = {length:32}{method sig:4}{address:32}{...} // 36 is the offset of the first parameter of the data, if encoded properly. // 32 bytes for the length of the bytes array, and the first 4 bytes for the function signature. // 32 bytes is the length of the bytes array!!!! } }
/* get signer address from data * @dev Gets an address encoded as the first argument in transaction data * @param b The byte array that should have an address as first argument * @returns a The address retrieved from the array */
Comment
v0.5.4+commit.9549d8ff
GNU GPLv3
bzzr://325ab23acf652cf963ee273c31a40feb195010aef23c1acf8f2f424fa1bd1a26
{ "func_code_index": [ 5095, 5776 ] }
2,788
Account
Account.sol
0x2ed747ed395cfd40ff750fdfa351b229d67c8c01
Solidity
BaseLogic
contract BaseLogic { bytes constant internal SIGN_HASH_PREFIX = "\x19Ethereum Signed Message:\n32"; mapping (address => uint256) keyNonce; AccountStorage public accountStorage; modifier allowSelfCallsOnly() { require (msg.sender == address(this), "only internal call is allowed"); _; } modifier allowAccountCallsOnly(Account _account) { require(msg.sender == address(_account), "caller must be account"); _; } event LogicInitialised(address wallet); // *************** Constructor ********************** // constructor(AccountStorage _accountStorage) public { accountStorage = _accountStorage; } // *************** Initialization ********************* // function initAccount(Account _account) external allowAccountCallsOnly(_account){ emit LogicInitialised(address(_account)); } // *************** Getter ********************** // function getKeyNonce(address _key) external view returns(uint256) { return keyNonce[_key]; } // *************** Signature ********************** // function getSignHash(bytes memory _data, uint256 _nonce) internal view returns(bytes32) { // use EIP 191 // 0x1900 + this logic address + data + nonce of signing key bytes32 msgHash = keccak256(abi.encodePacked(byte(0x19), byte(0), address(this), _data, _nonce)); bytes32 prefixedHash = keccak256(abi.encodePacked(SIGN_HASH_PREFIX, msgHash)); return prefixedHash; } function verifySig(address _signingKey, bytes memory _signature, bytes32 _signHash) internal pure { require(_signingKey != address(0), "invalid signing key"); address recoveredAddr = recover(_signHash, _signature); require(recoveredAddr == _signingKey, "signature verification failed"); } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * NOTE: This call _does not revert_ if the signature is invalid, or * if the signer is otherwise unable to be retrieved. In those scenarios, * the zero address is returned. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise) * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { // Check the signature length if (signature.length != 65) { return (address(0)); } // Divide the signature in r, s and v variables bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. // solhint-disable-next-line no-inline-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return address(0); } if (v != 27 && v != 28) { return address(0); } // If the signature is valid (and not malleable), return the signer address return ecrecover(hash, v, r, s); } /* get signer address from data * @dev Gets an address encoded as the first argument in transaction data * @param b The byte array that should have an address as first argument * @returns a The address retrieved from the array */ function getSignerAddress(bytes memory _b) internal pure returns (address _a) { require(_b.length >= 36, "invalid bytes"); // solium-disable-next-line security/no-inline-assembly assembly { let mask := 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF _a := and(mask, mload(add(_b, 36))) // b = {length:32}{method sig:4}{address:32}{...} // 36 is the offset of the first parameter of the data, if encoded properly. // 32 bytes for the length of the bytes array, and the first 4 bytes for the function signature. // 32 bytes is the length of the bytes array!!!! } } // get method id, first 4 bytes of data function getMethodId(bytes memory _b) internal pure returns (bytes4 _a) { require(_b.length >= 4, "invalid data"); // solium-disable-next-line security/no-inline-assembly assembly { // 32 bytes is the length of the bytes array _a := mload(add(_b, 32)) } } function checkKeyStatus(address _account, uint256 _index) internal { // check operation key status if (_index > 0) { require(accountStorage.getKeyStatus(_account, _index) != 1, "frozen key"); } } // _nonce is timestamp in microsecond(1/1000000 second) function checkAndUpdateNonce(address _key, uint256 _nonce) internal { require(_nonce > keyNonce[_key], "nonce too small"); require(SafeMath.div(_nonce, 1000000) <= now + 86400, "nonce too big"); // 86400=24*3600 seconds keyNonce[_key] = _nonce; } }
getMethodId
function getMethodId(bytes memory _b) internal pure returns (bytes4 _a) { require(_b.length >= 4, "invalid data"); // solium-disable-next-line security/no-inline-assembly assembly { // 32 bytes is the length of the bytes array _a := mload(add(_b, 32)) } }
// get method id, first 4 bytes of data
LineComment
v0.5.4+commit.9549d8ff
GNU GPLv3
bzzr://325ab23acf652cf963ee273c31a40feb195010aef23c1acf8f2f424fa1bd1a26
{ "func_code_index": [ 5824, 6151 ] }
2,789
Account
Account.sol
0x2ed747ed395cfd40ff750fdfa351b229d67c8c01
Solidity
BaseLogic
contract BaseLogic { bytes constant internal SIGN_HASH_PREFIX = "\x19Ethereum Signed Message:\n32"; mapping (address => uint256) keyNonce; AccountStorage public accountStorage; modifier allowSelfCallsOnly() { require (msg.sender == address(this), "only internal call is allowed"); _; } modifier allowAccountCallsOnly(Account _account) { require(msg.sender == address(_account), "caller must be account"); _; } event LogicInitialised(address wallet); // *************** Constructor ********************** // constructor(AccountStorage _accountStorage) public { accountStorage = _accountStorage; } // *************** Initialization ********************* // function initAccount(Account _account) external allowAccountCallsOnly(_account){ emit LogicInitialised(address(_account)); } // *************** Getter ********************** // function getKeyNonce(address _key) external view returns(uint256) { return keyNonce[_key]; } // *************** Signature ********************** // function getSignHash(bytes memory _data, uint256 _nonce) internal view returns(bytes32) { // use EIP 191 // 0x1900 + this logic address + data + nonce of signing key bytes32 msgHash = keccak256(abi.encodePacked(byte(0x19), byte(0), address(this), _data, _nonce)); bytes32 prefixedHash = keccak256(abi.encodePacked(SIGN_HASH_PREFIX, msgHash)); return prefixedHash; } function verifySig(address _signingKey, bytes memory _signature, bytes32 _signHash) internal pure { require(_signingKey != address(0), "invalid signing key"); address recoveredAddr = recover(_signHash, _signature); require(recoveredAddr == _signingKey, "signature verification failed"); } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * NOTE: This call _does not revert_ if the signature is invalid, or * if the signer is otherwise unable to be retrieved. In those scenarios, * the zero address is returned. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise) * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { // Check the signature length if (signature.length != 65) { return (address(0)); } // Divide the signature in r, s and v variables bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. // solhint-disable-next-line no-inline-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return address(0); } if (v != 27 && v != 28) { return address(0); } // If the signature is valid (and not malleable), return the signer address return ecrecover(hash, v, r, s); } /* get signer address from data * @dev Gets an address encoded as the first argument in transaction data * @param b The byte array that should have an address as first argument * @returns a The address retrieved from the array */ function getSignerAddress(bytes memory _b) internal pure returns (address _a) { require(_b.length >= 36, "invalid bytes"); // solium-disable-next-line security/no-inline-assembly assembly { let mask := 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF _a := and(mask, mload(add(_b, 36))) // b = {length:32}{method sig:4}{address:32}{...} // 36 is the offset of the first parameter of the data, if encoded properly. // 32 bytes for the length of the bytes array, and the first 4 bytes for the function signature. // 32 bytes is the length of the bytes array!!!! } } // get method id, first 4 bytes of data function getMethodId(bytes memory _b) internal pure returns (bytes4 _a) { require(_b.length >= 4, "invalid data"); // solium-disable-next-line security/no-inline-assembly assembly { // 32 bytes is the length of the bytes array _a := mload(add(_b, 32)) } } function checkKeyStatus(address _account, uint256 _index) internal { // check operation key status if (_index > 0) { require(accountStorage.getKeyStatus(_account, _index) != 1, "frozen key"); } } // _nonce is timestamp in microsecond(1/1000000 second) function checkAndUpdateNonce(address _key, uint256 _nonce) internal { require(_nonce > keyNonce[_key], "nonce too small"); require(SafeMath.div(_nonce, 1000000) <= now + 86400, "nonce too big"); // 86400=24*3600 seconds keyNonce[_key] = _nonce; } }
checkAndUpdateNonce
function checkAndUpdateNonce(address _key, uint256 _nonce) internal { require(_nonce > keyNonce[_key], "nonce too small"); require(SafeMath.div(_nonce, 1000000) <= now + 86400, "nonce too big"); // 86400=24*3600 seconds keyNonce[_key] = _nonce; }
// _nonce is timestamp in microsecond(1/1000000 second)
LineComment
v0.5.4+commit.9549d8ff
GNU GPLv3
bzzr://325ab23acf652cf963ee273c31a40feb195010aef23c1acf8f2f424fa1bd1a26
{ "func_code_index": [ 6463, 6748 ] }
2,790
Account
Account.sol
0x2ed747ed395cfd40ff750fdfa351b229d67c8c01
Solidity
Owned
contract Owned { // The owner address public owner; event OwnerChanged(address indexed _newOwner); /** * @dev Throws if the sender is not the owner. */ modifier onlyOwner { require(msg.sender == owner, "Must be owner"); _; } constructor() public { owner = msg.sender; } /** * @dev Lets the owner transfer ownership of the contract to a new owner. * @param _newOwner The new owner. */ function changeOwner(address _newOwner) external onlyOwner { require(_newOwner != address(0), "Address must not be null"); owner = _newOwner; emit OwnerChanged(_newOwner); } }
changeOwner
function changeOwner(address _newOwner) external onlyOwner { require(_newOwner != address(0), "Address must not be null"); owner = _newOwner; emit OwnerChanged(_newOwner); }
/** * @dev Lets the owner transfer ownership of the contract to a new owner. * @param _newOwner The new owner. */
NatSpecMultiLine
v0.5.4+commit.9549d8ff
GNU GPLv3
bzzr://325ab23acf652cf963ee273c31a40feb195010aef23c1acf8f2f424fa1bd1a26
{ "func_code_index": [ 497, 707 ] }
2,791
Account
Account.sol
0x2ed747ed395cfd40ff750fdfa351b229d67c8c01
Solidity
AccountStorage
contract AccountStorage { modifier allowAccountCallsOnly(Account _account) { require(msg.sender == address(_account), "caller must be account"); _; } modifier allowAuthorizedLogicContractsCallsOnly(address payable _account) { require(LogicManager(Account(_account).manager()).isAuthorized(msg.sender), "not an authorized logic"); _; } struct KeyItem { address pubKey; uint256 status; } struct BackupAccount { address backup; uint256 effectiveDate;//means not effective until this timestamp uint256 expiryDate;//means effective until this timestamp } struct DelayItem { bytes32 hash; uint256 dueTime; } struct Proposal { bytes32 hash; address[] approval; } // account => quantity of operation keys (index >= 1) mapping (address => uint256) operationKeyCount; // account => index => KeyItem mapping (address => mapping(uint256 => KeyItem)) keyData; // account => index => backup account mapping (address => mapping(uint256 => BackupAccount)) backupData; /* account => actionId => DelayItem delayData applies to these 4 actions: changeAdminKey, changeAllOperationKeys, unfreeze, changeAdminKeyByBackup */ mapping (address => mapping(bytes4 => DelayItem)) delayData; // client account => proposer account => proposed actionId => Proposal mapping (address => mapping(address => mapping(bytes4 => Proposal))) proposalData; // *************** keyCount ********************** // function getOperationKeyCount(address _account) external view returns(uint256) { return operationKeyCount[_account]; } function increaseKeyCount(address payable _account) external allowAuthorizedLogicContractsCallsOnly(_account) { operationKeyCount[_account] = operationKeyCount[_account] + 1; } // *************** keyData ********************** // function getKeyData(address _account, uint256 _index) public view returns(address) { KeyItem memory item = keyData[_account][_index]; return item.pubKey; } function setKeyData(address payable _account, uint256 _index, address _key) external allowAuthorizedLogicContractsCallsOnly(_account) { require(_key != address(0), "invalid _key value"); KeyItem storage item = keyData[_account][_index]; item.pubKey = _key; } // *************** keyStatus ********************** // function getKeyStatus(address _account, uint256 _index) external view returns(uint256) { KeyItem memory item = keyData[_account][_index]; return item.status; } function setKeyStatus(address payable _account, uint256 _index, uint256 _status) external allowAuthorizedLogicContractsCallsOnly(_account) { KeyItem storage item = keyData[_account][_index]; item.status = _status; } // *************** backupData ********************** // function getBackupAddress(address _account, uint256 _index) external view returns(address) { BackupAccount memory b = backupData[_account][_index]; return b.backup; } function getBackupEffectiveDate(address _account, uint256 _index) external view returns(uint256) { BackupAccount memory b = backupData[_account][_index]; return b.effectiveDate; } function getBackupExpiryDate(address _account, uint256 _index) external view returns(uint256) { BackupAccount memory b = backupData[_account][_index]; return b.expiryDate; } function setBackup(address payable _account, uint256 _index, address _backup, uint256 _effective, uint256 _expiry) external allowAuthorizedLogicContractsCallsOnly(_account) { BackupAccount storage b = backupData[_account][_index]; b.backup = _backup; b.effectiveDate = _effective; b.expiryDate = _expiry; } function setBackupExpiryDate(address payable _account, uint256 _index, uint256 _expiry) external allowAuthorizedLogicContractsCallsOnly(_account) { BackupAccount storage b = backupData[_account][_index]; b.expiryDate = _expiry; } function clearBackupData(address payable _account, uint256 _index) external allowAuthorizedLogicContractsCallsOnly(_account) { delete backupData[_account][_index]; } // *************** delayData ********************** // function getDelayDataHash(address payable _account, bytes4 _actionId) external view returns(bytes32) { DelayItem memory item = delayData[_account][_actionId]; return item.hash; } function getDelayDataDueTime(address payable _account, bytes4 _actionId) external view returns(uint256) { DelayItem memory item = delayData[_account][_actionId]; return item.dueTime; } function setDelayData(address payable _account, bytes4 _actionId, bytes32 _hash, uint256 _dueTime) external allowAuthorizedLogicContractsCallsOnly(_account) { DelayItem storage item = delayData[_account][_actionId]; item.hash = _hash; item.dueTime = _dueTime; } function clearDelayData(address payable _account, bytes4 _actionId) external allowAuthorizedLogicContractsCallsOnly(_account) { delete delayData[_account][_actionId]; } // *************** proposalData ********************** // function getProposalDataHash(address _client, address _proposer, bytes4 _actionId) external view returns(bytes32) { Proposal memory p = proposalData[_client][_proposer][_actionId]; return p.hash; } function getProposalDataApproval(address _client, address _proposer, bytes4 _actionId) external view returns(address[] memory) { Proposal memory p = proposalData[_client][_proposer][_actionId]; return p.approval; } function setProposalData(address payable _client, address _proposer, bytes4 _actionId, bytes32 _hash, address _approvedBackup) external allowAuthorizedLogicContractsCallsOnly(_client) { Proposal storage p = proposalData[_client][_proposer][_actionId]; if (p.hash > 0) { if (p.hash == _hash) { for (uint256 i = 0; i < p.approval.length; i++) { require(p.approval[i] != _approvedBackup, "backup already exists"); } p.approval.push(_approvedBackup); } else { p.hash = _hash; p.approval.length = 0; } } else { p.hash = _hash; p.approval.push(_approvedBackup); } } function clearProposalData(address payable _client, address _proposer, bytes4 _actionId) external allowAuthorizedLogicContractsCallsOnly(_client) { delete proposalData[_client][_proposer][_actionId]; } // *************** init ********************** // function initAccount(Account _account, address[] calldata _keys, address[] calldata _backups) external allowAccountCallsOnly(_account) { require(getKeyData(address(_account), 0) == address(0), "AccountStorage: account already initialized!"); require(_keys.length > 0, "empty keys array"); operationKeyCount[address(_account)] = _keys.length - 1; for (uint256 index = 0; index < _keys.length; index++) { address _key = _keys[index]; require(_key != address(0), "_key cannot be 0x0"); KeyItem storage item = keyData[address(_account)][index]; item.pubKey = _key; item.status = 0; } // avoid backup duplication if _backups.length > 1 // normally won't check duplication, in most cases only one initial backup when initialization if (_backups.length > 1) { address[] memory bkps = _backups; for (uint256 i = 0; i < _backups.length; i++) { for (uint256 j = 0; j < i; j++) { require(bkps[j] != _backups[i], "duplicate backup"); } } } for (uint256 index = 0; index < _backups.length; index++) { address _backup = _backups[index]; require(_backup != address(0), "backup cannot be 0x0"); require(_backup != address(_account), "cannot be backup of oneself"); backupData[address(_account)][index] = BackupAccount(_backup, now, uint256(-1)); } } }
getOperationKeyCount
function getOperationKeyCount(address _account) external view returns(uint256) { return operationKeyCount[_account]; }
// *************** keyCount ********************** //
LineComment
v0.5.4+commit.9549d8ff
GNU GPLv3
bzzr://325ab23acf652cf963ee273c31a40feb195010aef23c1acf8f2f424fa1bd1a26
{ "func_code_index": [ 1653, 1790 ] }
2,792
Account
Account.sol
0x2ed747ed395cfd40ff750fdfa351b229d67c8c01
Solidity
AccountStorage
contract AccountStorage { modifier allowAccountCallsOnly(Account _account) { require(msg.sender == address(_account), "caller must be account"); _; } modifier allowAuthorizedLogicContractsCallsOnly(address payable _account) { require(LogicManager(Account(_account).manager()).isAuthorized(msg.sender), "not an authorized logic"); _; } struct KeyItem { address pubKey; uint256 status; } struct BackupAccount { address backup; uint256 effectiveDate;//means not effective until this timestamp uint256 expiryDate;//means effective until this timestamp } struct DelayItem { bytes32 hash; uint256 dueTime; } struct Proposal { bytes32 hash; address[] approval; } // account => quantity of operation keys (index >= 1) mapping (address => uint256) operationKeyCount; // account => index => KeyItem mapping (address => mapping(uint256 => KeyItem)) keyData; // account => index => backup account mapping (address => mapping(uint256 => BackupAccount)) backupData; /* account => actionId => DelayItem delayData applies to these 4 actions: changeAdminKey, changeAllOperationKeys, unfreeze, changeAdminKeyByBackup */ mapping (address => mapping(bytes4 => DelayItem)) delayData; // client account => proposer account => proposed actionId => Proposal mapping (address => mapping(address => mapping(bytes4 => Proposal))) proposalData; // *************** keyCount ********************** // function getOperationKeyCount(address _account) external view returns(uint256) { return operationKeyCount[_account]; } function increaseKeyCount(address payable _account) external allowAuthorizedLogicContractsCallsOnly(_account) { operationKeyCount[_account] = operationKeyCount[_account] + 1; } // *************** keyData ********************** // function getKeyData(address _account, uint256 _index) public view returns(address) { KeyItem memory item = keyData[_account][_index]; return item.pubKey; } function setKeyData(address payable _account, uint256 _index, address _key) external allowAuthorizedLogicContractsCallsOnly(_account) { require(_key != address(0), "invalid _key value"); KeyItem storage item = keyData[_account][_index]; item.pubKey = _key; } // *************** keyStatus ********************** // function getKeyStatus(address _account, uint256 _index) external view returns(uint256) { KeyItem memory item = keyData[_account][_index]; return item.status; } function setKeyStatus(address payable _account, uint256 _index, uint256 _status) external allowAuthorizedLogicContractsCallsOnly(_account) { KeyItem storage item = keyData[_account][_index]; item.status = _status; } // *************** backupData ********************** // function getBackupAddress(address _account, uint256 _index) external view returns(address) { BackupAccount memory b = backupData[_account][_index]; return b.backup; } function getBackupEffectiveDate(address _account, uint256 _index) external view returns(uint256) { BackupAccount memory b = backupData[_account][_index]; return b.effectiveDate; } function getBackupExpiryDate(address _account, uint256 _index) external view returns(uint256) { BackupAccount memory b = backupData[_account][_index]; return b.expiryDate; } function setBackup(address payable _account, uint256 _index, address _backup, uint256 _effective, uint256 _expiry) external allowAuthorizedLogicContractsCallsOnly(_account) { BackupAccount storage b = backupData[_account][_index]; b.backup = _backup; b.effectiveDate = _effective; b.expiryDate = _expiry; } function setBackupExpiryDate(address payable _account, uint256 _index, uint256 _expiry) external allowAuthorizedLogicContractsCallsOnly(_account) { BackupAccount storage b = backupData[_account][_index]; b.expiryDate = _expiry; } function clearBackupData(address payable _account, uint256 _index) external allowAuthorizedLogicContractsCallsOnly(_account) { delete backupData[_account][_index]; } // *************** delayData ********************** // function getDelayDataHash(address payable _account, bytes4 _actionId) external view returns(bytes32) { DelayItem memory item = delayData[_account][_actionId]; return item.hash; } function getDelayDataDueTime(address payable _account, bytes4 _actionId) external view returns(uint256) { DelayItem memory item = delayData[_account][_actionId]; return item.dueTime; } function setDelayData(address payable _account, bytes4 _actionId, bytes32 _hash, uint256 _dueTime) external allowAuthorizedLogicContractsCallsOnly(_account) { DelayItem storage item = delayData[_account][_actionId]; item.hash = _hash; item.dueTime = _dueTime; } function clearDelayData(address payable _account, bytes4 _actionId) external allowAuthorizedLogicContractsCallsOnly(_account) { delete delayData[_account][_actionId]; } // *************** proposalData ********************** // function getProposalDataHash(address _client, address _proposer, bytes4 _actionId) external view returns(bytes32) { Proposal memory p = proposalData[_client][_proposer][_actionId]; return p.hash; } function getProposalDataApproval(address _client, address _proposer, bytes4 _actionId) external view returns(address[] memory) { Proposal memory p = proposalData[_client][_proposer][_actionId]; return p.approval; } function setProposalData(address payable _client, address _proposer, bytes4 _actionId, bytes32 _hash, address _approvedBackup) external allowAuthorizedLogicContractsCallsOnly(_client) { Proposal storage p = proposalData[_client][_proposer][_actionId]; if (p.hash > 0) { if (p.hash == _hash) { for (uint256 i = 0; i < p.approval.length; i++) { require(p.approval[i] != _approvedBackup, "backup already exists"); } p.approval.push(_approvedBackup); } else { p.hash = _hash; p.approval.length = 0; } } else { p.hash = _hash; p.approval.push(_approvedBackup); } } function clearProposalData(address payable _client, address _proposer, bytes4 _actionId) external allowAuthorizedLogicContractsCallsOnly(_client) { delete proposalData[_client][_proposer][_actionId]; } // *************** init ********************** // function initAccount(Account _account, address[] calldata _keys, address[] calldata _backups) external allowAccountCallsOnly(_account) { require(getKeyData(address(_account), 0) == address(0), "AccountStorage: account already initialized!"); require(_keys.length > 0, "empty keys array"); operationKeyCount[address(_account)] = _keys.length - 1; for (uint256 index = 0; index < _keys.length; index++) { address _key = _keys[index]; require(_key != address(0), "_key cannot be 0x0"); KeyItem storage item = keyData[address(_account)][index]; item.pubKey = _key; item.status = 0; } // avoid backup duplication if _backups.length > 1 // normally won't check duplication, in most cases only one initial backup when initialization if (_backups.length > 1) { address[] memory bkps = _backups; for (uint256 i = 0; i < _backups.length; i++) { for (uint256 j = 0; j < i; j++) { require(bkps[j] != _backups[i], "duplicate backup"); } } } for (uint256 index = 0; index < _backups.length; index++) { address _backup = _backups[index]; require(_backup != address(0), "backup cannot be 0x0"); require(_backup != address(_account), "cannot be backup of oneself"); backupData[address(_account)][index] = BackupAccount(_backup, now, uint256(-1)); } } }
getKeyData
function getKeyData(address _account, uint256 _index) public view returns(address) { KeyItem memory item = keyData[_account][_index]; return item.pubKey; }
// *************** keyData ********************** //
LineComment
v0.5.4+commit.9549d8ff
GNU GPLv3
bzzr://325ab23acf652cf963ee273c31a40feb195010aef23c1acf8f2f424fa1bd1a26
{ "func_code_index": [ 2051, 2234 ] }
2,793
Account
Account.sol
0x2ed747ed395cfd40ff750fdfa351b229d67c8c01
Solidity
AccountStorage
contract AccountStorage { modifier allowAccountCallsOnly(Account _account) { require(msg.sender == address(_account), "caller must be account"); _; } modifier allowAuthorizedLogicContractsCallsOnly(address payable _account) { require(LogicManager(Account(_account).manager()).isAuthorized(msg.sender), "not an authorized logic"); _; } struct KeyItem { address pubKey; uint256 status; } struct BackupAccount { address backup; uint256 effectiveDate;//means not effective until this timestamp uint256 expiryDate;//means effective until this timestamp } struct DelayItem { bytes32 hash; uint256 dueTime; } struct Proposal { bytes32 hash; address[] approval; } // account => quantity of operation keys (index >= 1) mapping (address => uint256) operationKeyCount; // account => index => KeyItem mapping (address => mapping(uint256 => KeyItem)) keyData; // account => index => backup account mapping (address => mapping(uint256 => BackupAccount)) backupData; /* account => actionId => DelayItem delayData applies to these 4 actions: changeAdminKey, changeAllOperationKeys, unfreeze, changeAdminKeyByBackup */ mapping (address => mapping(bytes4 => DelayItem)) delayData; // client account => proposer account => proposed actionId => Proposal mapping (address => mapping(address => mapping(bytes4 => Proposal))) proposalData; // *************** keyCount ********************** // function getOperationKeyCount(address _account) external view returns(uint256) { return operationKeyCount[_account]; } function increaseKeyCount(address payable _account) external allowAuthorizedLogicContractsCallsOnly(_account) { operationKeyCount[_account] = operationKeyCount[_account] + 1; } // *************** keyData ********************** // function getKeyData(address _account, uint256 _index) public view returns(address) { KeyItem memory item = keyData[_account][_index]; return item.pubKey; } function setKeyData(address payable _account, uint256 _index, address _key) external allowAuthorizedLogicContractsCallsOnly(_account) { require(_key != address(0), "invalid _key value"); KeyItem storage item = keyData[_account][_index]; item.pubKey = _key; } // *************** keyStatus ********************** // function getKeyStatus(address _account, uint256 _index) external view returns(uint256) { KeyItem memory item = keyData[_account][_index]; return item.status; } function setKeyStatus(address payable _account, uint256 _index, uint256 _status) external allowAuthorizedLogicContractsCallsOnly(_account) { KeyItem storage item = keyData[_account][_index]; item.status = _status; } // *************** backupData ********************** // function getBackupAddress(address _account, uint256 _index) external view returns(address) { BackupAccount memory b = backupData[_account][_index]; return b.backup; } function getBackupEffectiveDate(address _account, uint256 _index) external view returns(uint256) { BackupAccount memory b = backupData[_account][_index]; return b.effectiveDate; } function getBackupExpiryDate(address _account, uint256 _index) external view returns(uint256) { BackupAccount memory b = backupData[_account][_index]; return b.expiryDate; } function setBackup(address payable _account, uint256 _index, address _backup, uint256 _effective, uint256 _expiry) external allowAuthorizedLogicContractsCallsOnly(_account) { BackupAccount storage b = backupData[_account][_index]; b.backup = _backup; b.effectiveDate = _effective; b.expiryDate = _expiry; } function setBackupExpiryDate(address payable _account, uint256 _index, uint256 _expiry) external allowAuthorizedLogicContractsCallsOnly(_account) { BackupAccount storage b = backupData[_account][_index]; b.expiryDate = _expiry; } function clearBackupData(address payable _account, uint256 _index) external allowAuthorizedLogicContractsCallsOnly(_account) { delete backupData[_account][_index]; } // *************** delayData ********************** // function getDelayDataHash(address payable _account, bytes4 _actionId) external view returns(bytes32) { DelayItem memory item = delayData[_account][_actionId]; return item.hash; } function getDelayDataDueTime(address payable _account, bytes4 _actionId) external view returns(uint256) { DelayItem memory item = delayData[_account][_actionId]; return item.dueTime; } function setDelayData(address payable _account, bytes4 _actionId, bytes32 _hash, uint256 _dueTime) external allowAuthorizedLogicContractsCallsOnly(_account) { DelayItem storage item = delayData[_account][_actionId]; item.hash = _hash; item.dueTime = _dueTime; } function clearDelayData(address payable _account, bytes4 _actionId) external allowAuthorizedLogicContractsCallsOnly(_account) { delete delayData[_account][_actionId]; } // *************** proposalData ********************** // function getProposalDataHash(address _client, address _proposer, bytes4 _actionId) external view returns(bytes32) { Proposal memory p = proposalData[_client][_proposer][_actionId]; return p.hash; } function getProposalDataApproval(address _client, address _proposer, bytes4 _actionId) external view returns(address[] memory) { Proposal memory p = proposalData[_client][_proposer][_actionId]; return p.approval; } function setProposalData(address payable _client, address _proposer, bytes4 _actionId, bytes32 _hash, address _approvedBackup) external allowAuthorizedLogicContractsCallsOnly(_client) { Proposal storage p = proposalData[_client][_proposer][_actionId]; if (p.hash > 0) { if (p.hash == _hash) { for (uint256 i = 0; i < p.approval.length; i++) { require(p.approval[i] != _approvedBackup, "backup already exists"); } p.approval.push(_approvedBackup); } else { p.hash = _hash; p.approval.length = 0; } } else { p.hash = _hash; p.approval.push(_approvedBackup); } } function clearProposalData(address payable _client, address _proposer, bytes4 _actionId) external allowAuthorizedLogicContractsCallsOnly(_client) { delete proposalData[_client][_proposer][_actionId]; } // *************** init ********************** // function initAccount(Account _account, address[] calldata _keys, address[] calldata _backups) external allowAccountCallsOnly(_account) { require(getKeyData(address(_account), 0) == address(0), "AccountStorage: account already initialized!"); require(_keys.length > 0, "empty keys array"); operationKeyCount[address(_account)] = _keys.length - 1; for (uint256 index = 0; index < _keys.length; index++) { address _key = _keys[index]; require(_key != address(0), "_key cannot be 0x0"); KeyItem storage item = keyData[address(_account)][index]; item.pubKey = _key; item.status = 0; } // avoid backup duplication if _backups.length > 1 // normally won't check duplication, in most cases only one initial backup when initialization if (_backups.length > 1) { address[] memory bkps = _backups; for (uint256 i = 0; i < _backups.length; i++) { for (uint256 j = 0; j < i; j++) { require(bkps[j] != _backups[i], "duplicate backup"); } } } for (uint256 index = 0; index < _backups.length; index++) { address _backup = _backups[index]; require(_backup != address(0), "backup cannot be 0x0"); require(_backup != address(_account), "cannot be backup of oneself"); backupData[address(_account)][index] = BackupAccount(_backup, now, uint256(-1)); } } }
getKeyStatus
function getKeyStatus(address _account, uint256 _index) external view returns(uint256) { KeyItem memory item = keyData[_account][_index]; return item.status; }
// *************** keyStatus ********************** //
LineComment
v0.5.4+commit.9549d8ff
GNU GPLv3
bzzr://325ab23acf652cf963ee273c31a40feb195010aef23c1acf8f2f424fa1bd1a26
{ "func_code_index": [ 2597, 2784 ] }
2,794
Account
Account.sol
0x2ed747ed395cfd40ff750fdfa351b229d67c8c01
Solidity
AccountStorage
contract AccountStorage { modifier allowAccountCallsOnly(Account _account) { require(msg.sender == address(_account), "caller must be account"); _; } modifier allowAuthorizedLogicContractsCallsOnly(address payable _account) { require(LogicManager(Account(_account).manager()).isAuthorized(msg.sender), "not an authorized logic"); _; } struct KeyItem { address pubKey; uint256 status; } struct BackupAccount { address backup; uint256 effectiveDate;//means not effective until this timestamp uint256 expiryDate;//means effective until this timestamp } struct DelayItem { bytes32 hash; uint256 dueTime; } struct Proposal { bytes32 hash; address[] approval; } // account => quantity of operation keys (index >= 1) mapping (address => uint256) operationKeyCount; // account => index => KeyItem mapping (address => mapping(uint256 => KeyItem)) keyData; // account => index => backup account mapping (address => mapping(uint256 => BackupAccount)) backupData; /* account => actionId => DelayItem delayData applies to these 4 actions: changeAdminKey, changeAllOperationKeys, unfreeze, changeAdminKeyByBackup */ mapping (address => mapping(bytes4 => DelayItem)) delayData; // client account => proposer account => proposed actionId => Proposal mapping (address => mapping(address => mapping(bytes4 => Proposal))) proposalData; // *************** keyCount ********************** // function getOperationKeyCount(address _account) external view returns(uint256) { return operationKeyCount[_account]; } function increaseKeyCount(address payable _account) external allowAuthorizedLogicContractsCallsOnly(_account) { operationKeyCount[_account] = operationKeyCount[_account] + 1; } // *************** keyData ********************** // function getKeyData(address _account, uint256 _index) public view returns(address) { KeyItem memory item = keyData[_account][_index]; return item.pubKey; } function setKeyData(address payable _account, uint256 _index, address _key) external allowAuthorizedLogicContractsCallsOnly(_account) { require(_key != address(0), "invalid _key value"); KeyItem storage item = keyData[_account][_index]; item.pubKey = _key; } // *************** keyStatus ********************** // function getKeyStatus(address _account, uint256 _index) external view returns(uint256) { KeyItem memory item = keyData[_account][_index]; return item.status; } function setKeyStatus(address payable _account, uint256 _index, uint256 _status) external allowAuthorizedLogicContractsCallsOnly(_account) { KeyItem storage item = keyData[_account][_index]; item.status = _status; } // *************** backupData ********************** // function getBackupAddress(address _account, uint256 _index) external view returns(address) { BackupAccount memory b = backupData[_account][_index]; return b.backup; } function getBackupEffectiveDate(address _account, uint256 _index) external view returns(uint256) { BackupAccount memory b = backupData[_account][_index]; return b.effectiveDate; } function getBackupExpiryDate(address _account, uint256 _index) external view returns(uint256) { BackupAccount memory b = backupData[_account][_index]; return b.expiryDate; } function setBackup(address payable _account, uint256 _index, address _backup, uint256 _effective, uint256 _expiry) external allowAuthorizedLogicContractsCallsOnly(_account) { BackupAccount storage b = backupData[_account][_index]; b.backup = _backup; b.effectiveDate = _effective; b.expiryDate = _expiry; } function setBackupExpiryDate(address payable _account, uint256 _index, uint256 _expiry) external allowAuthorizedLogicContractsCallsOnly(_account) { BackupAccount storage b = backupData[_account][_index]; b.expiryDate = _expiry; } function clearBackupData(address payable _account, uint256 _index) external allowAuthorizedLogicContractsCallsOnly(_account) { delete backupData[_account][_index]; } // *************** delayData ********************** // function getDelayDataHash(address payable _account, bytes4 _actionId) external view returns(bytes32) { DelayItem memory item = delayData[_account][_actionId]; return item.hash; } function getDelayDataDueTime(address payable _account, bytes4 _actionId) external view returns(uint256) { DelayItem memory item = delayData[_account][_actionId]; return item.dueTime; } function setDelayData(address payable _account, bytes4 _actionId, bytes32 _hash, uint256 _dueTime) external allowAuthorizedLogicContractsCallsOnly(_account) { DelayItem storage item = delayData[_account][_actionId]; item.hash = _hash; item.dueTime = _dueTime; } function clearDelayData(address payable _account, bytes4 _actionId) external allowAuthorizedLogicContractsCallsOnly(_account) { delete delayData[_account][_actionId]; } // *************** proposalData ********************** // function getProposalDataHash(address _client, address _proposer, bytes4 _actionId) external view returns(bytes32) { Proposal memory p = proposalData[_client][_proposer][_actionId]; return p.hash; } function getProposalDataApproval(address _client, address _proposer, bytes4 _actionId) external view returns(address[] memory) { Proposal memory p = proposalData[_client][_proposer][_actionId]; return p.approval; } function setProposalData(address payable _client, address _proposer, bytes4 _actionId, bytes32 _hash, address _approvedBackup) external allowAuthorizedLogicContractsCallsOnly(_client) { Proposal storage p = proposalData[_client][_proposer][_actionId]; if (p.hash > 0) { if (p.hash == _hash) { for (uint256 i = 0; i < p.approval.length; i++) { require(p.approval[i] != _approvedBackup, "backup already exists"); } p.approval.push(_approvedBackup); } else { p.hash = _hash; p.approval.length = 0; } } else { p.hash = _hash; p.approval.push(_approvedBackup); } } function clearProposalData(address payable _client, address _proposer, bytes4 _actionId) external allowAuthorizedLogicContractsCallsOnly(_client) { delete proposalData[_client][_proposer][_actionId]; } // *************** init ********************** // function initAccount(Account _account, address[] calldata _keys, address[] calldata _backups) external allowAccountCallsOnly(_account) { require(getKeyData(address(_account), 0) == address(0), "AccountStorage: account already initialized!"); require(_keys.length > 0, "empty keys array"); operationKeyCount[address(_account)] = _keys.length - 1; for (uint256 index = 0; index < _keys.length; index++) { address _key = _keys[index]; require(_key != address(0), "_key cannot be 0x0"); KeyItem storage item = keyData[address(_account)][index]; item.pubKey = _key; item.status = 0; } // avoid backup duplication if _backups.length > 1 // normally won't check duplication, in most cases only one initial backup when initialization if (_backups.length > 1) { address[] memory bkps = _backups; for (uint256 i = 0; i < _backups.length; i++) { for (uint256 j = 0; j < i; j++) { require(bkps[j] != _backups[i], "duplicate backup"); } } } for (uint256 index = 0; index < _backups.length; index++) { address _backup = _backups[index]; require(_backup != address(0), "backup cannot be 0x0"); require(_backup != address(_account), "cannot be backup of oneself"); backupData[address(_account)][index] = BackupAccount(_backup, now, uint256(-1)); } } }
getBackupAddress
function getBackupAddress(address _account, uint256 _index) external view returns(address) { BackupAccount memory b = backupData[_account][_index]; return b.backup; }
// *************** backupData ********************** //
LineComment
v0.5.4+commit.9549d8ff
GNU GPLv3
bzzr://325ab23acf652cf963ee273c31a40feb195010aef23c1acf8f2f424fa1bd1a26
{ "func_code_index": [ 3096, 3290 ] }
2,795
Account
Account.sol
0x2ed747ed395cfd40ff750fdfa351b229d67c8c01
Solidity
AccountStorage
contract AccountStorage { modifier allowAccountCallsOnly(Account _account) { require(msg.sender == address(_account), "caller must be account"); _; } modifier allowAuthorizedLogicContractsCallsOnly(address payable _account) { require(LogicManager(Account(_account).manager()).isAuthorized(msg.sender), "not an authorized logic"); _; } struct KeyItem { address pubKey; uint256 status; } struct BackupAccount { address backup; uint256 effectiveDate;//means not effective until this timestamp uint256 expiryDate;//means effective until this timestamp } struct DelayItem { bytes32 hash; uint256 dueTime; } struct Proposal { bytes32 hash; address[] approval; } // account => quantity of operation keys (index >= 1) mapping (address => uint256) operationKeyCount; // account => index => KeyItem mapping (address => mapping(uint256 => KeyItem)) keyData; // account => index => backup account mapping (address => mapping(uint256 => BackupAccount)) backupData; /* account => actionId => DelayItem delayData applies to these 4 actions: changeAdminKey, changeAllOperationKeys, unfreeze, changeAdminKeyByBackup */ mapping (address => mapping(bytes4 => DelayItem)) delayData; // client account => proposer account => proposed actionId => Proposal mapping (address => mapping(address => mapping(bytes4 => Proposal))) proposalData; // *************** keyCount ********************** // function getOperationKeyCount(address _account) external view returns(uint256) { return operationKeyCount[_account]; } function increaseKeyCount(address payable _account) external allowAuthorizedLogicContractsCallsOnly(_account) { operationKeyCount[_account] = operationKeyCount[_account] + 1; } // *************** keyData ********************** // function getKeyData(address _account, uint256 _index) public view returns(address) { KeyItem memory item = keyData[_account][_index]; return item.pubKey; } function setKeyData(address payable _account, uint256 _index, address _key) external allowAuthorizedLogicContractsCallsOnly(_account) { require(_key != address(0), "invalid _key value"); KeyItem storage item = keyData[_account][_index]; item.pubKey = _key; } // *************** keyStatus ********************** // function getKeyStatus(address _account, uint256 _index) external view returns(uint256) { KeyItem memory item = keyData[_account][_index]; return item.status; } function setKeyStatus(address payable _account, uint256 _index, uint256 _status) external allowAuthorizedLogicContractsCallsOnly(_account) { KeyItem storage item = keyData[_account][_index]; item.status = _status; } // *************** backupData ********************** // function getBackupAddress(address _account, uint256 _index) external view returns(address) { BackupAccount memory b = backupData[_account][_index]; return b.backup; } function getBackupEffectiveDate(address _account, uint256 _index) external view returns(uint256) { BackupAccount memory b = backupData[_account][_index]; return b.effectiveDate; } function getBackupExpiryDate(address _account, uint256 _index) external view returns(uint256) { BackupAccount memory b = backupData[_account][_index]; return b.expiryDate; } function setBackup(address payable _account, uint256 _index, address _backup, uint256 _effective, uint256 _expiry) external allowAuthorizedLogicContractsCallsOnly(_account) { BackupAccount storage b = backupData[_account][_index]; b.backup = _backup; b.effectiveDate = _effective; b.expiryDate = _expiry; } function setBackupExpiryDate(address payable _account, uint256 _index, uint256 _expiry) external allowAuthorizedLogicContractsCallsOnly(_account) { BackupAccount storage b = backupData[_account][_index]; b.expiryDate = _expiry; } function clearBackupData(address payable _account, uint256 _index) external allowAuthorizedLogicContractsCallsOnly(_account) { delete backupData[_account][_index]; } // *************** delayData ********************** // function getDelayDataHash(address payable _account, bytes4 _actionId) external view returns(bytes32) { DelayItem memory item = delayData[_account][_actionId]; return item.hash; } function getDelayDataDueTime(address payable _account, bytes4 _actionId) external view returns(uint256) { DelayItem memory item = delayData[_account][_actionId]; return item.dueTime; } function setDelayData(address payable _account, bytes4 _actionId, bytes32 _hash, uint256 _dueTime) external allowAuthorizedLogicContractsCallsOnly(_account) { DelayItem storage item = delayData[_account][_actionId]; item.hash = _hash; item.dueTime = _dueTime; } function clearDelayData(address payable _account, bytes4 _actionId) external allowAuthorizedLogicContractsCallsOnly(_account) { delete delayData[_account][_actionId]; } // *************** proposalData ********************** // function getProposalDataHash(address _client, address _proposer, bytes4 _actionId) external view returns(bytes32) { Proposal memory p = proposalData[_client][_proposer][_actionId]; return p.hash; } function getProposalDataApproval(address _client, address _proposer, bytes4 _actionId) external view returns(address[] memory) { Proposal memory p = proposalData[_client][_proposer][_actionId]; return p.approval; } function setProposalData(address payable _client, address _proposer, bytes4 _actionId, bytes32 _hash, address _approvedBackup) external allowAuthorizedLogicContractsCallsOnly(_client) { Proposal storage p = proposalData[_client][_proposer][_actionId]; if (p.hash > 0) { if (p.hash == _hash) { for (uint256 i = 0; i < p.approval.length; i++) { require(p.approval[i] != _approvedBackup, "backup already exists"); } p.approval.push(_approvedBackup); } else { p.hash = _hash; p.approval.length = 0; } } else { p.hash = _hash; p.approval.push(_approvedBackup); } } function clearProposalData(address payable _client, address _proposer, bytes4 _actionId) external allowAuthorizedLogicContractsCallsOnly(_client) { delete proposalData[_client][_proposer][_actionId]; } // *************** init ********************** // function initAccount(Account _account, address[] calldata _keys, address[] calldata _backups) external allowAccountCallsOnly(_account) { require(getKeyData(address(_account), 0) == address(0), "AccountStorage: account already initialized!"); require(_keys.length > 0, "empty keys array"); operationKeyCount[address(_account)] = _keys.length - 1; for (uint256 index = 0; index < _keys.length; index++) { address _key = _keys[index]; require(_key != address(0), "_key cannot be 0x0"); KeyItem storage item = keyData[address(_account)][index]; item.pubKey = _key; item.status = 0; } // avoid backup duplication if _backups.length > 1 // normally won't check duplication, in most cases only one initial backup when initialization if (_backups.length > 1) { address[] memory bkps = _backups; for (uint256 i = 0; i < _backups.length; i++) { for (uint256 j = 0; j < i; j++) { require(bkps[j] != _backups[i], "duplicate backup"); } } } for (uint256 index = 0; index < _backups.length; index++) { address _backup = _backups[index]; require(_backup != address(0), "backup cannot be 0x0"); require(_backup != address(_account), "cannot be backup of oneself"); backupData[address(_account)][index] = BackupAccount(_backup, now, uint256(-1)); } } }
getDelayDataHash
function getDelayDataHash(address payable _account, bytes4 _actionId) external view returns(bytes32) { DelayItem memory item = delayData[_account][_actionId]; return item.hash; }
// *************** delayData ********************** //
LineComment
v0.5.4+commit.9549d8ff
GNU GPLv3
bzzr://325ab23acf652cf963ee273c31a40feb195010aef23c1acf8f2f424fa1bd1a26
{ "func_code_index": [ 4617, 4823 ] }
2,796
Account
Account.sol
0x2ed747ed395cfd40ff750fdfa351b229d67c8c01
Solidity
AccountStorage
contract AccountStorage { modifier allowAccountCallsOnly(Account _account) { require(msg.sender == address(_account), "caller must be account"); _; } modifier allowAuthorizedLogicContractsCallsOnly(address payable _account) { require(LogicManager(Account(_account).manager()).isAuthorized(msg.sender), "not an authorized logic"); _; } struct KeyItem { address pubKey; uint256 status; } struct BackupAccount { address backup; uint256 effectiveDate;//means not effective until this timestamp uint256 expiryDate;//means effective until this timestamp } struct DelayItem { bytes32 hash; uint256 dueTime; } struct Proposal { bytes32 hash; address[] approval; } // account => quantity of operation keys (index >= 1) mapping (address => uint256) operationKeyCount; // account => index => KeyItem mapping (address => mapping(uint256 => KeyItem)) keyData; // account => index => backup account mapping (address => mapping(uint256 => BackupAccount)) backupData; /* account => actionId => DelayItem delayData applies to these 4 actions: changeAdminKey, changeAllOperationKeys, unfreeze, changeAdminKeyByBackup */ mapping (address => mapping(bytes4 => DelayItem)) delayData; // client account => proposer account => proposed actionId => Proposal mapping (address => mapping(address => mapping(bytes4 => Proposal))) proposalData; // *************** keyCount ********************** // function getOperationKeyCount(address _account) external view returns(uint256) { return operationKeyCount[_account]; } function increaseKeyCount(address payable _account) external allowAuthorizedLogicContractsCallsOnly(_account) { operationKeyCount[_account] = operationKeyCount[_account] + 1; } // *************** keyData ********************** // function getKeyData(address _account, uint256 _index) public view returns(address) { KeyItem memory item = keyData[_account][_index]; return item.pubKey; } function setKeyData(address payable _account, uint256 _index, address _key) external allowAuthorizedLogicContractsCallsOnly(_account) { require(_key != address(0), "invalid _key value"); KeyItem storage item = keyData[_account][_index]; item.pubKey = _key; } // *************** keyStatus ********************** // function getKeyStatus(address _account, uint256 _index) external view returns(uint256) { KeyItem memory item = keyData[_account][_index]; return item.status; } function setKeyStatus(address payable _account, uint256 _index, uint256 _status) external allowAuthorizedLogicContractsCallsOnly(_account) { KeyItem storage item = keyData[_account][_index]; item.status = _status; } // *************** backupData ********************** // function getBackupAddress(address _account, uint256 _index) external view returns(address) { BackupAccount memory b = backupData[_account][_index]; return b.backup; } function getBackupEffectiveDate(address _account, uint256 _index) external view returns(uint256) { BackupAccount memory b = backupData[_account][_index]; return b.effectiveDate; } function getBackupExpiryDate(address _account, uint256 _index) external view returns(uint256) { BackupAccount memory b = backupData[_account][_index]; return b.expiryDate; } function setBackup(address payable _account, uint256 _index, address _backup, uint256 _effective, uint256 _expiry) external allowAuthorizedLogicContractsCallsOnly(_account) { BackupAccount storage b = backupData[_account][_index]; b.backup = _backup; b.effectiveDate = _effective; b.expiryDate = _expiry; } function setBackupExpiryDate(address payable _account, uint256 _index, uint256 _expiry) external allowAuthorizedLogicContractsCallsOnly(_account) { BackupAccount storage b = backupData[_account][_index]; b.expiryDate = _expiry; } function clearBackupData(address payable _account, uint256 _index) external allowAuthorizedLogicContractsCallsOnly(_account) { delete backupData[_account][_index]; } // *************** delayData ********************** // function getDelayDataHash(address payable _account, bytes4 _actionId) external view returns(bytes32) { DelayItem memory item = delayData[_account][_actionId]; return item.hash; } function getDelayDataDueTime(address payable _account, bytes4 _actionId) external view returns(uint256) { DelayItem memory item = delayData[_account][_actionId]; return item.dueTime; } function setDelayData(address payable _account, bytes4 _actionId, bytes32 _hash, uint256 _dueTime) external allowAuthorizedLogicContractsCallsOnly(_account) { DelayItem storage item = delayData[_account][_actionId]; item.hash = _hash; item.dueTime = _dueTime; } function clearDelayData(address payable _account, bytes4 _actionId) external allowAuthorizedLogicContractsCallsOnly(_account) { delete delayData[_account][_actionId]; } // *************** proposalData ********************** // function getProposalDataHash(address _client, address _proposer, bytes4 _actionId) external view returns(bytes32) { Proposal memory p = proposalData[_client][_proposer][_actionId]; return p.hash; } function getProposalDataApproval(address _client, address _proposer, bytes4 _actionId) external view returns(address[] memory) { Proposal memory p = proposalData[_client][_proposer][_actionId]; return p.approval; } function setProposalData(address payable _client, address _proposer, bytes4 _actionId, bytes32 _hash, address _approvedBackup) external allowAuthorizedLogicContractsCallsOnly(_client) { Proposal storage p = proposalData[_client][_proposer][_actionId]; if (p.hash > 0) { if (p.hash == _hash) { for (uint256 i = 0; i < p.approval.length; i++) { require(p.approval[i] != _approvedBackup, "backup already exists"); } p.approval.push(_approvedBackup); } else { p.hash = _hash; p.approval.length = 0; } } else { p.hash = _hash; p.approval.push(_approvedBackup); } } function clearProposalData(address payable _client, address _proposer, bytes4 _actionId) external allowAuthorizedLogicContractsCallsOnly(_client) { delete proposalData[_client][_proposer][_actionId]; } // *************** init ********************** // function initAccount(Account _account, address[] calldata _keys, address[] calldata _backups) external allowAccountCallsOnly(_account) { require(getKeyData(address(_account), 0) == address(0), "AccountStorage: account already initialized!"); require(_keys.length > 0, "empty keys array"); operationKeyCount[address(_account)] = _keys.length - 1; for (uint256 index = 0; index < _keys.length; index++) { address _key = _keys[index]; require(_key != address(0), "_key cannot be 0x0"); KeyItem storage item = keyData[address(_account)][index]; item.pubKey = _key; item.status = 0; } // avoid backup duplication if _backups.length > 1 // normally won't check duplication, in most cases only one initial backup when initialization if (_backups.length > 1) { address[] memory bkps = _backups; for (uint256 i = 0; i < _backups.length; i++) { for (uint256 j = 0; j < i; j++) { require(bkps[j] != _backups[i], "duplicate backup"); } } } for (uint256 index = 0; index < _backups.length; index++) { address _backup = _backups[index]; require(_backup != address(0), "backup cannot be 0x0"); require(_backup != address(_account), "cannot be backup of oneself"); backupData[address(_account)][index] = BackupAccount(_backup, now, uint256(-1)); } } }
getProposalDataHash
function getProposalDataHash(address _client, address _proposer, bytes4 _actionId) external view returns(bytes32) { Proposal memory p = proposalData[_client][_proposer][_actionId]; return p.hash; }
// *************** proposalData ********************** //
LineComment
v0.5.4+commit.9549d8ff
GNU GPLv3
bzzr://325ab23acf652cf963ee273c31a40feb195010aef23c1acf8f2f424fa1bd1a26
{ "func_code_index": [ 5597, 5822 ] }
2,797
Account
Account.sol
0x2ed747ed395cfd40ff750fdfa351b229d67c8c01
Solidity
AccountStorage
contract AccountStorage { modifier allowAccountCallsOnly(Account _account) { require(msg.sender == address(_account), "caller must be account"); _; } modifier allowAuthorizedLogicContractsCallsOnly(address payable _account) { require(LogicManager(Account(_account).manager()).isAuthorized(msg.sender), "not an authorized logic"); _; } struct KeyItem { address pubKey; uint256 status; } struct BackupAccount { address backup; uint256 effectiveDate;//means not effective until this timestamp uint256 expiryDate;//means effective until this timestamp } struct DelayItem { bytes32 hash; uint256 dueTime; } struct Proposal { bytes32 hash; address[] approval; } // account => quantity of operation keys (index >= 1) mapping (address => uint256) operationKeyCount; // account => index => KeyItem mapping (address => mapping(uint256 => KeyItem)) keyData; // account => index => backup account mapping (address => mapping(uint256 => BackupAccount)) backupData; /* account => actionId => DelayItem delayData applies to these 4 actions: changeAdminKey, changeAllOperationKeys, unfreeze, changeAdminKeyByBackup */ mapping (address => mapping(bytes4 => DelayItem)) delayData; // client account => proposer account => proposed actionId => Proposal mapping (address => mapping(address => mapping(bytes4 => Proposal))) proposalData; // *************** keyCount ********************** // function getOperationKeyCount(address _account) external view returns(uint256) { return operationKeyCount[_account]; } function increaseKeyCount(address payable _account) external allowAuthorizedLogicContractsCallsOnly(_account) { operationKeyCount[_account] = operationKeyCount[_account] + 1; } // *************** keyData ********************** // function getKeyData(address _account, uint256 _index) public view returns(address) { KeyItem memory item = keyData[_account][_index]; return item.pubKey; } function setKeyData(address payable _account, uint256 _index, address _key) external allowAuthorizedLogicContractsCallsOnly(_account) { require(_key != address(0), "invalid _key value"); KeyItem storage item = keyData[_account][_index]; item.pubKey = _key; } // *************** keyStatus ********************** // function getKeyStatus(address _account, uint256 _index) external view returns(uint256) { KeyItem memory item = keyData[_account][_index]; return item.status; } function setKeyStatus(address payable _account, uint256 _index, uint256 _status) external allowAuthorizedLogicContractsCallsOnly(_account) { KeyItem storage item = keyData[_account][_index]; item.status = _status; } // *************** backupData ********************** // function getBackupAddress(address _account, uint256 _index) external view returns(address) { BackupAccount memory b = backupData[_account][_index]; return b.backup; } function getBackupEffectiveDate(address _account, uint256 _index) external view returns(uint256) { BackupAccount memory b = backupData[_account][_index]; return b.effectiveDate; } function getBackupExpiryDate(address _account, uint256 _index) external view returns(uint256) { BackupAccount memory b = backupData[_account][_index]; return b.expiryDate; } function setBackup(address payable _account, uint256 _index, address _backup, uint256 _effective, uint256 _expiry) external allowAuthorizedLogicContractsCallsOnly(_account) { BackupAccount storage b = backupData[_account][_index]; b.backup = _backup; b.effectiveDate = _effective; b.expiryDate = _expiry; } function setBackupExpiryDate(address payable _account, uint256 _index, uint256 _expiry) external allowAuthorizedLogicContractsCallsOnly(_account) { BackupAccount storage b = backupData[_account][_index]; b.expiryDate = _expiry; } function clearBackupData(address payable _account, uint256 _index) external allowAuthorizedLogicContractsCallsOnly(_account) { delete backupData[_account][_index]; } // *************** delayData ********************** // function getDelayDataHash(address payable _account, bytes4 _actionId) external view returns(bytes32) { DelayItem memory item = delayData[_account][_actionId]; return item.hash; } function getDelayDataDueTime(address payable _account, bytes4 _actionId) external view returns(uint256) { DelayItem memory item = delayData[_account][_actionId]; return item.dueTime; } function setDelayData(address payable _account, bytes4 _actionId, bytes32 _hash, uint256 _dueTime) external allowAuthorizedLogicContractsCallsOnly(_account) { DelayItem storage item = delayData[_account][_actionId]; item.hash = _hash; item.dueTime = _dueTime; } function clearDelayData(address payable _account, bytes4 _actionId) external allowAuthorizedLogicContractsCallsOnly(_account) { delete delayData[_account][_actionId]; } // *************** proposalData ********************** // function getProposalDataHash(address _client, address _proposer, bytes4 _actionId) external view returns(bytes32) { Proposal memory p = proposalData[_client][_proposer][_actionId]; return p.hash; } function getProposalDataApproval(address _client, address _proposer, bytes4 _actionId) external view returns(address[] memory) { Proposal memory p = proposalData[_client][_proposer][_actionId]; return p.approval; } function setProposalData(address payable _client, address _proposer, bytes4 _actionId, bytes32 _hash, address _approvedBackup) external allowAuthorizedLogicContractsCallsOnly(_client) { Proposal storage p = proposalData[_client][_proposer][_actionId]; if (p.hash > 0) { if (p.hash == _hash) { for (uint256 i = 0; i < p.approval.length; i++) { require(p.approval[i] != _approvedBackup, "backup already exists"); } p.approval.push(_approvedBackup); } else { p.hash = _hash; p.approval.length = 0; } } else { p.hash = _hash; p.approval.push(_approvedBackup); } } function clearProposalData(address payable _client, address _proposer, bytes4 _actionId) external allowAuthorizedLogicContractsCallsOnly(_client) { delete proposalData[_client][_proposer][_actionId]; } // *************** init ********************** // function initAccount(Account _account, address[] calldata _keys, address[] calldata _backups) external allowAccountCallsOnly(_account) { require(getKeyData(address(_account), 0) == address(0), "AccountStorage: account already initialized!"); require(_keys.length > 0, "empty keys array"); operationKeyCount[address(_account)] = _keys.length - 1; for (uint256 index = 0; index < _keys.length; index++) { address _key = _keys[index]; require(_key != address(0), "_key cannot be 0x0"); KeyItem storage item = keyData[address(_account)][index]; item.pubKey = _key; item.status = 0; } // avoid backup duplication if _backups.length > 1 // normally won't check duplication, in most cases only one initial backup when initialization if (_backups.length > 1) { address[] memory bkps = _backups; for (uint256 i = 0; i < _backups.length; i++) { for (uint256 j = 0; j < i; j++) { require(bkps[j] != _backups[i], "duplicate backup"); } } } for (uint256 index = 0; index < _backups.length; index++) { address _backup = _backups[index]; require(_backup != address(0), "backup cannot be 0x0"); require(_backup != address(_account), "cannot be backup of oneself"); backupData[address(_account)][index] = BackupAccount(_backup, now, uint256(-1)); } } }
initAccount
function initAccount(Account _account, address[] calldata _keys, address[] calldata _backups) external allowAccountCallsOnly(_account) { require(getKeyData(address(_account), 0) == address(0), "AccountStorage: account already initialized!"); require(_keys.length > 0, "empty keys array"); operationKeyCount[address(_account)] = _keys.length - 1; for (uint256 index = 0; index < _keys.length; index++) { address _key = _keys[index]; require(_key != address(0), "_key cannot be 0x0"); KeyItem storage item = keyData[address(_account)][index]; item.pubKey = _key; item.status = 0; } // avoid backup duplication if _backups.length > 1 // normally won't check duplication, in most cases only one initial backup when initialization if (_backups.length > 1) { address[] memory bkps = _backups; for (uint256 i = 0; i < _backups.length; i++) { for (uint256 j = 0; j < i; j++) { require(bkps[j] != _backups[i], "duplicate backup"); } } } for (uint256 index = 0; index < _backups.length; index++) { address _backup = _backups[index]; require(_backup != address(0), "backup cannot be 0x0"); require(_backup != address(_account), "cannot be backup of oneself"); backupData[address(_account)][index] = BackupAccount(_backup, now, uint256(-1)); } }
// *************** init ********************** //
LineComment
v0.5.4+commit.9549d8ff
GNU GPLv3
bzzr://325ab23acf652cf963ee273c31a40feb195010aef23c1acf8f2f424fa1bd1a26
{ "func_code_index": [ 7152, 8738 ] }
2,798
Account
Account.sol
0x2ed747ed395cfd40ff750fdfa351b229d67c8c01
Solidity
Account
contract Account { // The implementation of the proxy address public implementation; // Logic manager address public manager; // The enabled static calls mapping (bytes4 => address) public enabled; event EnabledStaticCall(address indexed module, bytes4 indexed method); event Invoked(address indexed module, address indexed target, uint indexed value, bytes data); event Received(uint indexed value, address indexed sender, bytes data); event AccountInit(address indexed account); event ManagerChanged(address indexed mgr); modifier allowAuthorizedLogicContractsCallsOnly { require(LogicManager(manager).isAuthorized(msg.sender), "not an authorized logic"); _; } function init(address _manager, address _accountStorage, address[] calldata _logics, address[] calldata _keys, address[] calldata _backups) external { require(manager == address(0), "Account: account already initialized"); require(_manager != address(0) && _accountStorage != address(0), "Account: address is null"); manager = _manager; for (uint i = 0; i < _logics.length; i++) { address logic = _logics[i]; require(LogicManager(manager).isAuthorized(logic), "must be authorized logic"); BaseLogic(logic).initAccount(this); } AccountStorage(_accountStorage).initAccount(this, _keys, _backups); emit AccountInit(address(this)); } function invoke(address _target, uint _value, bytes calldata _data) external allowAuthorizedLogicContractsCallsOnly returns (bytes memory _res) { bool success; // solium-disable-next-line security/no-call-value (success, _res) = _target.call.value(_value)(_data); require(success, "call to target failed"); emit Invoked(msg.sender, _target, _value, _data); } /** * @dev Enables a static method by specifying the target module to which the call must be delegated. * @param _module The target module. * @param _method The static method signature. */ function enableStaticCall(address _module, bytes4 _method) external allowAuthorizedLogicContractsCallsOnly { enabled[_method] = _module; emit EnabledStaticCall(_module, _method); } function changeManager(address _newMgr) external allowAuthorizedLogicContractsCallsOnly { require(_newMgr != address(0), "address cannot be null"); require(_newMgr != manager, "already changed"); manager = _newMgr; emit ManagerChanged(_newMgr); } /** * @dev This method makes it possible for the wallet to comply to interfaces expecting the wallet to * implement specific static methods. It delegates the static call to a target contract if the data corresponds * to an enabled method, or logs the call otherwise. */ function() external payable { if(msg.data.length > 0) { address logic = enabled[msg.sig]; if(logic == address(0)) { emit Received(msg.value, msg.sender, msg.data); } else { require(LogicManager(manager).isAuthorized(logic), "must be an authorized logic for static call"); // solium-disable-next-line security/no-inline-assembly assembly { calldatacopy(0, 0, calldatasize()) let result := staticcall(gas, logic, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) switch result case 0 {revert(0, returndatasize())} default {return (0, returndatasize())} } } } } }
enableStaticCall
function enableStaticCall(address _module, bytes4 _method) external allowAuthorizedLogicContractsCallsOnly { enabled[_method] = _module; emit EnabledStaticCall(_module, _method); }
/** * @dev Enables a static method by specifying the target module to which the call must be delegated. * @param _module The target module. * @param _method The static method signature. */
NatSpecMultiLine
v0.5.4+commit.9549d8ff
GNU GPLv3
bzzr://325ab23acf652cf963ee273c31a40feb195010aef23c1acf8f2f424fa1bd1a26
{ "func_code_index": [ 2193, 2401 ] }
2,799