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
VTO
VTO.sol
0x02b66106c712ae79715f62be30a787cdfbcd79b2
Solidity
ERC20Detailed
contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @return the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @return the symbol of the token. */ function symbol() public view returns (string memory) { return _symbol; } /** * @return the number of decimals of the token. */ function decimals() public view returns (uint8) { return _decimals; } }
name
function name() public view returns (string memory) { return _name; }
/** * @return the name of the token. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
None
bzzr://b9179b633af1618d26883bc5623b55668f46bcbbd49aa5f18ea67376d9c5bced
{ "func_code_index": [ 356, 444 ] }
7,707
VTO
VTO.sol
0x02b66106c712ae79715f62be30a787cdfbcd79b2
Solidity
ERC20Detailed
contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @return the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @return the symbol of the token. */ function symbol() public view returns (string memory) { return _symbol; } /** * @return the number of decimals of the token. */ function decimals() public view returns (uint8) { return _decimals; } }
symbol
function symbol() public view returns (string memory) { return _symbol; }
/** * @return the symbol of the token. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
None
bzzr://b9179b633af1618d26883bc5623b55668f46bcbbd49aa5f18ea67376d9c5bced
{ "func_code_index": [ 506, 598 ] }
7,708
VTO
VTO.sol
0x02b66106c712ae79715f62be30a787cdfbcd79b2
Solidity
ERC20Detailed
contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @return the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @return the symbol of the token. */ function symbol() public view returns (string memory) { return _symbol; } /** * @return the number of decimals of the token. */ function decimals() public view returns (uint8) { return _decimals; } }
decimals
function decimals() public view returns (uint8) { return _decimals; }
/** * @return the number of decimals of the token. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
None
bzzr://b9179b633af1618d26883bc5623b55668f46bcbbd49aa5f18ea67376d9c5bced
{ "func_code_index": [ 672, 760 ] }
7,709
VTO
VTO.sol
0x02b66106c712ae79715f62be30a787cdfbcd79b2
Solidity
ERC20Burnable
contract ERC20Burnable is ERC20 { /** * @dev Burns a specific amount of tokens. * @param value The amount of token to be burned. */ function burn(uint256 value) public { _burn(msg.sender, value); } /** * @dev Burns a specific amount of tokens from the target address and decrements allowance * @param from address The address which you want to send tokens from * @param value uint256 The amount of token to be burned */ function burnFrom(address from, uint256 value) public { _burnFrom(from, value); } }
burn
function burn(uint256 value) public { _burn(msg.sender, value); }
/** * @dev Burns a specific amount of tokens. * @param value The amount of token to be burned. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
None
bzzr://b9179b633af1618d26883bc5623b55668f46bcbbd49aa5f18ea67376d9c5bced
{ "func_code_index": [ 156, 240 ] }
7,710
VTO
VTO.sol
0x02b66106c712ae79715f62be30a787cdfbcd79b2
Solidity
ERC20Burnable
contract ERC20Burnable is ERC20 { /** * @dev Burns a specific amount of tokens. * @param value The amount of token to be burned. */ function burn(uint256 value) public { _burn(msg.sender, value); } /** * @dev Burns a specific amount of tokens from the target address and decrements allowance * @param from address The address which you want to send tokens from * @param value uint256 The amount of token to be burned */ function burnFrom(address from, uint256 value) public { _burnFrom(from, value); } }
burnFrom
function burnFrom(address from, uint256 value) public { _burnFrom(from, value); }
/** * @dev Burns a specific amount of tokens from the target address and decrements allowance * @param from address The address which you want to send tokens from * @param value uint256 The amount of token to be burned */
NatSpecMultiLine
v0.5.17+commit.d19bba13
None
bzzr://b9179b633af1618d26883bc5623b55668f46bcbbd49aa5f18ea67376d9c5bced
{ "func_code_index": [ 494, 594 ] }
7,711
GLBToken
GLBToken.sol
0xb9581a458bd0e135f534fcb7a23441c7dc097ddc
Solidity
ContractTokenERC20
contract ContractTokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This generates a public event on the blockchain that will notify clients event Approval(address indexed _owner, address indexed _spender, uint256 _value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor( uint256 initialSupply, string memory tokenName, string memory tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != address(0x0)); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; emit Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, address(this), _extraData); return true; } } }
_transfer
function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != address(0x0)); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; emit Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); }
/** * Internal transfer, only can be called by this contract */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
bzzr://5e8a4668b19de91d748a9b05d6529816456d7c53664c67e0d07dec4d4534508a
{ "func_code_index": [ 1669, 2525 ] }
7,712
GLBToken
GLBToken.sol
0xb9581a458bd0e135f534fcb7a23441c7dc097ddc
Solidity
ContractTokenERC20
contract ContractTokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This generates a public event on the blockchain that will notify clients event Approval(address indexed _owner, address indexed _spender, uint256 _value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor( uint256 initialSupply, string memory tokenName, string memory tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != address(0x0)); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; emit Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, address(this), _extraData); return true; } } }
transfer
function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; }
/** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
bzzr://5e8a4668b19de91d748a9b05d6529816456d7c53664c67e0d07dec4d4534508a
{ "func_code_index": [ 2731, 2888 ] }
7,713
GLBToken
GLBToken.sol
0xb9581a458bd0e135f534fcb7a23441c7dc097ddc
Solidity
ContractTokenERC20
contract ContractTokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This generates a public event on the blockchain that will notify clients event Approval(address indexed _owner, address indexed _spender, uint256 _value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor( uint256 initialSupply, string memory tokenName, string memory tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != address(0x0)); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; emit Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, address(this), _extraData); return true; } } }
transferFrom
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; }
/** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
bzzr://5e8a4668b19de91d748a9b05d6529816456d7c53664c67e0d07dec4d4534508a
{ "func_code_index": [ 3163, 3464 ] }
7,714
GLBToken
GLBToken.sol
0xb9581a458bd0e135f534fcb7a23441c7dc097ddc
Solidity
ContractTokenERC20
contract ContractTokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This generates a public event on the blockchain that will notify clients event Approval(address indexed _owner, address indexed _spender, uint256 _value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor( uint256 initialSupply, string memory tokenName, string memory tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != address(0x0)); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; emit Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, address(this), _extraData); return true; } } }
approve
function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; }
/** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
bzzr://5e8a4668b19de91d748a9b05d6529816456d7c53664c67e0d07dec4d4534508a
{ "func_code_index": [ 3728, 3958 ] }
7,715
GLBToken
GLBToken.sol
0xb9581a458bd0e135f534fcb7a23441c7dc097ddc
Solidity
ContractTokenERC20
contract ContractTokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This generates a public event on the blockchain that will notify clients event Approval(address indexed _owner, address indexed _spender, uint256 _value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor( uint256 initialSupply, string memory tokenName, string memory tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != address(0x0)); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; emit Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, address(this), _extraData); return true; } } }
approveAndCall
function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, address(this), _extraData); return true; } }
/** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */
NatSpecMultiLine
v0.5.0+commit.1d4f565a
bzzr://5e8a4668b19de91d748a9b05d6529816456d7c53664c67e0d07dec4d4534508a
{ "func_code_index": [ 4352, 4720 ] }
7,716
GLBToken
GLBToken.sol
0xb9581a458bd0e135f534fcb7a23441c7dc097ddc
Solidity
GLBToken
contract GLBToken is ContractOwned, ContractTokenERC20 { uint256 public sellPrice; uint256 public buyPrice; mapping (address => bool) public frozenAccount; /* This generates a public event on the blockchain that will notify clients */ event FrozenFunds(address target, bool frozen); /* Initializes contract with initial supply tokens to the creator of the contract */ constructor( uint256 initialSupply, string memory tokenName, string memory tokenSymbol ) ContractTokenERC20(initialSupply, tokenName, tokenSymbol) public {} /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require (_to != address(0x0)); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows require(!frozenAccount[_from]); // Check if sender is frozen require(!frozenAccount[_to]); // Check if recipient is frozen balanceOf[_from] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient emit Transfer(_from, _to, _value); } /// @notice Create `mintedAmount` tokens and send it to `target` /// @param target Address to receive the tokens /// @param mintedAmount the amount of tokens it will receive function mintToken(address target, uint256 mintedAmount) onlyOwner public { balanceOf[target] += mintedAmount; totalSupply += mintedAmount; emit Transfer(address(0), address(this), mintedAmount); emit Transfer(address(this), target, mintedAmount); } /// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens /// @param target Address to be frozen /// @param freeze either to freeze it or not function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } /// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth /// @param newSellPrice Price the users can sell to the contract /// @param newBuyPrice Price users can buy from the contract function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public { sellPrice = newSellPrice; buyPrice = newBuyPrice; } /// @notice Buy tokens from contract by sending ether function buy() payable public { uint amount = msg.value / buyPrice; // calculates the amount _transfer(address(this), msg.sender, amount); // makes the transfers } /// @notice Sell `amount` tokens to contract /// @param amount amount of tokens to be sold function sell(uint256 amount) public { address myAddress = address(this); require(myAddress.balance >= amount * sellPrice); // checks if the contract has enough ether to buy _transfer(msg.sender, address(this), amount); // makes the transfers msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks } }
/******************************************/
NatSpecMultiLine
_transfer
function _transfer(address _from, address _to, uint _value) internal { require (_to != address(0x0)); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows require(!frozenAccount[_from]); // Check if sender is frozen require(!frozenAccount[_to]); // Check if recipient is frozen balanceOf[_from] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient emit Transfer(_from, _to, _value); }
/* Internal transfer, only can be called by this contract */
Comment
v0.5.0+commit.1d4f565a
bzzr://5e8a4668b19de91d748a9b05d6529816456d7c53664c67e0d07dec4d4534508a
{ "func_code_index": [ 669, 1484 ] }
7,717
GLBToken
GLBToken.sol
0xb9581a458bd0e135f534fcb7a23441c7dc097ddc
Solidity
GLBToken
contract GLBToken is ContractOwned, ContractTokenERC20 { uint256 public sellPrice; uint256 public buyPrice; mapping (address => bool) public frozenAccount; /* This generates a public event on the blockchain that will notify clients */ event FrozenFunds(address target, bool frozen); /* Initializes contract with initial supply tokens to the creator of the contract */ constructor( uint256 initialSupply, string memory tokenName, string memory tokenSymbol ) ContractTokenERC20(initialSupply, tokenName, tokenSymbol) public {} /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require (_to != address(0x0)); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows require(!frozenAccount[_from]); // Check if sender is frozen require(!frozenAccount[_to]); // Check if recipient is frozen balanceOf[_from] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient emit Transfer(_from, _to, _value); } /// @notice Create `mintedAmount` tokens and send it to `target` /// @param target Address to receive the tokens /// @param mintedAmount the amount of tokens it will receive function mintToken(address target, uint256 mintedAmount) onlyOwner public { balanceOf[target] += mintedAmount; totalSupply += mintedAmount; emit Transfer(address(0), address(this), mintedAmount); emit Transfer(address(this), target, mintedAmount); } /// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens /// @param target Address to be frozen /// @param freeze either to freeze it or not function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } /// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth /// @param newSellPrice Price the users can sell to the contract /// @param newBuyPrice Price users can buy from the contract function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public { sellPrice = newSellPrice; buyPrice = newBuyPrice; } /// @notice Buy tokens from contract by sending ether function buy() payable public { uint amount = msg.value / buyPrice; // calculates the amount _transfer(address(this), msg.sender, amount); // makes the transfers } /// @notice Sell `amount` tokens to contract /// @param amount amount of tokens to be sold function sell(uint256 amount) public { address myAddress = address(this); require(myAddress.balance >= amount * sellPrice); // checks if the contract has enough ether to buy _transfer(msg.sender, address(this), amount); // makes the transfers msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks } }
/******************************************/
NatSpecMultiLine
mintToken
function mintToken(address target, uint256 mintedAmount) onlyOwner public { balanceOf[target] += mintedAmount; totalSupply += mintedAmount; emit Transfer(address(0), address(this), mintedAmount); emit Transfer(address(this), target, mintedAmount); }
/// @notice Create `mintedAmount` tokens and send it to `target` /// @param target Address to receive the tokens /// @param mintedAmount the amount of tokens it will receive
NatSpecSingleLine
v0.5.0+commit.1d4f565a
bzzr://5e8a4668b19de91d748a9b05d6529816456d7c53664c67e0d07dec4d4534508a
{ "func_code_index": [ 1676, 1971 ] }
7,718
GLBToken
GLBToken.sol
0xb9581a458bd0e135f534fcb7a23441c7dc097ddc
Solidity
GLBToken
contract GLBToken is ContractOwned, ContractTokenERC20 { uint256 public sellPrice; uint256 public buyPrice; mapping (address => bool) public frozenAccount; /* This generates a public event on the blockchain that will notify clients */ event FrozenFunds(address target, bool frozen); /* Initializes contract with initial supply tokens to the creator of the contract */ constructor( uint256 initialSupply, string memory tokenName, string memory tokenSymbol ) ContractTokenERC20(initialSupply, tokenName, tokenSymbol) public {} /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require (_to != address(0x0)); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows require(!frozenAccount[_from]); // Check if sender is frozen require(!frozenAccount[_to]); // Check if recipient is frozen balanceOf[_from] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient emit Transfer(_from, _to, _value); } /// @notice Create `mintedAmount` tokens and send it to `target` /// @param target Address to receive the tokens /// @param mintedAmount the amount of tokens it will receive function mintToken(address target, uint256 mintedAmount) onlyOwner public { balanceOf[target] += mintedAmount; totalSupply += mintedAmount; emit Transfer(address(0), address(this), mintedAmount); emit Transfer(address(this), target, mintedAmount); } /// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens /// @param target Address to be frozen /// @param freeze either to freeze it or not function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } /// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth /// @param newSellPrice Price the users can sell to the contract /// @param newBuyPrice Price users can buy from the contract function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public { sellPrice = newSellPrice; buyPrice = newBuyPrice; } /// @notice Buy tokens from contract by sending ether function buy() payable public { uint amount = msg.value / buyPrice; // calculates the amount _transfer(address(this), msg.sender, amount); // makes the transfers } /// @notice Sell `amount` tokens to contract /// @param amount amount of tokens to be sold function sell(uint256 amount) public { address myAddress = address(this); require(myAddress.balance >= amount * sellPrice); // checks if the contract has enough ether to buy _transfer(msg.sender, address(this), amount); // makes the transfers msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks } }
/******************************************/
NatSpecMultiLine
freezeAccount
function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); }
/// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens /// @param target Address to be frozen /// @param freeze either to freeze it or not
NatSpecSingleLine
v0.5.0+commit.1d4f565a
bzzr://5e8a4668b19de91d748a9b05d6529816456d7c53664c67e0d07dec4d4534508a
{ "func_code_index": [ 2152, 2318 ] }
7,719
GLBToken
GLBToken.sol
0xb9581a458bd0e135f534fcb7a23441c7dc097ddc
Solidity
GLBToken
contract GLBToken is ContractOwned, ContractTokenERC20 { uint256 public sellPrice; uint256 public buyPrice; mapping (address => bool) public frozenAccount; /* This generates a public event on the blockchain that will notify clients */ event FrozenFunds(address target, bool frozen); /* Initializes contract with initial supply tokens to the creator of the contract */ constructor( uint256 initialSupply, string memory tokenName, string memory tokenSymbol ) ContractTokenERC20(initialSupply, tokenName, tokenSymbol) public {} /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require (_to != address(0x0)); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows require(!frozenAccount[_from]); // Check if sender is frozen require(!frozenAccount[_to]); // Check if recipient is frozen balanceOf[_from] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient emit Transfer(_from, _to, _value); } /// @notice Create `mintedAmount` tokens and send it to `target` /// @param target Address to receive the tokens /// @param mintedAmount the amount of tokens it will receive function mintToken(address target, uint256 mintedAmount) onlyOwner public { balanceOf[target] += mintedAmount; totalSupply += mintedAmount; emit Transfer(address(0), address(this), mintedAmount); emit Transfer(address(this), target, mintedAmount); } /// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens /// @param target Address to be frozen /// @param freeze either to freeze it or not function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } /// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth /// @param newSellPrice Price the users can sell to the contract /// @param newBuyPrice Price users can buy from the contract function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public { sellPrice = newSellPrice; buyPrice = newBuyPrice; } /// @notice Buy tokens from contract by sending ether function buy() payable public { uint amount = msg.value / buyPrice; // calculates the amount _transfer(address(this), msg.sender, amount); // makes the transfers } /// @notice Sell `amount` tokens to contract /// @param amount amount of tokens to be sold function sell(uint256 amount) public { address myAddress = address(this); require(myAddress.balance >= amount * sellPrice); // checks if the contract has enough ether to buy _transfer(msg.sender, address(this), amount); // makes the transfers msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks } }
/******************************************/
NatSpecMultiLine
setPrices
function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public { sellPrice = newSellPrice; buyPrice = newBuyPrice; }
/// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth /// @param newSellPrice Price the users can sell to the contract /// @param newBuyPrice Price users can buy from the contract
NatSpecSingleLine
v0.5.0+commit.1d4f565a
bzzr://5e8a4668b19de91d748a9b05d6529816456d7c53664c67e0d07dec4d4534508a
{ "func_code_index": [ 2561, 2721 ] }
7,720
GLBToken
GLBToken.sol
0xb9581a458bd0e135f534fcb7a23441c7dc097ddc
Solidity
GLBToken
contract GLBToken is ContractOwned, ContractTokenERC20 { uint256 public sellPrice; uint256 public buyPrice; mapping (address => bool) public frozenAccount; /* This generates a public event on the blockchain that will notify clients */ event FrozenFunds(address target, bool frozen); /* Initializes contract with initial supply tokens to the creator of the contract */ constructor( uint256 initialSupply, string memory tokenName, string memory tokenSymbol ) ContractTokenERC20(initialSupply, tokenName, tokenSymbol) public {} /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require (_to != address(0x0)); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows require(!frozenAccount[_from]); // Check if sender is frozen require(!frozenAccount[_to]); // Check if recipient is frozen balanceOf[_from] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient emit Transfer(_from, _to, _value); } /// @notice Create `mintedAmount` tokens and send it to `target` /// @param target Address to receive the tokens /// @param mintedAmount the amount of tokens it will receive function mintToken(address target, uint256 mintedAmount) onlyOwner public { balanceOf[target] += mintedAmount; totalSupply += mintedAmount; emit Transfer(address(0), address(this), mintedAmount); emit Transfer(address(this), target, mintedAmount); } /// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens /// @param target Address to be frozen /// @param freeze either to freeze it or not function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } /// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth /// @param newSellPrice Price the users can sell to the contract /// @param newBuyPrice Price users can buy from the contract function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public { sellPrice = newSellPrice; buyPrice = newBuyPrice; } /// @notice Buy tokens from contract by sending ether function buy() payable public { uint amount = msg.value / buyPrice; // calculates the amount _transfer(address(this), msg.sender, amount); // makes the transfers } /// @notice Sell `amount` tokens to contract /// @param amount amount of tokens to be sold function sell(uint256 amount) public { address myAddress = address(this); require(myAddress.balance >= amount * sellPrice); // checks if the contract has enough ether to buy _transfer(msg.sender, address(this), amount); // makes the transfers msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks } }
/******************************************/
NatSpecMultiLine
buy
function buy() payable public { uint amount = msg.value / buyPrice; // calculates the amount _transfer(address(this), msg.sender, amount); // makes the transfers }
/// @notice Buy tokens from contract by sending ether
NatSpecSingleLine
v0.5.0+commit.1d4f565a
bzzr://5e8a4668b19de91d748a9b05d6529816456d7c53664c67e0d07dec4d4534508a
{ "func_code_index": [ 2783, 2996 ] }
7,721
GLBToken
GLBToken.sol
0xb9581a458bd0e135f534fcb7a23441c7dc097ddc
Solidity
GLBToken
contract GLBToken is ContractOwned, ContractTokenERC20 { uint256 public sellPrice; uint256 public buyPrice; mapping (address => bool) public frozenAccount; /* This generates a public event on the blockchain that will notify clients */ event FrozenFunds(address target, bool frozen); /* Initializes contract with initial supply tokens to the creator of the contract */ constructor( uint256 initialSupply, string memory tokenName, string memory tokenSymbol ) ContractTokenERC20(initialSupply, tokenName, tokenSymbol) public {} /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require (_to != address(0x0)); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows require(!frozenAccount[_from]); // Check if sender is frozen require(!frozenAccount[_to]); // Check if recipient is frozen balanceOf[_from] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient emit Transfer(_from, _to, _value); } /// @notice Create `mintedAmount` tokens and send it to `target` /// @param target Address to receive the tokens /// @param mintedAmount the amount of tokens it will receive function mintToken(address target, uint256 mintedAmount) onlyOwner public { balanceOf[target] += mintedAmount; totalSupply += mintedAmount; emit Transfer(address(0), address(this), mintedAmount); emit Transfer(address(this), target, mintedAmount); } /// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens /// @param target Address to be frozen /// @param freeze either to freeze it or not function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } /// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth /// @param newSellPrice Price the users can sell to the contract /// @param newBuyPrice Price users can buy from the contract function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public { sellPrice = newSellPrice; buyPrice = newBuyPrice; } /// @notice Buy tokens from contract by sending ether function buy() payable public { uint amount = msg.value / buyPrice; // calculates the amount _transfer(address(this), msg.sender, amount); // makes the transfers } /// @notice Sell `amount` tokens to contract /// @param amount amount of tokens to be sold function sell(uint256 amount) public { address myAddress = address(this); require(myAddress.balance >= amount * sellPrice); // checks if the contract has enough ether to buy _transfer(msg.sender, address(this), amount); // makes the transfers msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks } }
/******************************************/
NatSpecMultiLine
sell
function sell(uint256 amount) public { address myAddress = address(this); require(myAddress.balance >= amount * sellPrice); // checks if the contract has enough ether to buy _transfer(msg.sender, address(this), amount); // makes the transfers msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks }
/// @notice Sell `amount` tokens to contract /// @param amount amount of tokens to be sold
NatSpecSingleLine
v0.5.0+commit.1d4f565a
bzzr://5e8a4668b19de91d748a9b05d6529816456d7c53664c67e0d07dec4d4534508a
{ "func_code_index": [ 3100, 3538 ] }
7,722
ForefrontVesting
contracts/ForefrontVesting.sol
0x95e26d3108ff64c5534fa64908c85e93bbb7e3ad
Solidity
ForefrontVesting
contract ForefrontVesting is Ownable { using SafeERC20 for IERC20; IERC20 public vestingToken; address public treasury; uint256 public startTimestamp; uint256 public finishingTimestamp; uint256 public globalForefrontVested; /// @dev change according to program uint256 public constant vestingLength = 365 days; struct Entry { uint256 locked; uint256 claimed; uint256 totalAllocation; } mapping(address => Entry) private entries; event TokenVested(address indexed wallet, uint256 amount); event EntryAdded(address indexed wallet, uint256 amount); event EntryRemoved(address indexed wallet, uint256 amount); constructor( uint256 _start, address _ffToken, address _treasury ) { startTimestamp = _start; finishingTimestamp = _start + vestingLength; vestingToken = IERC20(_ffToken); treasury = _treasury; } /* Public Functions */ function vest() public { uint256 amountCanClaim = vestableAmount(msg.sender); require(amountCanClaim > 0, "ForefrontVesting: no tokens are vestable"); entries[msg.sender].locked -= amountCanClaim; entries[msg.sender].claimed += amountCanClaim; globalForefrontVested -= amountCanClaim; vestingToken.safeTransfer(msg.sender, amountCanClaim); emit TokenVested(msg.sender, amountCanClaim); } /* Restricted Functions */ function addEntries(address[] memory wallets, uint256[] memory allocations) public onlyOwner returns (bool success) { for (uint256 i = 0; i < wallets.length; i++) { if (addEntry(wallets[i], allocations[i])) { success = true; } } } function addEntry(address wallet, uint256 allocation) public onlyOwner returns (bool success) { entries[wallet] = Entry(allocation, 0, allocation); globalForefrontVested += allocation; emit EntryAdded(wallet, allocation); success = true; } function removeEntries(address[] memory wallets) public onlyOwner returns (bool success) { for (uint256 i = 0; i < wallets.length; i++) { if (removeEntry(wallets[i])) { success = true; } } } function removeEntry(address wallet) public onlyOwner returns (bool success) { uint256 previousAllocation = entries[wallet].totalAllocation; globalForefrontVested -= previousAllocation; delete entries[wallet]; emit EntryRemoved(wallet, previousAllocation); success = true; } function retrieveFunds() public onlyOwner { vestingToken.safeTransfer( treasury, vestingToken.balanceOf(address(this)) ); } function emergencyWithdraw(address tokenAddress) public onlyOwner { IERC20 tokenToWithdraw = IERC20(tokenAddress); tokenToWithdraw.safeTransfer( treasury, tokenToWithdraw.balanceOf(address(this)) ); } /* Views */ function vestableAmount(address wallet) public view returns (uint256) { uint256 remainingAmount = entries[wallet].locked; if (block.timestamp >= finishingTimestamp) { return remainingAmount; } else { return (remainingAmount * (block.timestamp - startTimestamp)) / vestingLength; } } function claimed(address wallet) public view returns (uint256) { return entries[wallet].claimed; } function locked(address wallet) public view returns (uint256) { return entries[wallet].locked; } function totalAllocation(address wallet) public view returns (uint256) { return entries[wallet].totalAllocation; } }
/// @title Forefront News Vesting Contract /// @notice A contract used for the vesting entries of contributions made during the Treasury Diversification Round
NatSpecSingleLine
vest
function vest() public { uint256 amountCanClaim = vestableAmount(msg.sender); require(amountCanClaim > 0, "ForefrontVesting: no tokens are vestable"); entries[msg.sender].locked -= amountCanClaim; entries[msg.sender].claimed += amountCanClaim; globalForefrontVested -= amountCanClaim; vestingToken.safeTransfer(msg.sender, amountCanClaim); emit TokenVested(msg.sender, amountCanClaim); }
/* Public Functions */
Comment
v0.8.4+commit.c7e474f2
{ "func_code_index": [ 987, 1441 ] }
7,723
ForefrontVesting
contracts/ForefrontVesting.sol
0x95e26d3108ff64c5534fa64908c85e93bbb7e3ad
Solidity
ForefrontVesting
contract ForefrontVesting is Ownable { using SafeERC20 for IERC20; IERC20 public vestingToken; address public treasury; uint256 public startTimestamp; uint256 public finishingTimestamp; uint256 public globalForefrontVested; /// @dev change according to program uint256 public constant vestingLength = 365 days; struct Entry { uint256 locked; uint256 claimed; uint256 totalAllocation; } mapping(address => Entry) private entries; event TokenVested(address indexed wallet, uint256 amount); event EntryAdded(address indexed wallet, uint256 amount); event EntryRemoved(address indexed wallet, uint256 amount); constructor( uint256 _start, address _ffToken, address _treasury ) { startTimestamp = _start; finishingTimestamp = _start + vestingLength; vestingToken = IERC20(_ffToken); treasury = _treasury; } /* Public Functions */ function vest() public { uint256 amountCanClaim = vestableAmount(msg.sender); require(amountCanClaim > 0, "ForefrontVesting: no tokens are vestable"); entries[msg.sender].locked -= amountCanClaim; entries[msg.sender].claimed += amountCanClaim; globalForefrontVested -= amountCanClaim; vestingToken.safeTransfer(msg.sender, amountCanClaim); emit TokenVested(msg.sender, amountCanClaim); } /* Restricted Functions */ function addEntries(address[] memory wallets, uint256[] memory allocations) public onlyOwner returns (bool success) { for (uint256 i = 0; i < wallets.length; i++) { if (addEntry(wallets[i], allocations[i])) { success = true; } } } function addEntry(address wallet, uint256 allocation) public onlyOwner returns (bool success) { entries[wallet] = Entry(allocation, 0, allocation); globalForefrontVested += allocation; emit EntryAdded(wallet, allocation); success = true; } function removeEntries(address[] memory wallets) public onlyOwner returns (bool success) { for (uint256 i = 0; i < wallets.length; i++) { if (removeEntry(wallets[i])) { success = true; } } } function removeEntry(address wallet) public onlyOwner returns (bool success) { uint256 previousAllocation = entries[wallet].totalAllocation; globalForefrontVested -= previousAllocation; delete entries[wallet]; emit EntryRemoved(wallet, previousAllocation); success = true; } function retrieveFunds() public onlyOwner { vestingToken.safeTransfer( treasury, vestingToken.balanceOf(address(this)) ); } function emergencyWithdraw(address tokenAddress) public onlyOwner { IERC20 tokenToWithdraw = IERC20(tokenAddress); tokenToWithdraw.safeTransfer( treasury, tokenToWithdraw.balanceOf(address(this)) ); } /* Views */ function vestableAmount(address wallet) public view returns (uint256) { uint256 remainingAmount = entries[wallet].locked; if (block.timestamp >= finishingTimestamp) { return remainingAmount; } else { return (remainingAmount * (block.timestamp - startTimestamp)) / vestingLength; } } function claimed(address wallet) public view returns (uint256) { return entries[wallet].claimed; } function locked(address wallet) public view returns (uint256) { return entries[wallet].locked; } function totalAllocation(address wallet) public view returns (uint256) { return entries[wallet].totalAllocation; } }
/// @title Forefront News Vesting Contract /// @notice A contract used for the vesting entries of contributions made during the Treasury Diversification Round
NatSpecSingleLine
addEntries
function addEntries(address[] memory wallets, uint256[] memory allocations) public onlyOwner returns (bool success) { for (uint256 i = 0; i < wallets.length; i++) { if (addEntry(wallets[i], allocations[i])) { success = true; } } }
/* Restricted Functions */
Comment
v0.8.4+commit.c7e474f2
{ "func_code_index": [ 1475, 1797 ] }
7,724
ForefrontVesting
contracts/ForefrontVesting.sol
0x95e26d3108ff64c5534fa64908c85e93bbb7e3ad
Solidity
ForefrontVesting
contract ForefrontVesting is Ownable { using SafeERC20 for IERC20; IERC20 public vestingToken; address public treasury; uint256 public startTimestamp; uint256 public finishingTimestamp; uint256 public globalForefrontVested; /// @dev change according to program uint256 public constant vestingLength = 365 days; struct Entry { uint256 locked; uint256 claimed; uint256 totalAllocation; } mapping(address => Entry) private entries; event TokenVested(address indexed wallet, uint256 amount); event EntryAdded(address indexed wallet, uint256 amount); event EntryRemoved(address indexed wallet, uint256 amount); constructor( uint256 _start, address _ffToken, address _treasury ) { startTimestamp = _start; finishingTimestamp = _start + vestingLength; vestingToken = IERC20(_ffToken); treasury = _treasury; } /* Public Functions */ function vest() public { uint256 amountCanClaim = vestableAmount(msg.sender); require(amountCanClaim > 0, "ForefrontVesting: no tokens are vestable"); entries[msg.sender].locked -= amountCanClaim; entries[msg.sender].claimed += amountCanClaim; globalForefrontVested -= amountCanClaim; vestingToken.safeTransfer(msg.sender, amountCanClaim); emit TokenVested(msg.sender, amountCanClaim); } /* Restricted Functions */ function addEntries(address[] memory wallets, uint256[] memory allocations) public onlyOwner returns (bool success) { for (uint256 i = 0; i < wallets.length; i++) { if (addEntry(wallets[i], allocations[i])) { success = true; } } } function addEntry(address wallet, uint256 allocation) public onlyOwner returns (bool success) { entries[wallet] = Entry(allocation, 0, allocation); globalForefrontVested += allocation; emit EntryAdded(wallet, allocation); success = true; } function removeEntries(address[] memory wallets) public onlyOwner returns (bool success) { for (uint256 i = 0; i < wallets.length; i++) { if (removeEntry(wallets[i])) { success = true; } } } function removeEntry(address wallet) public onlyOwner returns (bool success) { uint256 previousAllocation = entries[wallet].totalAllocation; globalForefrontVested -= previousAllocation; delete entries[wallet]; emit EntryRemoved(wallet, previousAllocation); success = true; } function retrieveFunds() public onlyOwner { vestingToken.safeTransfer( treasury, vestingToken.balanceOf(address(this)) ); } function emergencyWithdraw(address tokenAddress) public onlyOwner { IERC20 tokenToWithdraw = IERC20(tokenAddress); tokenToWithdraw.safeTransfer( treasury, tokenToWithdraw.balanceOf(address(this)) ); } /* Views */ function vestableAmount(address wallet) public view returns (uint256) { uint256 remainingAmount = entries[wallet].locked; if (block.timestamp >= finishingTimestamp) { return remainingAmount; } else { return (remainingAmount * (block.timestamp - startTimestamp)) / vestingLength; } } function claimed(address wallet) public view returns (uint256) { return entries[wallet].claimed; } function locked(address wallet) public view returns (uint256) { return entries[wallet].locked; } function totalAllocation(address wallet) public view returns (uint256) { return entries[wallet].totalAllocation; } }
/// @title Forefront News Vesting Contract /// @notice A contract used for the vesting entries of contributions made during the Treasury Diversification Round
NatSpecSingleLine
vestableAmount
function vestableAmount(address wallet) public view returns (uint256) { uint256 remainingAmount = entries[wallet].locked; if (block.timestamp >= finishingTimestamp) { return remainingAmount; } else { return (remainingAmount * (block.timestamp - startTimestamp)) / vestingLength; } }
/* Views */
Comment
v0.8.4+commit.c7e474f2
{ "func_code_index": [ 3193, 3572 ] }
7,725
StableCoin
StableCoin.sol
0xfa654d0702ffdae6fe30272639c83ec4cbfe6d7d
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; } }
/** * @title SafeMath * *It's a Stable Coin having value as 1 CNYT = 1 YUAN (YUAN is a Chinese Currency) */
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.4.25+commit.59dbf8f1
None
bzzr://e35191faeaf754c518bef8c1ba3b812474cd40b050752aa462c281006bd2ebf1
{ "func_code_index": [ 90, 486 ] }
7,726
StableCoin
StableCoin.sol
0xfa654d0702ffdae6fe30272639c83ec4cbfe6d7d
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; } }
/** * @title SafeMath * *It's a Stable Coin having value as 1 CNYT = 1 YUAN (YUAN is a Chinese Currency) */
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.4.25+commit.59dbf8f1
None
bzzr://e35191faeaf754c518bef8c1ba3b812474cd40b050752aa462c281006bd2ebf1
{ "func_code_index": [ 598, 877 ] }
7,727
StableCoin
StableCoin.sol
0xfa654d0702ffdae6fe30272639c83ec4cbfe6d7d
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; } }
/** * @title SafeMath * *It's a Stable Coin having value as 1 CNYT = 1 YUAN (YUAN is a Chinese Currency) */
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.4.25+commit.59dbf8f1
None
bzzr://e35191faeaf754c518bef8c1ba3b812474cd40b050752aa462c281006bd2ebf1
{ "func_code_index": [ 992, 1131 ] }
7,728
StableCoin
StableCoin.sol
0xfa654d0702ffdae6fe30272639c83ec4cbfe6d7d
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; } }
/** * @title SafeMath * *It's a Stable Coin having value as 1 CNYT = 1 YUAN (YUAN is a Chinese Currency) */
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.4.25+commit.59dbf8f1
None
bzzr://e35191faeaf754c518bef8c1ba3b812474cd40b050752aa462c281006bd2ebf1
{ "func_code_index": [ 1196, 1335 ] }
7,729
StableCoin
StableCoin.sol
0xfa654d0702ffdae6fe30272639c83ec4cbfe6d7d
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; } }
/** * @title SafeMath * *It's a Stable Coin having value as 1 CNYT = 1 YUAN (YUAN is a Chinese Currency) */
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.4.25+commit.59dbf8f1
None
bzzr://e35191faeaf754c518bef8c1ba3b812474cd40b050752aa462c281006bd2ebf1
{ "func_code_index": [ 1470, 1587 ] }
7,730
StableCoin
StableCoin.sol
0xfa654d0702ffdae6fe30272639c83ec4cbfe6d7d
Solidity
StableCoin
contract StableCoin is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; constructor(string name, string symbol, uint8 decimals, uint256 totalSupply) public { _name = name; _symbol = symbol; _decimals = decimals; _totalSupply = totalSupply; _balances[msg.sender] = _balances[msg.sender].add(_totalSupply); emit Transfer(address(0), msg.sender, totalSupply); } /** * @return the name of the token. */ function name() public view returns(string) { return _name; } /** * @return the symbol of the token. */ function symbol() public view returns(string) { return _symbol; } /** * @return the number of decimals of the token. */ function decimals() public view returns(uint8) { return _decimals; } /** * @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 balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } /** * @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 Transfer token for a specified address * @param to The address to transfer to. * @param value The amount to be transferred. */ function transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, to, value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */ function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _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(value <= _allowed[from][msg.sender]); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param addedValue The amount of tokens to increase the allowance by. */ function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Transfer token for a specified addresses * @param from The address to transfer from. * @param to The address to transfer to. * @param value The amount to be transferred. */ function _transfer(address from, address to, uint256 value) internal { require(value <= _balances[from]); require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } }
name
function name() public view returns(string) { return _name; }
/** * @return the name of the token. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
None
bzzr://e35191faeaf754c518bef8c1ba3b812474cd40b050752aa462c281006bd2ebf1
{ "func_code_index": [ 683, 755 ] }
7,731
StableCoin
StableCoin.sol
0xfa654d0702ffdae6fe30272639c83ec4cbfe6d7d
Solidity
StableCoin
contract StableCoin is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; constructor(string name, string symbol, uint8 decimals, uint256 totalSupply) public { _name = name; _symbol = symbol; _decimals = decimals; _totalSupply = totalSupply; _balances[msg.sender] = _balances[msg.sender].add(_totalSupply); emit Transfer(address(0), msg.sender, totalSupply); } /** * @return the name of the token. */ function name() public view returns(string) { return _name; } /** * @return the symbol of the token. */ function symbol() public view returns(string) { return _symbol; } /** * @return the number of decimals of the token. */ function decimals() public view returns(uint8) { return _decimals; } /** * @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 balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } /** * @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 Transfer token for a specified address * @param to The address to transfer to. * @param value The amount to be transferred. */ function transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, to, value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */ function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _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(value <= _allowed[from][msg.sender]); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param addedValue The amount of tokens to increase the allowance by. */ function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Transfer token for a specified addresses * @param from The address to transfer from. * @param to The address to transfer to. * @param value The amount to be transferred. */ function _transfer(address from, address to, uint256 value) internal { require(value <= _balances[from]); require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } }
symbol
function symbol() public view returns(string) { return _symbol; }
/** * @return the symbol of the token. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
None
bzzr://e35191faeaf754c518bef8c1ba3b812474cd40b050752aa462c281006bd2ebf1
{ "func_code_index": [ 811, 887 ] }
7,732
StableCoin
StableCoin.sol
0xfa654d0702ffdae6fe30272639c83ec4cbfe6d7d
Solidity
StableCoin
contract StableCoin is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; constructor(string name, string symbol, uint8 decimals, uint256 totalSupply) public { _name = name; _symbol = symbol; _decimals = decimals; _totalSupply = totalSupply; _balances[msg.sender] = _balances[msg.sender].add(_totalSupply); emit Transfer(address(0), msg.sender, totalSupply); } /** * @return the name of the token. */ function name() public view returns(string) { return _name; } /** * @return the symbol of the token. */ function symbol() public view returns(string) { return _symbol; } /** * @return the number of decimals of the token. */ function decimals() public view returns(uint8) { return _decimals; } /** * @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 balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } /** * @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 Transfer token for a specified address * @param to The address to transfer to. * @param value The amount to be transferred. */ function transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, to, value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */ function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _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(value <= _allowed[from][msg.sender]); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param addedValue The amount of tokens to increase the allowance by. */ function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Transfer token for a specified addresses * @param from The address to transfer from. * @param to The address to transfer to. * @param value The amount to be transferred. */ function _transfer(address from, address to, uint256 value) internal { require(value <= _balances[from]); require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } }
decimals
function decimals() public view returns(uint8) { return _decimals; }
/** * @return the number of decimals of the token. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
None
bzzr://e35191faeaf754c518bef8c1ba3b812474cd40b050752aa462c281006bd2ebf1
{ "func_code_index": [ 955, 1034 ] }
7,733
StableCoin
StableCoin.sol
0xfa654d0702ffdae6fe30272639c83ec4cbfe6d7d
Solidity
StableCoin
contract StableCoin is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; constructor(string name, string symbol, uint8 decimals, uint256 totalSupply) public { _name = name; _symbol = symbol; _decimals = decimals; _totalSupply = totalSupply; _balances[msg.sender] = _balances[msg.sender].add(_totalSupply); emit Transfer(address(0), msg.sender, totalSupply); } /** * @return the name of the token. */ function name() public view returns(string) { return _name; } /** * @return the symbol of the token. */ function symbol() public view returns(string) { return _symbol; } /** * @return the number of decimals of the token. */ function decimals() public view returns(uint8) { return _decimals; } /** * @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 balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } /** * @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 Transfer token for a specified address * @param to The address to transfer to. * @param value The amount to be transferred. */ function transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, to, value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */ function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _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(value <= _allowed[from][msg.sender]); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param addedValue The amount of tokens to increase the allowance by. */ function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Transfer token for a specified addresses * @param from The address to transfer from. * @param to The address to transfer to. * @param value The amount to be transferred. */ function _transfer(address from, address to, uint256 value) internal { require(value <= _balances[from]); require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } }
totalSupply
function totalSupply() public view returns (uint256) { return _totalSupply; }
/** * @dev Total number of tokens in existence */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
None
bzzr://e35191faeaf754c518bef8c1ba3b812474cd40b050752aa462c281006bd2ebf1
{ "func_code_index": [ 1096, 1184 ] }
7,734
StableCoin
StableCoin.sol
0xfa654d0702ffdae6fe30272639c83ec4cbfe6d7d
Solidity
StableCoin
contract StableCoin is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; constructor(string name, string symbol, uint8 decimals, uint256 totalSupply) public { _name = name; _symbol = symbol; _decimals = decimals; _totalSupply = totalSupply; _balances[msg.sender] = _balances[msg.sender].add(_totalSupply); emit Transfer(address(0), msg.sender, totalSupply); } /** * @return the name of the token. */ function name() public view returns(string) { return _name; } /** * @return the symbol of the token. */ function symbol() public view returns(string) { return _symbol; } /** * @return the number of decimals of the token. */ function decimals() public view returns(uint8) { return _decimals; } /** * @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 balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } /** * @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 Transfer token for a specified address * @param to The address to transfer to. * @param value The amount to be transferred. */ function transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, to, value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */ function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _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(value <= _allowed[from][msg.sender]); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param addedValue The amount of tokens to increase the allowance by. */ function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Transfer token for a specified addresses * @param from The address to transfer from. * @param to The address to transfer to. * @param value The amount to be transferred. */ function _transfer(address from, address to, uint256 value) internal { require(value <= _balances[from]); require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } }
balanceOf
function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; }
/** * @dev Gets the balance of the specified address. * @param owner The address to query the balance of. * @return An uint256 representing the amount owned by the passed address. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
None
bzzr://e35191faeaf754c518bef8c1ba3b812474cd40b050752aa462c281006bd2ebf1
{ "func_code_index": [ 1385, 1488 ] }
7,735
StableCoin
StableCoin.sol
0xfa654d0702ffdae6fe30272639c83ec4cbfe6d7d
Solidity
StableCoin
contract StableCoin is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; constructor(string name, string symbol, uint8 decimals, uint256 totalSupply) public { _name = name; _symbol = symbol; _decimals = decimals; _totalSupply = totalSupply; _balances[msg.sender] = _balances[msg.sender].add(_totalSupply); emit Transfer(address(0), msg.sender, totalSupply); } /** * @return the name of the token. */ function name() public view returns(string) { return _name; } /** * @return the symbol of the token. */ function symbol() public view returns(string) { return _symbol; } /** * @return the number of decimals of the token. */ function decimals() public view returns(uint8) { return _decimals; } /** * @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 balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } /** * @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 Transfer token for a specified address * @param to The address to transfer to. * @param value The amount to be transferred. */ function transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, to, value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */ function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _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(value <= _allowed[from][msg.sender]); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param addedValue The amount of tokens to increase the allowance by. */ function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Transfer token for a specified addresses * @param from The address to transfer from. * @param to The address to transfer to. * @param value The amount to be transferred. */ function _transfer(address from, address to, uint256 value) internal { require(value <= _balances[from]); require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, 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
None
bzzr://e35191faeaf754c518bef8c1ba3b812474cd40b050752aa462c281006bd2ebf1
{ "func_code_index": [ 1810, 1972 ] }
7,736
StableCoin
StableCoin.sol
0xfa654d0702ffdae6fe30272639c83ec4cbfe6d7d
Solidity
StableCoin
contract StableCoin is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; constructor(string name, string symbol, uint8 decimals, uint256 totalSupply) public { _name = name; _symbol = symbol; _decimals = decimals; _totalSupply = totalSupply; _balances[msg.sender] = _balances[msg.sender].add(_totalSupply); emit Transfer(address(0), msg.sender, totalSupply); } /** * @return the name of the token. */ function name() public view returns(string) { return _name; } /** * @return the symbol of the token. */ function symbol() public view returns(string) { return _symbol; } /** * @return the number of decimals of the token. */ function decimals() public view returns(uint8) { return _decimals; } /** * @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 balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } /** * @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 Transfer token for a specified address * @param to The address to transfer to. * @param value The amount to be transferred. */ function transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, to, value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */ function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _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(value <= _allowed[from][msg.sender]); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param addedValue The amount of tokens to increase the allowance by. */ function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Transfer token for a specified addresses * @param from The address to transfer from. * @param to The address to transfer to. * @param value The amount to be transferred. */ function _transfer(address from, address to, uint256 value) internal { require(value <= _balances[from]); require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } }
transfer
function transfer(address to, uint256 value) public returns (bool) { _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
None
bzzr://e35191faeaf754c518bef8c1ba3b812474cd40b050752aa462c281006bd2ebf1
{ "func_code_index": [ 2128, 2261 ] }
7,737
StableCoin
StableCoin.sol
0xfa654d0702ffdae6fe30272639c83ec4cbfe6d7d
Solidity
StableCoin
contract StableCoin is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; constructor(string name, string symbol, uint8 decimals, uint256 totalSupply) public { _name = name; _symbol = symbol; _decimals = decimals; _totalSupply = totalSupply; _balances[msg.sender] = _balances[msg.sender].add(_totalSupply); emit Transfer(address(0), msg.sender, totalSupply); } /** * @return the name of the token. */ function name() public view returns(string) { return _name; } /** * @return the symbol of the token. */ function symbol() public view returns(string) { return _symbol; } /** * @return the number of decimals of the token. */ function decimals() public view returns(uint8) { return _decimals; } /** * @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 balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } /** * @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 Transfer token for a specified address * @param to The address to transfer to. * @param value The amount to be transferred. */ function transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, to, value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */ function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _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(value <= _allowed[from][msg.sender]); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param addedValue The amount of tokens to increase the allowance by. */ function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Transfer token for a specified addresses * @param from The address to transfer from. * @param to The address to transfer to. * @param value The amount to be transferred. */ function _transfer(address from, address to, uint256 value) internal { require(value <= _balances[from]); require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } }
approve
function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; }
/** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
None
bzzr://e35191faeaf754c518bef8c1ba3b812474cd40b050752aa462c281006bd2ebf1
{ "func_code_index": [ 2885, 3114 ] }
7,738
StableCoin
StableCoin.sol
0xfa654d0702ffdae6fe30272639c83ec4cbfe6d7d
Solidity
StableCoin
contract StableCoin is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; constructor(string name, string symbol, uint8 decimals, uint256 totalSupply) public { _name = name; _symbol = symbol; _decimals = decimals; _totalSupply = totalSupply; _balances[msg.sender] = _balances[msg.sender].add(_totalSupply); emit Transfer(address(0), msg.sender, totalSupply); } /** * @return the name of the token. */ function name() public view returns(string) { return _name; } /** * @return the symbol of the token. */ function symbol() public view returns(string) { return _symbol; } /** * @return the number of decimals of the token. */ function decimals() public view returns(uint8) { return _decimals; } /** * @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 balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } /** * @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 Transfer token for a specified address * @param to The address to transfer to. * @param value The amount to be transferred. */ function transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, to, value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */ function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _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(value <= _allowed[from][msg.sender]); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param addedValue The amount of tokens to increase the allowance by. */ function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Transfer token for a specified addresses * @param from The address to transfer from. * @param to The address to transfer to. * @param value The amount to be transferred. */ function _transfer(address from, address to, uint256 value) internal { require(value <= _balances[from]); require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } }
transferFrom
function transferFrom( address from, address to, uint256 value ) public returns (bool) { require(value <= _allowed[from][msg.sender]); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _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
None
bzzr://e35191faeaf754c518bef8c1ba3b812474cd40b050752aa462c281006bd2ebf1
{ "func_code_index": [ 3391, 3695 ] }
7,739
StableCoin
StableCoin.sol
0xfa654d0702ffdae6fe30272639c83ec4cbfe6d7d
Solidity
StableCoin
contract StableCoin is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; constructor(string name, string symbol, uint8 decimals, uint256 totalSupply) public { _name = name; _symbol = symbol; _decimals = decimals; _totalSupply = totalSupply; _balances[msg.sender] = _balances[msg.sender].add(_totalSupply); emit Transfer(address(0), msg.sender, totalSupply); } /** * @return the name of the token. */ function name() public view returns(string) { return _name; } /** * @return the symbol of the token. */ function symbol() public view returns(string) { return _symbol; } /** * @return the number of decimals of the token. */ function decimals() public view returns(uint8) { return _decimals; } /** * @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 balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } /** * @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 Transfer token for a specified address * @param to The address to transfer to. * @param value The amount to be transferred. */ function transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, to, value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */ function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _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(value <= _allowed[from][msg.sender]); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param addedValue The amount of tokens to increase the allowance by. */ function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Transfer token for a specified addresses * @param from The address to transfer from. * @param to The address to transfer to. * @param value The amount to be transferred. */ function _transfer(address from, address to, uint256 value) internal { require(value <= _balances[from]); require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } }
increaseAllowance
function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; }
/** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param addedValue The amount of tokens to increase the allowance by. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
None
bzzr://e35191faeaf754c518bef8c1ba3b812474cd40b050752aa462c281006bd2ebf1
{ "func_code_index": [ 4154, 4500 ] }
7,740
StableCoin
StableCoin.sol
0xfa654d0702ffdae6fe30272639c83ec4cbfe6d7d
Solidity
StableCoin
contract StableCoin is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; constructor(string name, string symbol, uint8 decimals, uint256 totalSupply) public { _name = name; _symbol = symbol; _decimals = decimals; _totalSupply = totalSupply; _balances[msg.sender] = _balances[msg.sender].add(_totalSupply); emit Transfer(address(0), msg.sender, totalSupply); } /** * @return the name of the token. */ function name() public view returns(string) { return _name; } /** * @return the symbol of the token. */ function symbol() public view returns(string) { return _symbol; } /** * @return the number of decimals of the token. */ function decimals() public view returns(uint8) { return _decimals; } /** * @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 balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } /** * @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 Transfer token for a specified address * @param to The address to transfer to. * @param value The amount to be transferred. */ function transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, to, value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */ function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _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(value <= _allowed[from][msg.sender]); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param addedValue The amount of tokens to increase the allowance by. */ function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Transfer token for a specified addresses * @param from The address to transfer from. * @param to The address to transfer to. * @param value The amount to be transferred. */ function _transfer(address from, address to, uint256 value) internal { require(value <= _balances[from]); require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } }
decreaseAllowance
function decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; }
/** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param subtractedValue The amount of tokens to decrease the allowance by. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
None
bzzr://e35191faeaf754c518bef8c1ba3b812474cd40b050752aa462c281006bd2ebf1
{ "func_code_index": [ 4964, 5320 ] }
7,741
StableCoin
StableCoin.sol
0xfa654d0702ffdae6fe30272639c83ec4cbfe6d7d
Solidity
StableCoin
contract StableCoin is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; constructor(string name, string symbol, uint8 decimals, uint256 totalSupply) public { _name = name; _symbol = symbol; _decimals = decimals; _totalSupply = totalSupply; _balances[msg.sender] = _balances[msg.sender].add(_totalSupply); emit Transfer(address(0), msg.sender, totalSupply); } /** * @return the name of the token. */ function name() public view returns(string) { return _name; } /** * @return the symbol of the token. */ function symbol() public view returns(string) { return _symbol; } /** * @return the number of decimals of the token. */ function decimals() public view returns(uint8) { return _decimals; } /** * @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 balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } /** * @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 Transfer token for a specified address * @param to The address to transfer to. * @param value The amount to be transferred. */ function transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, to, value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */ function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _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(value <= _allowed[from][msg.sender]); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param addedValue The amount of tokens to increase the allowance by. */ function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param spender The address which will spend the funds. * @param subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Transfer token for a specified addresses * @param from The address to transfer from. * @param to The address to transfer to. * @param value The amount to be transferred. */ function _transfer(address from, address to, uint256 value) internal { require(value <= _balances[from]); require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } }
_transfer
function _transfer(address from, address to, uint256 value) internal { require(value <= _balances[from]); require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); }
/** * @dev Transfer token for a specified addresses * @param from The address to transfer from. * @param to The address to transfer to. * @param value The amount to be transferred. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
None
bzzr://e35191faeaf754c518bef8c1ba3b812474cd40b050752aa462c281006bd2ebf1
{ "func_code_index": [ 5525, 5812 ] }
7,742
CredoIco
CredoIco.sol
0xd6a81d7a8b4d1cc947138d9e4aca5d3cde33a170
Solidity
SafeMath
contract SafeMath { function assert(bool assertion) internal { if (!assertion) { throw; } } // assert no longer needed once solidity is on 0.4.10 function safeAdd(uint256 x, uint256 y) internal returns(uint256) { uint256 z = x + y; assert((z >= x) && (z >= y)); return z; } function safeSubtract(uint256 x, uint256 y) internal returns(uint256) { assert(x >= y); uint256 z = x - y; return z; } function safeMult(uint256 x, uint256 y) internal returns(uint256) { uint256 z = x * y; assert((x == 0)||(z/x == y)); return z; } }
///////////////
NatSpecSingleLine
safeAdd
function safeAdd(uint256 x, uint256 y) internal returns(uint256) { uint256 z = x + y; assert((z >= x) && (z >= y)); return z; }
// assert no longer needed once solidity is on 0.4.10
LineComment
v0.4.8+commit.60cc1668
bzzr://123314378ad61d631e9cbea23008e96bf47e26ec663339416a4e52d79d8d4499
{ "func_code_index": [ 197, 355 ] }
7,743
CredoIco
CredoIco.sol
0xd6a81d7a8b4d1cc947138d9e4aca5d3cde33a170
Solidity
CredoIco
contract CredoIco is StandardToken, SafeMath { // Descriptive properties string public constant name = "Credo ICO Token"; string public constant symbol = "CREDOICO"; uint256 public constant decimals = 18; string public version = "1.0"; // Account for ether proceed. address public etherProceedsAccount; // These params specify the start, end, min, and max of the sale. bool public isFinalized; uint256 public fundingStartBlock; uint256 public fundingEndBlock; uint256 public constant tokenCreationCap = 375200000 * 10**decimals; uint256 public constant tokenCreationMin = 938000 * 10**decimals; // Setting the exchange rate for the first part of the ICO. uint256 public constant credoEthExchangeRate = 3752; // Events for logging refunds and token creation. event LogRefund(address indexed _to, uint256 _value); event CreateCredoIco(address indexed _to, uint256 _value); // constructor function CredoIco(address _etherProceedsAccount, uint256 _fundingStartBlock, uint256 _fundingEndBlock) { isFinalized = false; etherProceedsAccount = _etherProceedsAccount; fundingStartBlock = _fundingStartBlock; fundingEndBlock = _fundingEndBlock; totalSupply = 0; } function createTokens() payable external { if (isFinalized) throw; if (block.number < fundingStartBlock) throw; if (block.number > fundingEndBlock) throw; if (msg.value == 0) throw; uint256 tokens = safeMult(msg.value, credoEthExchangeRate); uint256 checkedSupply = safeAdd(totalSupply, tokens); if (tokenCreationCap < checkedSupply) throw; totalSupply = checkedSupply; balances[msg.sender] += tokens; CreateCredoIco(msg.sender, tokens); } function finalize() external { if (isFinalized) throw; if (msg.sender != etherProceedsAccount) throw; if (totalSupply < tokenCreationMin) throw; if (block.number <= fundingEndBlock && totalSupply != tokenCreationCap) throw; isFinalized = true; if (!etherProceedsAccount.send(this.balance)) throw; } function refund() external { if (isFinalized) throw; if (block.number <= fundingEndBlock) throw; if (totalSupply >= tokenCreationMin) throw; uint256 credoVal = balances[msg.sender]; if (credoVal == 0) throw; balances[msg.sender] = 0; totalSupply = safeSubtract(totalSupply, credoVal); uint256 ethVal = credoVal / credoEthExchangeRate; LogRefund(msg.sender, ethVal); if (!msg.sender.send(ethVal)) throw; } }
/////////////////////
NatSpecSingleLine
CredoIco
function CredoIco(address _etherProceedsAccount, uint256 _fundingStartBlock, uint256 _fundingEndBlock) { isFinalized = false; etherProceedsAccount = _etherProceedsAccount; fundingStartBlock = _fundingStartBlock; fundingEndBlock = _fundingEndBlock; totalSupply = 0; }
// constructor
LineComment
v0.4.8+commit.60cc1668
bzzr://123314378ad61d631e9cbea23008e96bf47e26ec663339416a4e52d79d8d4499
{ "func_code_index": [ 996, 1388 ] }
7,744
SuperRocks
@openzeppelin/contracts/interfaces/IERC2981.sol
0xf66bb6beebd5942d71e5e64e6008ef722f90a050
Solidity
IERC2981
interface IERC2981 is IERC165 { /** * @dev Called with the sale price to determine how much royalty is owed and to whom. * @param tokenId - the NFT asset queried for royalty information * @param salePrice - the sale price of the NFT asset specified by `tokenId` * @return receiver - address of who should be sent the royalty payment * @return royaltyAmount - the royalty payment amount for `salePrice` */ function royaltyInfo(uint256 tokenId, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount); }
/** * @dev Interface for the NFT Royalty Standard */
NatSpecMultiLine
royaltyInfo
function royaltyInfo(uint256 tokenId, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount);
/** * @dev Called with the sale price to determine how much royalty is owed and to whom. * @param tokenId - the NFT asset queried for royalty information * @param salePrice - the sale price of the NFT asset specified by `tokenId` * @return receiver - address of who should be sent the royalty payment * @return royaltyAmount - the royalty payment amount for `salePrice` */
NatSpecMultiLine
v0.8.9+commit.e5eed63a
{ "func_code_index": [ 439, 588 ] }
7,745
BattleRoyaleNoPrize
contracts/BattleRoyaleNoPrize.sol
0x29067696005279487ba66a46527087fb078286a6
Solidity
BattleRoyaleNoPrize
contract BattleRoyaleNoPrize is ERC721URIStorage, Ownable { using SafeERC20 for IERC20; using Strings for uint256; /// @notice Event emitted when contract is deployed. event BattleRoyaleDeployed(); /// @notice Event emitted when owner withdrew the ETH. event EthWithdrew(address receiver); /// @notice Event emitted when owner withdrew the ERC20 token. event ERC20TokenWithdrew(address receiver); /// @notice Event emitted when user purchased the tokens. event Purchased(address user, uint256 amount, uint256 totalSupply); /// @notice Event emitted when owner has set starting time. event StartingTimeSet(uint256 time); /// @notice Event emitted when battle has started. event BattleStarted(address battleAddress, uint32[] inPlay); /// @notice Event emitted when battle has ended. event BattleEnded( address battleAddress, uint256 tokenId, uint256 winnerTokenId, string prizeTokenURI ); /// @notice Event emitted when base token uri set. event BaseURISet(string baseURI); /// @notice Event emitted when default token uri set. event DefaultTokenURISet(string defaultTokenURI); /// @notice Event emitted when prize token uri set. event PrizeTokenURISet(string prizeTokenURI); /// @notice Event emitted when interval time set. event IntervalTimeSet(uint256 intervalTime); /// @notice Event emitted when token price set. event PriceSet(uint256 price); /// @notice Event emitted when the units per transaction set. event UnitsPerTransactionSet(uint256 unitsPerTransaction); /// @notice Event emitted when max supply set. event MaxSupplySet(uint256 maxSupply); enum BATTLE_STATE { STANDBY, RUNNING, ENDED } BATTLE_STATE public battleState; string public baseURI; string public defaultTokenURI; string public prizeTokenURI; uint256 public price; uint256 public maxSupply; uint256 public totalSupply; uint256 public unitsPerTransaction; uint256 public startingTime; uint32[] public inPlay; /** * @dev Constructor function * @param _name Token name * @param _symbol Token symbol * @param _price Token price * @param _unitsPerTransaction Purchasable token amounts per transaction * @param _maxSupply Maximum number of mintable tokens * @param _defaultTokenURI Deafult token uri * @param _prizeTokenURI Prize token uri * @param _baseURI Base token uri * @param _startingTime Start time to purchase NFT */ constructor( string memory _name, string memory _symbol, uint256 _price, uint256 _unitsPerTransaction, uint256 _maxSupply, string memory _baseURI, string memory _defaultTokenURI, string memory _prizeTokenURI, uint256 _startingTime ) ERC721(_name, _symbol) { battleState = BATTLE_STATE.STANDBY; price = _price; unitsPerTransaction = _unitsPerTransaction; maxSupply = _maxSupply; baseURI = _baseURI; defaultTokenURI = _defaultTokenURI; prizeTokenURI = _prizeTokenURI; startingTime = _startingTime; emit BattleRoyaleDeployed(); } /** * @dev External function to purchase tokens. * @param _amount Token amount to buy */ function purchase(uint256 _amount) external payable { require(price > 0, "Token price is zero"); require(battleState == BATTLE_STATE.STANDBY, "Not ready to purchase tokens"); require(maxSupply > 0 && totalSupply < maxSupply, "All NFTs were sold out"); require(block.timestamp >= startingTime, "Not time to purchase"); if (msg.sender != owner()) { require( _amount <= maxSupply - totalSupply && _amount > 0 && _amount <= unitsPerTransaction, "Out range of token amount" ); require(bytes(defaultTokenURI).length > 0, "Default token URI is not set"); require(msg.value >= (price * _amount), "Not enough ETH for buying tokens"); } for (uint256 i = 0; i < _amount; i++) { uint256 tokenId = totalSupply + i + 1; _safeMint(msg.sender, tokenId); string memory tokenURI = string(abi.encodePacked(baseURI, defaultTokenURI)); _setTokenURI(tokenId, tokenURI); inPlay.push(uint32(tokenId)); } totalSupply += _amount; emit Purchased(msg.sender, _amount, totalSupply); } /** * @dev External function to set starting time. This function can be called only by owner. */ function setStartingTime(uint256 _newTime) external onlyOwner { startingTime = _newTime; emit StartingTimeSet(_newTime); } /** * @dev External function to start the battle. This function can be called only by owner. */ function startBattle() external onlyOwner { require(bytes(prizeTokenURI).length > 0 && inPlay.length > 1, "Not enough tokens to play"); battleState = BATTLE_STATE.RUNNING; emit BattleStarted(address(this), inPlay); } /** * @dev External function to end the battle. This function can be called only by owner. * @param _winnerTokenId Winner token Id in battle */ function endBattle(uint256 _winnerTokenId) external onlyOwner { require(battleState == BATTLE_STATE.RUNNING, "Battle is not started"); battleState = BATTLE_STATE.ENDED; string memory tokenURI = string(abi.encodePacked(baseURI, prizeTokenURI)); emit BattleEnded(address(this), _winnerTokenId, _winnerTokenId, tokenURI); } /** * @dev External function to set the base token URI. This function can be called only by owner. * @param _tokenURI New base token uri */ function setBaseURI(string memory _tokenURI) external onlyOwner { baseURI = _tokenURI; emit BaseURISet(baseURI); } /** * @dev External function to set the default token URI. This function can be called only by owner. * @param _tokenURI New default token uri */ function setDefaultTokenURI(string memory _tokenURI) external onlyOwner { defaultTokenURI = _tokenURI; emit DefaultTokenURISet(defaultTokenURI); } /** * @dev External function to set the prize token URI. This function can be called only by owner. * @param _tokenURI New prize token uri */ function setPrizeTokenURI(string memory _tokenURI) external onlyOwner { prizeTokenURI = _tokenURI; emit PrizeTokenURISet(prizeTokenURI); } /** * @dev External function to set the token price. This function can be called only by owner. * @param _price New token price */ function setPrice(uint256 _price) external onlyOwner { price = _price; emit PriceSet(price); } /** * @dev External function to set the limit of buyable token amounts. This function can be called only by owner. * @param _unitsPerTransaction New purchasable token amounts per transaction */ function setUnitsPerTransaction(uint256 _unitsPerTransaction) external onlyOwner { unitsPerTransaction = _unitsPerTransaction; emit UnitsPerTransactionSet(unitsPerTransaction); } /** * @dev External function to set max supply. This function can be called only by owner. * @param _maxSupply New maximum token amounts */ function setMaxSupply(uint256 _maxSupply) external onlyOwner { maxSupply = _maxSupply; emit MaxSupplySet(maxSupply); } /** * Fallback function to receive ETH */ receive() external payable {} /** * @dev External function to withdraw ETH in contract. This function can be called only by owner. * @param _amount ETH amount */ function withdrawETH(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(_amount <= balance, "Out of balance"); payable(msg.sender).transfer(_amount); emit EthWithdrew(msg.sender); } /** * @dev External function to withdraw ERC-20 tokens in contract. This function can be called only by owner. * @param _tokenAddr Address of ERC-20 token * @param _amount ERC-20 token amount */ function withdrawERC20Token(address _tokenAddr, uint256 _amount) external onlyOwner { IERC20 token = IERC20(_tokenAddr); uint256 balance = token.balanceOf(address(this)); require(_amount <= balance, "Out of balance"); token.safeTransfer(msg.sender, _amount); emit ERC20TokenWithdrew(msg.sender); } }
purchase
function purchase(uint256 _amount) external payable { require(price > 0, "Token price is zero"); require(battleState == BATTLE_STATE.STANDBY, "Not ready to purchase tokens"); require(maxSupply > 0 && totalSupply < maxSupply, "All NFTs were sold out"); require(block.timestamp >= startingTime, "Not time to purchase"); if (msg.sender != owner()) { require( _amount <= maxSupply - totalSupply && _amount > 0 && _amount <= unitsPerTransaction, "Out range of token amount" ); require(bytes(defaultTokenURI).length > 0, "Default token URI is not set"); require(msg.value >= (price * _amount), "Not enough ETH for buying tokens"); } for (uint256 i = 0; i < _amount; i++) { uint256 tokenId = totalSupply + i + 1; _safeMint(msg.sender, tokenId); string memory tokenURI = string(abi.encodePacked(baseURI, defaultTokenURI)); _setTokenURI(tokenId, tokenURI); inPlay.push(uint32(tokenId)); } totalSupply += _amount; emit Purchased(msg.sender, _amount, totalSupply); }
/** * @dev External function to purchase tokens. * @param _amount Token amount to buy */
NatSpecMultiLine
v0.8.6+commit.11564f7e
{ "func_code_index": [ 3170, 4247 ] }
7,746
BattleRoyaleNoPrize
contracts/BattleRoyaleNoPrize.sol
0x29067696005279487ba66a46527087fb078286a6
Solidity
BattleRoyaleNoPrize
contract BattleRoyaleNoPrize is ERC721URIStorage, Ownable { using SafeERC20 for IERC20; using Strings for uint256; /// @notice Event emitted when contract is deployed. event BattleRoyaleDeployed(); /// @notice Event emitted when owner withdrew the ETH. event EthWithdrew(address receiver); /// @notice Event emitted when owner withdrew the ERC20 token. event ERC20TokenWithdrew(address receiver); /// @notice Event emitted when user purchased the tokens. event Purchased(address user, uint256 amount, uint256 totalSupply); /// @notice Event emitted when owner has set starting time. event StartingTimeSet(uint256 time); /// @notice Event emitted when battle has started. event BattleStarted(address battleAddress, uint32[] inPlay); /// @notice Event emitted when battle has ended. event BattleEnded( address battleAddress, uint256 tokenId, uint256 winnerTokenId, string prizeTokenURI ); /// @notice Event emitted when base token uri set. event BaseURISet(string baseURI); /// @notice Event emitted when default token uri set. event DefaultTokenURISet(string defaultTokenURI); /// @notice Event emitted when prize token uri set. event PrizeTokenURISet(string prizeTokenURI); /// @notice Event emitted when interval time set. event IntervalTimeSet(uint256 intervalTime); /// @notice Event emitted when token price set. event PriceSet(uint256 price); /// @notice Event emitted when the units per transaction set. event UnitsPerTransactionSet(uint256 unitsPerTransaction); /// @notice Event emitted when max supply set. event MaxSupplySet(uint256 maxSupply); enum BATTLE_STATE { STANDBY, RUNNING, ENDED } BATTLE_STATE public battleState; string public baseURI; string public defaultTokenURI; string public prizeTokenURI; uint256 public price; uint256 public maxSupply; uint256 public totalSupply; uint256 public unitsPerTransaction; uint256 public startingTime; uint32[] public inPlay; /** * @dev Constructor function * @param _name Token name * @param _symbol Token symbol * @param _price Token price * @param _unitsPerTransaction Purchasable token amounts per transaction * @param _maxSupply Maximum number of mintable tokens * @param _defaultTokenURI Deafult token uri * @param _prizeTokenURI Prize token uri * @param _baseURI Base token uri * @param _startingTime Start time to purchase NFT */ constructor( string memory _name, string memory _symbol, uint256 _price, uint256 _unitsPerTransaction, uint256 _maxSupply, string memory _baseURI, string memory _defaultTokenURI, string memory _prizeTokenURI, uint256 _startingTime ) ERC721(_name, _symbol) { battleState = BATTLE_STATE.STANDBY; price = _price; unitsPerTransaction = _unitsPerTransaction; maxSupply = _maxSupply; baseURI = _baseURI; defaultTokenURI = _defaultTokenURI; prizeTokenURI = _prizeTokenURI; startingTime = _startingTime; emit BattleRoyaleDeployed(); } /** * @dev External function to purchase tokens. * @param _amount Token amount to buy */ function purchase(uint256 _amount) external payable { require(price > 0, "Token price is zero"); require(battleState == BATTLE_STATE.STANDBY, "Not ready to purchase tokens"); require(maxSupply > 0 && totalSupply < maxSupply, "All NFTs were sold out"); require(block.timestamp >= startingTime, "Not time to purchase"); if (msg.sender != owner()) { require( _amount <= maxSupply - totalSupply && _amount > 0 && _amount <= unitsPerTransaction, "Out range of token amount" ); require(bytes(defaultTokenURI).length > 0, "Default token URI is not set"); require(msg.value >= (price * _amount), "Not enough ETH for buying tokens"); } for (uint256 i = 0; i < _amount; i++) { uint256 tokenId = totalSupply + i + 1; _safeMint(msg.sender, tokenId); string memory tokenURI = string(abi.encodePacked(baseURI, defaultTokenURI)); _setTokenURI(tokenId, tokenURI); inPlay.push(uint32(tokenId)); } totalSupply += _amount; emit Purchased(msg.sender, _amount, totalSupply); } /** * @dev External function to set starting time. This function can be called only by owner. */ function setStartingTime(uint256 _newTime) external onlyOwner { startingTime = _newTime; emit StartingTimeSet(_newTime); } /** * @dev External function to start the battle. This function can be called only by owner. */ function startBattle() external onlyOwner { require(bytes(prizeTokenURI).length > 0 && inPlay.length > 1, "Not enough tokens to play"); battleState = BATTLE_STATE.RUNNING; emit BattleStarted(address(this), inPlay); } /** * @dev External function to end the battle. This function can be called only by owner. * @param _winnerTokenId Winner token Id in battle */ function endBattle(uint256 _winnerTokenId) external onlyOwner { require(battleState == BATTLE_STATE.RUNNING, "Battle is not started"); battleState = BATTLE_STATE.ENDED; string memory tokenURI = string(abi.encodePacked(baseURI, prizeTokenURI)); emit BattleEnded(address(this), _winnerTokenId, _winnerTokenId, tokenURI); } /** * @dev External function to set the base token URI. This function can be called only by owner. * @param _tokenURI New base token uri */ function setBaseURI(string memory _tokenURI) external onlyOwner { baseURI = _tokenURI; emit BaseURISet(baseURI); } /** * @dev External function to set the default token URI. This function can be called only by owner. * @param _tokenURI New default token uri */ function setDefaultTokenURI(string memory _tokenURI) external onlyOwner { defaultTokenURI = _tokenURI; emit DefaultTokenURISet(defaultTokenURI); } /** * @dev External function to set the prize token URI. This function can be called only by owner. * @param _tokenURI New prize token uri */ function setPrizeTokenURI(string memory _tokenURI) external onlyOwner { prizeTokenURI = _tokenURI; emit PrizeTokenURISet(prizeTokenURI); } /** * @dev External function to set the token price. This function can be called only by owner. * @param _price New token price */ function setPrice(uint256 _price) external onlyOwner { price = _price; emit PriceSet(price); } /** * @dev External function to set the limit of buyable token amounts. This function can be called only by owner. * @param _unitsPerTransaction New purchasable token amounts per transaction */ function setUnitsPerTransaction(uint256 _unitsPerTransaction) external onlyOwner { unitsPerTransaction = _unitsPerTransaction; emit UnitsPerTransactionSet(unitsPerTransaction); } /** * @dev External function to set max supply. This function can be called only by owner. * @param _maxSupply New maximum token amounts */ function setMaxSupply(uint256 _maxSupply) external onlyOwner { maxSupply = _maxSupply; emit MaxSupplySet(maxSupply); } /** * Fallback function to receive ETH */ receive() external payable {} /** * @dev External function to withdraw ETH in contract. This function can be called only by owner. * @param _amount ETH amount */ function withdrawETH(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(_amount <= balance, "Out of balance"); payable(msg.sender).transfer(_amount); emit EthWithdrew(msg.sender); } /** * @dev External function to withdraw ERC-20 tokens in contract. This function can be called only by owner. * @param _tokenAddr Address of ERC-20 token * @param _amount ERC-20 token amount */ function withdrawERC20Token(address _tokenAddr, uint256 _amount) external onlyOwner { IERC20 token = IERC20(_tokenAddr); uint256 balance = token.balanceOf(address(this)); require(_amount <= balance, "Out of balance"); token.safeTransfer(msg.sender, _amount); emit ERC20TokenWithdrew(msg.sender); } }
setStartingTime
function setStartingTime(uint256 _newTime) external onlyOwner { startingTime = _newTime; emit StartingTimeSet(_newTime); }
/** * @dev External function to set starting time. This function can be called only by owner. */
NatSpecMultiLine
v0.8.6+commit.11564f7e
{ "func_code_index": [ 4354, 4489 ] }
7,747
BattleRoyaleNoPrize
contracts/BattleRoyaleNoPrize.sol
0x29067696005279487ba66a46527087fb078286a6
Solidity
BattleRoyaleNoPrize
contract BattleRoyaleNoPrize is ERC721URIStorage, Ownable { using SafeERC20 for IERC20; using Strings for uint256; /// @notice Event emitted when contract is deployed. event BattleRoyaleDeployed(); /// @notice Event emitted when owner withdrew the ETH. event EthWithdrew(address receiver); /// @notice Event emitted when owner withdrew the ERC20 token. event ERC20TokenWithdrew(address receiver); /// @notice Event emitted when user purchased the tokens. event Purchased(address user, uint256 amount, uint256 totalSupply); /// @notice Event emitted when owner has set starting time. event StartingTimeSet(uint256 time); /// @notice Event emitted when battle has started. event BattleStarted(address battleAddress, uint32[] inPlay); /// @notice Event emitted when battle has ended. event BattleEnded( address battleAddress, uint256 tokenId, uint256 winnerTokenId, string prizeTokenURI ); /// @notice Event emitted when base token uri set. event BaseURISet(string baseURI); /// @notice Event emitted when default token uri set. event DefaultTokenURISet(string defaultTokenURI); /// @notice Event emitted when prize token uri set. event PrizeTokenURISet(string prizeTokenURI); /// @notice Event emitted when interval time set. event IntervalTimeSet(uint256 intervalTime); /// @notice Event emitted when token price set. event PriceSet(uint256 price); /// @notice Event emitted when the units per transaction set. event UnitsPerTransactionSet(uint256 unitsPerTransaction); /// @notice Event emitted when max supply set. event MaxSupplySet(uint256 maxSupply); enum BATTLE_STATE { STANDBY, RUNNING, ENDED } BATTLE_STATE public battleState; string public baseURI; string public defaultTokenURI; string public prizeTokenURI; uint256 public price; uint256 public maxSupply; uint256 public totalSupply; uint256 public unitsPerTransaction; uint256 public startingTime; uint32[] public inPlay; /** * @dev Constructor function * @param _name Token name * @param _symbol Token symbol * @param _price Token price * @param _unitsPerTransaction Purchasable token amounts per transaction * @param _maxSupply Maximum number of mintable tokens * @param _defaultTokenURI Deafult token uri * @param _prizeTokenURI Prize token uri * @param _baseURI Base token uri * @param _startingTime Start time to purchase NFT */ constructor( string memory _name, string memory _symbol, uint256 _price, uint256 _unitsPerTransaction, uint256 _maxSupply, string memory _baseURI, string memory _defaultTokenURI, string memory _prizeTokenURI, uint256 _startingTime ) ERC721(_name, _symbol) { battleState = BATTLE_STATE.STANDBY; price = _price; unitsPerTransaction = _unitsPerTransaction; maxSupply = _maxSupply; baseURI = _baseURI; defaultTokenURI = _defaultTokenURI; prizeTokenURI = _prizeTokenURI; startingTime = _startingTime; emit BattleRoyaleDeployed(); } /** * @dev External function to purchase tokens. * @param _amount Token amount to buy */ function purchase(uint256 _amount) external payable { require(price > 0, "Token price is zero"); require(battleState == BATTLE_STATE.STANDBY, "Not ready to purchase tokens"); require(maxSupply > 0 && totalSupply < maxSupply, "All NFTs were sold out"); require(block.timestamp >= startingTime, "Not time to purchase"); if (msg.sender != owner()) { require( _amount <= maxSupply - totalSupply && _amount > 0 && _amount <= unitsPerTransaction, "Out range of token amount" ); require(bytes(defaultTokenURI).length > 0, "Default token URI is not set"); require(msg.value >= (price * _amount), "Not enough ETH for buying tokens"); } for (uint256 i = 0; i < _amount; i++) { uint256 tokenId = totalSupply + i + 1; _safeMint(msg.sender, tokenId); string memory tokenURI = string(abi.encodePacked(baseURI, defaultTokenURI)); _setTokenURI(tokenId, tokenURI); inPlay.push(uint32(tokenId)); } totalSupply += _amount; emit Purchased(msg.sender, _amount, totalSupply); } /** * @dev External function to set starting time. This function can be called only by owner. */ function setStartingTime(uint256 _newTime) external onlyOwner { startingTime = _newTime; emit StartingTimeSet(_newTime); } /** * @dev External function to start the battle. This function can be called only by owner. */ function startBattle() external onlyOwner { require(bytes(prizeTokenURI).length > 0 && inPlay.length > 1, "Not enough tokens to play"); battleState = BATTLE_STATE.RUNNING; emit BattleStarted(address(this), inPlay); } /** * @dev External function to end the battle. This function can be called only by owner. * @param _winnerTokenId Winner token Id in battle */ function endBattle(uint256 _winnerTokenId) external onlyOwner { require(battleState == BATTLE_STATE.RUNNING, "Battle is not started"); battleState = BATTLE_STATE.ENDED; string memory tokenURI = string(abi.encodePacked(baseURI, prizeTokenURI)); emit BattleEnded(address(this), _winnerTokenId, _winnerTokenId, tokenURI); } /** * @dev External function to set the base token URI. This function can be called only by owner. * @param _tokenURI New base token uri */ function setBaseURI(string memory _tokenURI) external onlyOwner { baseURI = _tokenURI; emit BaseURISet(baseURI); } /** * @dev External function to set the default token URI. This function can be called only by owner. * @param _tokenURI New default token uri */ function setDefaultTokenURI(string memory _tokenURI) external onlyOwner { defaultTokenURI = _tokenURI; emit DefaultTokenURISet(defaultTokenURI); } /** * @dev External function to set the prize token URI. This function can be called only by owner. * @param _tokenURI New prize token uri */ function setPrizeTokenURI(string memory _tokenURI) external onlyOwner { prizeTokenURI = _tokenURI; emit PrizeTokenURISet(prizeTokenURI); } /** * @dev External function to set the token price. This function can be called only by owner. * @param _price New token price */ function setPrice(uint256 _price) external onlyOwner { price = _price; emit PriceSet(price); } /** * @dev External function to set the limit of buyable token amounts. This function can be called only by owner. * @param _unitsPerTransaction New purchasable token amounts per transaction */ function setUnitsPerTransaction(uint256 _unitsPerTransaction) external onlyOwner { unitsPerTransaction = _unitsPerTransaction; emit UnitsPerTransactionSet(unitsPerTransaction); } /** * @dev External function to set max supply. This function can be called only by owner. * @param _maxSupply New maximum token amounts */ function setMaxSupply(uint256 _maxSupply) external onlyOwner { maxSupply = _maxSupply; emit MaxSupplySet(maxSupply); } /** * Fallback function to receive ETH */ receive() external payable {} /** * @dev External function to withdraw ETH in contract. This function can be called only by owner. * @param _amount ETH amount */ function withdrawETH(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(_amount <= balance, "Out of balance"); payable(msg.sender).transfer(_amount); emit EthWithdrew(msg.sender); } /** * @dev External function to withdraw ERC-20 tokens in contract. This function can be called only by owner. * @param _tokenAddr Address of ERC-20 token * @param _amount ERC-20 token amount */ function withdrawERC20Token(address _tokenAddr, uint256 _amount) external onlyOwner { IERC20 token = IERC20(_tokenAddr); uint256 balance = token.balanceOf(address(this)); require(_amount <= balance, "Out of balance"); token.safeTransfer(msg.sender, _amount); emit ERC20TokenWithdrew(msg.sender); } }
startBattle
function startBattle() external onlyOwner { require(bytes(prizeTokenURI).length > 0 && inPlay.length > 1, "Not enough tokens to play"); battleState = BATTLE_STATE.RUNNING; emit BattleStarted(address(this), inPlay); }
/** * @dev External function to start the battle. This function can be called only by owner. */
NatSpecMultiLine
v0.8.6+commit.11564f7e
{ "func_code_index": [ 4595, 4828 ] }
7,748
BattleRoyaleNoPrize
contracts/BattleRoyaleNoPrize.sol
0x29067696005279487ba66a46527087fb078286a6
Solidity
BattleRoyaleNoPrize
contract BattleRoyaleNoPrize is ERC721URIStorage, Ownable { using SafeERC20 for IERC20; using Strings for uint256; /// @notice Event emitted when contract is deployed. event BattleRoyaleDeployed(); /// @notice Event emitted when owner withdrew the ETH. event EthWithdrew(address receiver); /// @notice Event emitted when owner withdrew the ERC20 token. event ERC20TokenWithdrew(address receiver); /// @notice Event emitted when user purchased the tokens. event Purchased(address user, uint256 amount, uint256 totalSupply); /// @notice Event emitted when owner has set starting time. event StartingTimeSet(uint256 time); /// @notice Event emitted when battle has started. event BattleStarted(address battleAddress, uint32[] inPlay); /// @notice Event emitted when battle has ended. event BattleEnded( address battleAddress, uint256 tokenId, uint256 winnerTokenId, string prizeTokenURI ); /// @notice Event emitted when base token uri set. event BaseURISet(string baseURI); /// @notice Event emitted when default token uri set. event DefaultTokenURISet(string defaultTokenURI); /// @notice Event emitted when prize token uri set. event PrizeTokenURISet(string prizeTokenURI); /// @notice Event emitted when interval time set. event IntervalTimeSet(uint256 intervalTime); /// @notice Event emitted when token price set. event PriceSet(uint256 price); /// @notice Event emitted when the units per transaction set. event UnitsPerTransactionSet(uint256 unitsPerTransaction); /// @notice Event emitted when max supply set. event MaxSupplySet(uint256 maxSupply); enum BATTLE_STATE { STANDBY, RUNNING, ENDED } BATTLE_STATE public battleState; string public baseURI; string public defaultTokenURI; string public prizeTokenURI; uint256 public price; uint256 public maxSupply; uint256 public totalSupply; uint256 public unitsPerTransaction; uint256 public startingTime; uint32[] public inPlay; /** * @dev Constructor function * @param _name Token name * @param _symbol Token symbol * @param _price Token price * @param _unitsPerTransaction Purchasable token amounts per transaction * @param _maxSupply Maximum number of mintable tokens * @param _defaultTokenURI Deafult token uri * @param _prizeTokenURI Prize token uri * @param _baseURI Base token uri * @param _startingTime Start time to purchase NFT */ constructor( string memory _name, string memory _symbol, uint256 _price, uint256 _unitsPerTransaction, uint256 _maxSupply, string memory _baseURI, string memory _defaultTokenURI, string memory _prizeTokenURI, uint256 _startingTime ) ERC721(_name, _symbol) { battleState = BATTLE_STATE.STANDBY; price = _price; unitsPerTransaction = _unitsPerTransaction; maxSupply = _maxSupply; baseURI = _baseURI; defaultTokenURI = _defaultTokenURI; prizeTokenURI = _prizeTokenURI; startingTime = _startingTime; emit BattleRoyaleDeployed(); } /** * @dev External function to purchase tokens. * @param _amount Token amount to buy */ function purchase(uint256 _amount) external payable { require(price > 0, "Token price is zero"); require(battleState == BATTLE_STATE.STANDBY, "Not ready to purchase tokens"); require(maxSupply > 0 && totalSupply < maxSupply, "All NFTs were sold out"); require(block.timestamp >= startingTime, "Not time to purchase"); if (msg.sender != owner()) { require( _amount <= maxSupply - totalSupply && _amount > 0 && _amount <= unitsPerTransaction, "Out range of token amount" ); require(bytes(defaultTokenURI).length > 0, "Default token URI is not set"); require(msg.value >= (price * _amount), "Not enough ETH for buying tokens"); } for (uint256 i = 0; i < _amount; i++) { uint256 tokenId = totalSupply + i + 1; _safeMint(msg.sender, tokenId); string memory tokenURI = string(abi.encodePacked(baseURI, defaultTokenURI)); _setTokenURI(tokenId, tokenURI); inPlay.push(uint32(tokenId)); } totalSupply += _amount; emit Purchased(msg.sender, _amount, totalSupply); } /** * @dev External function to set starting time. This function can be called only by owner. */ function setStartingTime(uint256 _newTime) external onlyOwner { startingTime = _newTime; emit StartingTimeSet(_newTime); } /** * @dev External function to start the battle. This function can be called only by owner. */ function startBattle() external onlyOwner { require(bytes(prizeTokenURI).length > 0 && inPlay.length > 1, "Not enough tokens to play"); battleState = BATTLE_STATE.RUNNING; emit BattleStarted(address(this), inPlay); } /** * @dev External function to end the battle. This function can be called only by owner. * @param _winnerTokenId Winner token Id in battle */ function endBattle(uint256 _winnerTokenId) external onlyOwner { require(battleState == BATTLE_STATE.RUNNING, "Battle is not started"); battleState = BATTLE_STATE.ENDED; string memory tokenURI = string(abi.encodePacked(baseURI, prizeTokenURI)); emit BattleEnded(address(this), _winnerTokenId, _winnerTokenId, tokenURI); } /** * @dev External function to set the base token URI. This function can be called only by owner. * @param _tokenURI New base token uri */ function setBaseURI(string memory _tokenURI) external onlyOwner { baseURI = _tokenURI; emit BaseURISet(baseURI); } /** * @dev External function to set the default token URI. This function can be called only by owner. * @param _tokenURI New default token uri */ function setDefaultTokenURI(string memory _tokenURI) external onlyOwner { defaultTokenURI = _tokenURI; emit DefaultTokenURISet(defaultTokenURI); } /** * @dev External function to set the prize token URI. This function can be called only by owner. * @param _tokenURI New prize token uri */ function setPrizeTokenURI(string memory _tokenURI) external onlyOwner { prizeTokenURI = _tokenURI; emit PrizeTokenURISet(prizeTokenURI); } /** * @dev External function to set the token price. This function can be called only by owner. * @param _price New token price */ function setPrice(uint256 _price) external onlyOwner { price = _price; emit PriceSet(price); } /** * @dev External function to set the limit of buyable token amounts. This function can be called only by owner. * @param _unitsPerTransaction New purchasable token amounts per transaction */ function setUnitsPerTransaction(uint256 _unitsPerTransaction) external onlyOwner { unitsPerTransaction = _unitsPerTransaction; emit UnitsPerTransactionSet(unitsPerTransaction); } /** * @dev External function to set max supply. This function can be called only by owner. * @param _maxSupply New maximum token amounts */ function setMaxSupply(uint256 _maxSupply) external onlyOwner { maxSupply = _maxSupply; emit MaxSupplySet(maxSupply); } /** * Fallback function to receive ETH */ receive() external payable {} /** * @dev External function to withdraw ETH in contract. This function can be called only by owner. * @param _amount ETH amount */ function withdrawETH(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(_amount <= balance, "Out of balance"); payable(msg.sender).transfer(_amount); emit EthWithdrew(msg.sender); } /** * @dev External function to withdraw ERC-20 tokens in contract. This function can be called only by owner. * @param _tokenAddr Address of ERC-20 token * @param _amount ERC-20 token amount */ function withdrawERC20Token(address _tokenAddr, uint256 _amount) external onlyOwner { IERC20 token = IERC20(_tokenAddr); uint256 balance = token.balanceOf(address(this)); require(_amount <= balance, "Out of balance"); token.safeTransfer(msg.sender, _amount); emit ERC20TokenWithdrew(msg.sender); } }
endBattle
function endBattle(uint256 _winnerTokenId) external onlyOwner { require(battleState == BATTLE_STATE.RUNNING, "Battle is not started"); battleState = BATTLE_STATE.ENDED; string memory tokenURI = string(abi.encodePacked(baseURI, prizeTokenURI)); emit BattleEnded(address(this), _winnerTokenId, _winnerTokenId, tokenURI); }
/** * @dev External function to end the battle. This function can be called only by owner. * @param _winnerTokenId Winner token Id in battle */
NatSpecMultiLine
v0.8.6+commit.11564f7e
{ "func_code_index": [ 4985, 5327 ] }
7,749
BattleRoyaleNoPrize
contracts/BattleRoyaleNoPrize.sol
0x29067696005279487ba66a46527087fb078286a6
Solidity
BattleRoyaleNoPrize
contract BattleRoyaleNoPrize is ERC721URIStorage, Ownable { using SafeERC20 for IERC20; using Strings for uint256; /// @notice Event emitted when contract is deployed. event BattleRoyaleDeployed(); /// @notice Event emitted when owner withdrew the ETH. event EthWithdrew(address receiver); /// @notice Event emitted when owner withdrew the ERC20 token. event ERC20TokenWithdrew(address receiver); /// @notice Event emitted when user purchased the tokens. event Purchased(address user, uint256 amount, uint256 totalSupply); /// @notice Event emitted when owner has set starting time. event StartingTimeSet(uint256 time); /// @notice Event emitted when battle has started. event BattleStarted(address battleAddress, uint32[] inPlay); /// @notice Event emitted when battle has ended. event BattleEnded( address battleAddress, uint256 tokenId, uint256 winnerTokenId, string prizeTokenURI ); /// @notice Event emitted when base token uri set. event BaseURISet(string baseURI); /// @notice Event emitted when default token uri set. event DefaultTokenURISet(string defaultTokenURI); /// @notice Event emitted when prize token uri set. event PrizeTokenURISet(string prizeTokenURI); /// @notice Event emitted when interval time set. event IntervalTimeSet(uint256 intervalTime); /// @notice Event emitted when token price set. event PriceSet(uint256 price); /// @notice Event emitted when the units per transaction set. event UnitsPerTransactionSet(uint256 unitsPerTransaction); /// @notice Event emitted when max supply set. event MaxSupplySet(uint256 maxSupply); enum BATTLE_STATE { STANDBY, RUNNING, ENDED } BATTLE_STATE public battleState; string public baseURI; string public defaultTokenURI; string public prizeTokenURI; uint256 public price; uint256 public maxSupply; uint256 public totalSupply; uint256 public unitsPerTransaction; uint256 public startingTime; uint32[] public inPlay; /** * @dev Constructor function * @param _name Token name * @param _symbol Token symbol * @param _price Token price * @param _unitsPerTransaction Purchasable token amounts per transaction * @param _maxSupply Maximum number of mintable tokens * @param _defaultTokenURI Deafult token uri * @param _prizeTokenURI Prize token uri * @param _baseURI Base token uri * @param _startingTime Start time to purchase NFT */ constructor( string memory _name, string memory _symbol, uint256 _price, uint256 _unitsPerTransaction, uint256 _maxSupply, string memory _baseURI, string memory _defaultTokenURI, string memory _prizeTokenURI, uint256 _startingTime ) ERC721(_name, _symbol) { battleState = BATTLE_STATE.STANDBY; price = _price; unitsPerTransaction = _unitsPerTransaction; maxSupply = _maxSupply; baseURI = _baseURI; defaultTokenURI = _defaultTokenURI; prizeTokenURI = _prizeTokenURI; startingTime = _startingTime; emit BattleRoyaleDeployed(); } /** * @dev External function to purchase tokens. * @param _amount Token amount to buy */ function purchase(uint256 _amount) external payable { require(price > 0, "Token price is zero"); require(battleState == BATTLE_STATE.STANDBY, "Not ready to purchase tokens"); require(maxSupply > 0 && totalSupply < maxSupply, "All NFTs were sold out"); require(block.timestamp >= startingTime, "Not time to purchase"); if (msg.sender != owner()) { require( _amount <= maxSupply - totalSupply && _amount > 0 && _amount <= unitsPerTransaction, "Out range of token amount" ); require(bytes(defaultTokenURI).length > 0, "Default token URI is not set"); require(msg.value >= (price * _amount), "Not enough ETH for buying tokens"); } for (uint256 i = 0; i < _amount; i++) { uint256 tokenId = totalSupply + i + 1; _safeMint(msg.sender, tokenId); string memory tokenURI = string(abi.encodePacked(baseURI, defaultTokenURI)); _setTokenURI(tokenId, tokenURI); inPlay.push(uint32(tokenId)); } totalSupply += _amount; emit Purchased(msg.sender, _amount, totalSupply); } /** * @dev External function to set starting time. This function can be called only by owner. */ function setStartingTime(uint256 _newTime) external onlyOwner { startingTime = _newTime; emit StartingTimeSet(_newTime); } /** * @dev External function to start the battle. This function can be called only by owner. */ function startBattle() external onlyOwner { require(bytes(prizeTokenURI).length > 0 && inPlay.length > 1, "Not enough tokens to play"); battleState = BATTLE_STATE.RUNNING; emit BattleStarted(address(this), inPlay); } /** * @dev External function to end the battle. This function can be called only by owner. * @param _winnerTokenId Winner token Id in battle */ function endBattle(uint256 _winnerTokenId) external onlyOwner { require(battleState == BATTLE_STATE.RUNNING, "Battle is not started"); battleState = BATTLE_STATE.ENDED; string memory tokenURI = string(abi.encodePacked(baseURI, prizeTokenURI)); emit BattleEnded(address(this), _winnerTokenId, _winnerTokenId, tokenURI); } /** * @dev External function to set the base token URI. This function can be called only by owner. * @param _tokenURI New base token uri */ function setBaseURI(string memory _tokenURI) external onlyOwner { baseURI = _tokenURI; emit BaseURISet(baseURI); } /** * @dev External function to set the default token URI. This function can be called only by owner. * @param _tokenURI New default token uri */ function setDefaultTokenURI(string memory _tokenURI) external onlyOwner { defaultTokenURI = _tokenURI; emit DefaultTokenURISet(defaultTokenURI); } /** * @dev External function to set the prize token URI. This function can be called only by owner. * @param _tokenURI New prize token uri */ function setPrizeTokenURI(string memory _tokenURI) external onlyOwner { prizeTokenURI = _tokenURI; emit PrizeTokenURISet(prizeTokenURI); } /** * @dev External function to set the token price. This function can be called only by owner. * @param _price New token price */ function setPrice(uint256 _price) external onlyOwner { price = _price; emit PriceSet(price); } /** * @dev External function to set the limit of buyable token amounts. This function can be called only by owner. * @param _unitsPerTransaction New purchasable token amounts per transaction */ function setUnitsPerTransaction(uint256 _unitsPerTransaction) external onlyOwner { unitsPerTransaction = _unitsPerTransaction; emit UnitsPerTransactionSet(unitsPerTransaction); } /** * @dev External function to set max supply. This function can be called only by owner. * @param _maxSupply New maximum token amounts */ function setMaxSupply(uint256 _maxSupply) external onlyOwner { maxSupply = _maxSupply; emit MaxSupplySet(maxSupply); } /** * Fallback function to receive ETH */ receive() external payable {} /** * @dev External function to withdraw ETH in contract. This function can be called only by owner. * @param _amount ETH amount */ function withdrawETH(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(_amount <= balance, "Out of balance"); payable(msg.sender).transfer(_amount); emit EthWithdrew(msg.sender); } /** * @dev External function to withdraw ERC-20 tokens in contract. This function can be called only by owner. * @param _tokenAddr Address of ERC-20 token * @param _amount ERC-20 token amount */ function withdrawERC20Token(address _tokenAddr, uint256 _amount) external onlyOwner { IERC20 token = IERC20(_tokenAddr); uint256 balance = token.balanceOf(address(this)); require(_amount <= balance, "Out of balance"); token.safeTransfer(msg.sender, _amount); emit ERC20TokenWithdrew(msg.sender); } }
setBaseURI
function setBaseURI(string memory _tokenURI) external onlyOwner { baseURI = _tokenURI; emit BaseURISet(baseURI); }
/** * @dev External function to set the base token URI. This function can be called only by owner. * @param _tokenURI New base token uri */
NatSpecMultiLine
v0.8.6+commit.11564f7e
{ "func_code_index": [ 5480, 5607 ] }
7,750
BattleRoyaleNoPrize
contracts/BattleRoyaleNoPrize.sol
0x29067696005279487ba66a46527087fb078286a6
Solidity
BattleRoyaleNoPrize
contract BattleRoyaleNoPrize is ERC721URIStorage, Ownable { using SafeERC20 for IERC20; using Strings for uint256; /// @notice Event emitted when contract is deployed. event BattleRoyaleDeployed(); /// @notice Event emitted when owner withdrew the ETH. event EthWithdrew(address receiver); /// @notice Event emitted when owner withdrew the ERC20 token. event ERC20TokenWithdrew(address receiver); /// @notice Event emitted when user purchased the tokens. event Purchased(address user, uint256 amount, uint256 totalSupply); /// @notice Event emitted when owner has set starting time. event StartingTimeSet(uint256 time); /// @notice Event emitted when battle has started. event BattleStarted(address battleAddress, uint32[] inPlay); /// @notice Event emitted when battle has ended. event BattleEnded( address battleAddress, uint256 tokenId, uint256 winnerTokenId, string prizeTokenURI ); /// @notice Event emitted when base token uri set. event BaseURISet(string baseURI); /// @notice Event emitted when default token uri set. event DefaultTokenURISet(string defaultTokenURI); /// @notice Event emitted when prize token uri set. event PrizeTokenURISet(string prizeTokenURI); /// @notice Event emitted when interval time set. event IntervalTimeSet(uint256 intervalTime); /// @notice Event emitted when token price set. event PriceSet(uint256 price); /// @notice Event emitted when the units per transaction set. event UnitsPerTransactionSet(uint256 unitsPerTransaction); /// @notice Event emitted when max supply set. event MaxSupplySet(uint256 maxSupply); enum BATTLE_STATE { STANDBY, RUNNING, ENDED } BATTLE_STATE public battleState; string public baseURI; string public defaultTokenURI; string public prizeTokenURI; uint256 public price; uint256 public maxSupply; uint256 public totalSupply; uint256 public unitsPerTransaction; uint256 public startingTime; uint32[] public inPlay; /** * @dev Constructor function * @param _name Token name * @param _symbol Token symbol * @param _price Token price * @param _unitsPerTransaction Purchasable token amounts per transaction * @param _maxSupply Maximum number of mintable tokens * @param _defaultTokenURI Deafult token uri * @param _prizeTokenURI Prize token uri * @param _baseURI Base token uri * @param _startingTime Start time to purchase NFT */ constructor( string memory _name, string memory _symbol, uint256 _price, uint256 _unitsPerTransaction, uint256 _maxSupply, string memory _baseURI, string memory _defaultTokenURI, string memory _prizeTokenURI, uint256 _startingTime ) ERC721(_name, _symbol) { battleState = BATTLE_STATE.STANDBY; price = _price; unitsPerTransaction = _unitsPerTransaction; maxSupply = _maxSupply; baseURI = _baseURI; defaultTokenURI = _defaultTokenURI; prizeTokenURI = _prizeTokenURI; startingTime = _startingTime; emit BattleRoyaleDeployed(); } /** * @dev External function to purchase tokens. * @param _amount Token amount to buy */ function purchase(uint256 _amount) external payable { require(price > 0, "Token price is zero"); require(battleState == BATTLE_STATE.STANDBY, "Not ready to purchase tokens"); require(maxSupply > 0 && totalSupply < maxSupply, "All NFTs were sold out"); require(block.timestamp >= startingTime, "Not time to purchase"); if (msg.sender != owner()) { require( _amount <= maxSupply - totalSupply && _amount > 0 && _amount <= unitsPerTransaction, "Out range of token amount" ); require(bytes(defaultTokenURI).length > 0, "Default token URI is not set"); require(msg.value >= (price * _amount), "Not enough ETH for buying tokens"); } for (uint256 i = 0; i < _amount; i++) { uint256 tokenId = totalSupply + i + 1; _safeMint(msg.sender, tokenId); string memory tokenURI = string(abi.encodePacked(baseURI, defaultTokenURI)); _setTokenURI(tokenId, tokenURI); inPlay.push(uint32(tokenId)); } totalSupply += _amount; emit Purchased(msg.sender, _amount, totalSupply); } /** * @dev External function to set starting time. This function can be called only by owner. */ function setStartingTime(uint256 _newTime) external onlyOwner { startingTime = _newTime; emit StartingTimeSet(_newTime); } /** * @dev External function to start the battle. This function can be called only by owner. */ function startBattle() external onlyOwner { require(bytes(prizeTokenURI).length > 0 && inPlay.length > 1, "Not enough tokens to play"); battleState = BATTLE_STATE.RUNNING; emit BattleStarted(address(this), inPlay); } /** * @dev External function to end the battle. This function can be called only by owner. * @param _winnerTokenId Winner token Id in battle */ function endBattle(uint256 _winnerTokenId) external onlyOwner { require(battleState == BATTLE_STATE.RUNNING, "Battle is not started"); battleState = BATTLE_STATE.ENDED; string memory tokenURI = string(abi.encodePacked(baseURI, prizeTokenURI)); emit BattleEnded(address(this), _winnerTokenId, _winnerTokenId, tokenURI); } /** * @dev External function to set the base token URI. This function can be called only by owner. * @param _tokenURI New base token uri */ function setBaseURI(string memory _tokenURI) external onlyOwner { baseURI = _tokenURI; emit BaseURISet(baseURI); } /** * @dev External function to set the default token URI. This function can be called only by owner. * @param _tokenURI New default token uri */ function setDefaultTokenURI(string memory _tokenURI) external onlyOwner { defaultTokenURI = _tokenURI; emit DefaultTokenURISet(defaultTokenURI); } /** * @dev External function to set the prize token URI. This function can be called only by owner. * @param _tokenURI New prize token uri */ function setPrizeTokenURI(string memory _tokenURI) external onlyOwner { prizeTokenURI = _tokenURI; emit PrizeTokenURISet(prizeTokenURI); } /** * @dev External function to set the token price. This function can be called only by owner. * @param _price New token price */ function setPrice(uint256 _price) external onlyOwner { price = _price; emit PriceSet(price); } /** * @dev External function to set the limit of buyable token amounts. This function can be called only by owner. * @param _unitsPerTransaction New purchasable token amounts per transaction */ function setUnitsPerTransaction(uint256 _unitsPerTransaction) external onlyOwner { unitsPerTransaction = _unitsPerTransaction; emit UnitsPerTransactionSet(unitsPerTransaction); } /** * @dev External function to set max supply. This function can be called only by owner. * @param _maxSupply New maximum token amounts */ function setMaxSupply(uint256 _maxSupply) external onlyOwner { maxSupply = _maxSupply; emit MaxSupplySet(maxSupply); } /** * Fallback function to receive ETH */ receive() external payable {} /** * @dev External function to withdraw ETH in contract. This function can be called only by owner. * @param _amount ETH amount */ function withdrawETH(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(_amount <= balance, "Out of balance"); payable(msg.sender).transfer(_amount); emit EthWithdrew(msg.sender); } /** * @dev External function to withdraw ERC-20 tokens in contract. This function can be called only by owner. * @param _tokenAddr Address of ERC-20 token * @param _amount ERC-20 token amount */ function withdrawERC20Token(address _tokenAddr, uint256 _amount) external onlyOwner { IERC20 token = IERC20(_tokenAddr); uint256 balance = token.balanceOf(address(this)); require(_amount <= balance, "Out of balance"); token.safeTransfer(msg.sender, _amount); emit ERC20TokenWithdrew(msg.sender); } }
setDefaultTokenURI
function setDefaultTokenURI(string memory _tokenURI) external onlyOwner { defaultTokenURI = _tokenURI; emit DefaultTokenURISet(defaultTokenURI); }
/** * @dev External function to set the default token URI. This function can be called only by owner. * @param _tokenURI New default token uri */
NatSpecMultiLine
v0.8.6+commit.11564f7e
{ "func_code_index": [ 5766, 5925 ] }
7,751
BattleRoyaleNoPrize
contracts/BattleRoyaleNoPrize.sol
0x29067696005279487ba66a46527087fb078286a6
Solidity
BattleRoyaleNoPrize
contract BattleRoyaleNoPrize is ERC721URIStorage, Ownable { using SafeERC20 for IERC20; using Strings for uint256; /// @notice Event emitted when contract is deployed. event BattleRoyaleDeployed(); /// @notice Event emitted when owner withdrew the ETH. event EthWithdrew(address receiver); /// @notice Event emitted when owner withdrew the ERC20 token. event ERC20TokenWithdrew(address receiver); /// @notice Event emitted when user purchased the tokens. event Purchased(address user, uint256 amount, uint256 totalSupply); /// @notice Event emitted when owner has set starting time. event StartingTimeSet(uint256 time); /// @notice Event emitted when battle has started. event BattleStarted(address battleAddress, uint32[] inPlay); /// @notice Event emitted when battle has ended. event BattleEnded( address battleAddress, uint256 tokenId, uint256 winnerTokenId, string prizeTokenURI ); /// @notice Event emitted when base token uri set. event BaseURISet(string baseURI); /// @notice Event emitted when default token uri set. event DefaultTokenURISet(string defaultTokenURI); /// @notice Event emitted when prize token uri set. event PrizeTokenURISet(string prizeTokenURI); /// @notice Event emitted when interval time set. event IntervalTimeSet(uint256 intervalTime); /// @notice Event emitted when token price set. event PriceSet(uint256 price); /// @notice Event emitted when the units per transaction set. event UnitsPerTransactionSet(uint256 unitsPerTransaction); /// @notice Event emitted when max supply set. event MaxSupplySet(uint256 maxSupply); enum BATTLE_STATE { STANDBY, RUNNING, ENDED } BATTLE_STATE public battleState; string public baseURI; string public defaultTokenURI; string public prizeTokenURI; uint256 public price; uint256 public maxSupply; uint256 public totalSupply; uint256 public unitsPerTransaction; uint256 public startingTime; uint32[] public inPlay; /** * @dev Constructor function * @param _name Token name * @param _symbol Token symbol * @param _price Token price * @param _unitsPerTransaction Purchasable token amounts per transaction * @param _maxSupply Maximum number of mintable tokens * @param _defaultTokenURI Deafult token uri * @param _prizeTokenURI Prize token uri * @param _baseURI Base token uri * @param _startingTime Start time to purchase NFT */ constructor( string memory _name, string memory _symbol, uint256 _price, uint256 _unitsPerTransaction, uint256 _maxSupply, string memory _baseURI, string memory _defaultTokenURI, string memory _prizeTokenURI, uint256 _startingTime ) ERC721(_name, _symbol) { battleState = BATTLE_STATE.STANDBY; price = _price; unitsPerTransaction = _unitsPerTransaction; maxSupply = _maxSupply; baseURI = _baseURI; defaultTokenURI = _defaultTokenURI; prizeTokenURI = _prizeTokenURI; startingTime = _startingTime; emit BattleRoyaleDeployed(); } /** * @dev External function to purchase tokens. * @param _amount Token amount to buy */ function purchase(uint256 _amount) external payable { require(price > 0, "Token price is zero"); require(battleState == BATTLE_STATE.STANDBY, "Not ready to purchase tokens"); require(maxSupply > 0 && totalSupply < maxSupply, "All NFTs were sold out"); require(block.timestamp >= startingTime, "Not time to purchase"); if (msg.sender != owner()) { require( _amount <= maxSupply - totalSupply && _amount > 0 && _amount <= unitsPerTransaction, "Out range of token amount" ); require(bytes(defaultTokenURI).length > 0, "Default token URI is not set"); require(msg.value >= (price * _amount), "Not enough ETH for buying tokens"); } for (uint256 i = 0; i < _amount; i++) { uint256 tokenId = totalSupply + i + 1; _safeMint(msg.sender, tokenId); string memory tokenURI = string(abi.encodePacked(baseURI, defaultTokenURI)); _setTokenURI(tokenId, tokenURI); inPlay.push(uint32(tokenId)); } totalSupply += _amount; emit Purchased(msg.sender, _amount, totalSupply); } /** * @dev External function to set starting time. This function can be called only by owner. */ function setStartingTime(uint256 _newTime) external onlyOwner { startingTime = _newTime; emit StartingTimeSet(_newTime); } /** * @dev External function to start the battle. This function can be called only by owner. */ function startBattle() external onlyOwner { require(bytes(prizeTokenURI).length > 0 && inPlay.length > 1, "Not enough tokens to play"); battleState = BATTLE_STATE.RUNNING; emit BattleStarted(address(this), inPlay); } /** * @dev External function to end the battle. This function can be called only by owner. * @param _winnerTokenId Winner token Id in battle */ function endBattle(uint256 _winnerTokenId) external onlyOwner { require(battleState == BATTLE_STATE.RUNNING, "Battle is not started"); battleState = BATTLE_STATE.ENDED; string memory tokenURI = string(abi.encodePacked(baseURI, prizeTokenURI)); emit BattleEnded(address(this), _winnerTokenId, _winnerTokenId, tokenURI); } /** * @dev External function to set the base token URI. This function can be called only by owner. * @param _tokenURI New base token uri */ function setBaseURI(string memory _tokenURI) external onlyOwner { baseURI = _tokenURI; emit BaseURISet(baseURI); } /** * @dev External function to set the default token URI. This function can be called only by owner. * @param _tokenURI New default token uri */ function setDefaultTokenURI(string memory _tokenURI) external onlyOwner { defaultTokenURI = _tokenURI; emit DefaultTokenURISet(defaultTokenURI); } /** * @dev External function to set the prize token URI. This function can be called only by owner. * @param _tokenURI New prize token uri */ function setPrizeTokenURI(string memory _tokenURI) external onlyOwner { prizeTokenURI = _tokenURI; emit PrizeTokenURISet(prizeTokenURI); } /** * @dev External function to set the token price. This function can be called only by owner. * @param _price New token price */ function setPrice(uint256 _price) external onlyOwner { price = _price; emit PriceSet(price); } /** * @dev External function to set the limit of buyable token amounts. This function can be called only by owner. * @param _unitsPerTransaction New purchasable token amounts per transaction */ function setUnitsPerTransaction(uint256 _unitsPerTransaction) external onlyOwner { unitsPerTransaction = _unitsPerTransaction; emit UnitsPerTransactionSet(unitsPerTransaction); } /** * @dev External function to set max supply. This function can be called only by owner. * @param _maxSupply New maximum token amounts */ function setMaxSupply(uint256 _maxSupply) external onlyOwner { maxSupply = _maxSupply; emit MaxSupplySet(maxSupply); } /** * Fallback function to receive ETH */ receive() external payable {} /** * @dev External function to withdraw ETH in contract. This function can be called only by owner. * @param _amount ETH amount */ function withdrawETH(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(_amount <= balance, "Out of balance"); payable(msg.sender).transfer(_amount); emit EthWithdrew(msg.sender); } /** * @dev External function to withdraw ERC-20 tokens in contract. This function can be called only by owner. * @param _tokenAddr Address of ERC-20 token * @param _amount ERC-20 token amount */ function withdrawERC20Token(address _tokenAddr, uint256 _amount) external onlyOwner { IERC20 token = IERC20(_tokenAddr); uint256 balance = token.balanceOf(address(this)); require(_amount <= balance, "Out of balance"); token.safeTransfer(msg.sender, _amount); emit ERC20TokenWithdrew(msg.sender); } }
setPrizeTokenURI
function setPrizeTokenURI(string memory _tokenURI) external onlyOwner { prizeTokenURI = _tokenURI; emit PrizeTokenURISet(prizeTokenURI); }
/** * @dev External function to set the prize token URI. This function can be called only by owner. * @param _tokenURI New prize token uri */
NatSpecMultiLine
v0.8.6+commit.11564f7e
{ "func_code_index": [ 6080, 6231 ] }
7,752
BattleRoyaleNoPrize
contracts/BattleRoyaleNoPrize.sol
0x29067696005279487ba66a46527087fb078286a6
Solidity
BattleRoyaleNoPrize
contract BattleRoyaleNoPrize is ERC721URIStorage, Ownable { using SafeERC20 for IERC20; using Strings for uint256; /// @notice Event emitted when contract is deployed. event BattleRoyaleDeployed(); /// @notice Event emitted when owner withdrew the ETH. event EthWithdrew(address receiver); /// @notice Event emitted when owner withdrew the ERC20 token. event ERC20TokenWithdrew(address receiver); /// @notice Event emitted when user purchased the tokens. event Purchased(address user, uint256 amount, uint256 totalSupply); /// @notice Event emitted when owner has set starting time. event StartingTimeSet(uint256 time); /// @notice Event emitted when battle has started. event BattleStarted(address battleAddress, uint32[] inPlay); /// @notice Event emitted when battle has ended. event BattleEnded( address battleAddress, uint256 tokenId, uint256 winnerTokenId, string prizeTokenURI ); /// @notice Event emitted when base token uri set. event BaseURISet(string baseURI); /// @notice Event emitted when default token uri set. event DefaultTokenURISet(string defaultTokenURI); /// @notice Event emitted when prize token uri set. event PrizeTokenURISet(string prizeTokenURI); /// @notice Event emitted when interval time set. event IntervalTimeSet(uint256 intervalTime); /// @notice Event emitted when token price set. event PriceSet(uint256 price); /// @notice Event emitted when the units per transaction set. event UnitsPerTransactionSet(uint256 unitsPerTransaction); /// @notice Event emitted when max supply set. event MaxSupplySet(uint256 maxSupply); enum BATTLE_STATE { STANDBY, RUNNING, ENDED } BATTLE_STATE public battleState; string public baseURI; string public defaultTokenURI; string public prizeTokenURI; uint256 public price; uint256 public maxSupply; uint256 public totalSupply; uint256 public unitsPerTransaction; uint256 public startingTime; uint32[] public inPlay; /** * @dev Constructor function * @param _name Token name * @param _symbol Token symbol * @param _price Token price * @param _unitsPerTransaction Purchasable token amounts per transaction * @param _maxSupply Maximum number of mintable tokens * @param _defaultTokenURI Deafult token uri * @param _prizeTokenURI Prize token uri * @param _baseURI Base token uri * @param _startingTime Start time to purchase NFT */ constructor( string memory _name, string memory _symbol, uint256 _price, uint256 _unitsPerTransaction, uint256 _maxSupply, string memory _baseURI, string memory _defaultTokenURI, string memory _prizeTokenURI, uint256 _startingTime ) ERC721(_name, _symbol) { battleState = BATTLE_STATE.STANDBY; price = _price; unitsPerTransaction = _unitsPerTransaction; maxSupply = _maxSupply; baseURI = _baseURI; defaultTokenURI = _defaultTokenURI; prizeTokenURI = _prizeTokenURI; startingTime = _startingTime; emit BattleRoyaleDeployed(); } /** * @dev External function to purchase tokens. * @param _amount Token amount to buy */ function purchase(uint256 _amount) external payable { require(price > 0, "Token price is zero"); require(battleState == BATTLE_STATE.STANDBY, "Not ready to purchase tokens"); require(maxSupply > 0 && totalSupply < maxSupply, "All NFTs were sold out"); require(block.timestamp >= startingTime, "Not time to purchase"); if (msg.sender != owner()) { require( _amount <= maxSupply - totalSupply && _amount > 0 && _amount <= unitsPerTransaction, "Out range of token amount" ); require(bytes(defaultTokenURI).length > 0, "Default token URI is not set"); require(msg.value >= (price * _amount), "Not enough ETH for buying tokens"); } for (uint256 i = 0; i < _amount; i++) { uint256 tokenId = totalSupply + i + 1; _safeMint(msg.sender, tokenId); string memory tokenURI = string(abi.encodePacked(baseURI, defaultTokenURI)); _setTokenURI(tokenId, tokenURI); inPlay.push(uint32(tokenId)); } totalSupply += _amount; emit Purchased(msg.sender, _amount, totalSupply); } /** * @dev External function to set starting time. This function can be called only by owner. */ function setStartingTime(uint256 _newTime) external onlyOwner { startingTime = _newTime; emit StartingTimeSet(_newTime); } /** * @dev External function to start the battle. This function can be called only by owner. */ function startBattle() external onlyOwner { require(bytes(prizeTokenURI).length > 0 && inPlay.length > 1, "Not enough tokens to play"); battleState = BATTLE_STATE.RUNNING; emit BattleStarted(address(this), inPlay); } /** * @dev External function to end the battle. This function can be called only by owner. * @param _winnerTokenId Winner token Id in battle */ function endBattle(uint256 _winnerTokenId) external onlyOwner { require(battleState == BATTLE_STATE.RUNNING, "Battle is not started"); battleState = BATTLE_STATE.ENDED; string memory tokenURI = string(abi.encodePacked(baseURI, prizeTokenURI)); emit BattleEnded(address(this), _winnerTokenId, _winnerTokenId, tokenURI); } /** * @dev External function to set the base token URI. This function can be called only by owner. * @param _tokenURI New base token uri */ function setBaseURI(string memory _tokenURI) external onlyOwner { baseURI = _tokenURI; emit BaseURISet(baseURI); } /** * @dev External function to set the default token URI. This function can be called only by owner. * @param _tokenURI New default token uri */ function setDefaultTokenURI(string memory _tokenURI) external onlyOwner { defaultTokenURI = _tokenURI; emit DefaultTokenURISet(defaultTokenURI); } /** * @dev External function to set the prize token URI. This function can be called only by owner. * @param _tokenURI New prize token uri */ function setPrizeTokenURI(string memory _tokenURI) external onlyOwner { prizeTokenURI = _tokenURI; emit PrizeTokenURISet(prizeTokenURI); } /** * @dev External function to set the token price. This function can be called only by owner. * @param _price New token price */ function setPrice(uint256 _price) external onlyOwner { price = _price; emit PriceSet(price); } /** * @dev External function to set the limit of buyable token amounts. This function can be called only by owner. * @param _unitsPerTransaction New purchasable token amounts per transaction */ function setUnitsPerTransaction(uint256 _unitsPerTransaction) external onlyOwner { unitsPerTransaction = _unitsPerTransaction; emit UnitsPerTransactionSet(unitsPerTransaction); } /** * @dev External function to set max supply. This function can be called only by owner. * @param _maxSupply New maximum token amounts */ function setMaxSupply(uint256 _maxSupply) external onlyOwner { maxSupply = _maxSupply; emit MaxSupplySet(maxSupply); } /** * Fallback function to receive ETH */ receive() external payable {} /** * @dev External function to withdraw ETH in contract. This function can be called only by owner. * @param _amount ETH amount */ function withdrawETH(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(_amount <= balance, "Out of balance"); payable(msg.sender).transfer(_amount); emit EthWithdrew(msg.sender); } /** * @dev External function to withdraw ERC-20 tokens in contract. This function can be called only by owner. * @param _tokenAddr Address of ERC-20 token * @param _amount ERC-20 token amount */ function withdrawERC20Token(address _tokenAddr, uint256 _amount) external onlyOwner { IERC20 token = IERC20(_tokenAddr); uint256 balance = token.balanceOf(address(this)); require(_amount <= balance, "Out of balance"); token.safeTransfer(msg.sender, _amount); emit ERC20TokenWithdrew(msg.sender); } }
setPrice
function setPrice(uint256 _price) external onlyOwner { price = _price; emit PriceSet(price); }
/** * @dev External function to set the token price. This function can be called only by owner. * @param _price New token price */
NatSpecMultiLine
v0.8.6+commit.11564f7e
{ "func_code_index": [ 6375, 6482 ] }
7,753
BattleRoyaleNoPrize
contracts/BattleRoyaleNoPrize.sol
0x29067696005279487ba66a46527087fb078286a6
Solidity
BattleRoyaleNoPrize
contract BattleRoyaleNoPrize is ERC721URIStorage, Ownable { using SafeERC20 for IERC20; using Strings for uint256; /// @notice Event emitted when contract is deployed. event BattleRoyaleDeployed(); /// @notice Event emitted when owner withdrew the ETH. event EthWithdrew(address receiver); /// @notice Event emitted when owner withdrew the ERC20 token. event ERC20TokenWithdrew(address receiver); /// @notice Event emitted when user purchased the tokens. event Purchased(address user, uint256 amount, uint256 totalSupply); /// @notice Event emitted when owner has set starting time. event StartingTimeSet(uint256 time); /// @notice Event emitted when battle has started. event BattleStarted(address battleAddress, uint32[] inPlay); /// @notice Event emitted when battle has ended. event BattleEnded( address battleAddress, uint256 tokenId, uint256 winnerTokenId, string prizeTokenURI ); /// @notice Event emitted when base token uri set. event BaseURISet(string baseURI); /// @notice Event emitted when default token uri set. event DefaultTokenURISet(string defaultTokenURI); /// @notice Event emitted when prize token uri set. event PrizeTokenURISet(string prizeTokenURI); /// @notice Event emitted when interval time set. event IntervalTimeSet(uint256 intervalTime); /// @notice Event emitted when token price set. event PriceSet(uint256 price); /// @notice Event emitted when the units per transaction set. event UnitsPerTransactionSet(uint256 unitsPerTransaction); /// @notice Event emitted when max supply set. event MaxSupplySet(uint256 maxSupply); enum BATTLE_STATE { STANDBY, RUNNING, ENDED } BATTLE_STATE public battleState; string public baseURI; string public defaultTokenURI; string public prizeTokenURI; uint256 public price; uint256 public maxSupply; uint256 public totalSupply; uint256 public unitsPerTransaction; uint256 public startingTime; uint32[] public inPlay; /** * @dev Constructor function * @param _name Token name * @param _symbol Token symbol * @param _price Token price * @param _unitsPerTransaction Purchasable token amounts per transaction * @param _maxSupply Maximum number of mintable tokens * @param _defaultTokenURI Deafult token uri * @param _prizeTokenURI Prize token uri * @param _baseURI Base token uri * @param _startingTime Start time to purchase NFT */ constructor( string memory _name, string memory _symbol, uint256 _price, uint256 _unitsPerTransaction, uint256 _maxSupply, string memory _baseURI, string memory _defaultTokenURI, string memory _prizeTokenURI, uint256 _startingTime ) ERC721(_name, _symbol) { battleState = BATTLE_STATE.STANDBY; price = _price; unitsPerTransaction = _unitsPerTransaction; maxSupply = _maxSupply; baseURI = _baseURI; defaultTokenURI = _defaultTokenURI; prizeTokenURI = _prizeTokenURI; startingTime = _startingTime; emit BattleRoyaleDeployed(); } /** * @dev External function to purchase tokens. * @param _amount Token amount to buy */ function purchase(uint256 _amount) external payable { require(price > 0, "Token price is zero"); require(battleState == BATTLE_STATE.STANDBY, "Not ready to purchase tokens"); require(maxSupply > 0 && totalSupply < maxSupply, "All NFTs were sold out"); require(block.timestamp >= startingTime, "Not time to purchase"); if (msg.sender != owner()) { require( _amount <= maxSupply - totalSupply && _amount > 0 && _amount <= unitsPerTransaction, "Out range of token amount" ); require(bytes(defaultTokenURI).length > 0, "Default token URI is not set"); require(msg.value >= (price * _amount), "Not enough ETH for buying tokens"); } for (uint256 i = 0; i < _amount; i++) { uint256 tokenId = totalSupply + i + 1; _safeMint(msg.sender, tokenId); string memory tokenURI = string(abi.encodePacked(baseURI, defaultTokenURI)); _setTokenURI(tokenId, tokenURI); inPlay.push(uint32(tokenId)); } totalSupply += _amount; emit Purchased(msg.sender, _amount, totalSupply); } /** * @dev External function to set starting time. This function can be called only by owner. */ function setStartingTime(uint256 _newTime) external onlyOwner { startingTime = _newTime; emit StartingTimeSet(_newTime); } /** * @dev External function to start the battle. This function can be called only by owner. */ function startBattle() external onlyOwner { require(bytes(prizeTokenURI).length > 0 && inPlay.length > 1, "Not enough tokens to play"); battleState = BATTLE_STATE.RUNNING; emit BattleStarted(address(this), inPlay); } /** * @dev External function to end the battle. This function can be called only by owner. * @param _winnerTokenId Winner token Id in battle */ function endBattle(uint256 _winnerTokenId) external onlyOwner { require(battleState == BATTLE_STATE.RUNNING, "Battle is not started"); battleState = BATTLE_STATE.ENDED; string memory tokenURI = string(abi.encodePacked(baseURI, prizeTokenURI)); emit BattleEnded(address(this), _winnerTokenId, _winnerTokenId, tokenURI); } /** * @dev External function to set the base token URI. This function can be called only by owner. * @param _tokenURI New base token uri */ function setBaseURI(string memory _tokenURI) external onlyOwner { baseURI = _tokenURI; emit BaseURISet(baseURI); } /** * @dev External function to set the default token URI. This function can be called only by owner. * @param _tokenURI New default token uri */ function setDefaultTokenURI(string memory _tokenURI) external onlyOwner { defaultTokenURI = _tokenURI; emit DefaultTokenURISet(defaultTokenURI); } /** * @dev External function to set the prize token URI. This function can be called only by owner. * @param _tokenURI New prize token uri */ function setPrizeTokenURI(string memory _tokenURI) external onlyOwner { prizeTokenURI = _tokenURI; emit PrizeTokenURISet(prizeTokenURI); } /** * @dev External function to set the token price. This function can be called only by owner. * @param _price New token price */ function setPrice(uint256 _price) external onlyOwner { price = _price; emit PriceSet(price); } /** * @dev External function to set the limit of buyable token amounts. This function can be called only by owner. * @param _unitsPerTransaction New purchasable token amounts per transaction */ function setUnitsPerTransaction(uint256 _unitsPerTransaction) external onlyOwner { unitsPerTransaction = _unitsPerTransaction; emit UnitsPerTransactionSet(unitsPerTransaction); } /** * @dev External function to set max supply. This function can be called only by owner. * @param _maxSupply New maximum token amounts */ function setMaxSupply(uint256 _maxSupply) external onlyOwner { maxSupply = _maxSupply; emit MaxSupplySet(maxSupply); } /** * Fallback function to receive ETH */ receive() external payable {} /** * @dev External function to withdraw ETH in contract. This function can be called only by owner. * @param _amount ETH amount */ function withdrawETH(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(_amount <= balance, "Out of balance"); payable(msg.sender).transfer(_amount); emit EthWithdrew(msg.sender); } /** * @dev External function to withdraw ERC-20 tokens in contract. This function can be called only by owner. * @param _tokenAddr Address of ERC-20 token * @param _amount ERC-20 token amount */ function withdrawERC20Token(address _tokenAddr, uint256 _amount) external onlyOwner { IERC20 token = IERC20(_tokenAddr); uint256 balance = token.balanceOf(address(this)); require(_amount <= balance, "Out of balance"); token.safeTransfer(msg.sender, _amount); emit ERC20TokenWithdrew(msg.sender); } }
setUnitsPerTransaction
function setUnitsPerTransaction(uint256 _unitsPerTransaction) external onlyOwner { unitsPerTransaction = _unitsPerTransaction; emit UnitsPerTransactionSet(unitsPerTransaction); }
/** * @dev External function to set the limit of buyable token amounts. This function can be called only by owner. * @param _unitsPerTransaction New purchasable token amounts per transaction */
NatSpecMultiLine
v0.8.6+commit.11564f7e
{ "func_code_index": [ 6689, 6880 ] }
7,754
BattleRoyaleNoPrize
contracts/BattleRoyaleNoPrize.sol
0x29067696005279487ba66a46527087fb078286a6
Solidity
BattleRoyaleNoPrize
contract BattleRoyaleNoPrize is ERC721URIStorage, Ownable { using SafeERC20 for IERC20; using Strings for uint256; /// @notice Event emitted when contract is deployed. event BattleRoyaleDeployed(); /// @notice Event emitted when owner withdrew the ETH. event EthWithdrew(address receiver); /// @notice Event emitted when owner withdrew the ERC20 token. event ERC20TokenWithdrew(address receiver); /// @notice Event emitted when user purchased the tokens. event Purchased(address user, uint256 amount, uint256 totalSupply); /// @notice Event emitted when owner has set starting time. event StartingTimeSet(uint256 time); /// @notice Event emitted when battle has started. event BattleStarted(address battleAddress, uint32[] inPlay); /// @notice Event emitted when battle has ended. event BattleEnded( address battleAddress, uint256 tokenId, uint256 winnerTokenId, string prizeTokenURI ); /// @notice Event emitted when base token uri set. event BaseURISet(string baseURI); /// @notice Event emitted when default token uri set. event DefaultTokenURISet(string defaultTokenURI); /// @notice Event emitted when prize token uri set. event PrizeTokenURISet(string prizeTokenURI); /// @notice Event emitted when interval time set. event IntervalTimeSet(uint256 intervalTime); /// @notice Event emitted when token price set. event PriceSet(uint256 price); /// @notice Event emitted when the units per transaction set. event UnitsPerTransactionSet(uint256 unitsPerTransaction); /// @notice Event emitted when max supply set. event MaxSupplySet(uint256 maxSupply); enum BATTLE_STATE { STANDBY, RUNNING, ENDED } BATTLE_STATE public battleState; string public baseURI; string public defaultTokenURI; string public prizeTokenURI; uint256 public price; uint256 public maxSupply; uint256 public totalSupply; uint256 public unitsPerTransaction; uint256 public startingTime; uint32[] public inPlay; /** * @dev Constructor function * @param _name Token name * @param _symbol Token symbol * @param _price Token price * @param _unitsPerTransaction Purchasable token amounts per transaction * @param _maxSupply Maximum number of mintable tokens * @param _defaultTokenURI Deafult token uri * @param _prizeTokenURI Prize token uri * @param _baseURI Base token uri * @param _startingTime Start time to purchase NFT */ constructor( string memory _name, string memory _symbol, uint256 _price, uint256 _unitsPerTransaction, uint256 _maxSupply, string memory _baseURI, string memory _defaultTokenURI, string memory _prizeTokenURI, uint256 _startingTime ) ERC721(_name, _symbol) { battleState = BATTLE_STATE.STANDBY; price = _price; unitsPerTransaction = _unitsPerTransaction; maxSupply = _maxSupply; baseURI = _baseURI; defaultTokenURI = _defaultTokenURI; prizeTokenURI = _prizeTokenURI; startingTime = _startingTime; emit BattleRoyaleDeployed(); } /** * @dev External function to purchase tokens. * @param _amount Token amount to buy */ function purchase(uint256 _amount) external payable { require(price > 0, "Token price is zero"); require(battleState == BATTLE_STATE.STANDBY, "Not ready to purchase tokens"); require(maxSupply > 0 && totalSupply < maxSupply, "All NFTs were sold out"); require(block.timestamp >= startingTime, "Not time to purchase"); if (msg.sender != owner()) { require( _amount <= maxSupply - totalSupply && _amount > 0 && _amount <= unitsPerTransaction, "Out range of token amount" ); require(bytes(defaultTokenURI).length > 0, "Default token URI is not set"); require(msg.value >= (price * _amount), "Not enough ETH for buying tokens"); } for (uint256 i = 0; i < _amount; i++) { uint256 tokenId = totalSupply + i + 1; _safeMint(msg.sender, tokenId); string memory tokenURI = string(abi.encodePacked(baseURI, defaultTokenURI)); _setTokenURI(tokenId, tokenURI); inPlay.push(uint32(tokenId)); } totalSupply += _amount; emit Purchased(msg.sender, _amount, totalSupply); } /** * @dev External function to set starting time. This function can be called only by owner. */ function setStartingTime(uint256 _newTime) external onlyOwner { startingTime = _newTime; emit StartingTimeSet(_newTime); } /** * @dev External function to start the battle. This function can be called only by owner. */ function startBattle() external onlyOwner { require(bytes(prizeTokenURI).length > 0 && inPlay.length > 1, "Not enough tokens to play"); battleState = BATTLE_STATE.RUNNING; emit BattleStarted(address(this), inPlay); } /** * @dev External function to end the battle. This function can be called only by owner. * @param _winnerTokenId Winner token Id in battle */ function endBattle(uint256 _winnerTokenId) external onlyOwner { require(battleState == BATTLE_STATE.RUNNING, "Battle is not started"); battleState = BATTLE_STATE.ENDED; string memory tokenURI = string(abi.encodePacked(baseURI, prizeTokenURI)); emit BattleEnded(address(this), _winnerTokenId, _winnerTokenId, tokenURI); } /** * @dev External function to set the base token URI. This function can be called only by owner. * @param _tokenURI New base token uri */ function setBaseURI(string memory _tokenURI) external onlyOwner { baseURI = _tokenURI; emit BaseURISet(baseURI); } /** * @dev External function to set the default token URI. This function can be called only by owner. * @param _tokenURI New default token uri */ function setDefaultTokenURI(string memory _tokenURI) external onlyOwner { defaultTokenURI = _tokenURI; emit DefaultTokenURISet(defaultTokenURI); } /** * @dev External function to set the prize token URI. This function can be called only by owner. * @param _tokenURI New prize token uri */ function setPrizeTokenURI(string memory _tokenURI) external onlyOwner { prizeTokenURI = _tokenURI; emit PrizeTokenURISet(prizeTokenURI); } /** * @dev External function to set the token price. This function can be called only by owner. * @param _price New token price */ function setPrice(uint256 _price) external onlyOwner { price = _price; emit PriceSet(price); } /** * @dev External function to set the limit of buyable token amounts. This function can be called only by owner. * @param _unitsPerTransaction New purchasable token amounts per transaction */ function setUnitsPerTransaction(uint256 _unitsPerTransaction) external onlyOwner { unitsPerTransaction = _unitsPerTransaction; emit UnitsPerTransactionSet(unitsPerTransaction); } /** * @dev External function to set max supply. This function can be called only by owner. * @param _maxSupply New maximum token amounts */ function setMaxSupply(uint256 _maxSupply) external onlyOwner { maxSupply = _maxSupply; emit MaxSupplySet(maxSupply); } /** * Fallback function to receive ETH */ receive() external payable {} /** * @dev External function to withdraw ETH in contract. This function can be called only by owner. * @param _amount ETH amount */ function withdrawETH(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(_amount <= balance, "Out of balance"); payable(msg.sender).transfer(_amount); emit EthWithdrew(msg.sender); } /** * @dev External function to withdraw ERC-20 tokens in contract. This function can be called only by owner. * @param _tokenAddr Address of ERC-20 token * @param _amount ERC-20 token amount */ function withdrawERC20Token(address _tokenAddr, uint256 _amount) external onlyOwner { IERC20 token = IERC20(_tokenAddr); uint256 balance = token.balanceOf(address(this)); require(_amount <= balance, "Out of balance"); token.safeTransfer(msg.sender, _amount); emit ERC20TokenWithdrew(msg.sender); } }
setMaxSupply
function setMaxSupply(uint256 _maxSupply) external onlyOwner { maxSupply = _maxSupply; emit MaxSupplySet(maxSupply); }
/** * @dev External function to set max supply. This function can be called only by owner. * @param _maxSupply New maximum token amounts */
NatSpecMultiLine
v0.8.6+commit.11564f7e
{ "func_code_index": [ 7033, 7164 ] }
7,755
BattleRoyaleNoPrize
contracts/BattleRoyaleNoPrize.sol
0x29067696005279487ba66a46527087fb078286a6
Solidity
BattleRoyaleNoPrize
contract BattleRoyaleNoPrize is ERC721URIStorage, Ownable { using SafeERC20 for IERC20; using Strings for uint256; /// @notice Event emitted when contract is deployed. event BattleRoyaleDeployed(); /// @notice Event emitted when owner withdrew the ETH. event EthWithdrew(address receiver); /// @notice Event emitted when owner withdrew the ERC20 token. event ERC20TokenWithdrew(address receiver); /// @notice Event emitted when user purchased the tokens. event Purchased(address user, uint256 amount, uint256 totalSupply); /// @notice Event emitted when owner has set starting time. event StartingTimeSet(uint256 time); /// @notice Event emitted when battle has started. event BattleStarted(address battleAddress, uint32[] inPlay); /// @notice Event emitted when battle has ended. event BattleEnded( address battleAddress, uint256 tokenId, uint256 winnerTokenId, string prizeTokenURI ); /// @notice Event emitted when base token uri set. event BaseURISet(string baseURI); /// @notice Event emitted when default token uri set. event DefaultTokenURISet(string defaultTokenURI); /// @notice Event emitted when prize token uri set. event PrizeTokenURISet(string prizeTokenURI); /// @notice Event emitted when interval time set. event IntervalTimeSet(uint256 intervalTime); /// @notice Event emitted when token price set. event PriceSet(uint256 price); /// @notice Event emitted when the units per transaction set. event UnitsPerTransactionSet(uint256 unitsPerTransaction); /// @notice Event emitted when max supply set. event MaxSupplySet(uint256 maxSupply); enum BATTLE_STATE { STANDBY, RUNNING, ENDED } BATTLE_STATE public battleState; string public baseURI; string public defaultTokenURI; string public prizeTokenURI; uint256 public price; uint256 public maxSupply; uint256 public totalSupply; uint256 public unitsPerTransaction; uint256 public startingTime; uint32[] public inPlay; /** * @dev Constructor function * @param _name Token name * @param _symbol Token symbol * @param _price Token price * @param _unitsPerTransaction Purchasable token amounts per transaction * @param _maxSupply Maximum number of mintable tokens * @param _defaultTokenURI Deafult token uri * @param _prizeTokenURI Prize token uri * @param _baseURI Base token uri * @param _startingTime Start time to purchase NFT */ constructor( string memory _name, string memory _symbol, uint256 _price, uint256 _unitsPerTransaction, uint256 _maxSupply, string memory _baseURI, string memory _defaultTokenURI, string memory _prizeTokenURI, uint256 _startingTime ) ERC721(_name, _symbol) { battleState = BATTLE_STATE.STANDBY; price = _price; unitsPerTransaction = _unitsPerTransaction; maxSupply = _maxSupply; baseURI = _baseURI; defaultTokenURI = _defaultTokenURI; prizeTokenURI = _prizeTokenURI; startingTime = _startingTime; emit BattleRoyaleDeployed(); } /** * @dev External function to purchase tokens. * @param _amount Token amount to buy */ function purchase(uint256 _amount) external payable { require(price > 0, "Token price is zero"); require(battleState == BATTLE_STATE.STANDBY, "Not ready to purchase tokens"); require(maxSupply > 0 && totalSupply < maxSupply, "All NFTs were sold out"); require(block.timestamp >= startingTime, "Not time to purchase"); if (msg.sender != owner()) { require( _amount <= maxSupply - totalSupply && _amount > 0 && _amount <= unitsPerTransaction, "Out range of token amount" ); require(bytes(defaultTokenURI).length > 0, "Default token URI is not set"); require(msg.value >= (price * _amount), "Not enough ETH for buying tokens"); } for (uint256 i = 0; i < _amount; i++) { uint256 tokenId = totalSupply + i + 1; _safeMint(msg.sender, tokenId); string memory tokenURI = string(abi.encodePacked(baseURI, defaultTokenURI)); _setTokenURI(tokenId, tokenURI); inPlay.push(uint32(tokenId)); } totalSupply += _amount; emit Purchased(msg.sender, _amount, totalSupply); } /** * @dev External function to set starting time. This function can be called only by owner. */ function setStartingTime(uint256 _newTime) external onlyOwner { startingTime = _newTime; emit StartingTimeSet(_newTime); } /** * @dev External function to start the battle. This function can be called only by owner. */ function startBattle() external onlyOwner { require(bytes(prizeTokenURI).length > 0 && inPlay.length > 1, "Not enough tokens to play"); battleState = BATTLE_STATE.RUNNING; emit BattleStarted(address(this), inPlay); } /** * @dev External function to end the battle. This function can be called only by owner. * @param _winnerTokenId Winner token Id in battle */ function endBattle(uint256 _winnerTokenId) external onlyOwner { require(battleState == BATTLE_STATE.RUNNING, "Battle is not started"); battleState = BATTLE_STATE.ENDED; string memory tokenURI = string(abi.encodePacked(baseURI, prizeTokenURI)); emit BattleEnded(address(this), _winnerTokenId, _winnerTokenId, tokenURI); } /** * @dev External function to set the base token URI. This function can be called only by owner. * @param _tokenURI New base token uri */ function setBaseURI(string memory _tokenURI) external onlyOwner { baseURI = _tokenURI; emit BaseURISet(baseURI); } /** * @dev External function to set the default token URI. This function can be called only by owner. * @param _tokenURI New default token uri */ function setDefaultTokenURI(string memory _tokenURI) external onlyOwner { defaultTokenURI = _tokenURI; emit DefaultTokenURISet(defaultTokenURI); } /** * @dev External function to set the prize token URI. This function can be called only by owner. * @param _tokenURI New prize token uri */ function setPrizeTokenURI(string memory _tokenURI) external onlyOwner { prizeTokenURI = _tokenURI; emit PrizeTokenURISet(prizeTokenURI); } /** * @dev External function to set the token price. This function can be called only by owner. * @param _price New token price */ function setPrice(uint256 _price) external onlyOwner { price = _price; emit PriceSet(price); } /** * @dev External function to set the limit of buyable token amounts. This function can be called only by owner. * @param _unitsPerTransaction New purchasable token amounts per transaction */ function setUnitsPerTransaction(uint256 _unitsPerTransaction) external onlyOwner { unitsPerTransaction = _unitsPerTransaction; emit UnitsPerTransactionSet(unitsPerTransaction); } /** * @dev External function to set max supply. This function can be called only by owner. * @param _maxSupply New maximum token amounts */ function setMaxSupply(uint256 _maxSupply) external onlyOwner { maxSupply = _maxSupply; emit MaxSupplySet(maxSupply); } /** * Fallback function to receive ETH */ receive() external payable {} /** * @dev External function to withdraw ETH in contract. This function can be called only by owner. * @param _amount ETH amount */ function withdrawETH(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(_amount <= balance, "Out of balance"); payable(msg.sender).transfer(_amount); emit EthWithdrew(msg.sender); } /** * @dev External function to withdraw ERC-20 tokens in contract. This function can be called only by owner. * @param _tokenAddr Address of ERC-20 token * @param _amount ERC-20 token amount */ function withdrawERC20Token(address _tokenAddr, uint256 _amount) external onlyOwner { IERC20 token = IERC20(_tokenAddr); uint256 balance = token.balanceOf(address(this)); require(_amount <= balance, "Out of balance"); token.safeTransfer(msg.sender, _amount); emit ERC20TokenWithdrew(msg.sender); } }
/** * Fallback function to receive ETH */
NatSpecMultiLine
v0.8.6+commit.11564f7e
{ "func_code_index": [ 7216, 7247 ] }
7,756
BattleRoyaleNoPrize
contracts/BattleRoyaleNoPrize.sol
0x29067696005279487ba66a46527087fb078286a6
Solidity
BattleRoyaleNoPrize
contract BattleRoyaleNoPrize is ERC721URIStorage, Ownable { using SafeERC20 for IERC20; using Strings for uint256; /// @notice Event emitted when contract is deployed. event BattleRoyaleDeployed(); /// @notice Event emitted when owner withdrew the ETH. event EthWithdrew(address receiver); /// @notice Event emitted when owner withdrew the ERC20 token. event ERC20TokenWithdrew(address receiver); /// @notice Event emitted when user purchased the tokens. event Purchased(address user, uint256 amount, uint256 totalSupply); /// @notice Event emitted when owner has set starting time. event StartingTimeSet(uint256 time); /// @notice Event emitted when battle has started. event BattleStarted(address battleAddress, uint32[] inPlay); /// @notice Event emitted when battle has ended. event BattleEnded( address battleAddress, uint256 tokenId, uint256 winnerTokenId, string prizeTokenURI ); /// @notice Event emitted when base token uri set. event BaseURISet(string baseURI); /// @notice Event emitted when default token uri set. event DefaultTokenURISet(string defaultTokenURI); /// @notice Event emitted when prize token uri set. event PrizeTokenURISet(string prizeTokenURI); /// @notice Event emitted when interval time set. event IntervalTimeSet(uint256 intervalTime); /// @notice Event emitted when token price set. event PriceSet(uint256 price); /// @notice Event emitted when the units per transaction set. event UnitsPerTransactionSet(uint256 unitsPerTransaction); /// @notice Event emitted when max supply set. event MaxSupplySet(uint256 maxSupply); enum BATTLE_STATE { STANDBY, RUNNING, ENDED } BATTLE_STATE public battleState; string public baseURI; string public defaultTokenURI; string public prizeTokenURI; uint256 public price; uint256 public maxSupply; uint256 public totalSupply; uint256 public unitsPerTransaction; uint256 public startingTime; uint32[] public inPlay; /** * @dev Constructor function * @param _name Token name * @param _symbol Token symbol * @param _price Token price * @param _unitsPerTransaction Purchasable token amounts per transaction * @param _maxSupply Maximum number of mintable tokens * @param _defaultTokenURI Deafult token uri * @param _prizeTokenURI Prize token uri * @param _baseURI Base token uri * @param _startingTime Start time to purchase NFT */ constructor( string memory _name, string memory _symbol, uint256 _price, uint256 _unitsPerTransaction, uint256 _maxSupply, string memory _baseURI, string memory _defaultTokenURI, string memory _prizeTokenURI, uint256 _startingTime ) ERC721(_name, _symbol) { battleState = BATTLE_STATE.STANDBY; price = _price; unitsPerTransaction = _unitsPerTransaction; maxSupply = _maxSupply; baseURI = _baseURI; defaultTokenURI = _defaultTokenURI; prizeTokenURI = _prizeTokenURI; startingTime = _startingTime; emit BattleRoyaleDeployed(); } /** * @dev External function to purchase tokens. * @param _amount Token amount to buy */ function purchase(uint256 _amount) external payable { require(price > 0, "Token price is zero"); require(battleState == BATTLE_STATE.STANDBY, "Not ready to purchase tokens"); require(maxSupply > 0 && totalSupply < maxSupply, "All NFTs were sold out"); require(block.timestamp >= startingTime, "Not time to purchase"); if (msg.sender != owner()) { require( _amount <= maxSupply - totalSupply && _amount > 0 && _amount <= unitsPerTransaction, "Out range of token amount" ); require(bytes(defaultTokenURI).length > 0, "Default token URI is not set"); require(msg.value >= (price * _amount), "Not enough ETH for buying tokens"); } for (uint256 i = 0; i < _amount; i++) { uint256 tokenId = totalSupply + i + 1; _safeMint(msg.sender, tokenId); string memory tokenURI = string(abi.encodePacked(baseURI, defaultTokenURI)); _setTokenURI(tokenId, tokenURI); inPlay.push(uint32(tokenId)); } totalSupply += _amount; emit Purchased(msg.sender, _amount, totalSupply); } /** * @dev External function to set starting time. This function can be called only by owner. */ function setStartingTime(uint256 _newTime) external onlyOwner { startingTime = _newTime; emit StartingTimeSet(_newTime); } /** * @dev External function to start the battle. This function can be called only by owner. */ function startBattle() external onlyOwner { require(bytes(prizeTokenURI).length > 0 && inPlay.length > 1, "Not enough tokens to play"); battleState = BATTLE_STATE.RUNNING; emit BattleStarted(address(this), inPlay); } /** * @dev External function to end the battle. This function can be called only by owner. * @param _winnerTokenId Winner token Id in battle */ function endBattle(uint256 _winnerTokenId) external onlyOwner { require(battleState == BATTLE_STATE.RUNNING, "Battle is not started"); battleState = BATTLE_STATE.ENDED; string memory tokenURI = string(abi.encodePacked(baseURI, prizeTokenURI)); emit BattleEnded(address(this), _winnerTokenId, _winnerTokenId, tokenURI); } /** * @dev External function to set the base token URI. This function can be called only by owner. * @param _tokenURI New base token uri */ function setBaseURI(string memory _tokenURI) external onlyOwner { baseURI = _tokenURI; emit BaseURISet(baseURI); } /** * @dev External function to set the default token URI. This function can be called only by owner. * @param _tokenURI New default token uri */ function setDefaultTokenURI(string memory _tokenURI) external onlyOwner { defaultTokenURI = _tokenURI; emit DefaultTokenURISet(defaultTokenURI); } /** * @dev External function to set the prize token URI. This function can be called only by owner. * @param _tokenURI New prize token uri */ function setPrizeTokenURI(string memory _tokenURI) external onlyOwner { prizeTokenURI = _tokenURI; emit PrizeTokenURISet(prizeTokenURI); } /** * @dev External function to set the token price. This function can be called only by owner. * @param _price New token price */ function setPrice(uint256 _price) external onlyOwner { price = _price; emit PriceSet(price); } /** * @dev External function to set the limit of buyable token amounts. This function can be called only by owner. * @param _unitsPerTransaction New purchasable token amounts per transaction */ function setUnitsPerTransaction(uint256 _unitsPerTransaction) external onlyOwner { unitsPerTransaction = _unitsPerTransaction; emit UnitsPerTransactionSet(unitsPerTransaction); } /** * @dev External function to set max supply. This function can be called only by owner. * @param _maxSupply New maximum token amounts */ function setMaxSupply(uint256 _maxSupply) external onlyOwner { maxSupply = _maxSupply; emit MaxSupplySet(maxSupply); } /** * Fallback function to receive ETH */ receive() external payable {} /** * @dev External function to withdraw ETH in contract. This function can be called only by owner. * @param _amount ETH amount */ function withdrawETH(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(_amount <= balance, "Out of balance"); payable(msg.sender).transfer(_amount); emit EthWithdrew(msg.sender); } /** * @dev External function to withdraw ERC-20 tokens in contract. This function can be called only by owner. * @param _tokenAddr Address of ERC-20 token * @param _amount ERC-20 token amount */ function withdrawERC20Token(address _tokenAddr, uint256 _amount) external onlyOwner { IERC20 token = IERC20(_tokenAddr); uint256 balance = token.balanceOf(address(this)); require(_amount <= balance, "Out of balance"); token.safeTransfer(msg.sender, _amount); emit ERC20TokenWithdrew(msg.sender); } }
withdrawETH
function withdrawETH(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(_amount <= balance, "Out of balance"); payable(msg.sender).transfer(_amount); emit EthWithdrew(msg.sender); }
/** * @dev External function to withdraw ETH in contract. This function can be called only by owner. * @param _amount ETH amount */
NatSpecMultiLine
v0.8.6+commit.11564f7e
{ "func_code_index": [ 7392, 7631 ] }
7,757
BattleRoyaleNoPrize
contracts/BattleRoyaleNoPrize.sol
0x29067696005279487ba66a46527087fb078286a6
Solidity
BattleRoyaleNoPrize
contract BattleRoyaleNoPrize is ERC721URIStorage, Ownable { using SafeERC20 for IERC20; using Strings for uint256; /// @notice Event emitted when contract is deployed. event BattleRoyaleDeployed(); /// @notice Event emitted when owner withdrew the ETH. event EthWithdrew(address receiver); /// @notice Event emitted when owner withdrew the ERC20 token. event ERC20TokenWithdrew(address receiver); /// @notice Event emitted when user purchased the tokens. event Purchased(address user, uint256 amount, uint256 totalSupply); /// @notice Event emitted when owner has set starting time. event StartingTimeSet(uint256 time); /// @notice Event emitted when battle has started. event BattleStarted(address battleAddress, uint32[] inPlay); /// @notice Event emitted when battle has ended. event BattleEnded( address battleAddress, uint256 tokenId, uint256 winnerTokenId, string prizeTokenURI ); /// @notice Event emitted when base token uri set. event BaseURISet(string baseURI); /// @notice Event emitted when default token uri set. event DefaultTokenURISet(string defaultTokenURI); /// @notice Event emitted when prize token uri set. event PrizeTokenURISet(string prizeTokenURI); /// @notice Event emitted when interval time set. event IntervalTimeSet(uint256 intervalTime); /// @notice Event emitted when token price set. event PriceSet(uint256 price); /// @notice Event emitted when the units per transaction set. event UnitsPerTransactionSet(uint256 unitsPerTransaction); /// @notice Event emitted when max supply set. event MaxSupplySet(uint256 maxSupply); enum BATTLE_STATE { STANDBY, RUNNING, ENDED } BATTLE_STATE public battleState; string public baseURI; string public defaultTokenURI; string public prizeTokenURI; uint256 public price; uint256 public maxSupply; uint256 public totalSupply; uint256 public unitsPerTransaction; uint256 public startingTime; uint32[] public inPlay; /** * @dev Constructor function * @param _name Token name * @param _symbol Token symbol * @param _price Token price * @param _unitsPerTransaction Purchasable token amounts per transaction * @param _maxSupply Maximum number of mintable tokens * @param _defaultTokenURI Deafult token uri * @param _prizeTokenURI Prize token uri * @param _baseURI Base token uri * @param _startingTime Start time to purchase NFT */ constructor( string memory _name, string memory _symbol, uint256 _price, uint256 _unitsPerTransaction, uint256 _maxSupply, string memory _baseURI, string memory _defaultTokenURI, string memory _prizeTokenURI, uint256 _startingTime ) ERC721(_name, _symbol) { battleState = BATTLE_STATE.STANDBY; price = _price; unitsPerTransaction = _unitsPerTransaction; maxSupply = _maxSupply; baseURI = _baseURI; defaultTokenURI = _defaultTokenURI; prizeTokenURI = _prizeTokenURI; startingTime = _startingTime; emit BattleRoyaleDeployed(); } /** * @dev External function to purchase tokens. * @param _amount Token amount to buy */ function purchase(uint256 _amount) external payable { require(price > 0, "Token price is zero"); require(battleState == BATTLE_STATE.STANDBY, "Not ready to purchase tokens"); require(maxSupply > 0 && totalSupply < maxSupply, "All NFTs were sold out"); require(block.timestamp >= startingTime, "Not time to purchase"); if (msg.sender != owner()) { require( _amount <= maxSupply - totalSupply && _amount > 0 && _amount <= unitsPerTransaction, "Out range of token amount" ); require(bytes(defaultTokenURI).length > 0, "Default token URI is not set"); require(msg.value >= (price * _amount), "Not enough ETH for buying tokens"); } for (uint256 i = 0; i < _amount; i++) { uint256 tokenId = totalSupply + i + 1; _safeMint(msg.sender, tokenId); string memory tokenURI = string(abi.encodePacked(baseURI, defaultTokenURI)); _setTokenURI(tokenId, tokenURI); inPlay.push(uint32(tokenId)); } totalSupply += _amount; emit Purchased(msg.sender, _amount, totalSupply); } /** * @dev External function to set starting time. This function can be called only by owner. */ function setStartingTime(uint256 _newTime) external onlyOwner { startingTime = _newTime; emit StartingTimeSet(_newTime); } /** * @dev External function to start the battle. This function can be called only by owner. */ function startBattle() external onlyOwner { require(bytes(prizeTokenURI).length > 0 && inPlay.length > 1, "Not enough tokens to play"); battleState = BATTLE_STATE.RUNNING; emit BattleStarted(address(this), inPlay); } /** * @dev External function to end the battle. This function can be called only by owner. * @param _winnerTokenId Winner token Id in battle */ function endBattle(uint256 _winnerTokenId) external onlyOwner { require(battleState == BATTLE_STATE.RUNNING, "Battle is not started"); battleState = BATTLE_STATE.ENDED; string memory tokenURI = string(abi.encodePacked(baseURI, prizeTokenURI)); emit BattleEnded(address(this), _winnerTokenId, _winnerTokenId, tokenURI); } /** * @dev External function to set the base token URI. This function can be called only by owner. * @param _tokenURI New base token uri */ function setBaseURI(string memory _tokenURI) external onlyOwner { baseURI = _tokenURI; emit BaseURISet(baseURI); } /** * @dev External function to set the default token URI. This function can be called only by owner. * @param _tokenURI New default token uri */ function setDefaultTokenURI(string memory _tokenURI) external onlyOwner { defaultTokenURI = _tokenURI; emit DefaultTokenURISet(defaultTokenURI); } /** * @dev External function to set the prize token URI. This function can be called only by owner. * @param _tokenURI New prize token uri */ function setPrizeTokenURI(string memory _tokenURI) external onlyOwner { prizeTokenURI = _tokenURI; emit PrizeTokenURISet(prizeTokenURI); } /** * @dev External function to set the token price. This function can be called only by owner. * @param _price New token price */ function setPrice(uint256 _price) external onlyOwner { price = _price; emit PriceSet(price); } /** * @dev External function to set the limit of buyable token amounts. This function can be called only by owner. * @param _unitsPerTransaction New purchasable token amounts per transaction */ function setUnitsPerTransaction(uint256 _unitsPerTransaction) external onlyOwner { unitsPerTransaction = _unitsPerTransaction; emit UnitsPerTransactionSet(unitsPerTransaction); } /** * @dev External function to set max supply. This function can be called only by owner. * @param _maxSupply New maximum token amounts */ function setMaxSupply(uint256 _maxSupply) external onlyOwner { maxSupply = _maxSupply; emit MaxSupplySet(maxSupply); } /** * Fallback function to receive ETH */ receive() external payable {} /** * @dev External function to withdraw ETH in contract. This function can be called only by owner. * @param _amount ETH amount */ function withdrawETH(uint256 _amount) external onlyOwner { uint256 balance = address(this).balance; require(_amount <= balance, "Out of balance"); payable(msg.sender).transfer(_amount); emit EthWithdrew(msg.sender); } /** * @dev External function to withdraw ERC-20 tokens in contract. This function can be called only by owner. * @param _tokenAddr Address of ERC-20 token * @param _amount ERC-20 token amount */ function withdrawERC20Token(address _tokenAddr, uint256 _amount) external onlyOwner { IERC20 token = IERC20(_tokenAddr); uint256 balance = token.balanceOf(address(this)); require(_amount <= balance, "Out of balance"); token.safeTransfer(msg.sender, _amount); emit ERC20TokenWithdrew(msg.sender); } }
withdrawERC20Token
function withdrawERC20Token(address _tokenAddr, uint256 _amount) external onlyOwner { IERC20 token = IERC20(_tokenAddr); uint256 balance = token.balanceOf(address(this)); require(_amount <= balance, "Out of balance"); token.safeTransfer(msg.sender, _amount); emit ERC20TokenWithdrew(msg.sender); }
/** * @dev External function to withdraw ERC-20 tokens in contract. This function can be called only by owner. * @param _tokenAddr Address of ERC-20 token * @param _amount ERC-20 token amount */
NatSpecMultiLine
v0.8.6+commit.11564f7e
{ "func_code_index": [ 7842, 8166 ] }
7,758
BonumFinancialTokenPreSale
BonumFinancialTokenPreSale.sol
0x4e9992c9b97873a39e264832972f29ce672ebaf1
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() { 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; } }
/** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */
NatSpecMultiLine
Ownable
function Ownable() { owner = msg.sender; }
/** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */
NatSpecMultiLine
v0.4.21+commit.dfe3193c
bzzr://4e58174758f1fe805c45bbaefd214f94ca5a520f1a027a7f7aaf069bb9971b53
{ "func_code_index": [ 261, 314 ] }
7,759
BonumFinancialTokenPreSale
BonumFinancialTokenPreSale.sol
0x4e9992c9b97873a39e264832972f29ce672ebaf1
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() { 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; } }
/** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */
NatSpecMultiLine
transferOwnership
function transferOwnership(address newOwner) 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.21+commit.dfe3193c
bzzr://4e58174758f1fe805c45bbaefd214f94ca5a520f1a027a7f7aaf069bb9971b53
{ "func_code_index": [ 637, 813 ] }
7,760
BonumFinancialTokenPreSale
BonumFinancialTokenPreSale.sol
0x4e9992c9b97873a39e264832972f29ce672ebaf1
Solidity
Pausable
contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!paused); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() onlyOwner whenNotPaused public { paused = true; Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyOwner whenPaused public { paused = false; Unpause(); } }
/** * @title Pausable * @dev Base contract which allows children to implement an emergency stop mechanism. */
NatSpecMultiLine
pause
function pause() onlyOwner whenNotPaused public { paused = true; Pause(); }
/** * @dev called by the owner to pause, triggers stopped state */
NatSpecMultiLine
v0.4.21+commit.dfe3193c
bzzr://4e58174758f1fe805c45bbaefd214f94ca5a520f1a027a7f7aaf069bb9971b53
{ "func_code_index": [ 513, 604 ] }
7,761
BonumFinancialTokenPreSale
BonumFinancialTokenPreSale.sol
0x4e9992c9b97873a39e264832972f29ce672ebaf1
Solidity
Pausable
contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!paused); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() onlyOwner whenNotPaused public { paused = true; Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyOwner whenPaused public { paused = false; Unpause(); } }
/** * @title Pausable * @dev Base contract which allows children to implement an emergency stop mechanism. */
NatSpecMultiLine
unpause
function unpause() onlyOwner whenPaused public { paused = false; Unpause(); }
/** * @dev called by the owner to unpause, returns to normal state */
NatSpecMultiLine
v0.4.21+commit.dfe3193c
bzzr://4e58174758f1fe805c45bbaefd214f94ca5a520f1a027a7f7aaf069bb9971b53
{ "func_code_index": [ 688, 781 ] }
7,762
BonumFinancialTokenPreSale
BonumFinancialTokenPreSale.sol
0x4e9992c9b97873a39e264832972f29ce672ebaf1
Solidity
InvestorsList
contract InvestorsList is Ownable { using SafeMath for uint; /* Investor */ enum WhiteListStatus {Usual, WhiteList, PreWhiteList} struct Investor { bytes32 id; uint tokensCount; address walletForTokens; WhiteListStatus whiteListStatus; bool isVerified; } /*Investor's end*/ mapping (address => bool) manipulators; mapping (address => bytes32) public nativeInvestorsIds; mapping (bytes32 => Investor) public investorsList; /*Manipulators*/ modifier allowedToManipulate(){ require(manipulators[msg.sender] || msg.sender == owner); _; } function changeManipulatorAddress(address saleAddress, bool isAllowedToManipulate) external onlyOwner{ require(saleAddress != 0x0); manipulators[saleAddress] = isAllowedToManipulate; } /*Manipulators' end*/ function setInvestorId(address investorAddress, bytes32 id) external onlyOwner{ require(investorAddress != 0x0 && id != 0); nativeInvestorsIds[investorAddress] = id; } function addInvestor( bytes32 id, WhiteListStatus status, bool isVerified ) external onlyOwner { require(id != 0); require(investorsList[id].id == 0); investorsList[id].id = id; investorsList[id].tokensCount = 0; investorsList[id].whiteListStatus = status; investorsList[id].isVerified = isVerified; } function removeInvestor(bytes32 id) external onlyOwner { require(id != 0 && investorsList[id].id != 0); investorsList[id].id = 0; } function isAllowedToBuyByAddress(address investor) external view returns(bool){ require(investor != 0x0); bytes32 id = nativeInvestorsIds[investor]; require(id != 0 && investorsList[id].id != 0); return investorsList[id].isVerified; } function isAllowedToBuyByAddressWithoutVerification(address investor) external view returns(bool){ require(investor != 0x0); bytes32 id = nativeInvestorsIds[investor]; require(id != 0 && investorsList[id].id != 0); return true; } function isAllowedToBuy(bytes32 id) external view returns(bool){ require(id != 0 && investorsList[id].id != 0); return investorsList[id].isVerified; } function isPreWhiteListed(bytes32 id) external constant returns(bool){ require(id != 0 && investorsList[id].id != 0); return investorsList[id].whiteListStatus == WhiteListStatus.PreWhiteList; } function isWhiteListed(bytes32 id) external view returns(bool){ require(id != 0 && investorsList[id].id != 0); return investorsList[id].whiteListStatus == WhiteListStatus.WhiteList; } function setVerificationStatus(bytes32 id, bool status) external onlyOwner{ require(id != 0 && investorsList[id].id != 0); investorsList[id].isVerified = status; } function setWhiteListStatus(bytes32 id, WhiteListStatus status) external onlyOwner{ require(id != 0 && investorsList[id].id != 0); investorsList[id].whiteListStatus = status; } function addTokens(bytes32 id, uint tokens) external allowedToManipulate{ require(id != 0 && investorsList[id].id != 0); investorsList[id].tokensCount = investorsList[id].tokensCount.add(tokens); } function subTokens(bytes32 id, uint tokens) external allowedToManipulate{ require(id != 0 && investorsList[id].id != 0); investorsList[id].tokensCount = investorsList[id].tokensCount.sub(tokens); } function setWalletForTokens(bytes32 id, address wallet) external onlyOwner{ require(id != 0 && investorsList[id].id != 0); investorsList[id].walletForTokens = wallet; } }
setInvestorId
function setInvestorId(address investorAddress, bytes32 id) external onlyOwner{ require(investorAddress != 0x0 && id != 0); nativeInvestorsIds[investorAddress] = id; }
/*Manipulators' end*/
Comment
v0.4.21+commit.dfe3193c
bzzr://4e58174758f1fe805c45bbaefd214f94ca5a520f1a027a7f7aaf069bb9971b53
{ "func_code_index": [ 919, 1114 ] }
7,763
BonumFinancialTokenPreSale
BonumFinancialTokenPreSale.sol
0x4e9992c9b97873a39e264832972f29ce672ebaf1
Solidity
BonumFinancialTokenPreSale
contract BonumFinancialTokenPreSale is Pausable{ using SafeMath for uint; string public constant name = "Bonum Financial Token PreSale"; uint public startDate; uint public endDate; uint public whiteListPreSaleDuration = 1 days; function setWhiteListDuration(uint duration) external onlyOwner{ require(duration > 0); whiteListPreSaleDuration = duration * 1 days; } uint public fiatValueMultiplier = 10**6; uint public tokenDecimals = 10**18; InvestorsList public investors; address beneficiary; uint public ethUsdRate; uint public collected = 0; uint public tokensSold = 0; uint public tokensSoldWithBonus = 0; uint[] firstColumn; uint[] secondColumn; event NewContribution(address indexed holder, uint tokenAmount, uint etherAmount); function BonumFinancialTokenPreSale( uint _startDate, uint _endDate, address _investors, address _beneficiary, uint _baseEthUsdRate ) public { startDate = _startDate; endDate = _endDate; investors = InvestorsList(_investors); beneficiary = _beneficiary; ethUsdRate = _baseEthUsdRate; initBonusSystem(); } function initBonusSystem() private{ firstColumn.push(1750000); firstColumn.push(10360000); firstColumn.push(18980000); firstColumn.push(25000000); secondColumn.push(1560000); secondColumn.push(9220000); secondColumn.push(16880000); secondColumn.push(22230000); } function setNewBeneficiary(address newBeneficiary) external onlyOwner { require(newBeneficiary != 0x0); beneficiary = newBeneficiary; } function setEthUsdRate(uint rate) external onlyOwner { require(rate > 0); ethUsdRate = rate; } function setNewStartDate(uint newStartDate) external onlyOwner{ require(newStartDate > 0); startDate = newStartDate; } function setNewEndDate(uint newEndDate) external onlyOwner{ require(newEndDate > 0); endDate = newEndDate; } function setNewInvestorsList(address investorsList) external onlyOwner { require(investorsList != 0x0); investors = InvestorsList(investorsList); } modifier activePreSale(){ require(now >= startDate && now < endDate); _; } modifier underCap(){ require(tokensSold < uint(750000).mul(tokenDecimals)); _; } modifier isAllowedToBuy(){ require(investors.isAllowedToBuyByAddressWithoutVerification(msg.sender)); _; } modifier minimumAmount(){ require(msg.value.mul(ethUsdRate).div(fiatValueMultiplier.mul(1 ether)) >= 100); _; } function() payable public whenNotPaused activePreSale minimumAmount underCap isAllowedToBuy{ bytes32 id = investors.nativeInvestorsIds(msg.sender); uint tokens = msg.value.mul(ethUsdRate).div(fiatValueMultiplier); tokensSold = tokensSold.add(tokens); tokens = tokens.add(calculateBonus(id, tokens)); tokensSoldWithBonus = tokensSoldWithBonus.add(tokens); NewContribution(msg.sender, tokens, msg.value); collected = collected.add(msg.value); investors.addTokens(id, tokens); beneficiary.transfer(msg.value); } //usd * 10^6 function otherCoinsPurchase(bytes32 id, uint amountInUsd) external whenNotPaused underCap activePreSale onlyOwner { require(id.length > 0 && amountInUsd >= (uint(100).mul(fiatValueMultiplier)) && investors.isAllowedToBuy(id)); uint tokens = amountInUsd.mul(tokenDecimals).div(fiatValueMultiplier); tokensSold = tokensSold.add(tokens); tokens = tokens.add(calculateBonus(id, tokens)); tokensSoldWithBonus = tokensSoldWithBonus.add(tokens); investors.addTokens(id, tokens); } function calculateBonus(bytes32 id, uint tokensCount) public constant returns (uint){ if (now < (startDate.add(whiteListPreSaleDuration))) { require(tokensCount >= 3000 * tokenDecimals); if (investors.isPreWhiteListed(id)) { return tokensCount.mul(35).div(100); } return tokensCount.mul(25).div(100); } //+1 because needs whole days uint day = ((now.sub(startDate.add(whiteListPreSaleDuration))).div(1 days)).add(1); uint B1; uint B2; if (tokensCount < uint(1000).mul(tokenDecimals)) { B1 = (((tokensCount - 100 * tokenDecimals) * (firstColumn[1] - firstColumn[0])) / ((1000-100) * tokenDecimals)) + firstColumn[0]; B2 = (((tokensCount - 100 * tokenDecimals) * (secondColumn[1] - secondColumn[0])) / ((1000-100) * tokenDecimals)) + secondColumn[0]; } if (tokensCount >= uint(1000).mul(tokenDecimals) && tokensCount < uint(10000).mul(tokenDecimals)) { B1 = (((tokensCount - 1000 * tokenDecimals) * (firstColumn[2] - firstColumn[1])) / ((10000-1000) * tokenDecimals)) + firstColumn[1]; B2 = (((tokensCount - 1000 * tokenDecimals) * (secondColumn[2] - secondColumn[1])) / ((10000-1000) * tokenDecimals)) + secondColumn[1]; } if (tokensCount >= uint(10000).mul(tokenDecimals) && tokensCount < uint(50000).mul(tokenDecimals)) { B1 = (((tokensCount - 10000 * tokenDecimals) * (firstColumn[3] - firstColumn[2])) / ((50000-10000) * tokenDecimals)) + firstColumn[2]; B2 = (((tokensCount - 10000 * tokenDecimals) * (secondColumn[3] - secondColumn[2])) / ((50000-10000) * tokenDecimals)) + secondColumn[2]; } if (tokensCount >= uint(50000).mul(tokenDecimals)) { B1 = firstColumn[3]; B2 = secondColumn[3]; } uint bonusPercent = B1.sub(((day - 1).mul(B1 - B2)).div(12)); return calculateBonusTokensAmount(tokensCount, bonusPercent); } function calculateBonusTokensAmount(uint tokensCount, uint bonusPercent) private constant returns(uint){ uint bonus = tokensCount.mul(bonusPercent); bonus = bonus.div(100); bonus = bonus.div(fiatValueMultiplier); return bonus; } }
otherCoinsPurchase
function otherCoinsPurchase(bytes32 id, uint amountInUsd) external whenNotPaused underCap activePreSale onlyOwner { require(id.length > 0 && amountInUsd >= (uint(100).mul(fiatValueMultiplier)) && investors.isAllowedToBuy(id)); uint tokens = amountInUsd.mul(tokenDecimals).div(fiatValueMultiplier); tokensSold = tokensSold.add(tokens); tokens = tokens.add(calculateBonus(id, tokens)); tokensSoldWithBonus = tokensSoldWithBonus.add(tokens); investors.addTokens(id, tokens); }
//usd * 10^6
LineComment
v0.4.21+commit.dfe3193c
bzzr://4e58174758f1fe805c45bbaefd214f94ca5a520f1a027a7f7aaf069bb9971b53
{ "func_code_index": [ 3528, 4072 ] }
7,764
Fliquidator
contracts/Flashloans/Flasher.sol
0xe3a2df184c021b8cbdfe2e89f7d3f495473b2be0
Solidity
Flasher
contract Flasher is DyDxFlashloanBase, IFlashLoanReceiver, ICallee, Ownable { using SafeMath for uint256; using UniERC20 for IERC20; IFujiAdmin private _fujiAdmin; address public aave_lending_pool; address public dydx_solo_margin; receive() external payable {} constructor() public { aave_lending_pool = 0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9; dydx_solo_margin = 0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e; } modifier isAuthorized() { require( msg.sender == _fujiAdmin.getController() || msg.sender == _fujiAdmin.getFliquidator() || msg.sender == owner(), Errors.VL_NOT_AUTHORIZED ); _; } modifier isAuthorizedExternal() { require( msg.sender == dydx_solo_margin || msg.sender == aave_lending_pool, Errors.VL_NOT_AUTHORIZED ); _; } /** * @dev Sets the fujiAdmin Address * @param _newFujiAdmin: FujiAdmin Contract Address */ function setFujiAdmin(address _newFujiAdmin) public onlyOwner { _fujiAdmin = IFujiAdmin(_newFujiAdmin); } /** * @dev Routing Function for Flashloan Provider * @param info: struct information for flashLoan * @param _flashnum: integer identifier of flashloan provider */ function initiateFlashloan(FlashLoan.Info memory info, uint8 _flashnum) public isAuthorized { if(_flashnum==0) { initiateAaveFlashLoan(info); } else if(_flashnum==1) { initiateDyDxFlashLoan(info); } } // ===================== DyDx FlashLoan =================================== /** * @dev Initiates a DyDx flashloan. * @param info: data to be passed between functions executing flashloan logic */ function initiateDyDxFlashLoan( FlashLoan.Info memory info ) internal { ISoloMargin solo = ISoloMargin(dydx_solo_margin); // Get marketId from token address uint256 marketId = _getMarketIdFromTokenAddress(solo, info.asset); // 1. Withdraw $ // 2. Call callFunction(...) // 3. Deposit back $ Actions.ActionArgs[] memory operations = new Actions.ActionArgs[](3); operations[0] = _getWithdrawAction(marketId, info.amount); // Encode FlashLoan.Info for callFunction operations[1] = _getCallAction(abi.encode(info)); // add fee of 2 wei operations[2] = _getDepositAction(marketId, info.amount.add(2)); Account.Info[] memory accountInfos = new Account.Info[](1); accountInfos[0] = _getAccountInfo(address(this)); solo.operate(accountInfos, operations); } /** * @dev Executes DyDx Flashloan, this operation is required * and called by Solo when sending loaned amount * @param sender: Not used * @param account: Not used */ function callFunction( address sender, Account.Info memory account, bytes memory data ) external override isAuthorizedExternal { sender; account; FlashLoan.Info memory info = abi.decode(data, (FlashLoan.Info)); //Estimate flashloan payback + premium fee of 2 wei, uint amountOwing = info.amount.add(2); // Transfer to Vault the flashloan Amount IERC20(info.asset).uniTransfer(payable(info.vault), info.amount); if (info.callType == FlashLoan.CallType.Switch) { IVault(info.vault) .executeSwitch(info.newProvider, info.amount, 2); } else if (info.callType == FlashLoan.CallType.Close) { IFliquidator(info.fliquidator) .executeFlashClose(info.user, info.vault, info.amount, 2); } else { IFliquidator(info.fliquidator) .executeFlashLiquidation(info.user, info.userliquidator, info.vault, info.amount, 2); } //Approve DYDXSolo to spend to repay flashloan IERC20(info.asset).approve(dydx_solo_margin, amountOwing); } // ===================== Aave FlashLoan =================================== /** * @dev Initiates an Aave flashloan. * @param info: data to be passed between functions executing flashloan logic */ function initiateAaveFlashLoan( FlashLoan.Info memory info ) internal { //Initialize Instance of Aave Lending Pool ILendingPool aaveLp = ILendingPool(aave_lending_pool); //Passing arguments to construct Aave flashloan -limited to 1 asset type for now. address receiverAddress = address(this); address[] memory assets = new address[](1); assets[0] = address(info.asset); uint256[] memory amounts = new uint256[](1); amounts[0] = info.amount; // 0 = no debt, 1 = stable, 2 = variable uint256[] memory modes = new uint256[](1); modes[0] = 0; address onBehalfOf = address(this); bytes memory params = abi.encode(info); uint16 referralCode = 0; //Aave Flashloan initiated. aaveLp.flashLoan( receiverAddress, assets, amounts, modes, onBehalfOf, params, referralCode ); } /** * @dev Executes Aave Flashloan, this operation is required * and called by Aaveflashloan when sending loaned amount */ function executeOperation( address[] calldata assets, uint256[] calldata amounts, uint256[] calldata premiums, address initiator, bytes calldata params ) external override isAuthorizedExternal returns (bool) { initiator; FlashLoan.Info memory info = abi.decode(params, (FlashLoan.Info)); //Estimate flashloan payback + premium fee, uint amountOwing = amounts[0].add(premiums[0]); // Transfer to the vault ERC20 IERC20(assets[0]).uniTransfer(payable(info.vault), amounts[0]); if (info.callType == FlashLoan.CallType.Switch) { IVault(info.vault) .executeSwitch(info.newProvider, amounts[0], premiums[0]); } else if (info.callType == FlashLoan.CallType.Close) { IFliquidator(info.fliquidator) .executeFlashClose(info.user, info.vault, amounts[0], premiums[0]); } else { IFliquidator(info.fliquidator) .executeFlashLiquidation(info.user, info.userliquidator, info.vault, amounts[0],premiums[0]); } //Approve aaveLP to spend to repay flashloan IERC20(assets[0]).uniApprove(payable(aave_lending_pool), amountOwing); return true; } }
setFujiAdmin
function setFujiAdmin(address _newFujiAdmin) public onlyOwner { _fujiAdmin = IFujiAdmin(_newFujiAdmin); }
/** * @dev Sets the fujiAdmin Address * @param _newFujiAdmin: FujiAdmin Contract Address */
NatSpecMultiLine
v0.6.12+commit.27d51765
{ "func_code_index": [ 952, 1065 ] }
7,765
Fliquidator
contracts/Flashloans/Flasher.sol
0xe3a2df184c021b8cbdfe2e89f7d3f495473b2be0
Solidity
Flasher
contract Flasher is DyDxFlashloanBase, IFlashLoanReceiver, ICallee, Ownable { using SafeMath for uint256; using UniERC20 for IERC20; IFujiAdmin private _fujiAdmin; address public aave_lending_pool; address public dydx_solo_margin; receive() external payable {} constructor() public { aave_lending_pool = 0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9; dydx_solo_margin = 0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e; } modifier isAuthorized() { require( msg.sender == _fujiAdmin.getController() || msg.sender == _fujiAdmin.getFliquidator() || msg.sender == owner(), Errors.VL_NOT_AUTHORIZED ); _; } modifier isAuthorizedExternal() { require( msg.sender == dydx_solo_margin || msg.sender == aave_lending_pool, Errors.VL_NOT_AUTHORIZED ); _; } /** * @dev Sets the fujiAdmin Address * @param _newFujiAdmin: FujiAdmin Contract Address */ function setFujiAdmin(address _newFujiAdmin) public onlyOwner { _fujiAdmin = IFujiAdmin(_newFujiAdmin); } /** * @dev Routing Function for Flashloan Provider * @param info: struct information for flashLoan * @param _flashnum: integer identifier of flashloan provider */ function initiateFlashloan(FlashLoan.Info memory info, uint8 _flashnum) public isAuthorized { if(_flashnum==0) { initiateAaveFlashLoan(info); } else if(_flashnum==1) { initiateDyDxFlashLoan(info); } } // ===================== DyDx FlashLoan =================================== /** * @dev Initiates a DyDx flashloan. * @param info: data to be passed between functions executing flashloan logic */ function initiateDyDxFlashLoan( FlashLoan.Info memory info ) internal { ISoloMargin solo = ISoloMargin(dydx_solo_margin); // Get marketId from token address uint256 marketId = _getMarketIdFromTokenAddress(solo, info.asset); // 1. Withdraw $ // 2. Call callFunction(...) // 3. Deposit back $ Actions.ActionArgs[] memory operations = new Actions.ActionArgs[](3); operations[0] = _getWithdrawAction(marketId, info.amount); // Encode FlashLoan.Info for callFunction operations[1] = _getCallAction(abi.encode(info)); // add fee of 2 wei operations[2] = _getDepositAction(marketId, info.amount.add(2)); Account.Info[] memory accountInfos = new Account.Info[](1); accountInfos[0] = _getAccountInfo(address(this)); solo.operate(accountInfos, operations); } /** * @dev Executes DyDx Flashloan, this operation is required * and called by Solo when sending loaned amount * @param sender: Not used * @param account: Not used */ function callFunction( address sender, Account.Info memory account, bytes memory data ) external override isAuthorizedExternal { sender; account; FlashLoan.Info memory info = abi.decode(data, (FlashLoan.Info)); //Estimate flashloan payback + premium fee of 2 wei, uint amountOwing = info.amount.add(2); // Transfer to Vault the flashloan Amount IERC20(info.asset).uniTransfer(payable(info.vault), info.amount); if (info.callType == FlashLoan.CallType.Switch) { IVault(info.vault) .executeSwitch(info.newProvider, info.amount, 2); } else if (info.callType == FlashLoan.CallType.Close) { IFliquidator(info.fliquidator) .executeFlashClose(info.user, info.vault, info.amount, 2); } else { IFliquidator(info.fliquidator) .executeFlashLiquidation(info.user, info.userliquidator, info.vault, info.amount, 2); } //Approve DYDXSolo to spend to repay flashloan IERC20(info.asset).approve(dydx_solo_margin, amountOwing); } // ===================== Aave FlashLoan =================================== /** * @dev Initiates an Aave flashloan. * @param info: data to be passed between functions executing flashloan logic */ function initiateAaveFlashLoan( FlashLoan.Info memory info ) internal { //Initialize Instance of Aave Lending Pool ILendingPool aaveLp = ILendingPool(aave_lending_pool); //Passing arguments to construct Aave flashloan -limited to 1 asset type for now. address receiverAddress = address(this); address[] memory assets = new address[](1); assets[0] = address(info.asset); uint256[] memory amounts = new uint256[](1); amounts[0] = info.amount; // 0 = no debt, 1 = stable, 2 = variable uint256[] memory modes = new uint256[](1); modes[0] = 0; address onBehalfOf = address(this); bytes memory params = abi.encode(info); uint16 referralCode = 0; //Aave Flashloan initiated. aaveLp.flashLoan( receiverAddress, assets, amounts, modes, onBehalfOf, params, referralCode ); } /** * @dev Executes Aave Flashloan, this operation is required * and called by Aaveflashloan when sending loaned amount */ function executeOperation( address[] calldata assets, uint256[] calldata amounts, uint256[] calldata premiums, address initiator, bytes calldata params ) external override isAuthorizedExternal returns (bool) { initiator; FlashLoan.Info memory info = abi.decode(params, (FlashLoan.Info)); //Estimate flashloan payback + premium fee, uint amountOwing = amounts[0].add(premiums[0]); // Transfer to the vault ERC20 IERC20(assets[0]).uniTransfer(payable(info.vault), amounts[0]); if (info.callType == FlashLoan.CallType.Switch) { IVault(info.vault) .executeSwitch(info.newProvider, amounts[0], premiums[0]); } else if (info.callType == FlashLoan.CallType.Close) { IFliquidator(info.fliquidator) .executeFlashClose(info.user, info.vault, amounts[0], premiums[0]); } else { IFliquidator(info.fliquidator) .executeFlashLiquidation(info.user, info.userliquidator, info.vault, amounts[0],premiums[0]); } //Approve aaveLP to spend to repay flashloan IERC20(assets[0]).uniApprove(payable(aave_lending_pool), amountOwing); return true; } }
initiateFlashloan
function initiateFlashloan(FlashLoan.Info memory info, uint8 _flashnum) public isAuthorized { if(_flashnum==0) { initiateAaveFlashLoan(info); } else if(_flashnum==1) { initiateDyDxFlashLoan(info); } }
/** * @dev Routing Function for Flashloan Provider * @param info: struct information for flashLoan * @param _flashnum: integer identifier of flashloan provider */
NatSpecMultiLine
v0.6.12+commit.27d51765
{ "func_code_index": [ 1241, 1469 ] }
7,766
Fliquidator
contracts/Flashloans/Flasher.sol
0xe3a2df184c021b8cbdfe2e89f7d3f495473b2be0
Solidity
Flasher
contract Flasher is DyDxFlashloanBase, IFlashLoanReceiver, ICallee, Ownable { using SafeMath for uint256; using UniERC20 for IERC20; IFujiAdmin private _fujiAdmin; address public aave_lending_pool; address public dydx_solo_margin; receive() external payable {} constructor() public { aave_lending_pool = 0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9; dydx_solo_margin = 0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e; } modifier isAuthorized() { require( msg.sender == _fujiAdmin.getController() || msg.sender == _fujiAdmin.getFliquidator() || msg.sender == owner(), Errors.VL_NOT_AUTHORIZED ); _; } modifier isAuthorizedExternal() { require( msg.sender == dydx_solo_margin || msg.sender == aave_lending_pool, Errors.VL_NOT_AUTHORIZED ); _; } /** * @dev Sets the fujiAdmin Address * @param _newFujiAdmin: FujiAdmin Contract Address */ function setFujiAdmin(address _newFujiAdmin) public onlyOwner { _fujiAdmin = IFujiAdmin(_newFujiAdmin); } /** * @dev Routing Function for Flashloan Provider * @param info: struct information for flashLoan * @param _flashnum: integer identifier of flashloan provider */ function initiateFlashloan(FlashLoan.Info memory info, uint8 _flashnum) public isAuthorized { if(_flashnum==0) { initiateAaveFlashLoan(info); } else if(_flashnum==1) { initiateDyDxFlashLoan(info); } } // ===================== DyDx FlashLoan =================================== /** * @dev Initiates a DyDx flashloan. * @param info: data to be passed between functions executing flashloan logic */ function initiateDyDxFlashLoan( FlashLoan.Info memory info ) internal { ISoloMargin solo = ISoloMargin(dydx_solo_margin); // Get marketId from token address uint256 marketId = _getMarketIdFromTokenAddress(solo, info.asset); // 1. Withdraw $ // 2. Call callFunction(...) // 3. Deposit back $ Actions.ActionArgs[] memory operations = new Actions.ActionArgs[](3); operations[0] = _getWithdrawAction(marketId, info.amount); // Encode FlashLoan.Info for callFunction operations[1] = _getCallAction(abi.encode(info)); // add fee of 2 wei operations[2] = _getDepositAction(marketId, info.amount.add(2)); Account.Info[] memory accountInfos = new Account.Info[](1); accountInfos[0] = _getAccountInfo(address(this)); solo.operate(accountInfos, operations); } /** * @dev Executes DyDx Flashloan, this operation is required * and called by Solo when sending loaned amount * @param sender: Not used * @param account: Not used */ function callFunction( address sender, Account.Info memory account, bytes memory data ) external override isAuthorizedExternal { sender; account; FlashLoan.Info memory info = abi.decode(data, (FlashLoan.Info)); //Estimate flashloan payback + premium fee of 2 wei, uint amountOwing = info.amount.add(2); // Transfer to Vault the flashloan Amount IERC20(info.asset).uniTransfer(payable(info.vault), info.amount); if (info.callType == FlashLoan.CallType.Switch) { IVault(info.vault) .executeSwitch(info.newProvider, info.amount, 2); } else if (info.callType == FlashLoan.CallType.Close) { IFliquidator(info.fliquidator) .executeFlashClose(info.user, info.vault, info.amount, 2); } else { IFliquidator(info.fliquidator) .executeFlashLiquidation(info.user, info.userliquidator, info.vault, info.amount, 2); } //Approve DYDXSolo to spend to repay flashloan IERC20(info.asset).approve(dydx_solo_margin, amountOwing); } // ===================== Aave FlashLoan =================================== /** * @dev Initiates an Aave flashloan. * @param info: data to be passed between functions executing flashloan logic */ function initiateAaveFlashLoan( FlashLoan.Info memory info ) internal { //Initialize Instance of Aave Lending Pool ILendingPool aaveLp = ILendingPool(aave_lending_pool); //Passing arguments to construct Aave flashloan -limited to 1 asset type for now. address receiverAddress = address(this); address[] memory assets = new address[](1); assets[0] = address(info.asset); uint256[] memory amounts = new uint256[](1); amounts[0] = info.amount; // 0 = no debt, 1 = stable, 2 = variable uint256[] memory modes = new uint256[](1); modes[0] = 0; address onBehalfOf = address(this); bytes memory params = abi.encode(info); uint16 referralCode = 0; //Aave Flashloan initiated. aaveLp.flashLoan( receiverAddress, assets, amounts, modes, onBehalfOf, params, referralCode ); } /** * @dev Executes Aave Flashloan, this operation is required * and called by Aaveflashloan when sending loaned amount */ function executeOperation( address[] calldata assets, uint256[] calldata amounts, uint256[] calldata premiums, address initiator, bytes calldata params ) external override isAuthorizedExternal returns (bool) { initiator; FlashLoan.Info memory info = abi.decode(params, (FlashLoan.Info)); //Estimate flashloan payback + premium fee, uint amountOwing = amounts[0].add(premiums[0]); // Transfer to the vault ERC20 IERC20(assets[0]).uniTransfer(payable(info.vault), amounts[0]); if (info.callType == FlashLoan.CallType.Switch) { IVault(info.vault) .executeSwitch(info.newProvider, amounts[0], premiums[0]); } else if (info.callType == FlashLoan.CallType.Close) { IFliquidator(info.fliquidator) .executeFlashClose(info.user, info.vault, amounts[0], premiums[0]); } else { IFliquidator(info.fliquidator) .executeFlashLiquidation(info.user, info.userliquidator, info.vault, amounts[0],premiums[0]); } //Approve aaveLP to spend to repay flashloan IERC20(assets[0]).uniApprove(payable(aave_lending_pool), amountOwing); return true; } }
initiateDyDxFlashLoan
function initiateDyDxFlashLoan( FlashLoan.Info memory info ) internal { ISoloMargin solo = ISoloMargin(dydx_solo_margin); // Get marketId from token address uint256 marketId = _getMarketIdFromTokenAddress(solo, info.asset); // 1. Withdraw $ // 2. Call callFunction(...) // 3. Deposit back $ Actions.ActionArgs[] memory operations = new Actions.ActionArgs[](3); operations[0] = _getWithdrawAction(marketId, info.amount); // Encode FlashLoan.Info for callFunction operations[1] = _getCallAction(abi.encode(info)); // add fee of 2 wei operations[2] = _getDepositAction(marketId, info.amount.add(2)); Account.Info[] memory accountInfos = new Account.Info[](1); accountInfos[0] = _getAccountInfo(address(this)); solo.operate(accountInfos, operations); }
/** * @dev Initiates a DyDx flashloan. * @param info: data to be passed between functions executing flashloan logic */
NatSpecMultiLine
v0.6.12+commit.27d51765
{ "func_code_index": [ 1677, 2501 ] }
7,767
Fliquidator
contracts/Flashloans/Flasher.sol
0xe3a2df184c021b8cbdfe2e89f7d3f495473b2be0
Solidity
Flasher
contract Flasher is DyDxFlashloanBase, IFlashLoanReceiver, ICallee, Ownable { using SafeMath for uint256; using UniERC20 for IERC20; IFujiAdmin private _fujiAdmin; address public aave_lending_pool; address public dydx_solo_margin; receive() external payable {} constructor() public { aave_lending_pool = 0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9; dydx_solo_margin = 0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e; } modifier isAuthorized() { require( msg.sender == _fujiAdmin.getController() || msg.sender == _fujiAdmin.getFliquidator() || msg.sender == owner(), Errors.VL_NOT_AUTHORIZED ); _; } modifier isAuthorizedExternal() { require( msg.sender == dydx_solo_margin || msg.sender == aave_lending_pool, Errors.VL_NOT_AUTHORIZED ); _; } /** * @dev Sets the fujiAdmin Address * @param _newFujiAdmin: FujiAdmin Contract Address */ function setFujiAdmin(address _newFujiAdmin) public onlyOwner { _fujiAdmin = IFujiAdmin(_newFujiAdmin); } /** * @dev Routing Function for Flashloan Provider * @param info: struct information for flashLoan * @param _flashnum: integer identifier of flashloan provider */ function initiateFlashloan(FlashLoan.Info memory info, uint8 _flashnum) public isAuthorized { if(_flashnum==0) { initiateAaveFlashLoan(info); } else if(_flashnum==1) { initiateDyDxFlashLoan(info); } } // ===================== DyDx FlashLoan =================================== /** * @dev Initiates a DyDx flashloan. * @param info: data to be passed between functions executing flashloan logic */ function initiateDyDxFlashLoan( FlashLoan.Info memory info ) internal { ISoloMargin solo = ISoloMargin(dydx_solo_margin); // Get marketId from token address uint256 marketId = _getMarketIdFromTokenAddress(solo, info.asset); // 1. Withdraw $ // 2. Call callFunction(...) // 3. Deposit back $ Actions.ActionArgs[] memory operations = new Actions.ActionArgs[](3); operations[0] = _getWithdrawAction(marketId, info.amount); // Encode FlashLoan.Info for callFunction operations[1] = _getCallAction(abi.encode(info)); // add fee of 2 wei operations[2] = _getDepositAction(marketId, info.amount.add(2)); Account.Info[] memory accountInfos = new Account.Info[](1); accountInfos[0] = _getAccountInfo(address(this)); solo.operate(accountInfos, operations); } /** * @dev Executes DyDx Flashloan, this operation is required * and called by Solo when sending loaned amount * @param sender: Not used * @param account: Not used */ function callFunction( address sender, Account.Info memory account, bytes memory data ) external override isAuthorizedExternal { sender; account; FlashLoan.Info memory info = abi.decode(data, (FlashLoan.Info)); //Estimate flashloan payback + premium fee of 2 wei, uint amountOwing = info.amount.add(2); // Transfer to Vault the flashloan Amount IERC20(info.asset).uniTransfer(payable(info.vault), info.amount); if (info.callType == FlashLoan.CallType.Switch) { IVault(info.vault) .executeSwitch(info.newProvider, info.amount, 2); } else if (info.callType == FlashLoan.CallType.Close) { IFliquidator(info.fliquidator) .executeFlashClose(info.user, info.vault, info.amount, 2); } else { IFliquidator(info.fliquidator) .executeFlashLiquidation(info.user, info.userliquidator, info.vault, info.amount, 2); } //Approve DYDXSolo to spend to repay flashloan IERC20(info.asset).approve(dydx_solo_margin, amountOwing); } // ===================== Aave FlashLoan =================================== /** * @dev Initiates an Aave flashloan. * @param info: data to be passed between functions executing flashloan logic */ function initiateAaveFlashLoan( FlashLoan.Info memory info ) internal { //Initialize Instance of Aave Lending Pool ILendingPool aaveLp = ILendingPool(aave_lending_pool); //Passing arguments to construct Aave flashloan -limited to 1 asset type for now. address receiverAddress = address(this); address[] memory assets = new address[](1); assets[0] = address(info.asset); uint256[] memory amounts = new uint256[](1); amounts[0] = info.amount; // 0 = no debt, 1 = stable, 2 = variable uint256[] memory modes = new uint256[](1); modes[0] = 0; address onBehalfOf = address(this); bytes memory params = abi.encode(info); uint16 referralCode = 0; //Aave Flashloan initiated. aaveLp.flashLoan( receiverAddress, assets, amounts, modes, onBehalfOf, params, referralCode ); } /** * @dev Executes Aave Flashloan, this operation is required * and called by Aaveflashloan when sending loaned amount */ function executeOperation( address[] calldata assets, uint256[] calldata amounts, uint256[] calldata premiums, address initiator, bytes calldata params ) external override isAuthorizedExternal returns (bool) { initiator; FlashLoan.Info memory info = abi.decode(params, (FlashLoan.Info)); //Estimate flashloan payback + premium fee, uint amountOwing = amounts[0].add(premiums[0]); // Transfer to the vault ERC20 IERC20(assets[0]).uniTransfer(payable(info.vault), amounts[0]); if (info.callType == FlashLoan.CallType.Switch) { IVault(info.vault) .executeSwitch(info.newProvider, amounts[0], premiums[0]); } else if (info.callType == FlashLoan.CallType.Close) { IFliquidator(info.fliquidator) .executeFlashClose(info.user, info.vault, amounts[0], premiums[0]); } else { IFliquidator(info.fliquidator) .executeFlashLiquidation(info.user, info.userliquidator, info.vault, amounts[0],premiums[0]); } //Approve aaveLP to spend to repay flashloan IERC20(assets[0]).uniApprove(payable(aave_lending_pool), amountOwing); return true; } }
callFunction
function callFunction( address sender, Account.Info memory account, bytes memory data ) external override isAuthorizedExternal { sender; account; FlashLoan.Info memory info = abi.decode(data, (FlashLoan.Info)); //Estimate flashloan payback + premium fee of 2 wei, uint amountOwing = info.amount.add(2); // Transfer to Vault the flashloan Amount IERC20(info.asset).uniTransfer(payable(info.vault), info.amount); if (info.callType == FlashLoan.CallType.Switch) { IVault(info.vault) .executeSwitch(info.newProvider, info.amount, 2); } else if (info.callType == FlashLoan.CallType.Close) { IFliquidator(info.fliquidator) .executeFlashClose(info.user, info.vault, info.amount, 2); } else { IFliquidator(info.fliquidator) .executeFlashLiquidation(info.user, info.userliquidator, info.vault, info.amount, 2); } //Approve DYDXSolo to spend to repay flashloan IERC20(info.asset).approve(dydx_solo_margin, amountOwing); }
/** * @dev Executes DyDx Flashloan, this operation is required * and called by Solo when sending loaned amount * @param sender: Not used * @param account: Not used */
NatSpecMultiLine
v0.6.12+commit.27d51765
{ "func_code_index": [ 2682, 3712 ] }
7,768
Fliquidator
contracts/Flashloans/Flasher.sol
0xe3a2df184c021b8cbdfe2e89f7d3f495473b2be0
Solidity
Flasher
contract Flasher is DyDxFlashloanBase, IFlashLoanReceiver, ICallee, Ownable { using SafeMath for uint256; using UniERC20 for IERC20; IFujiAdmin private _fujiAdmin; address public aave_lending_pool; address public dydx_solo_margin; receive() external payable {} constructor() public { aave_lending_pool = 0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9; dydx_solo_margin = 0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e; } modifier isAuthorized() { require( msg.sender == _fujiAdmin.getController() || msg.sender == _fujiAdmin.getFliquidator() || msg.sender == owner(), Errors.VL_NOT_AUTHORIZED ); _; } modifier isAuthorizedExternal() { require( msg.sender == dydx_solo_margin || msg.sender == aave_lending_pool, Errors.VL_NOT_AUTHORIZED ); _; } /** * @dev Sets the fujiAdmin Address * @param _newFujiAdmin: FujiAdmin Contract Address */ function setFujiAdmin(address _newFujiAdmin) public onlyOwner { _fujiAdmin = IFujiAdmin(_newFujiAdmin); } /** * @dev Routing Function for Flashloan Provider * @param info: struct information for flashLoan * @param _flashnum: integer identifier of flashloan provider */ function initiateFlashloan(FlashLoan.Info memory info, uint8 _flashnum) public isAuthorized { if(_flashnum==0) { initiateAaveFlashLoan(info); } else if(_flashnum==1) { initiateDyDxFlashLoan(info); } } // ===================== DyDx FlashLoan =================================== /** * @dev Initiates a DyDx flashloan. * @param info: data to be passed between functions executing flashloan logic */ function initiateDyDxFlashLoan( FlashLoan.Info memory info ) internal { ISoloMargin solo = ISoloMargin(dydx_solo_margin); // Get marketId from token address uint256 marketId = _getMarketIdFromTokenAddress(solo, info.asset); // 1. Withdraw $ // 2. Call callFunction(...) // 3. Deposit back $ Actions.ActionArgs[] memory operations = new Actions.ActionArgs[](3); operations[0] = _getWithdrawAction(marketId, info.amount); // Encode FlashLoan.Info for callFunction operations[1] = _getCallAction(abi.encode(info)); // add fee of 2 wei operations[2] = _getDepositAction(marketId, info.amount.add(2)); Account.Info[] memory accountInfos = new Account.Info[](1); accountInfos[0] = _getAccountInfo(address(this)); solo.operate(accountInfos, operations); } /** * @dev Executes DyDx Flashloan, this operation is required * and called by Solo when sending loaned amount * @param sender: Not used * @param account: Not used */ function callFunction( address sender, Account.Info memory account, bytes memory data ) external override isAuthorizedExternal { sender; account; FlashLoan.Info memory info = abi.decode(data, (FlashLoan.Info)); //Estimate flashloan payback + premium fee of 2 wei, uint amountOwing = info.amount.add(2); // Transfer to Vault the flashloan Amount IERC20(info.asset).uniTransfer(payable(info.vault), info.amount); if (info.callType == FlashLoan.CallType.Switch) { IVault(info.vault) .executeSwitch(info.newProvider, info.amount, 2); } else if (info.callType == FlashLoan.CallType.Close) { IFliquidator(info.fliquidator) .executeFlashClose(info.user, info.vault, info.amount, 2); } else { IFliquidator(info.fliquidator) .executeFlashLiquidation(info.user, info.userliquidator, info.vault, info.amount, 2); } //Approve DYDXSolo to spend to repay flashloan IERC20(info.asset).approve(dydx_solo_margin, amountOwing); } // ===================== Aave FlashLoan =================================== /** * @dev Initiates an Aave flashloan. * @param info: data to be passed between functions executing flashloan logic */ function initiateAaveFlashLoan( FlashLoan.Info memory info ) internal { //Initialize Instance of Aave Lending Pool ILendingPool aaveLp = ILendingPool(aave_lending_pool); //Passing arguments to construct Aave flashloan -limited to 1 asset type for now. address receiverAddress = address(this); address[] memory assets = new address[](1); assets[0] = address(info.asset); uint256[] memory amounts = new uint256[](1); amounts[0] = info.amount; // 0 = no debt, 1 = stable, 2 = variable uint256[] memory modes = new uint256[](1); modes[0] = 0; address onBehalfOf = address(this); bytes memory params = abi.encode(info); uint16 referralCode = 0; //Aave Flashloan initiated. aaveLp.flashLoan( receiverAddress, assets, amounts, modes, onBehalfOf, params, referralCode ); } /** * @dev Executes Aave Flashloan, this operation is required * and called by Aaveflashloan when sending loaned amount */ function executeOperation( address[] calldata assets, uint256[] calldata amounts, uint256[] calldata premiums, address initiator, bytes calldata params ) external override isAuthorizedExternal returns (bool) { initiator; FlashLoan.Info memory info = abi.decode(params, (FlashLoan.Info)); //Estimate flashloan payback + premium fee, uint amountOwing = amounts[0].add(premiums[0]); // Transfer to the vault ERC20 IERC20(assets[0]).uniTransfer(payable(info.vault), amounts[0]); if (info.callType == FlashLoan.CallType.Switch) { IVault(info.vault) .executeSwitch(info.newProvider, amounts[0], premiums[0]); } else if (info.callType == FlashLoan.CallType.Close) { IFliquidator(info.fliquidator) .executeFlashClose(info.user, info.vault, amounts[0], premiums[0]); } else { IFliquidator(info.fliquidator) .executeFlashLiquidation(info.user, info.userliquidator, info.vault, amounts[0],premiums[0]); } //Approve aaveLP to spend to repay flashloan IERC20(assets[0]).uniApprove(payable(aave_lending_pool), amountOwing); return true; } }
initiateAaveFlashLoan
function initiateAaveFlashLoan( FlashLoan.Info memory info ) internal { //Initialize Instance of Aave Lending Pool ILendingPool aaveLp = ILendingPool(aave_lending_pool); //Passing arguments to construct Aave flashloan -limited to 1 asset type for now. address receiverAddress = address(this); address[] memory assets = new address[](1); assets[0] = address(info.asset); uint256[] memory amounts = new uint256[](1); amounts[0] = info.amount; // 0 = no debt, 1 = stable, 2 = variable uint256[] memory modes = new uint256[](1); modes[0] = 0; address onBehalfOf = address(this); bytes memory params = abi.encode(info); uint16 referralCode = 0; //Aave Flashloan initiated. aaveLp.flashLoan( receiverAddress, assets, amounts, modes, onBehalfOf, params, referralCode ); }
/** * @dev Initiates an Aave flashloan. * @param info: data to be passed between functions executing flashloan logic */
NatSpecMultiLine
v0.6.12+commit.27d51765
{ "func_code_index": [ 3922, 4811 ] }
7,769
Fliquidator
contracts/Flashloans/Flasher.sol
0xe3a2df184c021b8cbdfe2e89f7d3f495473b2be0
Solidity
Flasher
contract Flasher is DyDxFlashloanBase, IFlashLoanReceiver, ICallee, Ownable { using SafeMath for uint256; using UniERC20 for IERC20; IFujiAdmin private _fujiAdmin; address public aave_lending_pool; address public dydx_solo_margin; receive() external payable {} constructor() public { aave_lending_pool = 0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9; dydx_solo_margin = 0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e; } modifier isAuthorized() { require( msg.sender == _fujiAdmin.getController() || msg.sender == _fujiAdmin.getFliquidator() || msg.sender == owner(), Errors.VL_NOT_AUTHORIZED ); _; } modifier isAuthorizedExternal() { require( msg.sender == dydx_solo_margin || msg.sender == aave_lending_pool, Errors.VL_NOT_AUTHORIZED ); _; } /** * @dev Sets the fujiAdmin Address * @param _newFujiAdmin: FujiAdmin Contract Address */ function setFujiAdmin(address _newFujiAdmin) public onlyOwner { _fujiAdmin = IFujiAdmin(_newFujiAdmin); } /** * @dev Routing Function for Flashloan Provider * @param info: struct information for flashLoan * @param _flashnum: integer identifier of flashloan provider */ function initiateFlashloan(FlashLoan.Info memory info, uint8 _flashnum) public isAuthorized { if(_flashnum==0) { initiateAaveFlashLoan(info); } else if(_flashnum==1) { initiateDyDxFlashLoan(info); } } // ===================== DyDx FlashLoan =================================== /** * @dev Initiates a DyDx flashloan. * @param info: data to be passed between functions executing flashloan logic */ function initiateDyDxFlashLoan( FlashLoan.Info memory info ) internal { ISoloMargin solo = ISoloMargin(dydx_solo_margin); // Get marketId from token address uint256 marketId = _getMarketIdFromTokenAddress(solo, info.asset); // 1. Withdraw $ // 2. Call callFunction(...) // 3. Deposit back $ Actions.ActionArgs[] memory operations = new Actions.ActionArgs[](3); operations[0] = _getWithdrawAction(marketId, info.amount); // Encode FlashLoan.Info for callFunction operations[1] = _getCallAction(abi.encode(info)); // add fee of 2 wei operations[2] = _getDepositAction(marketId, info.amount.add(2)); Account.Info[] memory accountInfos = new Account.Info[](1); accountInfos[0] = _getAccountInfo(address(this)); solo.operate(accountInfos, operations); } /** * @dev Executes DyDx Flashloan, this operation is required * and called by Solo when sending loaned amount * @param sender: Not used * @param account: Not used */ function callFunction( address sender, Account.Info memory account, bytes memory data ) external override isAuthorizedExternal { sender; account; FlashLoan.Info memory info = abi.decode(data, (FlashLoan.Info)); //Estimate flashloan payback + premium fee of 2 wei, uint amountOwing = info.amount.add(2); // Transfer to Vault the flashloan Amount IERC20(info.asset).uniTransfer(payable(info.vault), info.amount); if (info.callType == FlashLoan.CallType.Switch) { IVault(info.vault) .executeSwitch(info.newProvider, info.amount, 2); } else if (info.callType == FlashLoan.CallType.Close) { IFliquidator(info.fliquidator) .executeFlashClose(info.user, info.vault, info.amount, 2); } else { IFliquidator(info.fliquidator) .executeFlashLiquidation(info.user, info.userliquidator, info.vault, info.amount, 2); } //Approve DYDXSolo to spend to repay flashloan IERC20(info.asset).approve(dydx_solo_margin, amountOwing); } // ===================== Aave FlashLoan =================================== /** * @dev Initiates an Aave flashloan. * @param info: data to be passed between functions executing flashloan logic */ function initiateAaveFlashLoan( FlashLoan.Info memory info ) internal { //Initialize Instance of Aave Lending Pool ILendingPool aaveLp = ILendingPool(aave_lending_pool); //Passing arguments to construct Aave flashloan -limited to 1 asset type for now. address receiverAddress = address(this); address[] memory assets = new address[](1); assets[0] = address(info.asset); uint256[] memory amounts = new uint256[](1); amounts[0] = info.amount; // 0 = no debt, 1 = stable, 2 = variable uint256[] memory modes = new uint256[](1); modes[0] = 0; address onBehalfOf = address(this); bytes memory params = abi.encode(info); uint16 referralCode = 0; //Aave Flashloan initiated. aaveLp.flashLoan( receiverAddress, assets, amounts, modes, onBehalfOf, params, referralCode ); } /** * @dev Executes Aave Flashloan, this operation is required * and called by Aaveflashloan when sending loaned amount */ function executeOperation( address[] calldata assets, uint256[] calldata amounts, uint256[] calldata premiums, address initiator, bytes calldata params ) external override isAuthorizedExternal returns (bool) { initiator; FlashLoan.Info memory info = abi.decode(params, (FlashLoan.Info)); //Estimate flashloan payback + premium fee, uint amountOwing = amounts[0].add(premiums[0]); // Transfer to the vault ERC20 IERC20(assets[0]).uniTransfer(payable(info.vault), amounts[0]); if (info.callType == FlashLoan.CallType.Switch) { IVault(info.vault) .executeSwitch(info.newProvider, amounts[0], premiums[0]); } else if (info.callType == FlashLoan.CallType.Close) { IFliquidator(info.fliquidator) .executeFlashClose(info.user, info.vault, amounts[0], premiums[0]); } else { IFliquidator(info.fliquidator) .executeFlashLiquidation(info.user, info.userliquidator, info.vault, amounts[0],premiums[0]); } //Approve aaveLP to spend to repay flashloan IERC20(assets[0]).uniApprove(payable(aave_lending_pool), amountOwing); return true; } }
executeOperation
function executeOperation( address[] calldata assets, uint256[] calldata amounts, uint256[] calldata premiums, address initiator, bytes calldata params ) external override isAuthorizedExternal returns (bool) { initiator; FlashLoan.Info memory info = abi.decode(params, (FlashLoan.Info)); //Estimate flashloan payback + premium fee, uint amountOwing = amounts[0].add(premiums[0]); // Transfer to the vault ERC20 IERC20(assets[0]).uniTransfer(payable(info.vault), amounts[0]); if (info.callType == FlashLoan.CallType.Switch) { IVault(info.vault) .executeSwitch(info.newProvider, amounts[0], premiums[0]); } else if (info.callType == FlashLoan.CallType.Close) { IFliquidator(info.fliquidator) .executeFlashClose(info.user, info.vault, amounts[0], premiums[0]); } else { IFliquidator(info.fliquidator) .executeFlashLiquidation(info.user, info.userliquidator, info.vault, amounts[0],premiums[0]); } //Approve aaveLP to spend to repay flashloan IERC20(assets[0]).uniApprove(payable(aave_lending_pool), amountOwing); return true; }
/** * @dev Executes Aave Flashloan, this operation is required * and called by Aaveflashloan when sending loaned amount */
NatSpecMultiLine
v0.6.12+commit.27d51765
{ "func_code_index": [ 4944, 6096 ] }
7,770
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { // Gas optimization: this is cheaper than asserting 'a' not being zero, but the // benefit is lost if 'b' is also tested. if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws 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 a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } }
/** * @title SafeMath * @dev Math operations with safety checks that throw on error */
NatSpecMultiLine
mul
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { // Gas optimization: this is cheaper than asserting 'a' not being zero, but the // benefit is lost if 'b' is also tested. if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; }
/** * @dev Multiplies two numbers, throws on overflow. */
NatSpecMultiLine
v0.4.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 83, 358 ] }
7,771
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { // Gas optimization: this is cheaper than asserting 'a' not being zero, but the // benefit is lost if 'b' is also tested. if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws 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 a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } }
/** * @title SafeMath * @dev Math operations with safety checks that throw on error */
NatSpecMultiLine
div
function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws 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 a / b; }
/** * @dev Integer division of two numbers, truncating the quotient. */
NatSpecMultiLine
v0.4.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 436, 696 ] }
7,772
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { // Gas optimization: this is cheaper than asserting 'a' not being zero, but the // benefit is lost if 'b' is also tested. if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws 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 a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } }
/** * @title SafeMath * @dev Math operations with safety checks that throw on error */
NatSpecMultiLine
sub
function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; }
/** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */
NatSpecMultiLine
v0.4.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 804, 908 ] }
7,773
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { // Gas optimization: this is cheaper than asserting 'a' not being zero, but the // benefit is lost if 'b' is also tested. if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws 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 a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } }
/** * @title SafeMath * @dev Math operations with safety checks that throw on error */
NatSpecMultiLine
add
function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; }
/** * @dev Adds two numbers, throws on overflow. */
NatSpecMultiLine
v0.4.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 966, 1080 ] }
7,774
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
BasicToken
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } }
/** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */
NatSpecMultiLine
totalSupply
function totalSupply() public view returns (uint256) { return totalSupply_; }
/** * @dev total number of tokens in existence */
NatSpecMultiLine
v0.4.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 187, 267 ] }
7,775
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
BasicToken
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } }
/** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */
NatSpecMultiLine
transfer
function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); 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.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 415, 719 ] }
7,776
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
BasicToken
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } }
/** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */
NatSpecMultiLine
balanceOf
function balanceOf(address _owner) public view returns (uint256) { 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.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 915, 1011 ] }
7,777
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _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 Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval( address _spender, uint _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval( address _spender, uint _subtractedValue ) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
/** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */
NatSpecMultiLine
transferFrom
function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); 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.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 382, 812 ] }
7,778
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _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 Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval( address _spender, uint _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval( address _spender, uint _subtractedValue ) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
/** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */
NatSpecMultiLine
approve
function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; 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.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 1034, 1213 ] }
7,779
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _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 Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval( address _spender, uint _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval( address _spender, uint _subtractedValue ) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
/** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */
NatSpecMultiLine
allowance
function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; }
/** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */
NatSpecMultiLine
v0.4.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 1520, 1652 ] }
7,780
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _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 Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval( address _spender, uint _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval( address _spender, uint _subtractedValue ) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
/** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */
NatSpecMultiLine
increaseApproval
function increaseApproval( address _spender, uint _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; }
/** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */
NatSpecMultiLine
v0.4.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 2089, 2354 ] }
7,781
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _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 Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval( address _spender, uint _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval( address _spender, uint _subtractedValue ) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
/** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */
NatSpecMultiLine
decreaseApproval
function decreaseApproval( address _spender, uint _subtractedValue ) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; }
/** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */
NatSpecMultiLine
v0.4.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 2796, 3179 ] }
7,782
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
Ownable
contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() 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 relinquish control of the contract. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } }
/** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */
NatSpecMultiLine
renounceOwnership
function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); }
/** * @dev Allows the current owner to relinquish control of the contract. */
NatSpecMultiLine
v0.4.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 575, 680 ] }
7,783
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
Ownable
contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() 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 relinquish control of the contract. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } }
/** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */
NatSpecMultiLine
transferOwnership
function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_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.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 834, 934 ] }
7,784
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
Ownable
contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() 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 relinquish control of the contract. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } }
/** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */
NatSpecMultiLine
_transferOwnership
function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; }
/** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */
NatSpecMultiLine
v0.4.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 1061, 1223 ] }
7,785
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
MintableToken
contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } modifier hasMintPermission() { require(msg.sender == owner); _; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint( address _to, uint256 _amount ) hasMintPermission canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; emit MintFinished(); return true; } }
/** * @title Mintable token */
NatSpecMultiLine
mint
function mint( address _to, uint256 _amount ) hasMintPermission canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; }
/** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */
NatSpecMultiLine
v0.4.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 520, 797 ] }
7,786
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
MintableToken
contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } modifier hasMintPermission() { require(msg.sender == owner); _; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint( address _to, uint256 _amount ) hasMintPermission canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; emit MintFinished(); return true; } }
/** * @title Mintable token */
NatSpecMultiLine
finishMinting
function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; emit MintFinished(); return true; }
/** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */
NatSpecMultiLine
v0.4.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 903, 1034 ] }
7,787
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
FreezableToken
contract FreezableToken is StandardToken { // freezing chains mapping (bytes32 => uint64) internal chains; // freezing amounts for each chain mapping (bytes32 => uint) internal freezings; // total freezing balance per address mapping (address => uint) internal freezingBalance; event Freezed(address indexed to, uint64 release, uint amount); event Released(address indexed owner, uint amount); /** * @dev Gets the balance of the specified address include freezing tokens. * @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 super.balanceOf(_owner) + freezingBalance[_owner]; } /** * @dev Gets the balance of the specified address without freezing tokens. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function actualBalanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner); } function freezingBalanceOf(address _owner) public view returns (uint256 balance) { return freezingBalance[_owner]; } /** * @dev gets freezing count * @param _addr Address of freeze tokens owner. */ function freezingCount(address _addr) public view returns (uint count) { uint64 release = chains[toKey(_addr, 0)]; while (release != 0) { count++; release = chains[toKey(_addr, release)]; } } /** * @dev gets freezing end date and freezing balance for the freezing portion specified by index. * @param _addr Address of freeze tokens owner. * @param _index Freezing portion index. It ordered by release date descending. */ function getFreezing(address _addr, uint _index) public view returns (uint64 _release, uint _balance) { for (uint i = 0; i < _index + 1; i++) { _release = chains[toKey(_addr, _release)]; if (_release == 0) { return; } } _balance = freezings[toKey(_addr, _release)]; } /** * @dev freeze your tokens to the specified address. * Be careful, gas usage is not deterministic, * and depends on how many freezes _to address already has. * @param _to Address to which token will be freeze. * @param _amount Amount of token to freeze. * @param _until Release date, must be in future. */ function freezeTo(address _to, uint _amount, uint64 _until) public { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Transfer(msg.sender, _to, _amount); emit Freezed(_to, _until, _amount); } /** * @dev release first available freezing tokens. */ function releaseOnce() public { bytes32 headKey = toKey(msg.sender, 0); uint64 head = chains[headKey]; require(head != 0); require(uint64(block.timestamp) > head); bytes32 currentKey = toKey(msg.sender, head); uint64 next = chains[currentKey]; uint amount = freezings[currentKey]; delete freezings[currentKey]; balances[msg.sender] = balances[msg.sender].add(amount); freezingBalance[msg.sender] = freezingBalance[msg.sender].sub(amount); if (next == 0) { delete chains[headKey]; } else { chains[headKey] = next; delete chains[currentKey]; } emit Released(msg.sender, amount); } /** * @dev release all available for release freezing tokens. Gas usage is not deterministic! * @return how many tokens was released */ function releaseAll() public returns (uint tokens) { uint release; uint balance; (release, balance) = getFreezing(msg.sender, 0); while (release != 0 && block.timestamp > release) { releaseOnce(); tokens += balance; (release, balance) = getFreezing(msg.sender, 0); } } function toKey(address _addr, uint _release) internal pure returns (bytes32 result) { // masc to increase entropy result = 0x5749534800000000000000000000000000000000000000000000000000000000; assembly { result := or(result, mul(_addr, 0x10000000000000000)) result := or(result, _release) } } function freeze(address _to, uint64 _until) internal { require(_until > block.timestamp); bytes32 key = toKey(_to, _until); bytes32 parentKey = toKey(_to, uint64(0)); uint64 next = chains[parentKey]; if (next == 0) { chains[parentKey] = _until; return; } bytes32 nextKey = toKey(_to, next); uint parent; while (next != 0 && _until > next) { parent = next; parentKey = nextKey; next = chains[nextKey]; nextKey = toKey(_to, next); } if (_until == next) { return; } if (next != 0) { chains[key] = next; } chains[parentKey] = _until; } }
balanceOf
function balanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner) + freezingBalance[_owner]; }
/** * @dev Gets the balance of the specified address include freezing tokens. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */
NatSpecMultiLine
v0.4.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 624, 761 ] }
7,788
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
FreezableToken
contract FreezableToken is StandardToken { // freezing chains mapping (bytes32 => uint64) internal chains; // freezing amounts for each chain mapping (bytes32 => uint) internal freezings; // total freezing balance per address mapping (address => uint) internal freezingBalance; event Freezed(address indexed to, uint64 release, uint amount); event Released(address indexed owner, uint amount); /** * @dev Gets the balance of the specified address include freezing tokens. * @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 super.balanceOf(_owner) + freezingBalance[_owner]; } /** * @dev Gets the balance of the specified address without freezing tokens. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function actualBalanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner); } function freezingBalanceOf(address _owner) public view returns (uint256 balance) { return freezingBalance[_owner]; } /** * @dev gets freezing count * @param _addr Address of freeze tokens owner. */ function freezingCount(address _addr) public view returns (uint count) { uint64 release = chains[toKey(_addr, 0)]; while (release != 0) { count++; release = chains[toKey(_addr, release)]; } } /** * @dev gets freezing end date and freezing balance for the freezing portion specified by index. * @param _addr Address of freeze tokens owner. * @param _index Freezing portion index. It ordered by release date descending. */ function getFreezing(address _addr, uint _index) public view returns (uint64 _release, uint _balance) { for (uint i = 0; i < _index + 1; i++) { _release = chains[toKey(_addr, _release)]; if (_release == 0) { return; } } _balance = freezings[toKey(_addr, _release)]; } /** * @dev freeze your tokens to the specified address. * Be careful, gas usage is not deterministic, * and depends on how many freezes _to address already has. * @param _to Address to which token will be freeze. * @param _amount Amount of token to freeze. * @param _until Release date, must be in future. */ function freezeTo(address _to, uint _amount, uint64 _until) public { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Transfer(msg.sender, _to, _amount); emit Freezed(_to, _until, _amount); } /** * @dev release first available freezing tokens. */ function releaseOnce() public { bytes32 headKey = toKey(msg.sender, 0); uint64 head = chains[headKey]; require(head != 0); require(uint64(block.timestamp) > head); bytes32 currentKey = toKey(msg.sender, head); uint64 next = chains[currentKey]; uint amount = freezings[currentKey]; delete freezings[currentKey]; balances[msg.sender] = balances[msg.sender].add(amount); freezingBalance[msg.sender] = freezingBalance[msg.sender].sub(amount); if (next == 0) { delete chains[headKey]; } else { chains[headKey] = next; delete chains[currentKey]; } emit Released(msg.sender, amount); } /** * @dev release all available for release freezing tokens. Gas usage is not deterministic! * @return how many tokens was released */ function releaseAll() public returns (uint tokens) { uint release; uint balance; (release, balance) = getFreezing(msg.sender, 0); while (release != 0 && block.timestamp > release) { releaseOnce(); tokens += balance; (release, balance) = getFreezing(msg.sender, 0); } } function toKey(address _addr, uint _release) internal pure returns (bytes32 result) { // masc to increase entropy result = 0x5749534800000000000000000000000000000000000000000000000000000000; assembly { result := or(result, mul(_addr, 0x10000000000000000)) result := or(result, _release) } } function freeze(address _to, uint64 _until) internal { require(_until > block.timestamp); bytes32 key = toKey(_to, _until); bytes32 parentKey = toKey(_to, uint64(0)); uint64 next = chains[parentKey]; if (next == 0) { chains[parentKey] = _until; return; } bytes32 nextKey = toKey(_to, next); uint parent; while (next != 0 && _until > next) { parent = next; parentKey = nextKey; next = chains[nextKey]; nextKey = toKey(_to, next); } if (_until == next) { return; } if (next != 0) { chains[key] = next; } chains[parentKey] = _until; } }
actualBalanceOf
function actualBalanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner); }
/** * @dev Gets the balance of the specified address without freezing tokens. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */
NatSpecMultiLine
v0.4.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 981, 1098 ] }
7,789
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
FreezableToken
contract FreezableToken is StandardToken { // freezing chains mapping (bytes32 => uint64) internal chains; // freezing amounts for each chain mapping (bytes32 => uint) internal freezings; // total freezing balance per address mapping (address => uint) internal freezingBalance; event Freezed(address indexed to, uint64 release, uint amount); event Released(address indexed owner, uint amount); /** * @dev Gets the balance of the specified address include freezing tokens. * @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 super.balanceOf(_owner) + freezingBalance[_owner]; } /** * @dev Gets the balance of the specified address without freezing tokens. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function actualBalanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner); } function freezingBalanceOf(address _owner) public view returns (uint256 balance) { return freezingBalance[_owner]; } /** * @dev gets freezing count * @param _addr Address of freeze tokens owner. */ function freezingCount(address _addr) public view returns (uint count) { uint64 release = chains[toKey(_addr, 0)]; while (release != 0) { count++; release = chains[toKey(_addr, release)]; } } /** * @dev gets freezing end date and freezing balance for the freezing portion specified by index. * @param _addr Address of freeze tokens owner. * @param _index Freezing portion index. It ordered by release date descending. */ function getFreezing(address _addr, uint _index) public view returns (uint64 _release, uint _balance) { for (uint i = 0; i < _index + 1; i++) { _release = chains[toKey(_addr, _release)]; if (_release == 0) { return; } } _balance = freezings[toKey(_addr, _release)]; } /** * @dev freeze your tokens to the specified address. * Be careful, gas usage is not deterministic, * and depends on how many freezes _to address already has. * @param _to Address to which token will be freeze. * @param _amount Amount of token to freeze. * @param _until Release date, must be in future. */ function freezeTo(address _to, uint _amount, uint64 _until) public { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Transfer(msg.sender, _to, _amount); emit Freezed(_to, _until, _amount); } /** * @dev release first available freezing tokens. */ function releaseOnce() public { bytes32 headKey = toKey(msg.sender, 0); uint64 head = chains[headKey]; require(head != 0); require(uint64(block.timestamp) > head); bytes32 currentKey = toKey(msg.sender, head); uint64 next = chains[currentKey]; uint amount = freezings[currentKey]; delete freezings[currentKey]; balances[msg.sender] = balances[msg.sender].add(amount); freezingBalance[msg.sender] = freezingBalance[msg.sender].sub(amount); if (next == 0) { delete chains[headKey]; } else { chains[headKey] = next; delete chains[currentKey]; } emit Released(msg.sender, amount); } /** * @dev release all available for release freezing tokens. Gas usage is not deterministic! * @return how many tokens was released */ function releaseAll() public returns (uint tokens) { uint release; uint balance; (release, balance) = getFreezing(msg.sender, 0); while (release != 0 && block.timestamp > release) { releaseOnce(); tokens += balance; (release, balance) = getFreezing(msg.sender, 0); } } function toKey(address _addr, uint _release) internal pure returns (bytes32 result) { // masc to increase entropy result = 0x5749534800000000000000000000000000000000000000000000000000000000; assembly { result := or(result, mul(_addr, 0x10000000000000000)) result := or(result, _release) } } function freeze(address _to, uint64 _until) internal { require(_until > block.timestamp); bytes32 key = toKey(_to, _until); bytes32 parentKey = toKey(_to, uint64(0)); uint64 next = chains[parentKey]; if (next == 0) { chains[parentKey] = _until; return; } bytes32 nextKey = toKey(_to, next); uint parent; while (next != 0 && _until > next) { parent = next; parentKey = nextKey; next = chains[nextKey]; nextKey = toKey(_to, next); } if (_until == next) { return; } if (next != 0) { chains[key] = next; } chains[parentKey] = _until; } }
freezingCount
function freezingCount(address _addr) public view returns (uint count) { uint64 release = chains[toKey(_addr, 0)]; while (release != 0) { count++; release = chains[toKey(_addr, release)]; } }
/** * @dev gets freezing count * @param _addr Address of freeze tokens owner. */
NatSpecMultiLine
v0.4.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 1308, 1506 ] }
7,790
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
FreezableToken
contract FreezableToken is StandardToken { // freezing chains mapping (bytes32 => uint64) internal chains; // freezing amounts for each chain mapping (bytes32 => uint) internal freezings; // total freezing balance per address mapping (address => uint) internal freezingBalance; event Freezed(address indexed to, uint64 release, uint amount); event Released(address indexed owner, uint amount); /** * @dev Gets the balance of the specified address include freezing tokens. * @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 super.balanceOf(_owner) + freezingBalance[_owner]; } /** * @dev Gets the balance of the specified address without freezing tokens. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function actualBalanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner); } function freezingBalanceOf(address _owner) public view returns (uint256 balance) { return freezingBalance[_owner]; } /** * @dev gets freezing count * @param _addr Address of freeze tokens owner. */ function freezingCount(address _addr) public view returns (uint count) { uint64 release = chains[toKey(_addr, 0)]; while (release != 0) { count++; release = chains[toKey(_addr, release)]; } } /** * @dev gets freezing end date and freezing balance for the freezing portion specified by index. * @param _addr Address of freeze tokens owner. * @param _index Freezing portion index. It ordered by release date descending. */ function getFreezing(address _addr, uint _index) public view returns (uint64 _release, uint _balance) { for (uint i = 0; i < _index + 1; i++) { _release = chains[toKey(_addr, _release)]; if (_release == 0) { return; } } _balance = freezings[toKey(_addr, _release)]; } /** * @dev freeze your tokens to the specified address. * Be careful, gas usage is not deterministic, * and depends on how many freezes _to address already has. * @param _to Address to which token will be freeze. * @param _amount Amount of token to freeze. * @param _until Release date, must be in future. */ function freezeTo(address _to, uint _amount, uint64 _until) public { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Transfer(msg.sender, _to, _amount); emit Freezed(_to, _until, _amount); } /** * @dev release first available freezing tokens. */ function releaseOnce() public { bytes32 headKey = toKey(msg.sender, 0); uint64 head = chains[headKey]; require(head != 0); require(uint64(block.timestamp) > head); bytes32 currentKey = toKey(msg.sender, head); uint64 next = chains[currentKey]; uint amount = freezings[currentKey]; delete freezings[currentKey]; balances[msg.sender] = balances[msg.sender].add(amount); freezingBalance[msg.sender] = freezingBalance[msg.sender].sub(amount); if (next == 0) { delete chains[headKey]; } else { chains[headKey] = next; delete chains[currentKey]; } emit Released(msg.sender, amount); } /** * @dev release all available for release freezing tokens. Gas usage is not deterministic! * @return how many tokens was released */ function releaseAll() public returns (uint tokens) { uint release; uint balance; (release, balance) = getFreezing(msg.sender, 0); while (release != 0 && block.timestamp > release) { releaseOnce(); tokens += balance; (release, balance) = getFreezing(msg.sender, 0); } } function toKey(address _addr, uint _release) internal pure returns (bytes32 result) { // masc to increase entropy result = 0x5749534800000000000000000000000000000000000000000000000000000000; assembly { result := or(result, mul(_addr, 0x10000000000000000)) result := or(result, _release) } } function freeze(address _to, uint64 _until) internal { require(_until > block.timestamp); bytes32 key = toKey(_to, _until); bytes32 parentKey = toKey(_to, uint64(0)); uint64 next = chains[parentKey]; if (next == 0) { chains[parentKey] = _until; return; } bytes32 nextKey = toKey(_to, next); uint parent; while (next != 0 && _until > next) { parent = next; parentKey = nextKey; next = chains[nextKey]; nextKey = toKey(_to, next); } if (_until == next) { return; } if (next != 0) { chains[key] = next; } chains[parentKey] = _until; } }
getFreezing
function getFreezing(address _addr, uint _index) public view returns (uint64 _release, uint _balance) { for (uint i = 0; i < _index + 1; i++) { _release = chains[toKey(_addr, _release)]; if (_release == 0) { return; } } _balance = freezings[toKey(_addr, _release)]; }
/** * @dev gets freezing end date and freezing balance for the freezing portion specified by index. * @param _addr Address of freeze tokens owner. * @param _index Freezing portion index. It ordered by release date descending. */
NatSpecMultiLine
v0.4.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 1743, 2019 ] }
7,791
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
FreezableToken
contract FreezableToken is StandardToken { // freezing chains mapping (bytes32 => uint64) internal chains; // freezing amounts for each chain mapping (bytes32 => uint) internal freezings; // total freezing balance per address mapping (address => uint) internal freezingBalance; event Freezed(address indexed to, uint64 release, uint amount); event Released(address indexed owner, uint amount); /** * @dev Gets the balance of the specified address include freezing tokens. * @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 super.balanceOf(_owner) + freezingBalance[_owner]; } /** * @dev Gets the balance of the specified address without freezing tokens. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function actualBalanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner); } function freezingBalanceOf(address _owner) public view returns (uint256 balance) { return freezingBalance[_owner]; } /** * @dev gets freezing count * @param _addr Address of freeze tokens owner. */ function freezingCount(address _addr) public view returns (uint count) { uint64 release = chains[toKey(_addr, 0)]; while (release != 0) { count++; release = chains[toKey(_addr, release)]; } } /** * @dev gets freezing end date and freezing balance for the freezing portion specified by index. * @param _addr Address of freeze tokens owner. * @param _index Freezing portion index. It ordered by release date descending. */ function getFreezing(address _addr, uint _index) public view returns (uint64 _release, uint _balance) { for (uint i = 0; i < _index + 1; i++) { _release = chains[toKey(_addr, _release)]; if (_release == 0) { return; } } _balance = freezings[toKey(_addr, _release)]; } /** * @dev freeze your tokens to the specified address. * Be careful, gas usage is not deterministic, * and depends on how many freezes _to address already has. * @param _to Address to which token will be freeze. * @param _amount Amount of token to freeze. * @param _until Release date, must be in future. */ function freezeTo(address _to, uint _amount, uint64 _until) public { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Transfer(msg.sender, _to, _amount); emit Freezed(_to, _until, _amount); } /** * @dev release first available freezing tokens. */ function releaseOnce() public { bytes32 headKey = toKey(msg.sender, 0); uint64 head = chains[headKey]; require(head != 0); require(uint64(block.timestamp) > head); bytes32 currentKey = toKey(msg.sender, head); uint64 next = chains[currentKey]; uint amount = freezings[currentKey]; delete freezings[currentKey]; balances[msg.sender] = balances[msg.sender].add(amount); freezingBalance[msg.sender] = freezingBalance[msg.sender].sub(amount); if (next == 0) { delete chains[headKey]; } else { chains[headKey] = next; delete chains[currentKey]; } emit Released(msg.sender, amount); } /** * @dev release all available for release freezing tokens. Gas usage is not deterministic! * @return how many tokens was released */ function releaseAll() public returns (uint tokens) { uint release; uint balance; (release, balance) = getFreezing(msg.sender, 0); while (release != 0 && block.timestamp > release) { releaseOnce(); tokens += balance; (release, balance) = getFreezing(msg.sender, 0); } } function toKey(address _addr, uint _release) internal pure returns (bytes32 result) { // masc to increase entropy result = 0x5749534800000000000000000000000000000000000000000000000000000000; assembly { result := or(result, mul(_addr, 0x10000000000000000)) result := or(result, _release) } } function freeze(address _to, uint64 _until) internal { require(_until > block.timestamp); bytes32 key = toKey(_to, _until); bytes32 parentKey = toKey(_to, uint64(0)); uint64 next = chains[parentKey]; if (next == 0) { chains[parentKey] = _until; return; } bytes32 nextKey = toKey(_to, next); uint parent; while (next != 0 && _until > next) { parent = next; parentKey = nextKey; next = chains[nextKey]; nextKey = toKey(_to, next); } if (_until == next) { return; } if (next != 0) { chains[key] = next; } chains[parentKey] = _until; } }
freezeTo
function freezeTo(address _to, uint _amount, uint64 _until) public { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Transfer(msg.sender, _to, _amount); emit Freezed(_to, _until, _amount); }
/** * @dev freeze your tokens to the specified address. * Be careful, gas usage is not deterministic, * and depends on how many freezes _to address already has. * @param _to Address to which token will be freeze. * @param _amount Amount of token to freeze. * @param _until Release date, must be in future. */
NatSpecMultiLine
v0.4.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 2339, 2811 ] }
7,792
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
FreezableToken
contract FreezableToken is StandardToken { // freezing chains mapping (bytes32 => uint64) internal chains; // freezing amounts for each chain mapping (bytes32 => uint) internal freezings; // total freezing balance per address mapping (address => uint) internal freezingBalance; event Freezed(address indexed to, uint64 release, uint amount); event Released(address indexed owner, uint amount); /** * @dev Gets the balance of the specified address include freezing tokens. * @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 super.balanceOf(_owner) + freezingBalance[_owner]; } /** * @dev Gets the balance of the specified address without freezing tokens. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function actualBalanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner); } function freezingBalanceOf(address _owner) public view returns (uint256 balance) { return freezingBalance[_owner]; } /** * @dev gets freezing count * @param _addr Address of freeze tokens owner. */ function freezingCount(address _addr) public view returns (uint count) { uint64 release = chains[toKey(_addr, 0)]; while (release != 0) { count++; release = chains[toKey(_addr, release)]; } } /** * @dev gets freezing end date and freezing balance for the freezing portion specified by index. * @param _addr Address of freeze tokens owner. * @param _index Freezing portion index. It ordered by release date descending. */ function getFreezing(address _addr, uint _index) public view returns (uint64 _release, uint _balance) { for (uint i = 0; i < _index + 1; i++) { _release = chains[toKey(_addr, _release)]; if (_release == 0) { return; } } _balance = freezings[toKey(_addr, _release)]; } /** * @dev freeze your tokens to the specified address. * Be careful, gas usage is not deterministic, * and depends on how many freezes _to address already has. * @param _to Address to which token will be freeze. * @param _amount Amount of token to freeze. * @param _until Release date, must be in future. */ function freezeTo(address _to, uint _amount, uint64 _until) public { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Transfer(msg.sender, _to, _amount); emit Freezed(_to, _until, _amount); } /** * @dev release first available freezing tokens. */ function releaseOnce() public { bytes32 headKey = toKey(msg.sender, 0); uint64 head = chains[headKey]; require(head != 0); require(uint64(block.timestamp) > head); bytes32 currentKey = toKey(msg.sender, head); uint64 next = chains[currentKey]; uint amount = freezings[currentKey]; delete freezings[currentKey]; balances[msg.sender] = balances[msg.sender].add(amount); freezingBalance[msg.sender] = freezingBalance[msg.sender].sub(amount); if (next == 0) { delete chains[headKey]; } else { chains[headKey] = next; delete chains[currentKey]; } emit Released(msg.sender, amount); } /** * @dev release all available for release freezing tokens. Gas usage is not deterministic! * @return how many tokens was released */ function releaseAll() public returns (uint tokens) { uint release; uint balance; (release, balance) = getFreezing(msg.sender, 0); while (release != 0 && block.timestamp > release) { releaseOnce(); tokens += balance; (release, balance) = getFreezing(msg.sender, 0); } } function toKey(address _addr, uint _release) internal pure returns (bytes32 result) { // masc to increase entropy result = 0x5749534800000000000000000000000000000000000000000000000000000000; assembly { result := or(result, mul(_addr, 0x10000000000000000)) result := or(result, _release) } } function freeze(address _to, uint64 _until) internal { require(_until > block.timestamp); bytes32 key = toKey(_to, _until); bytes32 parentKey = toKey(_to, uint64(0)); uint64 next = chains[parentKey]; if (next == 0) { chains[parentKey] = _until; return; } bytes32 nextKey = toKey(_to, next); uint parent; while (next != 0 && _until > next) { parent = next; parentKey = nextKey; next = chains[nextKey]; nextKey = toKey(_to, next); } if (_until == next) { return; } if (next != 0) { chains[key] = next; } chains[parentKey] = _until; } }
releaseOnce
function releaseOnce() public { bytes32 headKey = toKey(msg.sender, 0); uint64 head = chains[headKey]; require(head != 0); require(uint64(block.timestamp) > head); bytes32 currentKey = toKey(msg.sender, head); uint64 next = chains[currentKey]; uint amount = freezings[currentKey]; delete freezings[currentKey]; balances[msg.sender] = balances[msg.sender].add(amount); freezingBalance[msg.sender] = freezingBalance[msg.sender].sub(amount); if (next == 0) { delete chains[headKey]; } else { chains[headKey] = next; delete chains[currentKey]; } emit Released(msg.sender, amount); }
/** * @dev release first available freezing tokens. */
NatSpecMultiLine
v0.4.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 2872, 3477 ] }
7,793
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
FreezableToken
contract FreezableToken is StandardToken { // freezing chains mapping (bytes32 => uint64) internal chains; // freezing amounts for each chain mapping (bytes32 => uint) internal freezings; // total freezing balance per address mapping (address => uint) internal freezingBalance; event Freezed(address indexed to, uint64 release, uint amount); event Released(address indexed owner, uint amount); /** * @dev Gets the balance of the specified address include freezing tokens. * @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 super.balanceOf(_owner) + freezingBalance[_owner]; } /** * @dev Gets the balance of the specified address without freezing tokens. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function actualBalanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner); } function freezingBalanceOf(address _owner) public view returns (uint256 balance) { return freezingBalance[_owner]; } /** * @dev gets freezing count * @param _addr Address of freeze tokens owner. */ function freezingCount(address _addr) public view returns (uint count) { uint64 release = chains[toKey(_addr, 0)]; while (release != 0) { count++; release = chains[toKey(_addr, release)]; } } /** * @dev gets freezing end date and freezing balance for the freezing portion specified by index. * @param _addr Address of freeze tokens owner. * @param _index Freezing portion index. It ordered by release date descending. */ function getFreezing(address _addr, uint _index) public view returns (uint64 _release, uint _balance) { for (uint i = 0; i < _index + 1; i++) { _release = chains[toKey(_addr, _release)]; if (_release == 0) { return; } } _balance = freezings[toKey(_addr, _release)]; } /** * @dev freeze your tokens to the specified address. * Be careful, gas usage is not deterministic, * and depends on how many freezes _to address already has. * @param _to Address to which token will be freeze. * @param _amount Amount of token to freeze. * @param _until Release date, must be in future. */ function freezeTo(address _to, uint _amount, uint64 _until) public { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Transfer(msg.sender, _to, _amount); emit Freezed(_to, _until, _amount); } /** * @dev release first available freezing tokens. */ function releaseOnce() public { bytes32 headKey = toKey(msg.sender, 0); uint64 head = chains[headKey]; require(head != 0); require(uint64(block.timestamp) > head); bytes32 currentKey = toKey(msg.sender, head); uint64 next = chains[currentKey]; uint amount = freezings[currentKey]; delete freezings[currentKey]; balances[msg.sender] = balances[msg.sender].add(amount); freezingBalance[msg.sender] = freezingBalance[msg.sender].sub(amount); if (next == 0) { delete chains[headKey]; } else { chains[headKey] = next; delete chains[currentKey]; } emit Released(msg.sender, amount); } /** * @dev release all available for release freezing tokens. Gas usage is not deterministic! * @return how many tokens was released */ function releaseAll() public returns (uint tokens) { uint release; uint balance; (release, balance) = getFreezing(msg.sender, 0); while (release != 0 && block.timestamp > release) { releaseOnce(); tokens += balance; (release, balance) = getFreezing(msg.sender, 0); } } function toKey(address _addr, uint _release) internal pure returns (bytes32 result) { // masc to increase entropy result = 0x5749534800000000000000000000000000000000000000000000000000000000; assembly { result := or(result, mul(_addr, 0x10000000000000000)) result := or(result, _release) } } function freeze(address _to, uint64 _until) internal { require(_until > block.timestamp); bytes32 key = toKey(_to, _until); bytes32 parentKey = toKey(_to, uint64(0)); uint64 next = chains[parentKey]; if (next == 0) { chains[parentKey] = _until; return; } bytes32 nextKey = toKey(_to, next); uint parent; while (next != 0 && _until > next) { parent = next; parentKey = nextKey; next = chains[nextKey]; nextKey = toKey(_to, next); } if (_until == next) { return; } if (next != 0) { chains[key] = next; } chains[parentKey] = _until; } }
releaseAll
function releaseAll() public returns (uint tokens) { uint release; uint balance; (release, balance) = getFreezing(msg.sender, 0); while (release != 0 && block.timestamp > release) { releaseOnce(); tokens += balance; (release, balance) = getFreezing(msg.sender, 0); } }
/** * @dev release all available for release freezing tokens. Gas usage is not deterministic! * @return how many tokens was released */
NatSpecMultiLine
v0.4.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 3620, 3898 ] }
7,794
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
BurnableToken
contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); /** * @dev Burns a specific amount of tokens. * @param _value The amount of token to be burned. */ function burn(uint256 _value) public { _burn(msg.sender, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); // no need to require value <= totalSupply, since that would imply the // sender's balance is greater than the totalSupply, which *should* be an assertion failure balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } }
/** * @title Burnable Token * @dev Token that can be irreversibly burned (destroyed). */
NatSpecMultiLine
burn
function burn(uint256 _value) public { _burn(msg.sender, _value); }
/** * @dev Burns a specific amount of tokens. * @param _value The amount of token to be burned. */
NatSpecMultiLine
v0.4.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 199, 269 ] }
7,795
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
Pausable
contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!paused); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } }
/** * @title Pausable * @dev Base contract which allows children to implement an emergency stop mechanism. */
NatSpecMultiLine
pause
function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); }
/** * @dev called by the owner to pause, triggers stopped state */
NatSpecMultiLine
v0.4.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 459, 543 ] }
7,796
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
Pausable
contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!paused); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } }
/** * @title Pausable * @dev Base contract which allows children to implement an emergency stop mechanism. */
NatSpecMultiLine
unpause
function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); }
/** * @dev called by the owner to unpause, returns to normal state */
NatSpecMultiLine
v0.4.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 619, 705 ] }
7,797
MedistockPayCoin
MedistockPayCoin.sol
0x030f973bf5783cba771354f7e6f794f348c5f06c
Solidity
FreezableMintableToken
contract FreezableMintableToken is FreezableToken, MintableToken { /** * @dev Mint the specified amount of token to the specified address and freeze it until the specified date. * Be careful, gas usage is not deterministic, * and depends on how many freezes _to address already has. * @param _to Address to which token will be freeze. * @param _amount Amount of token to mint and freeze. * @param _until Release date, must be in future. * @return A boolean that indicates if the operation was successful. */ function mintAndFreeze(address _to, uint _amount, uint64 _until) public onlyOwner canMint returns (bool) { totalSupply_ = totalSupply_.add(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Mint(_to, _amount); emit Freezed(_to, _until, _amount); emit Transfer(msg.sender, _to, _amount); return true; } }
mintAndFreeze
function mintAndFreeze(address _to, uint _amount, uint64 _until) public onlyOwner canMint returns (bool) { totalSupply_ = totalSupply_.add(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Mint(_to, _amount); emit Freezed(_to, _until, _amount); emit Transfer(msg.sender, _to, _amount); return true; }
/** * @dev Mint the specified amount of token to the specified address and freeze it until the specified date. * Be careful, gas usage is not deterministic, * and depends on how many freezes _to address already has. * @param _to Address to which token will be freeze. * @param _amount Amount of token to mint and freeze. * @param _until Release date, must be in future. * @return A boolean that indicates if the operation was successful. */
NatSpecMultiLine
v0.4.26+commit.4563c3fc
MIT
bzzr://c7f22b1212324b47015fdfbcf83067298a9d8e1f685d6a6a5e0a9872521c7094
{ "func_code_index": [ 518, 978 ] }
7,798
kanekiinu
kanekiinu.sol
0xac720c675fba115ac6ac4c9dd67dc64a1d089d26
Solidity
IERC20
interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
/** * @dev Interface of the ERC20 standard as defined in the EIP. */
NatSpecMultiLine
totalSupply
function totalSupply() external view returns (uint256);
/** * @dev Returns the amount of tokens in existence. */
NatSpecMultiLine
v0.8.9+commit.e5eed63a
None
ipfs://6679f25f690c92432b307e316ce3662c35078a3b53ce19ddb13dc9845cfa37af
{ "func_code_index": [ 92, 152 ] }
7,799
kanekiinu
kanekiinu.sol
0xac720c675fba115ac6ac4c9dd67dc64a1d089d26
Solidity
IERC20
interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
/** * @dev Interface of the ERC20 standard as defined in the EIP. */
NatSpecMultiLine
balanceOf
function balanceOf(address account) external view returns (uint256);
/** * @dev Returns the amount of tokens owned by `account`. */
NatSpecMultiLine
v0.8.9+commit.e5eed63a
None
ipfs://6679f25f690c92432b307e316ce3662c35078a3b53ce19ddb13dc9845cfa37af
{ "func_code_index": [ 233, 306 ] }
7,800
kanekiinu
kanekiinu.sol
0xac720c675fba115ac6ac4c9dd67dc64a1d089d26
Solidity
IERC20
interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
/** * @dev Interface of the ERC20 standard as defined in the EIP. */
NatSpecMultiLine
transfer
function transfer(address recipient, uint256 amount) external returns (bool);
/** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */
NatSpecMultiLine
v0.8.9+commit.e5eed63a
None
ipfs://6679f25f690c92432b307e316ce3662c35078a3b53ce19ddb13dc9845cfa37af
{ "func_code_index": [ 524, 606 ] }
7,801
kanekiinu
kanekiinu.sol
0xac720c675fba115ac6ac4c9dd67dc64a1d089d26
Solidity
IERC20
interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
/** * @dev Interface of the ERC20 standard as defined in the EIP. */
NatSpecMultiLine
allowance
function allowance(address owner, address spender) external view returns (uint256);
/** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */
NatSpecMultiLine
v0.8.9+commit.e5eed63a
None
ipfs://6679f25f690c92432b307e316ce3662c35078a3b53ce19ddb13dc9845cfa37af
{ "func_code_index": [ 879, 967 ] }
7,802
kanekiinu
kanekiinu.sol
0xac720c675fba115ac6ac4c9dd67dc64a1d089d26
Solidity
IERC20
interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
/** * @dev Interface of the ERC20 standard as defined in the EIP. */
NatSpecMultiLine
approve
function approve(address spender, uint256 amount) external returns (bool);
/** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */
NatSpecMultiLine
v0.8.9+commit.e5eed63a
None
ipfs://6679f25f690c92432b307e316ce3662c35078a3b53ce19ddb13dc9845cfa37af
{ "func_code_index": [ 1618, 1697 ] }
7,803
kanekiinu
kanekiinu.sol
0xac720c675fba115ac6ac4c9dd67dc64a1d089d26
Solidity
IERC20
interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
/** * @dev Interface of the ERC20 standard as defined in the EIP. */
NatSpecMultiLine
transferFrom
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */
NatSpecMultiLine
v0.8.9+commit.e5eed63a
None
ipfs://6679f25f690c92432b307e316ce3662c35078a3b53ce19ddb13dc9845cfa37af
{ "func_code_index": [ 2002, 2104 ] }
7,804
kanekiinu
kanekiinu.sol
0xac720c675fba115ac6ac4c9dd67dc64a1d089d26
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // 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 (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @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) { return a + b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting 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 a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards 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). * * 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) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * 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) { unchecked { require(b > 0, errorMessage); return a % b; } } }
/** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */
NatSpecMultiLine
tryAdd
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } }
/** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */
NatSpecMultiLine
v0.8.9+commit.e5eed63a
None
ipfs://6679f25f690c92432b307e316ce3662c35078a3b53ce19ddb13dc9845cfa37af
{ "func_code_index": [ 157, 384 ] }
7,805
kanekiinu
kanekiinu.sol
0xac720c675fba115ac6ac4c9dd67dc64a1d089d26
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // 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 (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @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) { return a + b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting 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 a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards 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). * * 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) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * 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) { unchecked { require(b > 0, errorMessage); return a % b; } } }
/** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */
NatSpecMultiLine
trySub
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } }
/** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */
NatSpecMultiLine
v0.8.9+commit.e5eed63a
None
ipfs://6679f25f690c92432b307e316ce3662c35078a3b53ce19ddb13dc9845cfa37af
{ "func_code_index": [ 528, 727 ] }
7,806