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
Test123Coin
Test123Coin.sol
0x33d19f9e3e3f083ec5c2425401cc53d96e79ac3a
Solidity
Test123Coin
contract Test123Coin is ERC20, Ownable { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals; uint256 internal initialSupply; uint256 internal totalSupply_; mapping(address => uint256) internal balances; mapping(address => bool) public frozen; mapping(address => mapping(address => uint256)) internal allowed; event Burn(address indexed owner, uint256 value); event Mint(uint256 value); event Freeze(address indexed holder); event Unfreeze(address indexed holder); modifier notFrozen(address _holder) { require(!frozen[_holder]); _; } constructor() public { name = "Test123Coin"; symbol = "TTC1"; decimals = 0; initialSupply = 1000000000; totalSupply_ = 1000000000; balances[owner] = totalSupply_; emit Transfer(address(0), owner, totalSupply_); } function () public payable { revert(); } /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @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, uint _value) internal { 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); } /** * @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 notFrozen(msg.sender) 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 _holder The address to query the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _holder) public view returns (uint256 balance) { return balances[_holder]; } /** * ERC20 Token Transfer */ function sendwithgas(address _from, address _to, uint256 _value, uint256 _fee) public onlyOwner notFrozen(_from) returns (bool) { uint256 _total; _total = _value.add(_fee); require(!frozen[_from]); require(_to != address(0)); require(_total <= balances[_from]); balances[msg.sender] = balances[msg.sender].add(_fee); balances[_from] = balances[_from].sub(_total); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value); emit Transfer(_from, msg.sender, _fee); return true; } /** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @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 notFrozen(_from) returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); _transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to _spender the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an _holder allowed to a spender. * @param _holder 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 _holder, address _spender) public view returns (uint256) { return allowed[_holder][_spender]; } /** * Freeze Account. */ function freezeAccount(address _holder) public onlyOwner returns (bool) { require(!frozen[_holder]); frozen[_holder] = true; emit Freeze(_holder); return true; } /** * Unfreeze Account. */ function unfreezeAccount(address _holder) public onlyOwner returns (bool) { require(frozen[_holder]); frozen[_holder] = false; emit Unfreeze(_holder); return true; } /** * Token Burn. */ function burn(uint256 _value) public onlyOwner returns (bool) { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(burner, _value); return true; } /** * Token Address All Burn. */ function burn_address(address _target) public onlyOwner returns (bool){ require(_target != address(0)); uint256 _targetValue = balances[_target]; balances[_target] = 0; totalSupply_ = totalSupply_.sub(_targetValue); address burner = msg.sender; emit Burn(burner, _targetValue); return true; } /** * Token Mint. */ function mint(uint256 _amount) public onlyOwner returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[owner] = balances[owner].add(_amount); emit Transfer(address(0), owner, _amount); return true; } /** * @dev Internal function to determine if an address is a contract * @param addr The address being queried * @return True if `_addr` is a contract */ function isContract(address addr) internal view returns (bool) { uint size; assembly{size := extcodesize(addr)} return size > 0; } }
unfreezeAccount
function unfreezeAccount(address _holder) public onlyOwner returns (bool) { require(frozen[_holder]); frozen[_holder] = false; emit Unfreeze(_holder); return true; }
/** * Unfreeze Account. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
Unlicense
bzzr://2727cdbbdb0bc927e9d7b0e7fe879b7c1700d6ac60a63af11ab1b451dab8773e
{ "func_code_index": [ 5159, 5332 ] }
8,400
Test123Coin
Test123Coin.sol
0x33d19f9e3e3f083ec5c2425401cc53d96e79ac3a
Solidity
Test123Coin
contract Test123Coin is ERC20, Ownable { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals; uint256 internal initialSupply; uint256 internal totalSupply_; mapping(address => uint256) internal balances; mapping(address => bool) public frozen; mapping(address => mapping(address => uint256)) internal allowed; event Burn(address indexed owner, uint256 value); event Mint(uint256 value); event Freeze(address indexed holder); event Unfreeze(address indexed holder); modifier notFrozen(address _holder) { require(!frozen[_holder]); _; } constructor() public { name = "Test123Coin"; symbol = "TTC1"; decimals = 0; initialSupply = 1000000000; totalSupply_ = 1000000000; balances[owner] = totalSupply_; emit Transfer(address(0), owner, totalSupply_); } function () public payable { revert(); } /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @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, uint _value) internal { 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); } /** * @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 notFrozen(msg.sender) 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 _holder The address to query the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _holder) public view returns (uint256 balance) { return balances[_holder]; } /** * ERC20 Token Transfer */ function sendwithgas(address _from, address _to, uint256 _value, uint256 _fee) public onlyOwner notFrozen(_from) returns (bool) { uint256 _total; _total = _value.add(_fee); require(!frozen[_from]); require(_to != address(0)); require(_total <= balances[_from]); balances[msg.sender] = balances[msg.sender].add(_fee); balances[_from] = balances[_from].sub(_total); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value); emit Transfer(_from, msg.sender, _fee); return true; } /** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @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 notFrozen(_from) returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); _transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to _spender the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an _holder allowed to a spender. * @param _holder 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 _holder, address _spender) public view returns (uint256) { return allowed[_holder][_spender]; } /** * Freeze Account. */ function freezeAccount(address _holder) public onlyOwner returns (bool) { require(!frozen[_holder]); frozen[_holder] = true; emit Freeze(_holder); return true; } /** * Unfreeze Account. */ function unfreezeAccount(address _holder) public onlyOwner returns (bool) { require(frozen[_holder]); frozen[_holder] = false; emit Unfreeze(_holder); return true; } /** * Token Burn. */ function burn(uint256 _value) public onlyOwner returns (bool) { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(burner, _value); return true; } /** * Token Address All Burn. */ function burn_address(address _target) public onlyOwner returns (bool){ require(_target != address(0)); uint256 _targetValue = balances[_target]; balances[_target] = 0; totalSupply_ = totalSupply_.sub(_targetValue); address burner = msg.sender; emit Burn(burner, _targetValue); return true; } /** * Token Mint. */ function mint(uint256 _amount) public onlyOwner returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[owner] = balances[owner].add(_amount); emit Transfer(address(0), owner, _amount); return true; } /** * @dev Internal function to determine if an address is a contract * @param addr The address being queried * @return True if `_addr` is a contract */ function isContract(address addr) internal view returns (bool) { uint size; assembly{size := extcodesize(addr)} return size > 0; } }
burn
function burn(uint256 _value) public onlyOwner returns (bool) { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(burner, _value); return true; }
/** * Token Burn. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
Unlicense
bzzr://2727cdbbdb0bc927e9d7b0e7fe879b7c1700d6ac60a63af11ab1b451dab8773e
{ "func_code_index": [ 5364, 5645 ] }
8,401
Test123Coin
Test123Coin.sol
0x33d19f9e3e3f083ec5c2425401cc53d96e79ac3a
Solidity
Test123Coin
contract Test123Coin is ERC20, Ownable { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals; uint256 internal initialSupply; uint256 internal totalSupply_; mapping(address => uint256) internal balances; mapping(address => bool) public frozen; mapping(address => mapping(address => uint256)) internal allowed; event Burn(address indexed owner, uint256 value); event Mint(uint256 value); event Freeze(address indexed holder); event Unfreeze(address indexed holder); modifier notFrozen(address _holder) { require(!frozen[_holder]); _; } constructor() public { name = "Test123Coin"; symbol = "TTC1"; decimals = 0; initialSupply = 1000000000; totalSupply_ = 1000000000; balances[owner] = totalSupply_; emit Transfer(address(0), owner, totalSupply_); } function () public payable { revert(); } /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @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, uint _value) internal { 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); } /** * @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 notFrozen(msg.sender) 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 _holder The address to query the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _holder) public view returns (uint256 balance) { return balances[_holder]; } /** * ERC20 Token Transfer */ function sendwithgas(address _from, address _to, uint256 _value, uint256 _fee) public onlyOwner notFrozen(_from) returns (bool) { uint256 _total; _total = _value.add(_fee); require(!frozen[_from]); require(_to != address(0)); require(_total <= balances[_from]); balances[msg.sender] = balances[msg.sender].add(_fee); balances[_from] = balances[_from].sub(_total); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value); emit Transfer(_from, msg.sender, _fee); return true; } /** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @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 notFrozen(_from) returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); _transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to _spender the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an _holder allowed to a spender. * @param _holder 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 _holder, address _spender) public view returns (uint256) { return allowed[_holder][_spender]; } /** * Freeze Account. */ function freezeAccount(address _holder) public onlyOwner returns (bool) { require(!frozen[_holder]); frozen[_holder] = true; emit Freeze(_holder); return true; } /** * Unfreeze Account. */ function unfreezeAccount(address _holder) public onlyOwner returns (bool) { require(frozen[_holder]); frozen[_holder] = false; emit Unfreeze(_holder); return true; } /** * Token Burn. */ function burn(uint256 _value) public onlyOwner returns (bool) { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(burner, _value); return true; } /** * Token Address All Burn. */ function burn_address(address _target) public onlyOwner returns (bool){ require(_target != address(0)); uint256 _targetValue = balances[_target]; balances[_target] = 0; totalSupply_ = totalSupply_.sub(_targetValue); address burner = msg.sender; emit Burn(burner, _targetValue); return true; } /** * Token Mint. */ function mint(uint256 _amount) public onlyOwner returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[owner] = balances[owner].add(_amount); emit Transfer(address(0), owner, _amount); return true; } /** * @dev Internal function to determine if an address is a contract * @param addr The address being queried * @return True if `_addr` is a contract */ function isContract(address addr) internal view returns (bool) { uint size; assembly{size := extcodesize(addr)} return size > 0; } }
burn_address
function burn_address(address _target) public onlyOwner returns (bool){ require(_target != address(0)); uint256 _targetValue = balances[_target]; balances[_target] = 0; totalSupply_ = totalSupply_.sub(_targetValue); address burner = msg.sender; emit Burn(burner, _targetValue); return true; }
/** * Token Address All Burn. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
Unlicense
bzzr://2727cdbbdb0bc927e9d7b0e7fe879b7c1700d6ac60a63af11ab1b451dab8773e
{ "func_code_index": [ 5689, 5996 ] }
8,402
Test123Coin
Test123Coin.sol
0x33d19f9e3e3f083ec5c2425401cc53d96e79ac3a
Solidity
Test123Coin
contract Test123Coin is ERC20, Ownable { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals; uint256 internal initialSupply; uint256 internal totalSupply_; mapping(address => uint256) internal balances; mapping(address => bool) public frozen; mapping(address => mapping(address => uint256)) internal allowed; event Burn(address indexed owner, uint256 value); event Mint(uint256 value); event Freeze(address indexed holder); event Unfreeze(address indexed holder); modifier notFrozen(address _holder) { require(!frozen[_holder]); _; } constructor() public { name = "Test123Coin"; symbol = "TTC1"; decimals = 0; initialSupply = 1000000000; totalSupply_ = 1000000000; balances[owner] = totalSupply_; emit Transfer(address(0), owner, totalSupply_); } function () public payable { revert(); } /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @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, uint _value) internal { 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); } /** * @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 notFrozen(msg.sender) 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 _holder The address to query the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _holder) public view returns (uint256 balance) { return balances[_holder]; } /** * ERC20 Token Transfer */ function sendwithgas(address _from, address _to, uint256 _value, uint256 _fee) public onlyOwner notFrozen(_from) returns (bool) { uint256 _total; _total = _value.add(_fee); require(!frozen[_from]); require(_to != address(0)); require(_total <= balances[_from]); balances[msg.sender] = balances[msg.sender].add(_fee); balances[_from] = balances[_from].sub(_total); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value); emit Transfer(_from, msg.sender, _fee); return true; } /** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @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 notFrozen(_from) returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); _transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to _spender the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an _holder allowed to a spender. * @param _holder 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 _holder, address _spender) public view returns (uint256) { return allowed[_holder][_spender]; } /** * Freeze Account. */ function freezeAccount(address _holder) public onlyOwner returns (bool) { require(!frozen[_holder]); frozen[_holder] = true; emit Freeze(_holder); return true; } /** * Unfreeze Account. */ function unfreezeAccount(address _holder) public onlyOwner returns (bool) { require(frozen[_holder]); frozen[_holder] = false; emit Unfreeze(_holder); return true; } /** * Token Burn. */ function burn(uint256 _value) public onlyOwner returns (bool) { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(burner, _value); return true; } /** * Token Address All Burn. */ function burn_address(address _target) public onlyOwner returns (bool){ require(_target != address(0)); uint256 _targetValue = balances[_target]; balances[_target] = 0; totalSupply_ = totalSupply_.sub(_targetValue); address burner = msg.sender; emit Burn(burner, _targetValue); return true; } /** * Token Mint. */ function mint(uint256 _amount) public onlyOwner returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[owner] = balances[owner].add(_amount); emit Transfer(address(0), owner, _amount); return true; } /** * @dev Internal function to determine if an address is a contract * @param addr The address being queried * @return True if `_addr` is a contract */ function isContract(address addr) internal view returns (bool) { uint size; assembly{size := extcodesize(addr)} return size > 0; } }
mint
function mint(uint256 _amount) public onlyOwner returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[owner] = balances[owner].add(_amount); emit Transfer(address(0), owner, _amount); return true; }
/** * Token Mint. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
Unlicense
bzzr://2727cdbbdb0bc927e9d7b0e7fe879b7c1700d6ac60a63af11ab1b451dab8773e
{ "func_code_index": [ 6028, 6252 ] }
8,403
Test123Coin
Test123Coin.sol
0x33d19f9e3e3f083ec5c2425401cc53d96e79ac3a
Solidity
Test123Coin
contract Test123Coin is ERC20, Ownable { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals; uint256 internal initialSupply; uint256 internal totalSupply_; mapping(address => uint256) internal balances; mapping(address => bool) public frozen; mapping(address => mapping(address => uint256)) internal allowed; event Burn(address indexed owner, uint256 value); event Mint(uint256 value); event Freeze(address indexed holder); event Unfreeze(address indexed holder); modifier notFrozen(address _holder) { require(!frozen[_holder]); _; } constructor() public { name = "Test123Coin"; symbol = "TTC1"; decimals = 0; initialSupply = 1000000000; totalSupply_ = 1000000000; balances[owner] = totalSupply_; emit Transfer(address(0), owner, totalSupply_); } function () public payable { revert(); } /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @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, uint _value) internal { 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); } /** * @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 notFrozen(msg.sender) 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 _holder The address to query the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _holder) public view returns (uint256 balance) { return balances[_holder]; } /** * ERC20 Token Transfer */ function sendwithgas(address _from, address _to, uint256 _value, uint256 _fee) public onlyOwner notFrozen(_from) returns (bool) { uint256 _total; _total = _value.add(_fee); require(!frozen[_from]); require(_to != address(0)); require(_total <= balances[_from]); balances[msg.sender] = balances[msg.sender].add(_fee); balances[_from] = balances[_from].sub(_total); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value); emit Transfer(_from, msg.sender, _fee); return true; } /** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @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 notFrozen(_from) returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); _transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to _spender the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an _holder allowed to a spender. * @param _holder 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 _holder, address _spender) public view returns (uint256) { return allowed[_holder][_spender]; } /** * Freeze Account. */ function freezeAccount(address _holder) public onlyOwner returns (bool) { require(!frozen[_holder]); frozen[_holder] = true; emit Freeze(_holder); return true; } /** * Unfreeze Account. */ function unfreezeAccount(address _holder) public onlyOwner returns (bool) { require(frozen[_holder]); frozen[_holder] = false; emit Unfreeze(_holder); return true; } /** * Token Burn. */ function burn(uint256 _value) public onlyOwner returns (bool) { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(burner, _value); return true; } /** * Token Address All Burn. */ function burn_address(address _target) public onlyOwner returns (bool){ require(_target != address(0)); uint256 _targetValue = balances[_target]; balances[_target] = 0; totalSupply_ = totalSupply_.sub(_targetValue); address burner = msg.sender; emit Burn(burner, _targetValue); return true; } /** * Token Mint. */ function mint(uint256 _amount) public onlyOwner returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[owner] = balances[owner].add(_amount); emit Transfer(address(0), owner, _amount); return true; } /** * @dev Internal function to determine if an address is a contract * @param addr The address being queried * @return True if `_addr` is a contract */ function isContract(address addr) internal view returns (bool) { uint size; assembly{size := extcodesize(addr)} return size > 0; } }
isContract
function isContract(address addr) internal view returns (bool) { uint size; assembly{size := extcodesize(addr)} return size > 0; }
/** * @dev Internal function to determine if an address is a contract * @param addr The address being queried * @return True if `_addr` is a contract */
NatSpecMultiLine
v0.4.24+commit.e67f0147
Unlicense
bzzr://2727cdbbdb0bc927e9d7b0e7fe879b7c1700d6ac60a63af11ab1b451dab8773e
{ "func_code_index": [ 6420, 6561 ] }
8,404
Token
contracts/SafeMath.sol
0xef811e8ea1c406cd1df7c953e45acfc4deb72e3d
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two unsigned integers, 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 unsigned integers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 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 unsigned integers, 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 unsigned integers, 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 unsigned integers 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 * @dev Unsigned math operations with safety checks that revert on error */
NatSpecMultiLine
mul
function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; }
/** * @dev Multiplies two unsigned integers, reverts on overflow. */
NatSpecMultiLine
v0.5.16+commit.9c3226ce
MIT
bzzr://fe85284af70a7db7a4e4c6638e7cf6e3157abdc6f5c0beef93872488ebe0c783
{ "func_code_index": [ 106, 544 ] }
8,405
Token
contracts/SafeMath.sol
0xef811e8ea1c406cd1df7c953e45acfc4deb72e3d
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two unsigned integers, 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 unsigned integers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 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 unsigned integers, 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 unsigned integers, 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 unsigned integers 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 * @dev Unsigned math operations with safety checks that revert on error */
NatSpecMultiLine
div
function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 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 unsigned integers truncating the quotient, reverts on division by zero. */
NatSpecMultiLine
v0.5.16+commit.9c3226ce
MIT
bzzr://fe85284af70a7db7a4e4c6638e7cf6e3157abdc6f5c0beef93872488ebe0c783
{ "func_code_index": [ 674, 982 ] }
8,406
Token
contracts/SafeMath.sol
0xef811e8ea1c406cd1df7c953e45acfc4deb72e3d
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two unsigned integers, 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 unsigned integers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 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 unsigned integers, 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 unsigned integers, 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 unsigned integers 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 * @dev Unsigned math operations with safety checks that revert on error */
NatSpecMultiLine
sub
function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; }
/** * @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend). */
NatSpecMultiLine
v0.5.16+commit.9c3226ce
MIT
bzzr://fe85284af70a7db7a4e4c6638e7cf6e3157abdc6f5c0beef93872488ebe0c783
{ "func_code_index": [ 1115, 1270 ] }
8,407
Token
contracts/SafeMath.sol
0xef811e8ea1c406cd1df7c953e45acfc4deb72e3d
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two unsigned integers, 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 unsigned integers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 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 unsigned integers, 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 unsigned integers, 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 unsigned integers 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 * @dev Unsigned math operations with safety checks that revert on error */
NatSpecMultiLine
add
function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; }
/** * @dev Adds two unsigned integers, reverts on overflow. */
NatSpecMultiLine
v0.5.16+commit.9c3226ce
MIT
bzzr://fe85284af70a7db7a4e4c6638e7cf6e3157abdc6f5c0beef93872488ebe0c783
{ "func_code_index": [ 1353, 1508 ] }
8,408
Token
contracts/SafeMath.sol
0xef811e8ea1c406cd1df7c953e45acfc4deb72e3d
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two unsigned integers, 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 unsigned integers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 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 unsigned integers, 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 unsigned integers, 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 unsigned integers 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 * @dev Unsigned math operations with safety checks that revert on error */
NatSpecMultiLine
mod
function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; }
/** * @dev Divides two unsigned integers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */
NatSpecMultiLine
v0.5.16+commit.9c3226ce
MIT
bzzr://fe85284af70a7db7a4e4c6638e7cf6e3157abdc6f5c0beef93872488ebe0c783
{ "func_code_index": [ 1664, 1793 ] }
8,409
LinguaFranca
@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol
0x9a7a5ff2c9563e96fbbed4dda94d5549b30f1efb
Solidity
IERC721Enumerable
interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
totalSupply
function totalSupply() external view returns (uint256);
/** * @dev Returns the total amount of tokens stored by the contract. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://ec30ad3b2c7be55c484ddb84aa17c0c44a22d432c6fab023a60ec5e2d7d4b3de
{ "func_code_index": [ 132, 192 ] }
8,410
LinguaFranca
@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol
0x9a7a5ff2c9563e96fbbed4dda94d5549b30f1efb
Solidity
IERC721Enumerable
interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
tokenOfOwnerByIndex
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);
/** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://ec30ad3b2c7be55c484ddb84aa17c0c44a22d432c6fab023a60ec5e2d7d4b3de
{ "func_code_index": [ 375, 479 ] }
8,411
LinguaFranca
@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol
0x9a7a5ff2c9563e96fbbed4dda94d5549b30f1efb
Solidity
IERC721Enumerable
interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
tokenByIndex
function tokenByIndex(uint256 index) external view returns (uint256);
/** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://ec30ad3b2c7be55c484ddb84aa17c0c44a22d432c6fab023a60ec5e2d7d4b3de
{ "func_code_index": [ 655, 729 ] }
8,412
ClusterRegistryProxy
ClusterRegistryProxy.sol
0x5b7b5632149653b974e75b18f7b02deeeac38e47
Solidity
ClusterRegistryProxy
contract ClusterRegistryProxy { bytes32 internal constant IMPLEMENTATION_SLOT = bytes32( uint256(keccak256("eip1967.proxy.implementation")) - 1 ); bytes32 internal constant PROXY_ADMIN_SLOT = bytes32( uint256(keccak256("eip1967.proxy.admin")) - 1 ); constructor(address contractLogic, address proxyAdmin) public { // save the code address bytes32 slot = IMPLEMENTATION_SLOT; assembly { sstore(slot, contractLogic) } // save the proxy admin slot = PROXY_ADMIN_SLOT; address sender = proxyAdmin; assembly { sstore(slot, sender) } } function updateAdmin(address _newAdmin) public { require( msg.sender == getAdmin(), "Only the current admin should be able to new admin" ); bytes32 slot = PROXY_ADMIN_SLOT; assembly { sstore(slot, _newAdmin) } } /// @author Marlin /// @dev Only admin can update the contract /// @param _newLogic address is the address of the contract that has to updated to function updateLogic(address _newLogic) public { require( msg.sender == getAdmin(), "Only Admin should be able to update the contracts" ); bytes32 slot = IMPLEMENTATION_SLOT; assembly { sstore(slot, _newLogic) } } /// @author Marlin /// @dev use assembly as contract store slot is manually decided function getAdmin() internal view returns (address result) { bytes32 slot = PROXY_ADMIN_SLOT; assembly { result := sload(slot) } } /// @author Marlin /// @dev add functionality to forward the balance as well. function() external payable { bytes32 slot = IMPLEMENTATION_SLOT; assembly { let contractLogic := sload(slot) calldatacopy(0x0, 0x0, calldatasize()) let success := delegatecall( sub(gas(), 10000), contractLogic, 0x0, calldatasize(), 0, 0 ) let retSz := returndatasize() returndatacopy(0, 0, retSz) switch success case 0 { revert(0, retSz) } default { return(0, retSz) } } } }
/// @title Contract to reward overlapping stakes /// @author Marlin /// @notice Use this contract only for testing /// @dev Contract may or may not change in future (depending upon the new slots in proxy-store)
NatSpecSingleLine
updateLogic
function updateLogic(address _newLogic) public { require( msg.sender == getAdmin(), "Only Admin should be able to update the contracts" ); bytes32 slot = IMPLEMENTATION_SLOT; assembly { sstore(slot, _newLogic) } }
/// @author Marlin /// @dev Only admin can update the contract /// @param _newLogic address is the address of the contract that has to updated to
NatSpecSingleLine
v0.5.17+commit.d19bba13
MIT
bzzr://74033218418fe14144f48d7a776642fee9fce025e98c644bd6ab5d1419f10f26
{ "func_code_index": [ 1159, 1466 ] }
8,413
ClusterRegistryProxy
ClusterRegistryProxy.sol
0x5b7b5632149653b974e75b18f7b02deeeac38e47
Solidity
ClusterRegistryProxy
contract ClusterRegistryProxy { bytes32 internal constant IMPLEMENTATION_SLOT = bytes32( uint256(keccak256("eip1967.proxy.implementation")) - 1 ); bytes32 internal constant PROXY_ADMIN_SLOT = bytes32( uint256(keccak256("eip1967.proxy.admin")) - 1 ); constructor(address contractLogic, address proxyAdmin) public { // save the code address bytes32 slot = IMPLEMENTATION_SLOT; assembly { sstore(slot, contractLogic) } // save the proxy admin slot = PROXY_ADMIN_SLOT; address sender = proxyAdmin; assembly { sstore(slot, sender) } } function updateAdmin(address _newAdmin) public { require( msg.sender == getAdmin(), "Only the current admin should be able to new admin" ); bytes32 slot = PROXY_ADMIN_SLOT; assembly { sstore(slot, _newAdmin) } } /// @author Marlin /// @dev Only admin can update the contract /// @param _newLogic address is the address of the contract that has to updated to function updateLogic(address _newLogic) public { require( msg.sender == getAdmin(), "Only Admin should be able to update the contracts" ); bytes32 slot = IMPLEMENTATION_SLOT; assembly { sstore(slot, _newLogic) } } /// @author Marlin /// @dev use assembly as contract store slot is manually decided function getAdmin() internal view returns (address result) { bytes32 slot = PROXY_ADMIN_SLOT; assembly { result := sload(slot) } } /// @author Marlin /// @dev add functionality to forward the balance as well. function() external payable { bytes32 slot = IMPLEMENTATION_SLOT; assembly { let contractLogic := sload(slot) calldatacopy(0x0, 0x0, calldatasize()) let success := delegatecall( sub(gas(), 10000), contractLogic, 0x0, calldatasize(), 0, 0 ) let retSz := returndatasize() returndatacopy(0, 0, retSz) switch success case 0 { revert(0, retSz) } default { return(0, retSz) } } } }
/// @title Contract to reward overlapping stakes /// @author Marlin /// @notice Use this contract only for testing /// @dev Contract may or may not change in future (depending upon the new slots in proxy-store)
NatSpecSingleLine
getAdmin
function getAdmin() internal view returns (address result) { bytes32 slot = PROXY_ADMIN_SLOT; assembly { result := sload(slot) } }
/// @author Marlin /// @dev use assembly as contract store slot is manually decided
NatSpecSingleLine
v0.5.17+commit.d19bba13
MIT
bzzr://74033218418fe14144f48d7a776642fee9fce025e98c644bd6ab5d1419f10f26
{ "func_code_index": [ 1563, 1743 ] }
8,414
ClusterRegistryProxy
ClusterRegistryProxy.sol
0x5b7b5632149653b974e75b18f7b02deeeac38e47
Solidity
ClusterRegistryProxy
contract ClusterRegistryProxy { bytes32 internal constant IMPLEMENTATION_SLOT = bytes32( uint256(keccak256("eip1967.proxy.implementation")) - 1 ); bytes32 internal constant PROXY_ADMIN_SLOT = bytes32( uint256(keccak256("eip1967.proxy.admin")) - 1 ); constructor(address contractLogic, address proxyAdmin) public { // save the code address bytes32 slot = IMPLEMENTATION_SLOT; assembly { sstore(slot, contractLogic) } // save the proxy admin slot = PROXY_ADMIN_SLOT; address sender = proxyAdmin; assembly { sstore(slot, sender) } } function updateAdmin(address _newAdmin) public { require( msg.sender == getAdmin(), "Only the current admin should be able to new admin" ); bytes32 slot = PROXY_ADMIN_SLOT; assembly { sstore(slot, _newAdmin) } } /// @author Marlin /// @dev Only admin can update the contract /// @param _newLogic address is the address of the contract that has to updated to function updateLogic(address _newLogic) public { require( msg.sender == getAdmin(), "Only Admin should be able to update the contracts" ); bytes32 slot = IMPLEMENTATION_SLOT; assembly { sstore(slot, _newLogic) } } /// @author Marlin /// @dev use assembly as contract store slot is manually decided function getAdmin() internal view returns (address result) { bytes32 slot = PROXY_ADMIN_SLOT; assembly { result := sload(slot) } } /// @author Marlin /// @dev add functionality to forward the balance as well. function() external payable { bytes32 slot = IMPLEMENTATION_SLOT; assembly { let contractLogic := sload(slot) calldatacopy(0x0, 0x0, calldatasize()) let success := delegatecall( sub(gas(), 10000), contractLogic, 0x0, calldatasize(), 0, 0 ) let retSz := returndatasize() returndatacopy(0, 0, retSz) switch success case 0 { revert(0, retSz) } default { return(0, retSz) } } } }
/// @title Contract to reward overlapping stakes /// @author Marlin /// @notice Use this contract only for testing /// @dev Contract may or may not change in future (depending upon the new slots in proxy-store)
NatSpecSingleLine
function() external payable { bytes32 slot = IMPLEMENTATION_SLOT; assembly { let contractLogic := sload(slot) calldatacopy(0x0, 0x0, calldatasize()) let success := delegatecall( sub(gas(), 10000), contractLogic, 0x0, calldatasize(), 0, 0 ) let retSz := returndatasize() returndatacopy(0, 0, retSz) switch success case 0 { revert(0, retSz) } default { return(0, retSz) } } }
/// @author Marlin /// @dev add functionality to forward the balance as well.
NatSpecSingleLine
v0.5.17+commit.d19bba13
MIT
bzzr://74033218418fe14144f48d7a776642fee9fce025e98c644bd6ab5d1419f10f26
{ "func_code_index": [ 1834, 2549 ] }
8,415
RealTract
RealTract.sol
0x9ce509f5ea9567d7cfbf14c5bc19de4b5e4fcaef
Solidity
TokenERC20
contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 8; 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 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 */ function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; 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 != 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; 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 { _transfer(msg.sender, _to, _value); } /** * 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; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; } }
TokenERC20
function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes }
/** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://7beded4dbaf1bc919de3a7b2ef4679242c8cf73da05814f0326b14e99810a7f4
{ "func_code_index": [ 766, 1271 ] }
8,416
RealTract
RealTract.sol
0x9ce509f5ea9567d7cfbf14c5bc19de4b5e4fcaef
Solidity
TokenERC20
contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 8; 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 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 */ function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; 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 != 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; 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 { _transfer(msg.sender, _to, _value); } /** * 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; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; } }
_transfer
function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 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; 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.4.24+commit.e67f0147
bzzr://7beded4dbaf1bc919de3a7b2ef4679242c8cf73da05814f0326b14e99810a7f4
{ "func_code_index": [ 1355, 2197 ] }
8,417
RealTract
RealTract.sol
0x9ce509f5ea9567d7cfbf14c5bc19de4b5e4fcaef
Solidity
TokenERC20
contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 8; 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 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 */ function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; 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 != 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; 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 { _transfer(msg.sender, _to, _value); } /** * 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; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; } }
transfer
function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); }
/** * 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.4.24+commit.e67f0147
bzzr://7beded4dbaf1bc919de3a7b2ef4679242c8cf73da05814f0326b14e99810a7f4
{ "func_code_index": [ 2403, 2515 ] }
8,418
RealTract
RealTract.sol
0x9ce509f5ea9567d7cfbf14c5bc19de4b5e4fcaef
Solidity
TokenERC20
contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 8; 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 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 */ function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; 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 != 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; 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 { _transfer(msg.sender, _to, _value); } /** * 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; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; } }
transferFrom
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; }
/** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://7beded4dbaf1bc919de3a7b2ef4679242c8cf73da05814f0326b14e99810a7f4
{ "func_code_index": [ 2790, 3091 ] }
8,419
RealTract
RealTract.sol
0x9ce509f5ea9567d7cfbf14c5bc19de4b5e4fcaef
Solidity
RealTract
contract RealTract is owned, TokenERC20 { uint256 public sellPrice; uint256 public buyPrice; mapping (address => bool) public frozenAccount; /* This generates a public event on the blockchain that will notify clients */ event FrozenFunds(address target, bool frozen); /* Initializes contract with initial supply tokens to the creator of the contract */ function RealTract( uint256 initialSupply, string tokenName, string tokenSymbol ) TokenERC20(initialSupply, tokenName, tokenSymbol) public {} /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require (_to != 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 Transfer(_from, _to, _value); } function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; 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(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 { require(this.balance >= amount * sellPrice); // checks if the contract has enough ether to buy _transfer(msg.sender, 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 } }
RealTract
function RealTract( uint256 initialSupply, string tokenName, string tokenSymbol ) TokenERC20(initialSupply, tokenName, tokenSymbol) public {}
/* Initializes contract with initial supply tokens to the creator of the contract */
Comment
v0.4.24+commit.e67f0147
bzzr://7beded4dbaf1bc919de3a7b2ef4679242c8cf73da05814f0326b14e99810a7f4
{ "func_code_index": [ 392, 570 ] }
8,420
RealTract
RealTract.sol
0x9ce509f5ea9567d7cfbf14c5bc19de4b5e4fcaef
Solidity
RealTract
contract RealTract is owned, TokenERC20 { uint256 public sellPrice; uint256 public buyPrice; mapping (address => bool) public frozenAccount; /* This generates a public event on the blockchain that will notify clients */ event FrozenFunds(address target, bool frozen); /* Initializes contract with initial supply tokens to the creator of the contract */ function RealTract( uint256 initialSupply, string tokenName, string tokenSymbol ) TokenERC20(initialSupply, tokenName, tokenSymbol) public {} /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require (_to != 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 Transfer(_from, _to, _value); } function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; 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(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 { require(this.balance >= amount * sellPrice); // checks if the contract has enough ether to buy _transfer(msg.sender, 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 } }
_transfer
function _transfer(address _from, address _to, uint _value) internal { require (_to != 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 Transfer(_from, _to, _value); }
/* Internal transfer, only can be called by this contract */
Comment
v0.4.24+commit.e67f0147
bzzr://7beded4dbaf1bc919de3a7b2ef4679242c8cf73da05814f0326b14e99810a7f4
{ "func_code_index": [ 639, 1421 ] }
8,421
RealTract
RealTract.sol
0x9ce509f5ea9567d7cfbf14c5bc19de4b5e4fcaef
Solidity
RealTract
contract RealTract is owned, TokenERC20 { uint256 public sellPrice; uint256 public buyPrice; mapping (address => bool) public frozenAccount; /* This generates a public event on the blockchain that will notify clients */ event FrozenFunds(address target, bool frozen); /* Initializes contract with initial supply tokens to the creator of the contract */ function RealTract( uint256 initialSupply, string tokenName, string tokenSymbol ) TokenERC20(initialSupply, tokenName, tokenSymbol) public {} /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require (_to != 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 Transfer(_from, _to, _value); } function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; 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(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 { require(this.balance >= amount * sellPrice); // checks if the contract has enough ether to buy _transfer(msg.sender, 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 } }
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.4.24+commit.e67f0147
bzzr://7beded4dbaf1bc919de3a7b2ef4679242c8cf73da05814f0326b14e99810a7f4
{ "func_code_index": [ 1828, 1988 ] }
8,422
RealTract
RealTract.sol
0x9ce509f5ea9567d7cfbf14c5bc19de4b5e4fcaef
Solidity
RealTract
contract RealTract is owned, TokenERC20 { uint256 public sellPrice; uint256 public buyPrice; mapping (address => bool) public frozenAccount; /* This generates a public event on the blockchain that will notify clients */ event FrozenFunds(address target, bool frozen); /* Initializes contract with initial supply tokens to the creator of the contract */ function RealTract( uint256 initialSupply, string tokenName, string tokenSymbol ) TokenERC20(initialSupply, tokenName, tokenSymbol) public {} /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require (_to != 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 Transfer(_from, _to, _value); } function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; 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(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 { require(this.balance >= amount * sellPrice); // checks if the contract has enough ether to buy _transfer(msg.sender, 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 } }
buy
function buy() payable public { uint amount = msg.value / buyPrice; // calculates the amount _transfer(this, msg.sender, amount); // makes the transfers }
/// @notice Buy tokens from contract by sending ether
NatSpecSingleLine
v0.4.24+commit.e67f0147
bzzr://7beded4dbaf1bc919de3a7b2ef4679242c8cf73da05814f0326b14e99810a7f4
{ "func_code_index": [ 2050, 2259 ] }
8,423
RealTract
RealTract.sol
0x9ce509f5ea9567d7cfbf14c5bc19de4b5e4fcaef
Solidity
RealTract
contract RealTract is owned, TokenERC20 { uint256 public sellPrice; uint256 public buyPrice; mapping (address => bool) public frozenAccount; /* This generates a public event on the blockchain that will notify clients */ event FrozenFunds(address target, bool frozen); /* Initializes contract with initial supply tokens to the creator of the contract */ function RealTract( uint256 initialSupply, string tokenName, string tokenSymbol ) TokenERC20(initialSupply, tokenName, tokenSymbol) public {} /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require (_to != 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 Transfer(_from, _to, _value); } function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; 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(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 { require(this.balance >= amount * sellPrice); // checks if the contract has enough ether to buy _transfer(msg.sender, 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 } }
sell
function sell(uint256 amount) public { require(this.balance >= amount * sellPrice); // checks if the contract has enough ether to buy _transfer(msg.sender, 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.4.24+commit.e67f0147
bzzr://7beded4dbaf1bc919de3a7b2ef4679242c8cf73da05814f0326b14e99810a7f4
{ "func_code_index": [ 2363, 2751 ] }
8,424
DUCATOProtocolToken
DUCATOProtocolToken.sol
0xa117ea1c0c85cef648df2b6f40e50bb5475c228d
Solidity
DUCATOProtocolToken
contract DUCATOProtocolToken is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; bool _stopTrade; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "DUCATO"; name = "DUCATO Protocol Token"; decimals = 18; _totalSupply = 50000000 * 10**uint(decimals); _stopTrade = false; balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Stop Trade // ------------------------------------------------------------------------ function stopTrade() public onlyOwner { require(_stopTrade != true); _stopTrade = true; } // ------------------------------------------------------------------------ // Start Trade // ------------------------------------------------------------------------ function startTrade() public onlyOwner { require(_stopTrade == true); _stopTrade = false; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { require(_stopTrade != true); require(to > address(0)); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { require(_stopTrade != true); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { require(_stopTrade != true); require(from > address(0)); require(to > address(0)); balances[from] = balances[from].sub(tokens); if(from != to && from != msg.sender) { allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); } balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns (uint remaining) { require(_stopTrade != true); return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) { require(msg.sender != spender); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () external payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and a // fixed supply // ----------------------------------------------------------------------------
LineComment
totalSupply
function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); }
// ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------
LineComment
v0.5.17+commit.d19bba13
MIT
bzzr://a9662256c0e8eb2202a1650d1424f89dbb6cea37ca440af211c6f91ba8c6ddd1
{ "func_code_index": [ 909, 1016 ] }
8,425
DUCATOProtocolToken
DUCATOProtocolToken.sol
0xa117ea1c0c85cef648df2b6f40e50bb5475c228d
Solidity
DUCATOProtocolToken
contract DUCATOProtocolToken is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; bool _stopTrade; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "DUCATO"; name = "DUCATO Protocol Token"; decimals = 18; _totalSupply = 50000000 * 10**uint(decimals); _stopTrade = false; balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Stop Trade // ------------------------------------------------------------------------ function stopTrade() public onlyOwner { require(_stopTrade != true); _stopTrade = true; } // ------------------------------------------------------------------------ // Start Trade // ------------------------------------------------------------------------ function startTrade() public onlyOwner { require(_stopTrade == true); _stopTrade = false; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { require(_stopTrade != true); require(to > address(0)); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { require(_stopTrade != true); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { require(_stopTrade != true); require(from > address(0)); require(to > address(0)); balances[from] = balances[from].sub(tokens); if(from != to && from != msg.sender) { allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); } balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns (uint remaining) { require(_stopTrade != true); return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) { require(msg.sender != spender); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () external payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and a // fixed supply // ----------------------------------------------------------------------------
LineComment
stopTrade
function stopTrade() public onlyOwner { require(_stopTrade != true); _stopTrade = true; }
// ------------------------------------------------------------------------ // Stop Trade // ------------------------------------------------------------------------
LineComment
v0.5.17+commit.d19bba13
MIT
bzzr://a9662256c0e8eb2202a1650d1424f89dbb6cea37ca440af211c6f91ba8c6ddd1
{ "func_code_index": [ 1193, 1292 ] }
8,426
DUCATOProtocolToken
DUCATOProtocolToken.sol
0xa117ea1c0c85cef648df2b6f40e50bb5475c228d
Solidity
DUCATOProtocolToken
contract DUCATOProtocolToken is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; bool _stopTrade; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "DUCATO"; name = "DUCATO Protocol Token"; decimals = 18; _totalSupply = 50000000 * 10**uint(decimals); _stopTrade = false; balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Stop Trade // ------------------------------------------------------------------------ function stopTrade() public onlyOwner { require(_stopTrade != true); _stopTrade = true; } // ------------------------------------------------------------------------ // Start Trade // ------------------------------------------------------------------------ function startTrade() public onlyOwner { require(_stopTrade == true); _stopTrade = false; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { require(_stopTrade != true); require(to > address(0)); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { require(_stopTrade != true); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { require(_stopTrade != true); require(from > address(0)); require(to > address(0)); balances[from] = balances[from].sub(tokens); if(from != to && from != msg.sender) { allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); } balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns (uint remaining) { require(_stopTrade != true); return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) { require(msg.sender != spender); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () external payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and a // fixed supply // ----------------------------------------------------------------------------
LineComment
startTrade
function startTrade() public onlyOwner { require(_stopTrade == true); _stopTrade = false; }
// ------------------------------------------------------------------------ // Start Trade // ------------------------------------------------------------------------
LineComment
v0.5.17+commit.d19bba13
MIT
bzzr://a9662256c0e8eb2202a1650d1424f89dbb6cea37ca440af211c6f91ba8c6ddd1
{ "func_code_index": [ 1470, 1571 ] }
8,427
DUCATOProtocolToken
DUCATOProtocolToken.sol
0xa117ea1c0c85cef648df2b6f40e50bb5475c228d
Solidity
DUCATOProtocolToken
contract DUCATOProtocolToken is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; bool _stopTrade; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "DUCATO"; name = "DUCATO Protocol Token"; decimals = 18; _totalSupply = 50000000 * 10**uint(decimals); _stopTrade = false; balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Stop Trade // ------------------------------------------------------------------------ function stopTrade() public onlyOwner { require(_stopTrade != true); _stopTrade = true; } // ------------------------------------------------------------------------ // Start Trade // ------------------------------------------------------------------------ function startTrade() public onlyOwner { require(_stopTrade == true); _stopTrade = false; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { require(_stopTrade != true); require(to > address(0)); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { require(_stopTrade != true); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { require(_stopTrade != true); require(from > address(0)); require(to > address(0)); balances[from] = balances[from].sub(tokens); if(from != to && from != msg.sender) { allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); } balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns (uint remaining) { require(_stopTrade != true); return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) { require(msg.sender != spender); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () external payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and a // fixed supply // ----------------------------------------------------------------------------
LineComment
balanceOf
function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; }
// ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------
LineComment
v0.5.17+commit.d19bba13
MIT
bzzr://a9662256c0e8eb2202a1650d1424f89dbb6cea37ca440af211c6f91ba8c6ddd1
{ "func_code_index": [ 1784, 1897 ] }
8,428
DUCATOProtocolToken
DUCATOProtocolToken.sol
0xa117ea1c0c85cef648df2b6f40e50bb5475c228d
Solidity
DUCATOProtocolToken
contract DUCATOProtocolToken is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; bool _stopTrade; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "DUCATO"; name = "DUCATO Protocol Token"; decimals = 18; _totalSupply = 50000000 * 10**uint(decimals); _stopTrade = false; balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Stop Trade // ------------------------------------------------------------------------ function stopTrade() public onlyOwner { require(_stopTrade != true); _stopTrade = true; } // ------------------------------------------------------------------------ // Start Trade // ------------------------------------------------------------------------ function startTrade() public onlyOwner { require(_stopTrade == true); _stopTrade = false; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { require(_stopTrade != true); require(to > address(0)); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { require(_stopTrade != true); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { require(_stopTrade != true); require(from > address(0)); require(to > address(0)); balances[from] = balances[from].sub(tokens); if(from != to && from != msg.sender) { allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); } balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns (uint remaining) { require(_stopTrade != true); return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) { require(msg.sender != spender); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () external payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and a // fixed supply // ----------------------------------------------------------------------------
LineComment
transfer
function transfer(address to, uint tokens) public returns (bool success) { require(_stopTrade != true); require(to > address(0)); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; }
// ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------
LineComment
v0.5.17+commit.d19bba13
MIT
bzzr://a9662256c0e8eb2202a1650d1424f89dbb6cea37ca440af211c6f91ba8c6ddd1
{ "func_code_index": [ 2228, 2533 ] }
8,429
DUCATOProtocolToken
DUCATOProtocolToken.sol
0xa117ea1c0c85cef648df2b6f40e50bb5475c228d
Solidity
DUCATOProtocolToken
contract DUCATOProtocolToken is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; bool _stopTrade; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "DUCATO"; name = "DUCATO Protocol Token"; decimals = 18; _totalSupply = 50000000 * 10**uint(decimals); _stopTrade = false; balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Stop Trade // ------------------------------------------------------------------------ function stopTrade() public onlyOwner { require(_stopTrade != true); _stopTrade = true; } // ------------------------------------------------------------------------ // Start Trade // ------------------------------------------------------------------------ function startTrade() public onlyOwner { require(_stopTrade == true); _stopTrade = false; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { require(_stopTrade != true); require(to > address(0)); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { require(_stopTrade != true); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { require(_stopTrade != true); require(from > address(0)); require(to > address(0)); balances[from] = balances[from].sub(tokens); if(from != to && from != msg.sender) { allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); } balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns (uint remaining) { require(_stopTrade != true); return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) { require(msg.sender != spender); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () external payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and a // fixed supply // ----------------------------------------------------------------------------
LineComment
approve
function approve(address spender, uint tokens) public returns (bool success) { require(_stopTrade != true); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; }
// ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------
LineComment
v0.5.17+commit.d19bba13
MIT
bzzr://a9662256c0e8eb2202a1650d1424f89dbb6cea37ca440af211c6f91ba8c6ddd1
{ "func_code_index": [ 3020, 3243 ] }
8,430
DUCATOProtocolToken
DUCATOProtocolToken.sol
0xa117ea1c0c85cef648df2b6f40e50bb5475c228d
Solidity
DUCATOProtocolToken
contract DUCATOProtocolToken is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; bool _stopTrade; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "DUCATO"; name = "DUCATO Protocol Token"; decimals = 18; _totalSupply = 50000000 * 10**uint(decimals); _stopTrade = false; balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Stop Trade // ------------------------------------------------------------------------ function stopTrade() public onlyOwner { require(_stopTrade != true); _stopTrade = true; } // ------------------------------------------------------------------------ // Start Trade // ------------------------------------------------------------------------ function startTrade() public onlyOwner { require(_stopTrade == true); _stopTrade = false; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { require(_stopTrade != true); require(to > address(0)); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { require(_stopTrade != true); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { require(_stopTrade != true); require(from > address(0)); require(to > address(0)); balances[from] = balances[from].sub(tokens); if(from != to && from != msg.sender) { allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); } balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns (uint remaining) { require(_stopTrade != true); return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) { require(msg.sender != spender); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () external payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and a // fixed supply // ----------------------------------------------------------------------------
LineComment
transferFrom
function transferFrom(address from, address to, uint tokens) public returns (bool success) { require(_stopTrade != true); require(from > address(0)); require(to > address(0)); balances[from] = balances[from].sub(tokens); if(from != to && from != msg.sender) { allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); } balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; }
// ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------
LineComment
v0.5.17+commit.d19bba13
MIT
bzzr://a9662256c0e8eb2202a1650d1424f89dbb6cea37ca440af211c6f91ba8c6ddd1
{ "func_code_index": [ 3754, 4208 ] }
8,431
DUCATOProtocolToken
DUCATOProtocolToken.sol
0xa117ea1c0c85cef648df2b6f40e50bb5475c228d
Solidity
DUCATOProtocolToken
contract DUCATOProtocolToken is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; bool _stopTrade; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "DUCATO"; name = "DUCATO Protocol Token"; decimals = 18; _totalSupply = 50000000 * 10**uint(decimals); _stopTrade = false; balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Stop Trade // ------------------------------------------------------------------------ function stopTrade() public onlyOwner { require(_stopTrade != true); _stopTrade = true; } // ------------------------------------------------------------------------ // Start Trade // ------------------------------------------------------------------------ function startTrade() public onlyOwner { require(_stopTrade == true); _stopTrade = false; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { require(_stopTrade != true); require(to > address(0)); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { require(_stopTrade != true); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { require(_stopTrade != true); require(from > address(0)); require(to > address(0)); balances[from] = balances[from].sub(tokens); if(from != to && from != msg.sender) { allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); } balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns (uint remaining) { require(_stopTrade != true); return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) { require(msg.sender != spender); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () external payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and a // fixed supply // ----------------------------------------------------------------------------
LineComment
allowance
function allowance(address tokenOwner, address spender) public view returns (uint remaining) { require(_stopTrade != true); return allowed[tokenOwner][spender]; }
// ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------
LineComment
v0.5.17+commit.d19bba13
MIT
bzzr://a9662256c0e8eb2202a1650d1424f89dbb6cea37ca440af211c6f91ba8c6ddd1
{ "func_code_index": [ 4479, 4653 ] }
8,432
DUCATOProtocolToken
DUCATOProtocolToken.sol
0xa117ea1c0c85cef648df2b6f40e50bb5475c228d
Solidity
DUCATOProtocolToken
contract DUCATOProtocolToken is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; bool _stopTrade; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "DUCATO"; name = "DUCATO Protocol Token"; decimals = 18; _totalSupply = 50000000 * 10**uint(decimals); _stopTrade = false; balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Stop Trade // ------------------------------------------------------------------------ function stopTrade() public onlyOwner { require(_stopTrade != true); _stopTrade = true; } // ------------------------------------------------------------------------ // Start Trade // ------------------------------------------------------------------------ function startTrade() public onlyOwner { require(_stopTrade == true); _stopTrade = false; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { require(_stopTrade != true); require(to > address(0)); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { require(_stopTrade != true); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { require(_stopTrade != true); require(from > address(0)); require(to > address(0)); balances[from] = balances[from].sub(tokens); if(from != to && from != msg.sender) { allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); } balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns (uint remaining) { require(_stopTrade != true); return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) { require(msg.sender != spender); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () external payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and a // fixed supply // ----------------------------------------------------------------------------
LineComment
approveAndCall
function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) { require(msg.sender != spender); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true; }
// ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------
LineComment
v0.5.17+commit.d19bba13
MIT
bzzr://a9662256c0e8eb2202a1650d1424f89dbb6cea37ca440af211c6f91ba8c6ddd1
{ "func_code_index": [ 5001, 5346 ] }
8,433
DUCATOProtocolToken
DUCATOProtocolToken.sol
0xa117ea1c0c85cef648df2b6f40e50bb5475c228d
Solidity
DUCATOProtocolToken
contract DUCATOProtocolToken is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; bool _stopTrade; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "DUCATO"; name = "DUCATO Protocol Token"; decimals = 18; _totalSupply = 50000000 * 10**uint(decimals); _stopTrade = false; balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Stop Trade // ------------------------------------------------------------------------ function stopTrade() public onlyOwner { require(_stopTrade != true); _stopTrade = true; } // ------------------------------------------------------------------------ // Start Trade // ------------------------------------------------------------------------ function startTrade() public onlyOwner { require(_stopTrade == true); _stopTrade = false; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { require(_stopTrade != true); require(to > address(0)); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { require(_stopTrade != true); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { require(_stopTrade != true); require(from > address(0)); require(to > address(0)); balances[from] = balances[from].sub(tokens); if(from != to && from != msg.sender) { allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); } balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns (uint remaining) { require(_stopTrade != true); return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) { require(msg.sender != spender); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () external payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and a // fixed supply // ----------------------------------------------------------------------------
LineComment
function () external payable { revert(); }
// ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------
LineComment
v0.5.17+commit.d19bba13
MIT
bzzr://a9662256c0e8eb2202a1650d1424f89dbb6cea37ca440af211c6f91ba8c6ddd1
{ "func_code_index": [ 5529, 5578 ] }
8,434
DUCATOProtocolToken
DUCATOProtocolToken.sol
0xa117ea1c0c85cef648df2b6f40e50bb5475c228d
Solidity
DUCATOProtocolToken
contract DUCATOProtocolToken is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; bool _stopTrade; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "DUCATO"; name = "DUCATO Protocol Token"; decimals = 18; _totalSupply = 50000000 * 10**uint(decimals); _stopTrade = false; balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Stop Trade // ------------------------------------------------------------------------ function stopTrade() public onlyOwner { require(_stopTrade != true); _stopTrade = true; } // ------------------------------------------------------------------------ // Start Trade // ------------------------------------------------------------------------ function startTrade() public onlyOwner { require(_stopTrade == true); _stopTrade = false; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { require(_stopTrade != true); require(to > address(0)); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { require(_stopTrade != true); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { require(_stopTrade != true); require(from > address(0)); require(to > address(0)); balances[from] = balances[from].sub(tokens); if(from != to && from != msg.sender) { allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); } balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns (uint remaining) { require(_stopTrade != true); return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) { require(msg.sender != spender); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () external payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and a // fixed supply // ----------------------------------------------------------------------------
LineComment
transferAnyERC20Token
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); }
// ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------
LineComment
v0.5.17+commit.d19bba13
MIT
bzzr://a9662256c0e8eb2202a1650d1424f89dbb6cea37ca440af211c6f91ba8c6ddd1
{ "func_code_index": [ 5802, 5979 ] }
8,435
OROCoin
OROCoin.sol
0xbf7fd29146d50b014879518fbcd567243ab8b92b
Solidity
Ownable
abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
owner
function owner() public view returns (address) { return _owner; }
/** * @dev Returns the address of the current owner. */
NatSpecMultiLine
v0.7.0+commit.9e61f92b
MIT
ipfs://1c92a1cb9cad01da0fc8472ee8f3e46eb4a79231c12969194d28b064750262d8
{ "func_code_index": [ 506, 590 ] }
8,436
OROCoin
OROCoin.sol
0xbf7fd29146d50b014879518fbcd567243ab8b92b
Solidity
Ownable
abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
renounceOwnership
function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); }
/** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */
NatSpecMultiLine
v0.7.0+commit.9e61f92b
MIT
ipfs://1c92a1cb9cad01da0fc8472ee8f3e46eb4a79231c12969194d28b064750262d8
{ "func_code_index": [ 1148, 1301 ] }
8,437
OROCoin
OROCoin.sol
0xbf7fd29146d50b014879518fbcd567243ab8b92b
Solidity
Ownable
abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
transferOwnership
function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; }
/** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */
NatSpecMultiLine
v0.7.0+commit.9e61f92b
MIT
ipfs://1c92a1cb9cad01da0fc8472ee8f3e46eb4a79231c12969194d28b064750262d8
{ "func_code_index": [ 1451, 1700 ] }
8,438
OROCoin
OROCoin.sol
0xbf7fd29146d50b014879518fbcd567243ab8b92b
Solidity
OROCoin
contract OROCoin is Ownable { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; mapping(address => mapping(uint => bool)) public usedSigIds; address public rescueAccount; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); modifier rescueAccountOnly {require(msg.sender == rescueAccount); _;} enum sigStandard { typed, personal, stringHex } enum sigDestination { transfer, approve, approveAndCall, transferFrom } bytes constant public ethSignedMessagePrefix = "\x19Ethereum Signed Message:\n"; bytes32 constant public sigDestinationTransfer = keccak256(abi.encodePacked( "address Token Contract Address", "address Sender's Address", "address Recipient's Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferViaSignature`: keccak256(address(this), from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationTransferFrom = keccak256(abi.encodePacked( "address Token Contract Address", "address Address Approved for Withdraw", "address Account to Withdraw From", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferFromViaSignature`: keccak256(address(this), signer, from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationApprove = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveViaSignature`: keccak256(address(this), from, spender, value, fee, deadline, sigId) bytes32 constant public sigDestinationApproveAndCall = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "bytes Data to Transfer", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveAndCallViaSignature`: keccak256(address(this), from, spender, value, extraData, fee, deadline, sigId) constructor () public { name = "ORO (GBP)"; symbol = "ORP"; rescueAccount = msg.sender; } /** * Utility internal function used to safely transfer `value` tokens `from` -> `to`. Throws if transfer is impossible. * @param from - account to make the transfer from * @param to - account to transfer `value` tokens to * @param value - tokens to transfer to account `to` */ function internalTransfer (address from, address to, uint value) internal { require(to != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(from, to, value); } /** * Utility internal function used to safely transfer `value1` tokens `from` -> `to1`, and `value2` tokens * `from` -> `to2`, minimizing gas usage (calling `internalTransfer` twice is more expensive). Throws if * transfers are impossible. * @param from - account to make the transfer from * @param to1 - account to transfer `value1` tokens to * @param value1 - tokens to transfer to account `to1` * @param to2 - account to transfer `value2` tokens to * @param value2 - tokens to transfer to account `to2` */ function internalDoubleTransfer (address from, address to1, uint value1, address to2, uint value2) internal { require(to1 != address(0x0) && to2 != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value1.add(value2)); balanceOf[to1] = balanceOf[to1].add(value1); emit Transfer(from, to1, value1); if (value2 > 0) { balanceOf[to2] = balanceOf[to2].add(value2); emit Transfer(from, to2, value2); } } /** * Internal method that makes sure that the given signature corresponds to a given data and is made by `signer`. * It utilizes three (four) standards of message signing in Ethereum, as at the moment of this smart contract * development there is no single signing standard defined. For example, Metamask and Geth both support * personal_sign standard, SignTypedData is only supported by Matamask, Trezor does not support "widely adopted" * Ethereum personal_sign but rather personal_sign with fixed prefix and so on. * Note that it is always possible to forge any of these signatures using the private key, the problem is that * third-party wallets must adopt a single standard for signing messages. * @param data - original data which had to be signed by `signer` * @param signer - account which made a signature * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use * @param sigDest - for which type of action this signature was made */ function requireSignature ( bytes32 data, address signer, uint256 deadline, uint256 sigId, bytes memory sig, sigStandard sigStd, sigDestination sigDest ) internal { bytes32 r; bytes32 s; uint8 v; assembly { // solium-disable-line security/no-inline-assembly r := mload(add(sig, 32)) s := mload(add(sig, 64)) v := byte(0, mload(add(sig, 96))) } if (v < 27) v += 27; require(block.timestamp <= deadline && !usedSigIds[signer][sigId]); // solium-disable-line security/no-block-members if (sigStd == sigStandard.typed) { // Typed signature. This is the most likely scenario to be used and accepted require( signer == ecrecover( keccak256(abi.encodePacked( sigDest == sigDestination.transfer ? sigDestinationTransfer : sigDest == sigDestination.approve ? sigDestinationApprove : sigDest == sigDestination.approveAndCall ? sigDestinationApproveAndCall : sigDestinationTransferFrom, data )), v, r, s ) ); } else if (sigStd == sigStandard.personal) { // Ethereum signed message signature (Geth and Trezor) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "32", data)), v, r, s) // Geth-adopted || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x20", data)), v, r, s) // Trezor-adopted ); } else { // == 2; Signed string hash signature (the most expensive but universal) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "64", hexToString(data))), v, r, s) // Geth || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x40", hexToString(data))), v, r, s) // Trezor ); } usedSigIds[signer][sigId] = true; } /** * Utility costly function to encode bytes HEX representation as string. * @param sig - signature as bytes32 to represent as string */ function hexToString (bytes32 sig) internal pure returns (bytes memory) { bytes memory str = new bytes(64); for (uint8 i = 0; i < 32; ++i) { str[2 * i] = byte((uint8(sig[i]) / 16 < 10 ? 48 : 87) + uint8(sig[i]) / 16); str[2 * i + 1] = byte((uint8(sig[i]) % 16 < 10 ? 48 : 87) + (uint8(sig[i]) % 16)); } return str; } /** * Transfer `value` tokens to `to` address from the account of sender. * @param to - the address of the recipient * @param value - the amount to send */ function transfer (address to, uint256 value) public returns (bool) { internalTransfer(msg.sender, to, value); return true; } /** * This function distincts transaction signer from transaction executor. It allows anyone to transfer tokens * from the `from` account by providing a valid signature, which can only be obtained from the `from` account * owner. * Note that passed parameter sigId is unique and cannot be passed twice (prevents replay attacks). When there's * a need to make signature once again (because the first one is lost or whatever), user should sign the message * with the same sigId, thus ensuring that the previous signature can't be used if the new one passes. * Use case: the user wants to send some tokens to another user or smart contract, but don't have Ether to do so. * @param from - the account giving its signature to transfer `value` tokens to `to` address * @param to - the account receiving `value` tokens * @param value - the value in tokens to transfer * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferViaSignature ( address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.transfer ); internalDoubleTransfer(from, to, value, feeRecipient, fee); return true; } /** * Allow `spender` to take `value` tokens from the transaction sender's account. * Beware that changing an allowance with this method brings the risk that `spender` 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 authorized to spend * @param value - the maximum amount they can spend */ function approve (address spender, uint256 value) public returns (bool) { allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * Same as `transferViaSignature`, but for `approve`. * Use case: the user wants to set an allowance for the smart contract or another user without having Ether on * their balance. * @param from - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address * @param value - the value in tokens to approve to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveViaSignature ( address from, address spender, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, spender, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.approve ); allowance[from][spender] = value; emit Approval(from, spender, value); internalTransfer(from, feeRecipient, fee); return true; } /** * Transfer `value` tokens to `to` address from the `from` account, using the previously set allowance. * @param from - the address to transfer tokens from * @param to - the address of the recipient * @param value - the amount to send */ function transferFrom (address from, address to, uint256 value) public returns (bool) { allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); internalTransfer(from, to, value); return true; } /** * Same as `transferViaSignature`, but for `transferFrom`. * Use case: the user wants to withdraw tokens from a smart contract or another user who allowed the user to * do so. Important note: the fee is subtracted from the `value`, and `to` address receives `value - fee`. * @param signer - the address allowed to call transferFrom, which signed all below parameters * @param from - the account to make withdrawal from * @param to - the address of the recipient * @param value - the value in tokens to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferFromViaSignature ( address signer, address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), signer, deadline, sigId, sig, sigStd, sigDestination.transferFrom ); allowance[from][signer] = allowance[from][signer].sub(value); internalDoubleTransfer(from, to, value.sub(fee), feeRecipient, fee); return true; } /** * Utility function, which acts the same as approve(...), but also calls `receiveApproval` function on a * `spender` address, which is usually the address of the smart contract. In the same call, smart contract can * withdraw tokens from the sender's account and receive additional `extraData` for processing. * @param spender - the address to be authorized to spend tokens * @param value - the max amount the `spender` can withdraw * @param extraData - some extra information to send to the approved contract */ function approveAndCall (address spender, uint256 value, bytes memory extraData) public returns (bool) { approve(spender, value); tokenRecipient(spender).receiveApproval(msg.sender, value, address(this), extraData); return true; } /** * Same as `approveViaSignature`, but for `approveAndCall`. * Use case: the user wants to send tokens to the smart contract and pass additional data within one transaction. * @param fromAddress - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address (in this case, smart contract only) * @param value - the value in tokens to approve to withdraw * @param extraData - additional data to pass to the `spender` smart contract * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveAndCallViaSignature ( address fromAddress, address spender, uint256 value, bytes calldata extraData, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), fromAddress, spender, value, extraData, fee, feeRecipient, deadline, sigId)), fromAddress, deadline, sigId, sig, sigStd, sigDestination.approveAndCall); allowance[fromAddress][spender] = value; emit Approval(fromAddress, spender, value); tokenRecipient(spender).receiveApproval(fromAddress, value, address(this), extraData); internalTransfer(fromAddress, feeRecipient, fee); return true; } /** * Mint some tokens to the sender's address. */ function mintTokens (uint newSupply) onlyOwner external { totalSupply = totalSupply.add(newSupply); balanceOf[msg.sender] = balanceOf[msg.sender].add(newSupply); emit Transfer(address(0x0), msg.sender, newSupply); } /** * ERC20 tokens are not designed to hold any other tokens (or Ether) on their balances. There were thousands * of cases when people accidentally transfer tokens to a contract address while there is no way to get them * back. This function adds a possibility to "rescue" tokens that were accidentally sent to this smart contract. * @param tokenContract - ERC20-compatible token * @param value - amount to rescue */ function rescueLostTokens (ERC20CompatibleToken tokenContract, uint256 value) external rescueAccountOnly { tokenContract.transfer(rescueAccount, value); } /** * Utility function that allows to change the rescueAccount address, which can "rescue" tokens accidentally sent to * this smart contract address. * @param newRescueAccount - account which will become authorized to rescue tokens */ function changeRescueAccount (address newRescueAccount) external rescueAccountOnly { rescueAccount = newRescueAccount; } }
internalTransfer
function internalTransfer (address from, address to, uint value) internal { require(to != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(from, to, value); }
/** * Utility internal function used to safely transfer `value` tokens `from` -> `to`. Throws if transfer is impossible. * @param from - account to make the transfer from * @param to - account to transfer `value` tokens to * @param value - tokens to transfer to account `to` */
NatSpecMultiLine
v0.7.0+commit.9e61f92b
MIT
ipfs://1c92a1cb9cad01da0fc8472ee8f3e46eb4a79231c12969194d28b064750262d8
{ "func_code_index": [ 4017, 4346 ] }
8,439
OROCoin
OROCoin.sol
0xbf7fd29146d50b014879518fbcd567243ab8b92b
Solidity
OROCoin
contract OROCoin is Ownable { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; mapping(address => mapping(uint => bool)) public usedSigIds; address public rescueAccount; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); modifier rescueAccountOnly {require(msg.sender == rescueAccount); _;} enum sigStandard { typed, personal, stringHex } enum sigDestination { transfer, approve, approveAndCall, transferFrom } bytes constant public ethSignedMessagePrefix = "\x19Ethereum Signed Message:\n"; bytes32 constant public sigDestinationTransfer = keccak256(abi.encodePacked( "address Token Contract Address", "address Sender's Address", "address Recipient's Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferViaSignature`: keccak256(address(this), from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationTransferFrom = keccak256(abi.encodePacked( "address Token Contract Address", "address Address Approved for Withdraw", "address Account to Withdraw From", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferFromViaSignature`: keccak256(address(this), signer, from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationApprove = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveViaSignature`: keccak256(address(this), from, spender, value, fee, deadline, sigId) bytes32 constant public sigDestinationApproveAndCall = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "bytes Data to Transfer", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveAndCallViaSignature`: keccak256(address(this), from, spender, value, extraData, fee, deadline, sigId) constructor () public { name = "ORO (GBP)"; symbol = "ORP"; rescueAccount = msg.sender; } /** * Utility internal function used to safely transfer `value` tokens `from` -> `to`. Throws if transfer is impossible. * @param from - account to make the transfer from * @param to - account to transfer `value` tokens to * @param value - tokens to transfer to account `to` */ function internalTransfer (address from, address to, uint value) internal { require(to != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(from, to, value); } /** * Utility internal function used to safely transfer `value1` tokens `from` -> `to1`, and `value2` tokens * `from` -> `to2`, minimizing gas usage (calling `internalTransfer` twice is more expensive). Throws if * transfers are impossible. * @param from - account to make the transfer from * @param to1 - account to transfer `value1` tokens to * @param value1 - tokens to transfer to account `to1` * @param to2 - account to transfer `value2` tokens to * @param value2 - tokens to transfer to account `to2` */ function internalDoubleTransfer (address from, address to1, uint value1, address to2, uint value2) internal { require(to1 != address(0x0) && to2 != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value1.add(value2)); balanceOf[to1] = balanceOf[to1].add(value1); emit Transfer(from, to1, value1); if (value2 > 0) { balanceOf[to2] = balanceOf[to2].add(value2); emit Transfer(from, to2, value2); } } /** * Internal method that makes sure that the given signature corresponds to a given data and is made by `signer`. * It utilizes three (four) standards of message signing in Ethereum, as at the moment of this smart contract * development there is no single signing standard defined. For example, Metamask and Geth both support * personal_sign standard, SignTypedData is only supported by Matamask, Trezor does not support "widely adopted" * Ethereum personal_sign but rather personal_sign with fixed prefix and so on. * Note that it is always possible to forge any of these signatures using the private key, the problem is that * third-party wallets must adopt a single standard for signing messages. * @param data - original data which had to be signed by `signer` * @param signer - account which made a signature * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use * @param sigDest - for which type of action this signature was made */ function requireSignature ( bytes32 data, address signer, uint256 deadline, uint256 sigId, bytes memory sig, sigStandard sigStd, sigDestination sigDest ) internal { bytes32 r; bytes32 s; uint8 v; assembly { // solium-disable-line security/no-inline-assembly r := mload(add(sig, 32)) s := mload(add(sig, 64)) v := byte(0, mload(add(sig, 96))) } if (v < 27) v += 27; require(block.timestamp <= deadline && !usedSigIds[signer][sigId]); // solium-disable-line security/no-block-members if (sigStd == sigStandard.typed) { // Typed signature. This is the most likely scenario to be used and accepted require( signer == ecrecover( keccak256(abi.encodePacked( sigDest == sigDestination.transfer ? sigDestinationTransfer : sigDest == sigDestination.approve ? sigDestinationApprove : sigDest == sigDestination.approveAndCall ? sigDestinationApproveAndCall : sigDestinationTransferFrom, data )), v, r, s ) ); } else if (sigStd == sigStandard.personal) { // Ethereum signed message signature (Geth and Trezor) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "32", data)), v, r, s) // Geth-adopted || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x20", data)), v, r, s) // Trezor-adopted ); } else { // == 2; Signed string hash signature (the most expensive but universal) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "64", hexToString(data))), v, r, s) // Geth || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x40", hexToString(data))), v, r, s) // Trezor ); } usedSigIds[signer][sigId] = true; } /** * Utility costly function to encode bytes HEX representation as string. * @param sig - signature as bytes32 to represent as string */ function hexToString (bytes32 sig) internal pure returns (bytes memory) { bytes memory str = new bytes(64); for (uint8 i = 0; i < 32; ++i) { str[2 * i] = byte((uint8(sig[i]) / 16 < 10 ? 48 : 87) + uint8(sig[i]) / 16); str[2 * i + 1] = byte((uint8(sig[i]) % 16 < 10 ? 48 : 87) + (uint8(sig[i]) % 16)); } return str; } /** * Transfer `value` tokens to `to` address from the account of sender. * @param to - the address of the recipient * @param value - the amount to send */ function transfer (address to, uint256 value) public returns (bool) { internalTransfer(msg.sender, to, value); return true; } /** * This function distincts transaction signer from transaction executor. It allows anyone to transfer tokens * from the `from` account by providing a valid signature, which can only be obtained from the `from` account * owner. * Note that passed parameter sigId is unique and cannot be passed twice (prevents replay attacks). When there's * a need to make signature once again (because the first one is lost or whatever), user should sign the message * with the same sigId, thus ensuring that the previous signature can't be used if the new one passes. * Use case: the user wants to send some tokens to another user or smart contract, but don't have Ether to do so. * @param from - the account giving its signature to transfer `value` tokens to `to` address * @param to - the account receiving `value` tokens * @param value - the value in tokens to transfer * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferViaSignature ( address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.transfer ); internalDoubleTransfer(from, to, value, feeRecipient, fee); return true; } /** * Allow `spender` to take `value` tokens from the transaction sender's account. * Beware that changing an allowance with this method brings the risk that `spender` 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 authorized to spend * @param value - the maximum amount they can spend */ function approve (address spender, uint256 value) public returns (bool) { allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * Same as `transferViaSignature`, but for `approve`. * Use case: the user wants to set an allowance for the smart contract or another user without having Ether on * their balance. * @param from - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address * @param value - the value in tokens to approve to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveViaSignature ( address from, address spender, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, spender, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.approve ); allowance[from][spender] = value; emit Approval(from, spender, value); internalTransfer(from, feeRecipient, fee); return true; } /** * Transfer `value` tokens to `to` address from the `from` account, using the previously set allowance. * @param from - the address to transfer tokens from * @param to - the address of the recipient * @param value - the amount to send */ function transferFrom (address from, address to, uint256 value) public returns (bool) { allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); internalTransfer(from, to, value); return true; } /** * Same as `transferViaSignature`, but for `transferFrom`. * Use case: the user wants to withdraw tokens from a smart contract or another user who allowed the user to * do so. Important note: the fee is subtracted from the `value`, and `to` address receives `value - fee`. * @param signer - the address allowed to call transferFrom, which signed all below parameters * @param from - the account to make withdrawal from * @param to - the address of the recipient * @param value - the value in tokens to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferFromViaSignature ( address signer, address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), signer, deadline, sigId, sig, sigStd, sigDestination.transferFrom ); allowance[from][signer] = allowance[from][signer].sub(value); internalDoubleTransfer(from, to, value.sub(fee), feeRecipient, fee); return true; } /** * Utility function, which acts the same as approve(...), but also calls `receiveApproval` function on a * `spender` address, which is usually the address of the smart contract. In the same call, smart contract can * withdraw tokens from the sender's account and receive additional `extraData` for processing. * @param spender - the address to be authorized to spend tokens * @param value - the max amount the `spender` can withdraw * @param extraData - some extra information to send to the approved contract */ function approveAndCall (address spender, uint256 value, bytes memory extraData) public returns (bool) { approve(spender, value); tokenRecipient(spender).receiveApproval(msg.sender, value, address(this), extraData); return true; } /** * Same as `approveViaSignature`, but for `approveAndCall`. * Use case: the user wants to send tokens to the smart contract and pass additional data within one transaction. * @param fromAddress - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address (in this case, smart contract only) * @param value - the value in tokens to approve to withdraw * @param extraData - additional data to pass to the `spender` smart contract * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveAndCallViaSignature ( address fromAddress, address spender, uint256 value, bytes calldata extraData, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), fromAddress, spender, value, extraData, fee, feeRecipient, deadline, sigId)), fromAddress, deadline, sigId, sig, sigStd, sigDestination.approveAndCall); allowance[fromAddress][spender] = value; emit Approval(fromAddress, spender, value); tokenRecipient(spender).receiveApproval(fromAddress, value, address(this), extraData); internalTransfer(fromAddress, feeRecipient, fee); return true; } /** * Mint some tokens to the sender's address. */ function mintTokens (uint newSupply) onlyOwner external { totalSupply = totalSupply.add(newSupply); balanceOf[msg.sender] = balanceOf[msg.sender].add(newSupply); emit Transfer(address(0x0), msg.sender, newSupply); } /** * ERC20 tokens are not designed to hold any other tokens (or Ether) on their balances. There were thousands * of cases when people accidentally transfer tokens to a contract address while there is no way to get them * back. This function adds a possibility to "rescue" tokens that were accidentally sent to this smart contract. * @param tokenContract - ERC20-compatible token * @param value - amount to rescue */ function rescueLostTokens (ERC20CompatibleToken tokenContract, uint256 value) external rescueAccountOnly { tokenContract.transfer(rescueAccount, value); } /** * Utility function that allows to change the rescueAccount address, which can "rescue" tokens accidentally sent to * this smart contract address. * @param newRescueAccount - account which will become authorized to rescue tokens */ function changeRescueAccount (address newRescueAccount) external rescueAccountOnly { rescueAccount = newRescueAccount; } }
internalDoubleTransfer
function internalDoubleTransfer (address from, address to1, uint value1, address to2, uint value2) internal { require(to1 != address(0x0) && to2 != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value1.add(value2)); balanceOf[to1] = balanceOf[to1].add(value1); emit Transfer(from, to1, value1); if (value2 > 0) { balanceOf[to2] = balanceOf[to2].add(value2); emit Transfer(from, to2, value2); } }
/** * Utility internal function used to safely transfer `value1` tokens `from` -> `to1`, and `value2` tokens * `from` -> `to2`, minimizing gas usage (calling `internalTransfer` twice is more expensive). Throws if * transfers are impossible. * @param from - account to make the transfer from * @param to1 - account to transfer `value1` tokens to * @param value1 - tokens to transfer to account `to1` * @param to2 - account to transfer `value2` tokens to * @param value2 - tokens to transfer to account `to2` */
NatSpecMultiLine
v0.7.0+commit.9e61f92b
MIT
ipfs://1c92a1cb9cad01da0fc8472ee8f3e46eb4a79231c12969194d28b064750262d8
{ "func_code_index": [ 4918, 5466 ] }
8,440
OROCoin
OROCoin.sol
0xbf7fd29146d50b014879518fbcd567243ab8b92b
Solidity
OROCoin
contract OROCoin is Ownable { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; mapping(address => mapping(uint => bool)) public usedSigIds; address public rescueAccount; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); modifier rescueAccountOnly {require(msg.sender == rescueAccount); _;} enum sigStandard { typed, personal, stringHex } enum sigDestination { transfer, approve, approveAndCall, transferFrom } bytes constant public ethSignedMessagePrefix = "\x19Ethereum Signed Message:\n"; bytes32 constant public sigDestinationTransfer = keccak256(abi.encodePacked( "address Token Contract Address", "address Sender's Address", "address Recipient's Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferViaSignature`: keccak256(address(this), from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationTransferFrom = keccak256(abi.encodePacked( "address Token Contract Address", "address Address Approved for Withdraw", "address Account to Withdraw From", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferFromViaSignature`: keccak256(address(this), signer, from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationApprove = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveViaSignature`: keccak256(address(this), from, spender, value, fee, deadline, sigId) bytes32 constant public sigDestinationApproveAndCall = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "bytes Data to Transfer", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveAndCallViaSignature`: keccak256(address(this), from, spender, value, extraData, fee, deadline, sigId) constructor () public { name = "ORO (GBP)"; symbol = "ORP"; rescueAccount = msg.sender; } /** * Utility internal function used to safely transfer `value` tokens `from` -> `to`. Throws if transfer is impossible. * @param from - account to make the transfer from * @param to - account to transfer `value` tokens to * @param value - tokens to transfer to account `to` */ function internalTransfer (address from, address to, uint value) internal { require(to != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(from, to, value); } /** * Utility internal function used to safely transfer `value1` tokens `from` -> `to1`, and `value2` tokens * `from` -> `to2`, minimizing gas usage (calling `internalTransfer` twice is more expensive). Throws if * transfers are impossible. * @param from - account to make the transfer from * @param to1 - account to transfer `value1` tokens to * @param value1 - tokens to transfer to account `to1` * @param to2 - account to transfer `value2` tokens to * @param value2 - tokens to transfer to account `to2` */ function internalDoubleTransfer (address from, address to1, uint value1, address to2, uint value2) internal { require(to1 != address(0x0) && to2 != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value1.add(value2)); balanceOf[to1] = balanceOf[to1].add(value1); emit Transfer(from, to1, value1); if (value2 > 0) { balanceOf[to2] = balanceOf[to2].add(value2); emit Transfer(from, to2, value2); } } /** * Internal method that makes sure that the given signature corresponds to a given data and is made by `signer`. * It utilizes three (four) standards of message signing in Ethereum, as at the moment of this smart contract * development there is no single signing standard defined. For example, Metamask and Geth both support * personal_sign standard, SignTypedData is only supported by Matamask, Trezor does not support "widely adopted" * Ethereum personal_sign but rather personal_sign with fixed prefix and so on. * Note that it is always possible to forge any of these signatures using the private key, the problem is that * third-party wallets must adopt a single standard for signing messages. * @param data - original data which had to be signed by `signer` * @param signer - account which made a signature * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use * @param sigDest - for which type of action this signature was made */ function requireSignature ( bytes32 data, address signer, uint256 deadline, uint256 sigId, bytes memory sig, sigStandard sigStd, sigDestination sigDest ) internal { bytes32 r; bytes32 s; uint8 v; assembly { // solium-disable-line security/no-inline-assembly r := mload(add(sig, 32)) s := mload(add(sig, 64)) v := byte(0, mload(add(sig, 96))) } if (v < 27) v += 27; require(block.timestamp <= deadline && !usedSigIds[signer][sigId]); // solium-disable-line security/no-block-members if (sigStd == sigStandard.typed) { // Typed signature. This is the most likely scenario to be used and accepted require( signer == ecrecover( keccak256(abi.encodePacked( sigDest == sigDestination.transfer ? sigDestinationTransfer : sigDest == sigDestination.approve ? sigDestinationApprove : sigDest == sigDestination.approveAndCall ? sigDestinationApproveAndCall : sigDestinationTransferFrom, data )), v, r, s ) ); } else if (sigStd == sigStandard.personal) { // Ethereum signed message signature (Geth and Trezor) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "32", data)), v, r, s) // Geth-adopted || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x20", data)), v, r, s) // Trezor-adopted ); } else { // == 2; Signed string hash signature (the most expensive but universal) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "64", hexToString(data))), v, r, s) // Geth || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x40", hexToString(data))), v, r, s) // Trezor ); } usedSigIds[signer][sigId] = true; } /** * Utility costly function to encode bytes HEX representation as string. * @param sig - signature as bytes32 to represent as string */ function hexToString (bytes32 sig) internal pure returns (bytes memory) { bytes memory str = new bytes(64); for (uint8 i = 0; i < 32; ++i) { str[2 * i] = byte((uint8(sig[i]) / 16 < 10 ? 48 : 87) + uint8(sig[i]) / 16); str[2 * i + 1] = byte((uint8(sig[i]) % 16 < 10 ? 48 : 87) + (uint8(sig[i]) % 16)); } return str; } /** * Transfer `value` tokens to `to` address from the account of sender. * @param to - the address of the recipient * @param value - the amount to send */ function transfer (address to, uint256 value) public returns (bool) { internalTransfer(msg.sender, to, value); return true; } /** * This function distincts transaction signer from transaction executor. It allows anyone to transfer tokens * from the `from` account by providing a valid signature, which can only be obtained from the `from` account * owner. * Note that passed parameter sigId is unique and cannot be passed twice (prevents replay attacks). When there's * a need to make signature once again (because the first one is lost or whatever), user should sign the message * with the same sigId, thus ensuring that the previous signature can't be used if the new one passes. * Use case: the user wants to send some tokens to another user or smart contract, but don't have Ether to do so. * @param from - the account giving its signature to transfer `value` tokens to `to` address * @param to - the account receiving `value` tokens * @param value - the value in tokens to transfer * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferViaSignature ( address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.transfer ); internalDoubleTransfer(from, to, value, feeRecipient, fee); return true; } /** * Allow `spender` to take `value` tokens from the transaction sender's account. * Beware that changing an allowance with this method brings the risk that `spender` 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 authorized to spend * @param value - the maximum amount they can spend */ function approve (address spender, uint256 value) public returns (bool) { allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * Same as `transferViaSignature`, but for `approve`. * Use case: the user wants to set an allowance for the smart contract or another user without having Ether on * their balance. * @param from - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address * @param value - the value in tokens to approve to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveViaSignature ( address from, address spender, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, spender, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.approve ); allowance[from][spender] = value; emit Approval(from, spender, value); internalTransfer(from, feeRecipient, fee); return true; } /** * Transfer `value` tokens to `to` address from the `from` account, using the previously set allowance. * @param from - the address to transfer tokens from * @param to - the address of the recipient * @param value - the amount to send */ function transferFrom (address from, address to, uint256 value) public returns (bool) { allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); internalTransfer(from, to, value); return true; } /** * Same as `transferViaSignature`, but for `transferFrom`. * Use case: the user wants to withdraw tokens from a smart contract or another user who allowed the user to * do so. Important note: the fee is subtracted from the `value`, and `to` address receives `value - fee`. * @param signer - the address allowed to call transferFrom, which signed all below parameters * @param from - the account to make withdrawal from * @param to - the address of the recipient * @param value - the value in tokens to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferFromViaSignature ( address signer, address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), signer, deadline, sigId, sig, sigStd, sigDestination.transferFrom ); allowance[from][signer] = allowance[from][signer].sub(value); internalDoubleTransfer(from, to, value.sub(fee), feeRecipient, fee); return true; } /** * Utility function, which acts the same as approve(...), but also calls `receiveApproval` function on a * `spender` address, which is usually the address of the smart contract. In the same call, smart contract can * withdraw tokens from the sender's account and receive additional `extraData` for processing. * @param spender - the address to be authorized to spend tokens * @param value - the max amount the `spender` can withdraw * @param extraData - some extra information to send to the approved contract */ function approveAndCall (address spender, uint256 value, bytes memory extraData) public returns (bool) { approve(spender, value); tokenRecipient(spender).receiveApproval(msg.sender, value, address(this), extraData); return true; } /** * Same as `approveViaSignature`, but for `approveAndCall`. * Use case: the user wants to send tokens to the smart contract and pass additional data within one transaction. * @param fromAddress - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address (in this case, smart contract only) * @param value - the value in tokens to approve to withdraw * @param extraData - additional data to pass to the `spender` smart contract * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveAndCallViaSignature ( address fromAddress, address spender, uint256 value, bytes calldata extraData, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), fromAddress, spender, value, extraData, fee, feeRecipient, deadline, sigId)), fromAddress, deadline, sigId, sig, sigStd, sigDestination.approveAndCall); allowance[fromAddress][spender] = value; emit Approval(fromAddress, spender, value); tokenRecipient(spender).receiveApproval(fromAddress, value, address(this), extraData); internalTransfer(fromAddress, feeRecipient, fee); return true; } /** * Mint some tokens to the sender's address. */ function mintTokens (uint newSupply) onlyOwner external { totalSupply = totalSupply.add(newSupply); balanceOf[msg.sender] = balanceOf[msg.sender].add(newSupply); emit Transfer(address(0x0), msg.sender, newSupply); } /** * ERC20 tokens are not designed to hold any other tokens (or Ether) on their balances. There were thousands * of cases when people accidentally transfer tokens to a contract address while there is no way to get them * back. This function adds a possibility to "rescue" tokens that were accidentally sent to this smart contract. * @param tokenContract - ERC20-compatible token * @param value - amount to rescue */ function rescueLostTokens (ERC20CompatibleToken tokenContract, uint256 value) external rescueAccountOnly { tokenContract.transfer(rescueAccount, value); } /** * Utility function that allows to change the rescueAccount address, which can "rescue" tokens accidentally sent to * this smart contract address. * @param newRescueAccount - account which will become authorized to rescue tokens */ function changeRescueAccount (address newRescueAccount) external rescueAccountOnly { rescueAccount = newRescueAccount; } }
requireSignature
function requireSignature ( bytes32 data, address signer, uint256 deadline, uint256 sigId, bytes memory sig, sigStandard sigStd, sigDestination sigDest ) internal { bytes32 r; bytes32 s; uint8 v; assembly { // solium-disable-line security/no-inline-assembly r := mload(add(sig, 32)) s := mload(add(sig, 64)) v := byte(0, mload(add(sig, 96))) } if (v < 27) v += 27; require(block.timestamp <= deadline && !usedSigIds[signer][sigId]); // solium-disable-line security/no-block-members if (sigStd == sigStandard.typed) { // Typed signature. This is the most likely scenario to be used and accepted require( signer == ecrecover( keccak256(abi.encodePacked( sigDest == sigDestination.transfer ? sigDestinationTransfer : sigDest == sigDestination.approve ? sigDestinationApprove : sigDest == sigDestination.approveAndCall ? sigDestinationApproveAndCall : sigDestinationTransferFrom, data )), v, r, s ) ); } else if (sigStd == sigStandard.personal) { // Ethereum signed message signature (Geth and Trezor) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "32", data)), v, r, s) // Geth-adopted || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x20", data)), v, r, s) // Trezor-adopted ); } else { // == 2; Signed string hash signature (the most expensive but universal) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "64", hexToString(data))), v, r, s) // Geth || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x40", hexToString(data))), v, r, s) // Trezor ); } usedSigIds[signer][sigId] = true; }
/** * Internal method that makes sure that the given signature corresponds to a given data and is made by `signer`. * It utilizes three (four) standards of message signing in Ethereum, as at the moment of this smart contract * development there is no single signing standard defined. For example, Metamask and Geth both support * personal_sign standard, SignTypedData is only supported by Matamask, Trezor does not support "widely adopted" * Ethereum personal_sign but rather personal_sign with fixed prefix and so on. * Note that it is always possible to forge any of these signatures using the private key, the problem is that * third-party wallets must adopt a single standard for signing messages. * @param data - original data which had to be signed by `signer` * @param signer - account which made a signature * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use * @param sigDest - for which type of action this signature was made */
NatSpecMultiLine
v0.7.0+commit.9e61f92b
MIT
ipfs://1c92a1cb9cad01da0fc8472ee8f3e46eb4a79231c12969194d28b064750262d8
{ "func_code_index": [ 6836, 9300 ] }
8,441
OROCoin
OROCoin.sol
0xbf7fd29146d50b014879518fbcd567243ab8b92b
Solidity
OROCoin
contract OROCoin is Ownable { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; mapping(address => mapping(uint => bool)) public usedSigIds; address public rescueAccount; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); modifier rescueAccountOnly {require(msg.sender == rescueAccount); _;} enum sigStandard { typed, personal, stringHex } enum sigDestination { transfer, approve, approveAndCall, transferFrom } bytes constant public ethSignedMessagePrefix = "\x19Ethereum Signed Message:\n"; bytes32 constant public sigDestinationTransfer = keccak256(abi.encodePacked( "address Token Contract Address", "address Sender's Address", "address Recipient's Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferViaSignature`: keccak256(address(this), from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationTransferFrom = keccak256(abi.encodePacked( "address Token Contract Address", "address Address Approved for Withdraw", "address Account to Withdraw From", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferFromViaSignature`: keccak256(address(this), signer, from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationApprove = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveViaSignature`: keccak256(address(this), from, spender, value, fee, deadline, sigId) bytes32 constant public sigDestinationApproveAndCall = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "bytes Data to Transfer", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveAndCallViaSignature`: keccak256(address(this), from, spender, value, extraData, fee, deadline, sigId) constructor () public { name = "ORO (GBP)"; symbol = "ORP"; rescueAccount = msg.sender; } /** * Utility internal function used to safely transfer `value` tokens `from` -> `to`. Throws if transfer is impossible. * @param from - account to make the transfer from * @param to - account to transfer `value` tokens to * @param value - tokens to transfer to account `to` */ function internalTransfer (address from, address to, uint value) internal { require(to != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(from, to, value); } /** * Utility internal function used to safely transfer `value1` tokens `from` -> `to1`, and `value2` tokens * `from` -> `to2`, minimizing gas usage (calling `internalTransfer` twice is more expensive). Throws if * transfers are impossible. * @param from - account to make the transfer from * @param to1 - account to transfer `value1` tokens to * @param value1 - tokens to transfer to account `to1` * @param to2 - account to transfer `value2` tokens to * @param value2 - tokens to transfer to account `to2` */ function internalDoubleTransfer (address from, address to1, uint value1, address to2, uint value2) internal { require(to1 != address(0x0) && to2 != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value1.add(value2)); balanceOf[to1] = balanceOf[to1].add(value1); emit Transfer(from, to1, value1); if (value2 > 0) { balanceOf[to2] = balanceOf[to2].add(value2); emit Transfer(from, to2, value2); } } /** * Internal method that makes sure that the given signature corresponds to a given data and is made by `signer`. * It utilizes three (four) standards of message signing in Ethereum, as at the moment of this smart contract * development there is no single signing standard defined. For example, Metamask and Geth both support * personal_sign standard, SignTypedData is only supported by Matamask, Trezor does not support "widely adopted" * Ethereum personal_sign but rather personal_sign with fixed prefix and so on. * Note that it is always possible to forge any of these signatures using the private key, the problem is that * third-party wallets must adopt a single standard for signing messages. * @param data - original data which had to be signed by `signer` * @param signer - account which made a signature * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use * @param sigDest - for which type of action this signature was made */ function requireSignature ( bytes32 data, address signer, uint256 deadline, uint256 sigId, bytes memory sig, sigStandard sigStd, sigDestination sigDest ) internal { bytes32 r; bytes32 s; uint8 v; assembly { // solium-disable-line security/no-inline-assembly r := mload(add(sig, 32)) s := mload(add(sig, 64)) v := byte(0, mload(add(sig, 96))) } if (v < 27) v += 27; require(block.timestamp <= deadline && !usedSigIds[signer][sigId]); // solium-disable-line security/no-block-members if (sigStd == sigStandard.typed) { // Typed signature. This is the most likely scenario to be used and accepted require( signer == ecrecover( keccak256(abi.encodePacked( sigDest == sigDestination.transfer ? sigDestinationTransfer : sigDest == sigDestination.approve ? sigDestinationApprove : sigDest == sigDestination.approveAndCall ? sigDestinationApproveAndCall : sigDestinationTransferFrom, data )), v, r, s ) ); } else if (sigStd == sigStandard.personal) { // Ethereum signed message signature (Geth and Trezor) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "32", data)), v, r, s) // Geth-adopted || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x20", data)), v, r, s) // Trezor-adopted ); } else { // == 2; Signed string hash signature (the most expensive but universal) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "64", hexToString(data))), v, r, s) // Geth || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x40", hexToString(data))), v, r, s) // Trezor ); } usedSigIds[signer][sigId] = true; } /** * Utility costly function to encode bytes HEX representation as string. * @param sig - signature as bytes32 to represent as string */ function hexToString (bytes32 sig) internal pure returns (bytes memory) { bytes memory str = new bytes(64); for (uint8 i = 0; i < 32; ++i) { str[2 * i] = byte((uint8(sig[i]) / 16 < 10 ? 48 : 87) + uint8(sig[i]) / 16); str[2 * i + 1] = byte((uint8(sig[i]) % 16 < 10 ? 48 : 87) + (uint8(sig[i]) % 16)); } return str; } /** * Transfer `value` tokens to `to` address from the account of sender. * @param to - the address of the recipient * @param value - the amount to send */ function transfer (address to, uint256 value) public returns (bool) { internalTransfer(msg.sender, to, value); return true; } /** * This function distincts transaction signer from transaction executor. It allows anyone to transfer tokens * from the `from` account by providing a valid signature, which can only be obtained from the `from` account * owner. * Note that passed parameter sigId is unique and cannot be passed twice (prevents replay attacks). When there's * a need to make signature once again (because the first one is lost or whatever), user should sign the message * with the same sigId, thus ensuring that the previous signature can't be used if the new one passes. * Use case: the user wants to send some tokens to another user or smart contract, but don't have Ether to do so. * @param from - the account giving its signature to transfer `value` tokens to `to` address * @param to - the account receiving `value` tokens * @param value - the value in tokens to transfer * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferViaSignature ( address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.transfer ); internalDoubleTransfer(from, to, value, feeRecipient, fee); return true; } /** * Allow `spender` to take `value` tokens from the transaction sender's account. * Beware that changing an allowance with this method brings the risk that `spender` 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 authorized to spend * @param value - the maximum amount they can spend */ function approve (address spender, uint256 value) public returns (bool) { allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * Same as `transferViaSignature`, but for `approve`. * Use case: the user wants to set an allowance for the smart contract or another user without having Ether on * their balance. * @param from - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address * @param value - the value in tokens to approve to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveViaSignature ( address from, address spender, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, spender, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.approve ); allowance[from][spender] = value; emit Approval(from, spender, value); internalTransfer(from, feeRecipient, fee); return true; } /** * Transfer `value` tokens to `to` address from the `from` account, using the previously set allowance. * @param from - the address to transfer tokens from * @param to - the address of the recipient * @param value - the amount to send */ function transferFrom (address from, address to, uint256 value) public returns (bool) { allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); internalTransfer(from, to, value); return true; } /** * Same as `transferViaSignature`, but for `transferFrom`. * Use case: the user wants to withdraw tokens from a smart contract or another user who allowed the user to * do so. Important note: the fee is subtracted from the `value`, and `to` address receives `value - fee`. * @param signer - the address allowed to call transferFrom, which signed all below parameters * @param from - the account to make withdrawal from * @param to - the address of the recipient * @param value - the value in tokens to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferFromViaSignature ( address signer, address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), signer, deadline, sigId, sig, sigStd, sigDestination.transferFrom ); allowance[from][signer] = allowance[from][signer].sub(value); internalDoubleTransfer(from, to, value.sub(fee), feeRecipient, fee); return true; } /** * Utility function, which acts the same as approve(...), but also calls `receiveApproval` function on a * `spender` address, which is usually the address of the smart contract. In the same call, smart contract can * withdraw tokens from the sender's account and receive additional `extraData` for processing. * @param spender - the address to be authorized to spend tokens * @param value - the max amount the `spender` can withdraw * @param extraData - some extra information to send to the approved contract */ function approveAndCall (address spender, uint256 value, bytes memory extraData) public returns (bool) { approve(spender, value); tokenRecipient(spender).receiveApproval(msg.sender, value, address(this), extraData); return true; } /** * Same as `approveViaSignature`, but for `approveAndCall`. * Use case: the user wants to send tokens to the smart contract and pass additional data within one transaction. * @param fromAddress - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address (in this case, smart contract only) * @param value - the value in tokens to approve to withdraw * @param extraData - additional data to pass to the `spender` smart contract * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveAndCallViaSignature ( address fromAddress, address spender, uint256 value, bytes calldata extraData, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), fromAddress, spender, value, extraData, fee, feeRecipient, deadline, sigId)), fromAddress, deadline, sigId, sig, sigStd, sigDestination.approveAndCall); allowance[fromAddress][spender] = value; emit Approval(fromAddress, spender, value); tokenRecipient(spender).receiveApproval(fromAddress, value, address(this), extraData); internalTransfer(fromAddress, feeRecipient, fee); return true; } /** * Mint some tokens to the sender's address. */ function mintTokens (uint newSupply) onlyOwner external { totalSupply = totalSupply.add(newSupply); balanceOf[msg.sender] = balanceOf[msg.sender].add(newSupply); emit Transfer(address(0x0), msg.sender, newSupply); } /** * ERC20 tokens are not designed to hold any other tokens (or Ether) on their balances. There were thousands * of cases when people accidentally transfer tokens to a contract address while there is no way to get them * back. This function adds a possibility to "rescue" tokens that were accidentally sent to this smart contract. * @param tokenContract - ERC20-compatible token * @param value - amount to rescue */ function rescueLostTokens (ERC20CompatibleToken tokenContract, uint256 value) external rescueAccountOnly { tokenContract.transfer(rescueAccount, value); } /** * Utility function that allows to change the rescueAccount address, which can "rescue" tokens accidentally sent to * this smart contract address. * @param newRescueAccount - account which will become authorized to rescue tokens */ function changeRescueAccount (address newRescueAccount) external rescueAccountOnly { rescueAccount = newRescueAccount; } }
hexToString
function hexToString (bytes32 sig) internal pure returns (bytes memory) { bytes memory str = new bytes(64); for (uint8 i = 0; i < 32; ++i) { str[2 * i] = byte((uint8(sig[i]) / 16 < 10 ? 48 : 87) + uint8(sig[i]) / 16); str[2 * i + 1] = byte((uint8(sig[i]) % 16 < 10 ? 48 : 87) + (uint8(sig[i]) % 16)); } return str; }
/** * Utility costly function to encode bytes HEX representation as string. * @param sig - signature as bytes32 to represent as string */
NatSpecMultiLine
v0.7.0+commit.9e61f92b
MIT
ipfs://1c92a1cb9cad01da0fc8472ee8f3e46eb4a79231c12969194d28b064750262d8
{ "func_code_index": [ 9464, 9852 ] }
8,442
OROCoin
OROCoin.sol
0xbf7fd29146d50b014879518fbcd567243ab8b92b
Solidity
OROCoin
contract OROCoin is Ownable { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; mapping(address => mapping(uint => bool)) public usedSigIds; address public rescueAccount; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); modifier rescueAccountOnly {require(msg.sender == rescueAccount); _;} enum sigStandard { typed, personal, stringHex } enum sigDestination { transfer, approve, approveAndCall, transferFrom } bytes constant public ethSignedMessagePrefix = "\x19Ethereum Signed Message:\n"; bytes32 constant public sigDestinationTransfer = keccak256(abi.encodePacked( "address Token Contract Address", "address Sender's Address", "address Recipient's Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferViaSignature`: keccak256(address(this), from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationTransferFrom = keccak256(abi.encodePacked( "address Token Contract Address", "address Address Approved for Withdraw", "address Account to Withdraw From", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferFromViaSignature`: keccak256(address(this), signer, from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationApprove = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveViaSignature`: keccak256(address(this), from, spender, value, fee, deadline, sigId) bytes32 constant public sigDestinationApproveAndCall = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "bytes Data to Transfer", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveAndCallViaSignature`: keccak256(address(this), from, spender, value, extraData, fee, deadline, sigId) constructor () public { name = "ORO (GBP)"; symbol = "ORP"; rescueAccount = msg.sender; } /** * Utility internal function used to safely transfer `value` tokens `from` -> `to`. Throws if transfer is impossible. * @param from - account to make the transfer from * @param to - account to transfer `value` tokens to * @param value - tokens to transfer to account `to` */ function internalTransfer (address from, address to, uint value) internal { require(to != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(from, to, value); } /** * Utility internal function used to safely transfer `value1` tokens `from` -> `to1`, and `value2` tokens * `from` -> `to2`, minimizing gas usage (calling `internalTransfer` twice is more expensive). Throws if * transfers are impossible. * @param from - account to make the transfer from * @param to1 - account to transfer `value1` tokens to * @param value1 - tokens to transfer to account `to1` * @param to2 - account to transfer `value2` tokens to * @param value2 - tokens to transfer to account `to2` */ function internalDoubleTransfer (address from, address to1, uint value1, address to2, uint value2) internal { require(to1 != address(0x0) && to2 != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value1.add(value2)); balanceOf[to1] = balanceOf[to1].add(value1); emit Transfer(from, to1, value1); if (value2 > 0) { balanceOf[to2] = balanceOf[to2].add(value2); emit Transfer(from, to2, value2); } } /** * Internal method that makes sure that the given signature corresponds to a given data and is made by `signer`. * It utilizes three (four) standards of message signing in Ethereum, as at the moment of this smart contract * development there is no single signing standard defined. For example, Metamask and Geth both support * personal_sign standard, SignTypedData is only supported by Matamask, Trezor does not support "widely adopted" * Ethereum personal_sign but rather personal_sign with fixed prefix and so on. * Note that it is always possible to forge any of these signatures using the private key, the problem is that * third-party wallets must adopt a single standard for signing messages. * @param data - original data which had to be signed by `signer` * @param signer - account which made a signature * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use * @param sigDest - for which type of action this signature was made */ function requireSignature ( bytes32 data, address signer, uint256 deadline, uint256 sigId, bytes memory sig, sigStandard sigStd, sigDestination sigDest ) internal { bytes32 r; bytes32 s; uint8 v; assembly { // solium-disable-line security/no-inline-assembly r := mload(add(sig, 32)) s := mload(add(sig, 64)) v := byte(0, mload(add(sig, 96))) } if (v < 27) v += 27; require(block.timestamp <= deadline && !usedSigIds[signer][sigId]); // solium-disable-line security/no-block-members if (sigStd == sigStandard.typed) { // Typed signature. This is the most likely scenario to be used and accepted require( signer == ecrecover( keccak256(abi.encodePacked( sigDest == sigDestination.transfer ? sigDestinationTransfer : sigDest == sigDestination.approve ? sigDestinationApprove : sigDest == sigDestination.approveAndCall ? sigDestinationApproveAndCall : sigDestinationTransferFrom, data )), v, r, s ) ); } else if (sigStd == sigStandard.personal) { // Ethereum signed message signature (Geth and Trezor) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "32", data)), v, r, s) // Geth-adopted || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x20", data)), v, r, s) // Trezor-adopted ); } else { // == 2; Signed string hash signature (the most expensive but universal) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "64", hexToString(data))), v, r, s) // Geth || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x40", hexToString(data))), v, r, s) // Trezor ); } usedSigIds[signer][sigId] = true; } /** * Utility costly function to encode bytes HEX representation as string. * @param sig - signature as bytes32 to represent as string */ function hexToString (bytes32 sig) internal pure returns (bytes memory) { bytes memory str = new bytes(64); for (uint8 i = 0; i < 32; ++i) { str[2 * i] = byte((uint8(sig[i]) / 16 < 10 ? 48 : 87) + uint8(sig[i]) / 16); str[2 * i + 1] = byte((uint8(sig[i]) % 16 < 10 ? 48 : 87) + (uint8(sig[i]) % 16)); } return str; } /** * Transfer `value` tokens to `to` address from the account of sender. * @param to - the address of the recipient * @param value - the amount to send */ function transfer (address to, uint256 value) public returns (bool) { internalTransfer(msg.sender, to, value); return true; } /** * This function distincts transaction signer from transaction executor. It allows anyone to transfer tokens * from the `from` account by providing a valid signature, which can only be obtained from the `from` account * owner. * Note that passed parameter sigId is unique and cannot be passed twice (prevents replay attacks). When there's * a need to make signature once again (because the first one is lost or whatever), user should sign the message * with the same sigId, thus ensuring that the previous signature can't be used if the new one passes. * Use case: the user wants to send some tokens to another user or smart contract, but don't have Ether to do so. * @param from - the account giving its signature to transfer `value` tokens to `to` address * @param to - the account receiving `value` tokens * @param value - the value in tokens to transfer * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferViaSignature ( address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.transfer ); internalDoubleTransfer(from, to, value, feeRecipient, fee); return true; } /** * Allow `spender` to take `value` tokens from the transaction sender's account. * Beware that changing an allowance with this method brings the risk that `spender` 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 authorized to spend * @param value - the maximum amount they can spend */ function approve (address spender, uint256 value) public returns (bool) { allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * Same as `transferViaSignature`, but for `approve`. * Use case: the user wants to set an allowance for the smart contract or another user without having Ether on * their balance. * @param from - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address * @param value - the value in tokens to approve to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveViaSignature ( address from, address spender, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, spender, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.approve ); allowance[from][spender] = value; emit Approval(from, spender, value); internalTransfer(from, feeRecipient, fee); return true; } /** * Transfer `value` tokens to `to` address from the `from` account, using the previously set allowance. * @param from - the address to transfer tokens from * @param to - the address of the recipient * @param value - the amount to send */ function transferFrom (address from, address to, uint256 value) public returns (bool) { allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); internalTransfer(from, to, value); return true; } /** * Same as `transferViaSignature`, but for `transferFrom`. * Use case: the user wants to withdraw tokens from a smart contract or another user who allowed the user to * do so. Important note: the fee is subtracted from the `value`, and `to` address receives `value - fee`. * @param signer - the address allowed to call transferFrom, which signed all below parameters * @param from - the account to make withdrawal from * @param to - the address of the recipient * @param value - the value in tokens to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferFromViaSignature ( address signer, address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), signer, deadline, sigId, sig, sigStd, sigDestination.transferFrom ); allowance[from][signer] = allowance[from][signer].sub(value); internalDoubleTransfer(from, to, value.sub(fee), feeRecipient, fee); return true; } /** * Utility function, which acts the same as approve(...), but also calls `receiveApproval` function on a * `spender` address, which is usually the address of the smart contract. In the same call, smart contract can * withdraw tokens from the sender's account and receive additional `extraData` for processing. * @param spender - the address to be authorized to spend tokens * @param value - the max amount the `spender` can withdraw * @param extraData - some extra information to send to the approved contract */ function approveAndCall (address spender, uint256 value, bytes memory extraData) public returns (bool) { approve(spender, value); tokenRecipient(spender).receiveApproval(msg.sender, value, address(this), extraData); return true; } /** * Same as `approveViaSignature`, but for `approveAndCall`. * Use case: the user wants to send tokens to the smart contract and pass additional data within one transaction. * @param fromAddress - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address (in this case, smart contract only) * @param value - the value in tokens to approve to withdraw * @param extraData - additional data to pass to the `spender` smart contract * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveAndCallViaSignature ( address fromAddress, address spender, uint256 value, bytes calldata extraData, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), fromAddress, spender, value, extraData, fee, feeRecipient, deadline, sigId)), fromAddress, deadline, sigId, sig, sigStd, sigDestination.approveAndCall); allowance[fromAddress][spender] = value; emit Approval(fromAddress, spender, value); tokenRecipient(spender).receiveApproval(fromAddress, value, address(this), extraData); internalTransfer(fromAddress, feeRecipient, fee); return true; } /** * Mint some tokens to the sender's address. */ function mintTokens (uint newSupply) onlyOwner external { totalSupply = totalSupply.add(newSupply); balanceOf[msg.sender] = balanceOf[msg.sender].add(newSupply); emit Transfer(address(0x0), msg.sender, newSupply); } /** * ERC20 tokens are not designed to hold any other tokens (or Ether) on their balances. There were thousands * of cases when people accidentally transfer tokens to a contract address while there is no way to get them * back. This function adds a possibility to "rescue" tokens that were accidentally sent to this smart contract. * @param tokenContract - ERC20-compatible token * @param value - amount to rescue */ function rescueLostTokens (ERC20CompatibleToken tokenContract, uint256 value) external rescueAccountOnly { tokenContract.transfer(rescueAccount, value); } /** * Utility function that allows to change the rescueAccount address, which can "rescue" tokens accidentally sent to * this smart contract address. * @param newRescueAccount - account which will become authorized to rescue tokens */ function changeRescueAccount (address newRescueAccount) external rescueAccountOnly { rescueAccount = newRescueAccount; } }
transfer
function transfer (address to, uint256 value) public returns (bool) { internalTransfer(msg.sender, to, value); return true; }
/** * Transfer `value` tokens to `to` address from the account of sender. * @param to - the address of the recipient * @param value - the amount to send */
NatSpecMultiLine
v0.7.0+commit.9e61f92b
MIT
ipfs://1c92a1cb9cad01da0fc8472ee8f3e46eb4a79231c12969194d28b064750262d8
{ "func_code_index": [ 10040, 10193 ] }
8,443
OROCoin
OROCoin.sol
0xbf7fd29146d50b014879518fbcd567243ab8b92b
Solidity
OROCoin
contract OROCoin is Ownable { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; mapping(address => mapping(uint => bool)) public usedSigIds; address public rescueAccount; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); modifier rescueAccountOnly {require(msg.sender == rescueAccount); _;} enum sigStandard { typed, personal, stringHex } enum sigDestination { transfer, approve, approveAndCall, transferFrom } bytes constant public ethSignedMessagePrefix = "\x19Ethereum Signed Message:\n"; bytes32 constant public sigDestinationTransfer = keccak256(abi.encodePacked( "address Token Contract Address", "address Sender's Address", "address Recipient's Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferViaSignature`: keccak256(address(this), from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationTransferFrom = keccak256(abi.encodePacked( "address Token Contract Address", "address Address Approved for Withdraw", "address Account to Withdraw From", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferFromViaSignature`: keccak256(address(this), signer, from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationApprove = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveViaSignature`: keccak256(address(this), from, spender, value, fee, deadline, sigId) bytes32 constant public sigDestinationApproveAndCall = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "bytes Data to Transfer", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveAndCallViaSignature`: keccak256(address(this), from, spender, value, extraData, fee, deadline, sigId) constructor () public { name = "ORO (GBP)"; symbol = "ORP"; rescueAccount = msg.sender; } /** * Utility internal function used to safely transfer `value` tokens `from` -> `to`. Throws if transfer is impossible. * @param from - account to make the transfer from * @param to - account to transfer `value` tokens to * @param value - tokens to transfer to account `to` */ function internalTransfer (address from, address to, uint value) internal { require(to != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(from, to, value); } /** * Utility internal function used to safely transfer `value1` tokens `from` -> `to1`, and `value2` tokens * `from` -> `to2`, minimizing gas usage (calling `internalTransfer` twice is more expensive). Throws if * transfers are impossible. * @param from - account to make the transfer from * @param to1 - account to transfer `value1` tokens to * @param value1 - tokens to transfer to account `to1` * @param to2 - account to transfer `value2` tokens to * @param value2 - tokens to transfer to account `to2` */ function internalDoubleTransfer (address from, address to1, uint value1, address to2, uint value2) internal { require(to1 != address(0x0) && to2 != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value1.add(value2)); balanceOf[to1] = balanceOf[to1].add(value1); emit Transfer(from, to1, value1); if (value2 > 0) { balanceOf[to2] = balanceOf[to2].add(value2); emit Transfer(from, to2, value2); } } /** * Internal method that makes sure that the given signature corresponds to a given data and is made by `signer`. * It utilizes three (four) standards of message signing in Ethereum, as at the moment of this smart contract * development there is no single signing standard defined. For example, Metamask and Geth both support * personal_sign standard, SignTypedData is only supported by Matamask, Trezor does not support "widely adopted" * Ethereum personal_sign but rather personal_sign with fixed prefix and so on. * Note that it is always possible to forge any of these signatures using the private key, the problem is that * third-party wallets must adopt a single standard for signing messages. * @param data - original data which had to be signed by `signer` * @param signer - account which made a signature * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use * @param sigDest - for which type of action this signature was made */ function requireSignature ( bytes32 data, address signer, uint256 deadline, uint256 sigId, bytes memory sig, sigStandard sigStd, sigDestination sigDest ) internal { bytes32 r; bytes32 s; uint8 v; assembly { // solium-disable-line security/no-inline-assembly r := mload(add(sig, 32)) s := mload(add(sig, 64)) v := byte(0, mload(add(sig, 96))) } if (v < 27) v += 27; require(block.timestamp <= deadline && !usedSigIds[signer][sigId]); // solium-disable-line security/no-block-members if (sigStd == sigStandard.typed) { // Typed signature. This is the most likely scenario to be used and accepted require( signer == ecrecover( keccak256(abi.encodePacked( sigDest == sigDestination.transfer ? sigDestinationTransfer : sigDest == sigDestination.approve ? sigDestinationApprove : sigDest == sigDestination.approveAndCall ? sigDestinationApproveAndCall : sigDestinationTransferFrom, data )), v, r, s ) ); } else if (sigStd == sigStandard.personal) { // Ethereum signed message signature (Geth and Trezor) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "32", data)), v, r, s) // Geth-adopted || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x20", data)), v, r, s) // Trezor-adopted ); } else { // == 2; Signed string hash signature (the most expensive but universal) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "64", hexToString(data))), v, r, s) // Geth || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x40", hexToString(data))), v, r, s) // Trezor ); } usedSigIds[signer][sigId] = true; } /** * Utility costly function to encode bytes HEX representation as string. * @param sig - signature as bytes32 to represent as string */ function hexToString (bytes32 sig) internal pure returns (bytes memory) { bytes memory str = new bytes(64); for (uint8 i = 0; i < 32; ++i) { str[2 * i] = byte((uint8(sig[i]) / 16 < 10 ? 48 : 87) + uint8(sig[i]) / 16); str[2 * i + 1] = byte((uint8(sig[i]) % 16 < 10 ? 48 : 87) + (uint8(sig[i]) % 16)); } return str; } /** * Transfer `value` tokens to `to` address from the account of sender. * @param to - the address of the recipient * @param value - the amount to send */ function transfer (address to, uint256 value) public returns (bool) { internalTransfer(msg.sender, to, value); return true; } /** * This function distincts transaction signer from transaction executor. It allows anyone to transfer tokens * from the `from` account by providing a valid signature, which can only be obtained from the `from` account * owner. * Note that passed parameter sigId is unique and cannot be passed twice (prevents replay attacks). When there's * a need to make signature once again (because the first one is lost or whatever), user should sign the message * with the same sigId, thus ensuring that the previous signature can't be used if the new one passes. * Use case: the user wants to send some tokens to another user or smart contract, but don't have Ether to do so. * @param from - the account giving its signature to transfer `value` tokens to `to` address * @param to - the account receiving `value` tokens * @param value - the value in tokens to transfer * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferViaSignature ( address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.transfer ); internalDoubleTransfer(from, to, value, feeRecipient, fee); return true; } /** * Allow `spender` to take `value` tokens from the transaction sender's account. * Beware that changing an allowance with this method brings the risk that `spender` 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 authorized to spend * @param value - the maximum amount they can spend */ function approve (address spender, uint256 value) public returns (bool) { allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * Same as `transferViaSignature`, but for `approve`. * Use case: the user wants to set an allowance for the smart contract or another user without having Ether on * their balance. * @param from - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address * @param value - the value in tokens to approve to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveViaSignature ( address from, address spender, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, spender, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.approve ); allowance[from][spender] = value; emit Approval(from, spender, value); internalTransfer(from, feeRecipient, fee); return true; } /** * Transfer `value` tokens to `to` address from the `from` account, using the previously set allowance. * @param from - the address to transfer tokens from * @param to - the address of the recipient * @param value - the amount to send */ function transferFrom (address from, address to, uint256 value) public returns (bool) { allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); internalTransfer(from, to, value); return true; } /** * Same as `transferViaSignature`, but for `transferFrom`. * Use case: the user wants to withdraw tokens from a smart contract or another user who allowed the user to * do so. Important note: the fee is subtracted from the `value`, and `to` address receives `value - fee`. * @param signer - the address allowed to call transferFrom, which signed all below parameters * @param from - the account to make withdrawal from * @param to - the address of the recipient * @param value - the value in tokens to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferFromViaSignature ( address signer, address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), signer, deadline, sigId, sig, sigStd, sigDestination.transferFrom ); allowance[from][signer] = allowance[from][signer].sub(value); internalDoubleTransfer(from, to, value.sub(fee), feeRecipient, fee); return true; } /** * Utility function, which acts the same as approve(...), but also calls `receiveApproval` function on a * `spender` address, which is usually the address of the smart contract. In the same call, smart contract can * withdraw tokens from the sender's account and receive additional `extraData` for processing. * @param spender - the address to be authorized to spend tokens * @param value - the max amount the `spender` can withdraw * @param extraData - some extra information to send to the approved contract */ function approveAndCall (address spender, uint256 value, bytes memory extraData) public returns (bool) { approve(spender, value); tokenRecipient(spender).receiveApproval(msg.sender, value, address(this), extraData); return true; } /** * Same as `approveViaSignature`, but for `approveAndCall`. * Use case: the user wants to send tokens to the smart contract and pass additional data within one transaction. * @param fromAddress - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address (in this case, smart contract only) * @param value - the value in tokens to approve to withdraw * @param extraData - additional data to pass to the `spender` smart contract * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveAndCallViaSignature ( address fromAddress, address spender, uint256 value, bytes calldata extraData, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), fromAddress, spender, value, extraData, fee, feeRecipient, deadline, sigId)), fromAddress, deadline, sigId, sig, sigStd, sigDestination.approveAndCall); allowance[fromAddress][spender] = value; emit Approval(fromAddress, spender, value); tokenRecipient(spender).receiveApproval(fromAddress, value, address(this), extraData); internalTransfer(fromAddress, feeRecipient, fee); return true; } /** * Mint some tokens to the sender's address. */ function mintTokens (uint newSupply) onlyOwner external { totalSupply = totalSupply.add(newSupply); balanceOf[msg.sender] = balanceOf[msg.sender].add(newSupply); emit Transfer(address(0x0), msg.sender, newSupply); } /** * ERC20 tokens are not designed to hold any other tokens (or Ether) on their balances. There were thousands * of cases when people accidentally transfer tokens to a contract address while there is no way to get them * back. This function adds a possibility to "rescue" tokens that were accidentally sent to this smart contract. * @param tokenContract - ERC20-compatible token * @param value - amount to rescue */ function rescueLostTokens (ERC20CompatibleToken tokenContract, uint256 value) external rescueAccountOnly { tokenContract.transfer(rescueAccount, value); } /** * Utility function that allows to change the rescueAccount address, which can "rescue" tokens accidentally sent to * this smart contract address. * @param newRescueAccount - account which will become authorized to rescue tokens */ function changeRescueAccount (address newRescueAccount) external rescueAccountOnly { rescueAccount = newRescueAccount; } }
transferViaSignature
function transferViaSignature ( address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.transfer ); internalDoubleTransfer(from, to, value, feeRecipient, fee); return true; }
/** * This function distincts transaction signer from transaction executor. It allows anyone to transfer tokens * from the `from` account by providing a valid signature, which can only be obtained from the `from` account * owner. * Note that passed parameter sigId is unique and cannot be passed twice (prevents replay attacks). When there's * a need to make signature once again (because the first one is lost or whatever), user should sign the message * with the same sigId, thus ensuring that the previous signature can't be used if the new one passes. * Use case: the user wants to send some tokens to another user or smart contract, but don't have Ether to do so. * @param from - the account giving its signature to transfer `value` tokens to `to` address * @param to - the account receiving `value` tokens * @param value - the value in tokens to transfer * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */
NatSpecMultiLine
v0.7.0+commit.9e61f92b
MIT
ipfs://1c92a1cb9cad01da0fc8472ee8f3e46eb4a79231c12969194d28b064750262d8
{ "func_code_index": [ 11653, 12419 ] }
8,444
OROCoin
OROCoin.sol
0xbf7fd29146d50b014879518fbcd567243ab8b92b
Solidity
OROCoin
contract OROCoin is Ownable { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; mapping(address => mapping(uint => bool)) public usedSigIds; address public rescueAccount; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); modifier rescueAccountOnly {require(msg.sender == rescueAccount); _;} enum sigStandard { typed, personal, stringHex } enum sigDestination { transfer, approve, approveAndCall, transferFrom } bytes constant public ethSignedMessagePrefix = "\x19Ethereum Signed Message:\n"; bytes32 constant public sigDestinationTransfer = keccak256(abi.encodePacked( "address Token Contract Address", "address Sender's Address", "address Recipient's Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferViaSignature`: keccak256(address(this), from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationTransferFrom = keccak256(abi.encodePacked( "address Token Contract Address", "address Address Approved for Withdraw", "address Account to Withdraw From", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferFromViaSignature`: keccak256(address(this), signer, from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationApprove = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveViaSignature`: keccak256(address(this), from, spender, value, fee, deadline, sigId) bytes32 constant public sigDestinationApproveAndCall = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "bytes Data to Transfer", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveAndCallViaSignature`: keccak256(address(this), from, spender, value, extraData, fee, deadline, sigId) constructor () public { name = "ORO (GBP)"; symbol = "ORP"; rescueAccount = msg.sender; } /** * Utility internal function used to safely transfer `value` tokens `from` -> `to`. Throws if transfer is impossible. * @param from - account to make the transfer from * @param to - account to transfer `value` tokens to * @param value - tokens to transfer to account `to` */ function internalTransfer (address from, address to, uint value) internal { require(to != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(from, to, value); } /** * Utility internal function used to safely transfer `value1` tokens `from` -> `to1`, and `value2` tokens * `from` -> `to2`, minimizing gas usage (calling `internalTransfer` twice is more expensive). Throws if * transfers are impossible. * @param from - account to make the transfer from * @param to1 - account to transfer `value1` tokens to * @param value1 - tokens to transfer to account `to1` * @param to2 - account to transfer `value2` tokens to * @param value2 - tokens to transfer to account `to2` */ function internalDoubleTransfer (address from, address to1, uint value1, address to2, uint value2) internal { require(to1 != address(0x0) && to2 != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value1.add(value2)); balanceOf[to1] = balanceOf[to1].add(value1); emit Transfer(from, to1, value1); if (value2 > 0) { balanceOf[to2] = balanceOf[to2].add(value2); emit Transfer(from, to2, value2); } } /** * Internal method that makes sure that the given signature corresponds to a given data and is made by `signer`. * It utilizes three (four) standards of message signing in Ethereum, as at the moment of this smart contract * development there is no single signing standard defined. For example, Metamask and Geth both support * personal_sign standard, SignTypedData is only supported by Matamask, Trezor does not support "widely adopted" * Ethereum personal_sign but rather personal_sign with fixed prefix and so on. * Note that it is always possible to forge any of these signatures using the private key, the problem is that * third-party wallets must adopt a single standard for signing messages. * @param data - original data which had to be signed by `signer` * @param signer - account which made a signature * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use * @param sigDest - for which type of action this signature was made */ function requireSignature ( bytes32 data, address signer, uint256 deadline, uint256 sigId, bytes memory sig, sigStandard sigStd, sigDestination sigDest ) internal { bytes32 r; bytes32 s; uint8 v; assembly { // solium-disable-line security/no-inline-assembly r := mload(add(sig, 32)) s := mload(add(sig, 64)) v := byte(0, mload(add(sig, 96))) } if (v < 27) v += 27; require(block.timestamp <= deadline && !usedSigIds[signer][sigId]); // solium-disable-line security/no-block-members if (sigStd == sigStandard.typed) { // Typed signature. This is the most likely scenario to be used and accepted require( signer == ecrecover( keccak256(abi.encodePacked( sigDest == sigDestination.transfer ? sigDestinationTransfer : sigDest == sigDestination.approve ? sigDestinationApprove : sigDest == sigDestination.approveAndCall ? sigDestinationApproveAndCall : sigDestinationTransferFrom, data )), v, r, s ) ); } else if (sigStd == sigStandard.personal) { // Ethereum signed message signature (Geth and Trezor) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "32", data)), v, r, s) // Geth-adopted || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x20", data)), v, r, s) // Trezor-adopted ); } else { // == 2; Signed string hash signature (the most expensive but universal) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "64", hexToString(data))), v, r, s) // Geth || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x40", hexToString(data))), v, r, s) // Trezor ); } usedSigIds[signer][sigId] = true; } /** * Utility costly function to encode bytes HEX representation as string. * @param sig - signature as bytes32 to represent as string */ function hexToString (bytes32 sig) internal pure returns (bytes memory) { bytes memory str = new bytes(64); for (uint8 i = 0; i < 32; ++i) { str[2 * i] = byte((uint8(sig[i]) / 16 < 10 ? 48 : 87) + uint8(sig[i]) / 16); str[2 * i + 1] = byte((uint8(sig[i]) % 16 < 10 ? 48 : 87) + (uint8(sig[i]) % 16)); } return str; } /** * Transfer `value` tokens to `to` address from the account of sender. * @param to - the address of the recipient * @param value - the amount to send */ function transfer (address to, uint256 value) public returns (bool) { internalTransfer(msg.sender, to, value); return true; } /** * This function distincts transaction signer from transaction executor. It allows anyone to transfer tokens * from the `from` account by providing a valid signature, which can only be obtained from the `from` account * owner. * Note that passed parameter sigId is unique and cannot be passed twice (prevents replay attacks). When there's * a need to make signature once again (because the first one is lost or whatever), user should sign the message * with the same sigId, thus ensuring that the previous signature can't be used if the new one passes. * Use case: the user wants to send some tokens to another user or smart contract, but don't have Ether to do so. * @param from - the account giving its signature to transfer `value` tokens to `to` address * @param to - the account receiving `value` tokens * @param value - the value in tokens to transfer * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferViaSignature ( address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.transfer ); internalDoubleTransfer(from, to, value, feeRecipient, fee); return true; } /** * Allow `spender` to take `value` tokens from the transaction sender's account. * Beware that changing an allowance with this method brings the risk that `spender` 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 authorized to spend * @param value - the maximum amount they can spend */ function approve (address spender, uint256 value) public returns (bool) { allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * Same as `transferViaSignature`, but for `approve`. * Use case: the user wants to set an allowance for the smart contract or another user without having Ether on * their balance. * @param from - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address * @param value - the value in tokens to approve to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveViaSignature ( address from, address spender, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, spender, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.approve ); allowance[from][spender] = value; emit Approval(from, spender, value); internalTransfer(from, feeRecipient, fee); return true; } /** * Transfer `value` tokens to `to` address from the `from` account, using the previously set allowance. * @param from - the address to transfer tokens from * @param to - the address of the recipient * @param value - the amount to send */ function transferFrom (address from, address to, uint256 value) public returns (bool) { allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); internalTransfer(from, to, value); return true; } /** * Same as `transferViaSignature`, but for `transferFrom`. * Use case: the user wants to withdraw tokens from a smart contract or another user who allowed the user to * do so. Important note: the fee is subtracted from the `value`, and `to` address receives `value - fee`. * @param signer - the address allowed to call transferFrom, which signed all below parameters * @param from - the account to make withdrawal from * @param to - the address of the recipient * @param value - the value in tokens to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferFromViaSignature ( address signer, address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), signer, deadline, sigId, sig, sigStd, sigDestination.transferFrom ); allowance[from][signer] = allowance[from][signer].sub(value); internalDoubleTransfer(from, to, value.sub(fee), feeRecipient, fee); return true; } /** * Utility function, which acts the same as approve(...), but also calls `receiveApproval` function on a * `spender` address, which is usually the address of the smart contract. In the same call, smart contract can * withdraw tokens from the sender's account and receive additional `extraData` for processing. * @param spender - the address to be authorized to spend tokens * @param value - the max amount the `spender` can withdraw * @param extraData - some extra information to send to the approved contract */ function approveAndCall (address spender, uint256 value, bytes memory extraData) public returns (bool) { approve(spender, value); tokenRecipient(spender).receiveApproval(msg.sender, value, address(this), extraData); return true; } /** * Same as `approveViaSignature`, but for `approveAndCall`. * Use case: the user wants to send tokens to the smart contract and pass additional data within one transaction. * @param fromAddress - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address (in this case, smart contract only) * @param value - the value in tokens to approve to withdraw * @param extraData - additional data to pass to the `spender` smart contract * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveAndCallViaSignature ( address fromAddress, address spender, uint256 value, bytes calldata extraData, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), fromAddress, spender, value, extraData, fee, feeRecipient, deadline, sigId)), fromAddress, deadline, sigId, sig, sigStd, sigDestination.approveAndCall); allowance[fromAddress][spender] = value; emit Approval(fromAddress, spender, value); tokenRecipient(spender).receiveApproval(fromAddress, value, address(this), extraData); internalTransfer(fromAddress, feeRecipient, fee); return true; } /** * Mint some tokens to the sender's address. */ function mintTokens (uint newSupply) onlyOwner external { totalSupply = totalSupply.add(newSupply); balanceOf[msg.sender] = balanceOf[msg.sender].add(newSupply); emit Transfer(address(0x0), msg.sender, newSupply); } /** * ERC20 tokens are not designed to hold any other tokens (or Ether) on their balances. There were thousands * of cases when people accidentally transfer tokens to a contract address while there is no way to get them * back. This function adds a possibility to "rescue" tokens that were accidentally sent to this smart contract. * @param tokenContract - ERC20-compatible token * @param value - amount to rescue */ function rescueLostTokens (ERC20CompatibleToken tokenContract, uint256 value) external rescueAccountOnly { tokenContract.transfer(rescueAccount, value); } /** * Utility function that allows to change the rescueAccount address, which can "rescue" tokens accidentally sent to * this smart contract address. * @param newRescueAccount - account which will become authorized to rescue tokens */ function changeRescueAccount (address newRescueAccount) external rescueAccountOnly { rescueAccount = newRescueAccount; } }
approve
function approve (address spender, uint256 value) public returns (bool) { allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; }
/** * Allow `spender` to take `value` tokens from the transaction sender's account. * Beware that changing an allowance with this method brings the risk that `spender` 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 authorized to spend * @param value - the maximum amount they can spend */
NatSpecMultiLine
v0.7.0+commit.9e61f92b
MIT
ipfs://1c92a1cb9cad01da0fc8472ee8f3e46eb4a79231c12969194d28b064750262d8
{ "func_code_index": [ 13040, 13248 ] }
8,445
OROCoin
OROCoin.sol
0xbf7fd29146d50b014879518fbcd567243ab8b92b
Solidity
OROCoin
contract OROCoin is Ownable { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; mapping(address => mapping(uint => bool)) public usedSigIds; address public rescueAccount; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); modifier rescueAccountOnly {require(msg.sender == rescueAccount); _;} enum sigStandard { typed, personal, stringHex } enum sigDestination { transfer, approve, approveAndCall, transferFrom } bytes constant public ethSignedMessagePrefix = "\x19Ethereum Signed Message:\n"; bytes32 constant public sigDestinationTransfer = keccak256(abi.encodePacked( "address Token Contract Address", "address Sender's Address", "address Recipient's Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferViaSignature`: keccak256(address(this), from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationTransferFrom = keccak256(abi.encodePacked( "address Token Contract Address", "address Address Approved for Withdraw", "address Account to Withdraw From", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferFromViaSignature`: keccak256(address(this), signer, from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationApprove = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveViaSignature`: keccak256(address(this), from, spender, value, fee, deadline, sigId) bytes32 constant public sigDestinationApproveAndCall = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "bytes Data to Transfer", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveAndCallViaSignature`: keccak256(address(this), from, spender, value, extraData, fee, deadline, sigId) constructor () public { name = "ORO (GBP)"; symbol = "ORP"; rescueAccount = msg.sender; } /** * Utility internal function used to safely transfer `value` tokens `from` -> `to`. Throws if transfer is impossible. * @param from - account to make the transfer from * @param to - account to transfer `value` tokens to * @param value - tokens to transfer to account `to` */ function internalTransfer (address from, address to, uint value) internal { require(to != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(from, to, value); } /** * Utility internal function used to safely transfer `value1` tokens `from` -> `to1`, and `value2` tokens * `from` -> `to2`, minimizing gas usage (calling `internalTransfer` twice is more expensive). Throws if * transfers are impossible. * @param from - account to make the transfer from * @param to1 - account to transfer `value1` tokens to * @param value1 - tokens to transfer to account `to1` * @param to2 - account to transfer `value2` tokens to * @param value2 - tokens to transfer to account `to2` */ function internalDoubleTransfer (address from, address to1, uint value1, address to2, uint value2) internal { require(to1 != address(0x0) && to2 != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value1.add(value2)); balanceOf[to1] = balanceOf[to1].add(value1); emit Transfer(from, to1, value1); if (value2 > 0) { balanceOf[to2] = balanceOf[to2].add(value2); emit Transfer(from, to2, value2); } } /** * Internal method that makes sure that the given signature corresponds to a given data and is made by `signer`. * It utilizes three (four) standards of message signing in Ethereum, as at the moment of this smart contract * development there is no single signing standard defined. For example, Metamask and Geth both support * personal_sign standard, SignTypedData is only supported by Matamask, Trezor does not support "widely adopted" * Ethereum personal_sign but rather personal_sign with fixed prefix and so on. * Note that it is always possible to forge any of these signatures using the private key, the problem is that * third-party wallets must adopt a single standard for signing messages. * @param data - original data which had to be signed by `signer` * @param signer - account which made a signature * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use * @param sigDest - for which type of action this signature was made */ function requireSignature ( bytes32 data, address signer, uint256 deadline, uint256 sigId, bytes memory sig, sigStandard sigStd, sigDestination sigDest ) internal { bytes32 r; bytes32 s; uint8 v; assembly { // solium-disable-line security/no-inline-assembly r := mload(add(sig, 32)) s := mload(add(sig, 64)) v := byte(0, mload(add(sig, 96))) } if (v < 27) v += 27; require(block.timestamp <= deadline && !usedSigIds[signer][sigId]); // solium-disable-line security/no-block-members if (sigStd == sigStandard.typed) { // Typed signature. This is the most likely scenario to be used and accepted require( signer == ecrecover( keccak256(abi.encodePacked( sigDest == sigDestination.transfer ? sigDestinationTransfer : sigDest == sigDestination.approve ? sigDestinationApprove : sigDest == sigDestination.approveAndCall ? sigDestinationApproveAndCall : sigDestinationTransferFrom, data )), v, r, s ) ); } else if (sigStd == sigStandard.personal) { // Ethereum signed message signature (Geth and Trezor) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "32", data)), v, r, s) // Geth-adopted || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x20", data)), v, r, s) // Trezor-adopted ); } else { // == 2; Signed string hash signature (the most expensive but universal) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "64", hexToString(data))), v, r, s) // Geth || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x40", hexToString(data))), v, r, s) // Trezor ); } usedSigIds[signer][sigId] = true; } /** * Utility costly function to encode bytes HEX representation as string. * @param sig - signature as bytes32 to represent as string */ function hexToString (bytes32 sig) internal pure returns (bytes memory) { bytes memory str = new bytes(64); for (uint8 i = 0; i < 32; ++i) { str[2 * i] = byte((uint8(sig[i]) / 16 < 10 ? 48 : 87) + uint8(sig[i]) / 16); str[2 * i + 1] = byte((uint8(sig[i]) % 16 < 10 ? 48 : 87) + (uint8(sig[i]) % 16)); } return str; } /** * Transfer `value` tokens to `to` address from the account of sender. * @param to - the address of the recipient * @param value - the amount to send */ function transfer (address to, uint256 value) public returns (bool) { internalTransfer(msg.sender, to, value); return true; } /** * This function distincts transaction signer from transaction executor. It allows anyone to transfer tokens * from the `from` account by providing a valid signature, which can only be obtained from the `from` account * owner. * Note that passed parameter sigId is unique and cannot be passed twice (prevents replay attacks). When there's * a need to make signature once again (because the first one is lost or whatever), user should sign the message * with the same sigId, thus ensuring that the previous signature can't be used if the new one passes. * Use case: the user wants to send some tokens to another user or smart contract, but don't have Ether to do so. * @param from - the account giving its signature to transfer `value` tokens to `to` address * @param to - the account receiving `value` tokens * @param value - the value in tokens to transfer * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferViaSignature ( address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.transfer ); internalDoubleTransfer(from, to, value, feeRecipient, fee); return true; } /** * Allow `spender` to take `value` tokens from the transaction sender's account. * Beware that changing an allowance with this method brings the risk that `spender` 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 authorized to spend * @param value - the maximum amount they can spend */ function approve (address spender, uint256 value) public returns (bool) { allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * Same as `transferViaSignature`, but for `approve`. * Use case: the user wants to set an allowance for the smart contract or another user without having Ether on * their balance. * @param from - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address * @param value - the value in tokens to approve to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveViaSignature ( address from, address spender, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, spender, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.approve ); allowance[from][spender] = value; emit Approval(from, spender, value); internalTransfer(from, feeRecipient, fee); return true; } /** * Transfer `value` tokens to `to` address from the `from` account, using the previously set allowance. * @param from - the address to transfer tokens from * @param to - the address of the recipient * @param value - the amount to send */ function transferFrom (address from, address to, uint256 value) public returns (bool) { allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); internalTransfer(from, to, value); return true; } /** * Same as `transferViaSignature`, but for `transferFrom`. * Use case: the user wants to withdraw tokens from a smart contract or another user who allowed the user to * do so. Important note: the fee is subtracted from the `value`, and `to` address receives `value - fee`. * @param signer - the address allowed to call transferFrom, which signed all below parameters * @param from - the account to make withdrawal from * @param to - the address of the recipient * @param value - the value in tokens to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferFromViaSignature ( address signer, address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), signer, deadline, sigId, sig, sigStd, sigDestination.transferFrom ); allowance[from][signer] = allowance[from][signer].sub(value); internalDoubleTransfer(from, to, value.sub(fee), feeRecipient, fee); return true; } /** * Utility function, which acts the same as approve(...), but also calls `receiveApproval` function on a * `spender` address, which is usually the address of the smart contract. In the same call, smart contract can * withdraw tokens from the sender's account and receive additional `extraData` for processing. * @param spender - the address to be authorized to spend tokens * @param value - the max amount the `spender` can withdraw * @param extraData - some extra information to send to the approved contract */ function approveAndCall (address spender, uint256 value, bytes memory extraData) public returns (bool) { approve(spender, value); tokenRecipient(spender).receiveApproval(msg.sender, value, address(this), extraData); return true; } /** * Same as `approveViaSignature`, but for `approveAndCall`. * Use case: the user wants to send tokens to the smart contract and pass additional data within one transaction. * @param fromAddress - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address (in this case, smart contract only) * @param value - the value in tokens to approve to withdraw * @param extraData - additional data to pass to the `spender` smart contract * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveAndCallViaSignature ( address fromAddress, address spender, uint256 value, bytes calldata extraData, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), fromAddress, spender, value, extraData, fee, feeRecipient, deadline, sigId)), fromAddress, deadline, sigId, sig, sigStd, sigDestination.approveAndCall); allowance[fromAddress][spender] = value; emit Approval(fromAddress, spender, value); tokenRecipient(spender).receiveApproval(fromAddress, value, address(this), extraData); internalTransfer(fromAddress, feeRecipient, fee); return true; } /** * Mint some tokens to the sender's address. */ function mintTokens (uint newSupply) onlyOwner external { totalSupply = totalSupply.add(newSupply); balanceOf[msg.sender] = balanceOf[msg.sender].add(newSupply); emit Transfer(address(0x0), msg.sender, newSupply); } /** * ERC20 tokens are not designed to hold any other tokens (or Ether) on their balances. There were thousands * of cases when people accidentally transfer tokens to a contract address while there is no way to get them * back. This function adds a possibility to "rescue" tokens that were accidentally sent to this smart contract. * @param tokenContract - ERC20-compatible token * @param value - amount to rescue */ function rescueLostTokens (ERC20CompatibleToken tokenContract, uint256 value) external rescueAccountOnly { tokenContract.transfer(rescueAccount, value); } /** * Utility function that allows to change the rescueAccount address, which can "rescue" tokens accidentally sent to * this smart contract address. * @param newRescueAccount - account which will become authorized to rescue tokens */ function changeRescueAccount (address newRescueAccount) external rescueAccountOnly { rescueAccount = newRescueAccount; } }
approveViaSignature
function approveViaSignature ( address from, address spender, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, spender, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.approve ); allowance[from][spender] = value; emit Approval(from, spender, value); internalTransfer(from, feeRecipient, fee); return true; }
/** * Same as `transferViaSignature`, but for `approve`. * Use case: the user wants to set an allowance for the smart contract or another user without having Ether on * their balance. * @param from - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address * @param value - the value in tokens to approve to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */
NatSpecMultiLine
v0.7.0+commit.9e61f92b
MIT
ipfs://1c92a1cb9cad01da0fc8472ee8f3e46eb4a79231c12969194d28b064750262d8
{ "func_code_index": [ 14235, 14985 ] }
8,446
OROCoin
OROCoin.sol
0xbf7fd29146d50b014879518fbcd567243ab8b92b
Solidity
OROCoin
contract OROCoin is Ownable { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; mapping(address => mapping(uint => bool)) public usedSigIds; address public rescueAccount; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); modifier rescueAccountOnly {require(msg.sender == rescueAccount); _;} enum sigStandard { typed, personal, stringHex } enum sigDestination { transfer, approve, approveAndCall, transferFrom } bytes constant public ethSignedMessagePrefix = "\x19Ethereum Signed Message:\n"; bytes32 constant public sigDestinationTransfer = keccak256(abi.encodePacked( "address Token Contract Address", "address Sender's Address", "address Recipient's Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferViaSignature`: keccak256(address(this), from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationTransferFrom = keccak256(abi.encodePacked( "address Token Contract Address", "address Address Approved for Withdraw", "address Account to Withdraw From", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferFromViaSignature`: keccak256(address(this), signer, from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationApprove = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveViaSignature`: keccak256(address(this), from, spender, value, fee, deadline, sigId) bytes32 constant public sigDestinationApproveAndCall = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "bytes Data to Transfer", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveAndCallViaSignature`: keccak256(address(this), from, spender, value, extraData, fee, deadline, sigId) constructor () public { name = "ORO (GBP)"; symbol = "ORP"; rescueAccount = msg.sender; } /** * Utility internal function used to safely transfer `value` tokens `from` -> `to`. Throws if transfer is impossible. * @param from - account to make the transfer from * @param to - account to transfer `value` tokens to * @param value - tokens to transfer to account `to` */ function internalTransfer (address from, address to, uint value) internal { require(to != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(from, to, value); } /** * Utility internal function used to safely transfer `value1` tokens `from` -> `to1`, and `value2` tokens * `from` -> `to2`, minimizing gas usage (calling `internalTransfer` twice is more expensive). Throws if * transfers are impossible. * @param from - account to make the transfer from * @param to1 - account to transfer `value1` tokens to * @param value1 - tokens to transfer to account `to1` * @param to2 - account to transfer `value2` tokens to * @param value2 - tokens to transfer to account `to2` */ function internalDoubleTransfer (address from, address to1, uint value1, address to2, uint value2) internal { require(to1 != address(0x0) && to2 != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value1.add(value2)); balanceOf[to1] = balanceOf[to1].add(value1); emit Transfer(from, to1, value1); if (value2 > 0) { balanceOf[to2] = balanceOf[to2].add(value2); emit Transfer(from, to2, value2); } } /** * Internal method that makes sure that the given signature corresponds to a given data and is made by `signer`. * It utilizes three (four) standards of message signing in Ethereum, as at the moment of this smart contract * development there is no single signing standard defined. For example, Metamask and Geth both support * personal_sign standard, SignTypedData is only supported by Matamask, Trezor does not support "widely adopted" * Ethereum personal_sign but rather personal_sign with fixed prefix and so on. * Note that it is always possible to forge any of these signatures using the private key, the problem is that * third-party wallets must adopt a single standard for signing messages. * @param data - original data which had to be signed by `signer` * @param signer - account which made a signature * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use * @param sigDest - for which type of action this signature was made */ function requireSignature ( bytes32 data, address signer, uint256 deadline, uint256 sigId, bytes memory sig, sigStandard sigStd, sigDestination sigDest ) internal { bytes32 r; bytes32 s; uint8 v; assembly { // solium-disable-line security/no-inline-assembly r := mload(add(sig, 32)) s := mload(add(sig, 64)) v := byte(0, mload(add(sig, 96))) } if (v < 27) v += 27; require(block.timestamp <= deadline && !usedSigIds[signer][sigId]); // solium-disable-line security/no-block-members if (sigStd == sigStandard.typed) { // Typed signature. This is the most likely scenario to be used and accepted require( signer == ecrecover( keccak256(abi.encodePacked( sigDest == sigDestination.transfer ? sigDestinationTransfer : sigDest == sigDestination.approve ? sigDestinationApprove : sigDest == sigDestination.approveAndCall ? sigDestinationApproveAndCall : sigDestinationTransferFrom, data )), v, r, s ) ); } else if (sigStd == sigStandard.personal) { // Ethereum signed message signature (Geth and Trezor) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "32", data)), v, r, s) // Geth-adopted || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x20", data)), v, r, s) // Trezor-adopted ); } else { // == 2; Signed string hash signature (the most expensive but universal) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "64", hexToString(data))), v, r, s) // Geth || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x40", hexToString(data))), v, r, s) // Trezor ); } usedSigIds[signer][sigId] = true; } /** * Utility costly function to encode bytes HEX representation as string. * @param sig - signature as bytes32 to represent as string */ function hexToString (bytes32 sig) internal pure returns (bytes memory) { bytes memory str = new bytes(64); for (uint8 i = 0; i < 32; ++i) { str[2 * i] = byte((uint8(sig[i]) / 16 < 10 ? 48 : 87) + uint8(sig[i]) / 16); str[2 * i + 1] = byte((uint8(sig[i]) % 16 < 10 ? 48 : 87) + (uint8(sig[i]) % 16)); } return str; } /** * Transfer `value` tokens to `to` address from the account of sender. * @param to - the address of the recipient * @param value - the amount to send */ function transfer (address to, uint256 value) public returns (bool) { internalTransfer(msg.sender, to, value); return true; } /** * This function distincts transaction signer from transaction executor. It allows anyone to transfer tokens * from the `from` account by providing a valid signature, which can only be obtained from the `from` account * owner. * Note that passed parameter sigId is unique and cannot be passed twice (prevents replay attacks). When there's * a need to make signature once again (because the first one is lost or whatever), user should sign the message * with the same sigId, thus ensuring that the previous signature can't be used if the new one passes. * Use case: the user wants to send some tokens to another user or smart contract, but don't have Ether to do so. * @param from - the account giving its signature to transfer `value` tokens to `to` address * @param to - the account receiving `value` tokens * @param value - the value in tokens to transfer * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferViaSignature ( address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.transfer ); internalDoubleTransfer(from, to, value, feeRecipient, fee); return true; } /** * Allow `spender` to take `value` tokens from the transaction sender's account. * Beware that changing an allowance with this method brings the risk that `spender` 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 authorized to spend * @param value - the maximum amount they can spend */ function approve (address spender, uint256 value) public returns (bool) { allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * Same as `transferViaSignature`, but for `approve`. * Use case: the user wants to set an allowance for the smart contract or another user without having Ether on * their balance. * @param from - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address * @param value - the value in tokens to approve to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveViaSignature ( address from, address spender, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, spender, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.approve ); allowance[from][spender] = value; emit Approval(from, spender, value); internalTransfer(from, feeRecipient, fee); return true; } /** * Transfer `value` tokens to `to` address from the `from` account, using the previously set allowance. * @param from - the address to transfer tokens from * @param to - the address of the recipient * @param value - the amount to send */ function transferFrom (address from, address to, uint256 value) public returns (bool) { allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); internalTransfer(from, to, value); return true; } /** * Same as `transferViaSignature`, but for `transferFrom`. * Use case: the user wants to withdraw tokens from a smart contract or another user who allowed the user to * do so. Important note: the fee is subtracted from the `value`, and `to` address receives `value - fee`. * @param signer - the address allowed to call transferFrom, which signed all below parameters * @param from - the account to make withdrawal from * @param to - the address of the recipient * @param value - the value in tokens to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferFromViaSignature ( address signer, address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), signer, deadline, sigId, sig, sigStd, sigDestination.transferFrom ); allowance[from][signer] = allowance[from][signer].sub(value); internalDoubleTransfer(from, to, value.sub(fee), feeRecipient, fee); return true; } /** * Utility function, which acts the same as approve(...), but also calls `receiveApproval` function on a * `spender` address, which is usually the address of the smart contract. In the same call, smart contract can * withdraw tokens from the sender's account and receive additional `extraData` for processing. * @param spender - the address to be authorized to spend tokens * @param value - the max amount the `spender` can withdraw * @param extraData - some extra information to send to the approved contract */ function approveAndCall (address spender, uint256 value, bytes memory extraData) public returns (bool) { approve(spender, value); tokenRecipient(spender).receiveApproval(msg.sender, value, address(this), extraData); return true; } /** * Same as `approveViaSignature`, but for `approveAndCall`. * Use case: the user wants to send tokens to the smart contract and pass additional data within one transaction. * @param fromAddress - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address (in this case, smart contract only) * @param value - the value in tokens to approve to withdraw * @param extraData - additional data to pass to the `spender` smart contract * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveAndCallViaSignature ( address fromAddress, address spender, uint256 value, bytes calldata extraData, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), fromAddress, spender, value, extraData, fee, feeRecipient, deadline, sigId)), fromAddress, deadline, sigId, sig, sigStd, sigDestination.approveAndCall); allowance[fromAddress][spender] = value; emit Approval(fromAddress, spender, value); tokenRecipient(spender).receiveApproval(fromAddress, value, address(this), extraData); internalTransfer(fromAddress, feeRecipient, fee); return true; } /** * Mint some tokens to the sender's address. */ function mintTokens (uint newSupply) onlyOwner external { totalSupply = totalSupply.add(newSupply); balanceOf[msg.sender] = balanceOf[msg.sender].add(newSupply); emit Transfer(address(0x0), msg.sender, newSupply); } /** * ERC20 tokens are not designed to hold any other tokens (or Ether) on their balances. There were thousands * of cases when people accidentally transfer tokens to a contract address while there is no way to get them * back. This function adds a possibility to "rescue" tokens that were accidentally sent to this smart contract. * @param tokenContract - ERC20-compatible token * @param value - amount to rescue */ function rescueLostTokens (ERC20CompatibleToken tokenContract, uint256 value) external rescueAccountOnly { tokenContract.transfer(rescueAccount, value); } /** * Utility function that allows to change the rescueAccount address, which can "rescue" tokens accidentally sent to * this smart contract address. * @param newRescueAccount - account which will become authorized to rescue tokens */ function changeRescueAccount (address newRescueAccount) external rescueAccountOnly { rescueAccount = newRescueAccount; } }
transferFrom
function transferFrom (address from, address to, uint256 value) public returns (bool) { allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); internalTransfer(from, to, value); return true; }
/** * Transfer `value` tokens to `to` address from the `from` account, using the previously set allowance. * @param from - the address to transfer tokens from * @param to - the address of the recipient * @param value - the amount to send */
NatSpecMultiLine
v0.7.0+commit.9e61f92b
MIT
ipfs://1c92a1cb9cad01da0fc8472ee8f3e46eb4a79231c12969194d28b064750262d8
{ "func_code_index": [ 15264, 15508 ] }
8,447
OROCoin
OROCoin.sol
0xbf7fd29146d50b014879518fbcd567243ab8b92b
Solidity
OROCoin
contract OROCoin is Ownable { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; mapping(address => mapping(uint => bool)) public usedSigIds; address public rescueAccount; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); modifier rescueAccountOnly {require(msg.sender == rescueAccount); _;} enum sigStandard { typed, personal, stringHex } enum sigDestination { transfer, approve, approveAndCall, transferFrom } bytes constant public ethSignedMessagePrefix = "\x19Ethereum Signed Message:\n"; bytes32 constant public sigDestinationTransfer = keccak256(abi.encodePacked( "address Token Contract Address", "address Sender's Address", "address Recipient's Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferViaSignature`: keccak256(address(this), from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationTransferFrom = keccak256(abi.encodePacked( "address Token Contract Address", "address Address Approved for Withdraw", "address Account to Withdraw From", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferFromViaSignature`: keccak256(address(this), signer, from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationApprove = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveViaSignature`: keccak256(address(this), from, spender, value, fee, deadline, sigId) bytes32 constant public sigDestinationApproveAndCall = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "bytes Data to Transfer", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveAndCallViaSignature`: keccak256(address(this), from, spender, value, extraData, fee, deadline, sigId) constructor () public { name = "ORO (GBP)"; symbol = "ORP"; rescueAccount = msg.sender; } /** * Utility internal function used to safely transfer `value` tokens `from` -> `to`. Throws if transfer is impossible. * @param from - account to make the transfer from * @param to - account to transfer `value` tokens to * @param value - tokens to transfer to account `to` */ function internalTransfer (address from, address to, uint value) internal { require(to != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(from, to, value); } /** * Utility internal function used to safely transfer `value1` tokens `from` -> `to1`, and `value2` tokens * `from` -> `to2`, minimizing gas usage (calling `internalTransfer` twice is more expensive). Throws if * transfers are impossible. * @param from - account to make the transfer from * @param to1 - account to transfer `value1` tokens to * @param value1 - tokens to transfer to account `to1` * @param to2 - account to transfer `value2` tokens to * @param value2 - tokens to transfer to account `to2` */ function internalDoubleTransfer (address from, address to1, uint value1, address to2, uint value2) internal { require(to1 != address(0x0) && to2 != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value1.add(value2)); balanceOf[to1] = balanceOf[to1].add(value1); emit Transfer(from, to1, value1); if (value2 > 0) { balanceOf[to2] = balanceOf[to2].add(value2); emit Transfer(from, to2, value2); } } /** * Internal method that makes sure that the given signature corresponds to a given data and is made by `signer`. * It utilizes three (four) standards of message signing in Ethereum, as at the moment of this smart contract * development there is no single signing standard defined. For example, Metamask and Geth both support * personal_sign standard, SignTypedData is only supported by Matamask, Trezor does not support "widely adopted" * Ethereum personal_sign but rather personal_sign with fixed prefix and so on. * Note that it is always possible to forge any of these signatures using the private key, the problem is that * third-party wallets must adopt a single standard for signing messages. * @param data - original data which had to be signed by `signer` * @param signer - account which made a signature * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use * @param sigDest - for which type of action this signature was made */ function requireSignature ( bytes32 data, address signer, uint256 deadline, uint256 sigId, bytes memory sig, sigStandard sigStd, sigDestination sigDest ) internal { bytes32 r; bytes32 s; uint8 v; assembly { // solium-disable-line security/no-inline-assembly r := mload(add(sig, 32)) s := mload(add(sig, 64)) v := byte(0, mload(add(sig, 96))) } if (v < 27) v += 27; require(block.timestamp <= deadline && !usedSigIds[signer][sigId]); // solium-disable-line security/no-block-members if (sigStd == sigStandard.typed) { // Typed signature. This is the most likely scenario to be used and accepted require( signer == ecrecover( keccak256(abi.encodePacked( sigDest == sigDestination.transfer ? sigDestinationTransfer : sigDest == sigDestination.approve ? sigDestinationApprove : sigDest == sigDestination.approveAndCall ? sigDestinationApproveAndCall : sigDestinationTransferFrom, data )), v, r, s ) ); } else if (sigStd == sigStandard.personal) { // Ethereum signed message signature (Geth and Trezor) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "32", data)), v, r, s) // Geth-adopted || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x20", data)), v, r, s) // Trezor-adopted ); } else { // == 2; Signed string hash signature (the most expensive but universal) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "64", hexToString(data))), v, r, s) // Geth || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x40", hexToString(data))), v, r, s) // Trezor ); } usedSigIds[signer][sigId] = true; } /** * Utility costly function to encode bytes HEX representation as string. * @param sig - signature as bytes32 to represent as string */ function hexToString (bytes32 sig) internal pure returns (bytes memory) { bytes memory str = new bytes(64); for (uint8 i = 0; i < 32; ++i) { str[2 * i] = byte((uint8(sig[i]) / 16 < 10 ? 48 : 87) + uint8(sig[i]) / 16); str[2 * i + 1] = byte((uint8(sig[i]) % 16 < 10 ? 48 : 87) + (uint8(sig[i]) % 16)); } return str; } /** * Transfer `value` tokens to `to` address from the account of sender. * @param to - the address of the recipient * @param value - the amount to send */ function transfer (address to, uint256 value) public returns (bool) { internalTransfer(msg.sender, to, value); return true; } /** * This function distincts transaction signer from transaction executor. It allows anyone to transfer tokens * from the `from` account by providing a valid signature, which can only be obtained from the `from` account * owner. * Note that passed parameter sigId is unique and cannot be passed twice (prevents replay attacks). When there's * a need to make signature once again (because the first one is lost or whatever), user should sign the message * with the same sigId, thus ensuring that the previous signature can't be used if the new one passes. * Use case: the user wants to send some tokens to another user or smart contract, but don't have Ether to do so. * @param from - the account giving its signature to transfer `value` tokens to `to` address * @param to - the account receiving `value` tokens * @param value - the value in tokens to transfer * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferViaSignature ( address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.transfer ); internalDoubleTransfer(from, to, value, feeRecipient, fee); return true; } /** * Allow `spender` to take `value` tokens from the transaction sender's account. * Beware that changing an allowance with this method brings the risk that `spender` 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 authorized to spend * @param value - the maximum amount they can spend */ function approve (address spender, uint256 value) public returns (bool) { allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * Same as `transferViaSignature`, but for `approve`. * Use case: the user wants to set an allowance for the smart contract or another user without having Ether on * their balance. * @param from - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address * @param value - the value in tokens to approve to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveViaSignature ( address from, address spender, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, spender, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.approve ); allowance[from][spender] = value; emit Approval(from, spender, value); internalTransfer(from, feeRecipient, fee); return true; } /** * Transfer `value` tokens to `to` address from the `from` account, using the previously set allowance. * @param from - the address to transfer tokens from * @param to - the address of the recipient * @param value - the amount to send */ function transferFrom (address from, address to, uint256 value) public returns (bool) { allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); internalTransfer(from, to, value); return true; } /** * Same as `transferViaSignature`, but for `transferFrom`. * Use case: the user wants to withdraw tokens from a smart contract or another user who allowed the user to * do so. Important note: the fee is subtracted from the `value`, and `to` address receives `value - fee`. * @param signer - the address allowed to call transferFrom, which signed all below parameters * @param from - the account to make withdrawal from * @param to - the address of the recipient * @param value - the value in tokens to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferFromViaSignature ( address signer, address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), signer, deadline, sigId, sig, sigStd, sigDestination.transferFrom ); allowance[from][signer] = allowance[from][signer].sub(value); internalDoubleTransfer(from, to, value.sub(fee), feeRecipient, fee); return true; } /** * Utility function, which acts the same as approve(...), but also calls `receiveApproval` function on a * `spender` address, which is usually the address of the smart contract. In the same call, smart contract can * withdraw tokens from the sender's account and receive additional `extraData` for processing. * @param spender - the address to be authorized to spend tokens * @param value - the max amount the `spender` can withdraw * @param extraData - some extra information to send to the approved contract */ function approveAndCall (address spender, uint256 value, bytes memory extraData) public returns (bool) { approve(spender, value); tokenRecipient(spender).receiveApproval(msg.sender, value, address(this), extraData); return true; } /** * Same as `approveViaSignature`, but for `approveAndCall`. * Use case: the user wants to send tokens to the smart contract and pass additional data within one transaction. * @param fromAddress - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address (in this case, smart contract only) * @param value - the value in tokens to approve to withdraw * @param extraData - additional data to pass to the `spender` smart contract * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveAndCallViaSignature ( address fromAddress, address spender, uint256 value, bytes calldata extraData, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), fromAddress, spender, value, extraData, fee, feeRecipient, deadline, sigId)), fromAddress, deadline, sigId, sig, sigStd, sigDestination.approveAndCall); allowance[fromAddress][spender] = value; emit Approval(fromAddress, spender, value); tokenRecipient(spender).receiveApproval(fromAddress, value, address(this), extraData); internalTransfer(fromAddress, feeRecipient, fee); return true; } /** * Mint some tokens to the sender's address. */ function mintTokens (uint newSupply) onlyOwner external { totalSupply = totalSupply.add(newSupply); balanceOf[msg.sender] = balanceOf[msg.sender].add(newSupply); emit Transfer(address(0x0), msg.sender, newSupply); } /** * ERC20 tokens are not designed to hold any other tokens (or Ether) on their balances. There were thousands * of cases when people accidentally transfer tokens to a contract address while there is no way to get them * back. This function adds a possibility to "rescue" tokens that were accidentally sent to this smart contract. * @param tokenContract - ERC20-compatible token * @param value - amount to rescue */ function rescueLostTokens (ERC20CompatibleToken tokenContract, uint256 value) external rescueAccountOnly { tokenContract.transfer(rescueAccount, value); } /** * Utility function that allows to change the rescueAccount address, which can "rescue" tokens accidentally sent to * this smart contract address. * @param newRescueAccount - account which will become authorized to rescue tokens */ function changeRescueAccount (address newRescueAccount) external rescueAccountOnly { rescueAccount = newRescueAccount; } }
transferFromViaSignature
function transferFromViaSignature ( address signer, address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), signer, deadline, sigId, sig, sigStd, sigDestination.transferFrom ); allowance[from][signer] = allowance[from][signer].sub(value); internalDoubleTransfer(from, to, value.sub(fee), feeRecipient, fee); return true; }
/** * Same as `transferViaSignature`, but for `transferFrom`. * Use case: the user wants to withdraw tokens from a smart contract or another user who allowed the user to * do so. Important note: the fee is subtracted from the `value`, and `to` address receives `value - fee`. * @param signer - the address allowed to call transferFrom, which signed all below parameters * @param from - the account to make withdrawal from * @param to - the address of the recipient * @param value - the value in tokens to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */
NatSpecMultiLine
v0.7.0+commit.9e61f92b
MIT
ipfs://1c92a1cb9cad01da0fc8472ee8f3e46eb4a79231c12969194d28b064750262d8
{ "func_code_index": [ 16603, 17491 ] }
8,448
OROCoin
OROCoin.sol
0xbf7fd29146d50b014879518fbcd567243ab8b92b
Solidity
OROCoin
contract OROCoin is Ownable { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; mapping(address => mapping(uint => bool)) public usedSigIds; address public rescueAccount; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); modifier rescueAccountOnly {require(msg.sender == rescueAccount); _;} enum sigStandard { typed, personal, stringHex } enum sigDestination { transfer, approve, approveAndCall, transferFrom } bytes constant public ethSignedMessagePrefix = "\x19Ethereum Signed Message:\n"; bytes32 constant public sigDestinationTransfer = keccak256(abi.encodePacked( "address Token Contract Address", "address Sender's Address", "address Recipient's Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferViaSignature`: keccak256(address(this), from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationTransferFrom = keccak256(abi.encodePacked( "address Token Contract Address", "address Address Approved for Withdraw", "address Account to Withdraw From", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferFromViaSignature`: keccak256(address(this), signer, from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationApprove = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveViaSignature`: keccak256(address(this), from, spender, value, fee, deadline, sigId) bytes32 constant public sigDestinationApproveAndCall = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "bytes Data to Transfer", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveAndCallViaSignature`: keccak256(address(this), from, spender, value, extraData, fee, deadline, sigId) constructor () public { name = "ORO (GBP)"; symbol = "ORP"; rescueAccount = msg.sender; } /** * Utility internal function used to safely transfer `value` tokens `from` -> `to`. Throws if transfer is impossible. * @param from - account to make the transfer from * @param to - account to transfer `value` tokens to * @param value - tokens to transfer to account `to` */ function internalTransfer (address from, address to, uint value) internal { require(to != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(from, to, value); } /** * Utility internal function used to safely transfer `value1` tokens `from` -> `to1`, and `value2` tokens * `from` -> `to2`, minimizing gas usage (calling `internalTransfer` twice is more expensive). Throws if * transfers are impossible. * @param from - account to make the transfer from * @param to1 - account to transfer `value1` tokens to * @param value1 - tokens to transfer to account `to1` * @param to2 - account to transfer `value2` tokens to * @param value2 - tokens to transfer to account `to2` */ function internalDoubleTransfer (address from, address to1, uint value1, address to2, uint value2) internal { require(to1 != address(0x0) && to2 != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value1.add(value2)); balanceOf[to1] = balanceOf[to1].add(value1); emit Transfer(from, to1, value1); if (value2 > 0) { balanceOf[to2] = balanceOf[to2].add(value2); emit Transfer(from, to2, value2); } } /** * Internal method that makes sure that the given signature corresponds to a given data and is made by `signer`. * It utilizes three (four) standards of message signing in Ethereum, as at the moment of this smart contract * development there is no single signing standard defined. For example, Metamask and Geth both support * personal_sign standard, SignTypedData is only supported by Matamask, Trezor does not support "widely adopted" * Ethereum personal_sign but rather personal_sign with fixed prefix and so on. * Note that it is always possible to forge any of these signatures using the private key, the problem is that * third-party wallets must adopt a single standard for signing messages. * @param data - original data which had to be signed by `signer` * @param signer - account which made a signature * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use * @param sigDest - for which type of action this signature was made */ function requireSignature ( bytes32 data, address signer, uint256 deadline, uint256 sigId, bytes memory sig, sigStandard sigStd, sigDestination sigDest ) internal { bytes32 r; bytes32 s; uint8 v; assembly { // solium-disable-line security/no-inline-assembly r := mload(add(sig, 32)) s := mload(add(sig, 64)) v := byte(0, mload(add(sig, 96))) } if (v < 27) v += 27; require(block.timestamp <= deadline && !usedSigIds[signer][sigId]); // solium-disable-line security/no-block-members if (sigStd == sigStandard.typed) { // Typed signature. This is the most likely scenario to be used and accepted require( signer == ecrecover( keccak256(abi.encodePacked( sigDest == sigDestination.transfer ? sigDestinationTransfer : sigDest == sigDestination.approve ? sigDestinationApprove : sigDest == sigDestination.approveAndCall ? sigDestinationApproveAndCall : sigDestinationTransferFrom, data )), v, r, s ) ); } else if (sigStd == sigStandard.personal) { // Ethereum signed message signature (Geth and Trezor) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "32", data)), v, r, s) // Geth-adopted || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x20", data)), v, r, s) // Trezor-adopted ); } else { // == 2; Signed string hash signature (the most expensive but universal) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "64", hexToString(data))), v, r, s) // Geth || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x40", hexToString(data))), v, r, s) // Trezor ); } usedSigIds[signer][sigId] = true; } /** * Utility costly function to encode bytes HEX representation as string. * @param sig - signature as bytes32 to represent as string */ function hexToString (bytes32 sig) internal pure returns (bytes memory) { bytes memory str = new bytes(64); for (uint8 i = 0; i < 32; ++i) { str[2 * i] = byte((uint8(sig[i]) / 16 < 10 ? 48 : 87) + uint8(sig[i]) / 16); str[2 * i + 1] = byte((uint8(sig[i]) % 16 < 10 ? 48 : 87) + (uint8(sig[i]) % 16)); } return str; } /** * Transfer `value` tokens to `to` address from the account of sender. * @param to - the address of the recipient * @param value - the amount to send */ function transfer (address to, uint256 value) public returns (bool) { internalTransfer(msg.sender, to, value); return true; } /** * This function distincts transaction signer from transaction executor. It allows anyone to transfer tokens * from the `from` account by providing a valid signature, which can only be obtained from the `from` account * owner. * Note that passed parameter sigId is unique and cannot be passed twice (prevents replay attacks). When there's * a need to make signature once again (because the first one is lost or whatever), user should sign the message * with the same sigId, thus ensuring that the previous signature can't be used if the new one passes. * Use case: the user wants to send some tokens to another user or smart contract, but don't have Ether to do so. * @param from - the account giving its signature to transfer `value` tokens to `to` address * @param to - the account receiving `value` tokens * @param value - the value in tokens to transfer * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferViaSignature ( address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.transfer ); internalDoubleTransfer(from, to, value, feeRecipient, fee); return true; } /** * Allow `spender` to take `value` tokens from the transaction sender's account. * Beware that changing an allowance with this method brings the risk that `spender` 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 authorized to spend * @param value - the maximum amount they can spend */ function approve (address spender, uint256 value) public returns (bool) { allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * Same as `transferViaSignature`, but for `approve`. * Use case: the user wants to set an allowance for the smart contract or another user without having Ether on * their balance. * @param from - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address * @param value - the value in tokens to approve to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveViaSignature ( address from, address spender, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, spender, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.approve ); allowance[from][spender] = value; emit Approval(from, spender, value); internalTransfer(from, feeRecipient, fee); return true; } /** * Transfer `value` tokens to `to` address from the `from` account, using the previously set allowance. * @param from - the address to transfer tokens from * @param to - the address of the recipient * @param value - the amount to send */ function transferFrom (address from, address to, uint256 value) public returns (bool) { allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); internalTransfer(from, to, value); return true; } /** * Same as `transferViaSignature`, but for `transferFrom`. * Use case: the user wants to withdraw tokens from a smart contract or another user who allowed the user to * do so. Important note: the fee is subtracted from the `value`, and `to` address receives `value - fee`. * @param signer - the address allowed to call transferFrom, which signed all below parameters * @param from - the account to make withdrawal from * @param to - the address of the recipient * @param value - the value in tokens to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferFromViaSignature ( address signer, address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), signer, deadline, sigId, sig, sigStd, sigDestination.transferFrom ); allowance[from][signer] = allowance[from][signer].sub(value); internalDoubleTransfer(from, to, value.sub(fee), feeRecipient, fee); return true; } /** * Utility function, which acts the same as approve(...), but also calls `receiveApproval` function on a * `spender` address, which is usually the address of the smart contract. In the same call, smart contract can * withdraw tokens from the sender's account and receive additional `extraData` for processing. * @param spender - the address to be authorized to spend tokens * @param value - the max amount the `spender` can withdraw * @param extraData - some extra information to send to the approved contract */ function approveAndCall (address spender, uint256 value, bytes memory extraData) public returns (bool) { approve(spender, value); tokenRecipient(spender).receiveApproval(msg.sender, value, address(this), extraData); return true; } /** * Same as `approveViaSignature`, but for `approveAndCall`. * Use case: the user wants to send tokens to the smart contract and pass additional data within one transaction. * @param fromAddress - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address (in this case, smart contract only) * @param value - the value in tokens to approve to withdraw * @param extraData - additional data to pass to the `spender` smart contract * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveAndCallViaSignature ( address fromAddress, address spender, uint256 value, bytes calldata extraData, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), fromAddress, spender, value, extraData, fee, feeRecipient, deadline, sigId)), fromAddress, deadline, sigId, sig, sigStd, sigDestination.approveAndCall); allowance[fromAddress][spender] = value; emit Approval(fromAddress, spender, value); tokenRecipient(spender).receiveApproval(fromAddress, value, address(this), extraData); internalTransfer(fromAddress, feeRecipient, fee); return true; } /** * Mint some tokens to the sender's address. */ function mintTokens (uint newSupply) onlyOwner external { totalSupply = totalSupply.add(newSupply); balanceOf[msg.sender] = balanceOf[msg.sender].add(newSupply); emit Transfer(address(0x0), msg.sender, newSupply); } /** * ERC20 tokens are not designed to hold any other tokens (or Ether) on their balances. There were thousands * of cases when people accidentally transfer tokens to a contract address while there is no way to get them * back. This function adds a possibility to "rescue" tokens that were accidentally sent to this smart contract. * @param tokenContract - ERC20-compatible token * @param value - amount to rescue */ function rescueLostTokens (ERC20CompatibleToken tokenContract, uint256 value) external rescueAccountOnly { tokenContract.transfer(rescueAccount, value); } /** * Utility function that allows to change the rescueAccount address, which can "rescue" tokens accidentally sent to * this smart contract address. * @param newRescueAccount - account which will become authorized to rescue tokens */ function changeRescueAccount (address newRescueAccount) external rescueAccountOnly { rescueAccount = newRescueAccount; } }
approveAndCall
function approveAndCall (address spender, uint256 value, bytes memory extraData) public returns (bool) { approve(spender, value); tokenRecipient(spender).receiveApproval(msg.sender, value, address(this), extraData); return true; }
/** * Utility function, which acts the same as approve(...), but also calls `receiveApproval` function on a * `spender` address, which is usually the address of the smart contract. In the same call, smart contract can * withdraw tokens from the sender's account and receive additional `extraData` for processing. * @param spender - the address to be authorized to spend tokens * @param value - the max amount the `spender` can withdraw * @param extraData - some extra information to send to the approved contract */
NatSpecMultiLine
v0.7.0+commit.9e61f92b
MIT
ipfs://1c92a1cb9cad01da0fc8472ee8f3e46eb4a79231c12969194d28b064750262d8
{ "func_code_index": [ 18057, 18324 ] }
8,449
OROCoin
OROCoin.sol
0xbf7fd29146d50b014879518fbcd567243ab8b92b
Solidity
OROCoin
contract OROCoin is Ownable { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; mapping(address => mapping(uint => bool)) public usedSigIds; address public rescueAccount; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); modifier rescueAccountOnly {require(msg.sender == rescueAccount); _;} enum sigStandard { typed, personal, stringHex } enum sigDestination { transfer, approve, approveAndCall, transferFrom } bytes constant public ethSignedMessagePrefix = "\x19Ethereum Signed Message:\n"; bytes32 constant public sigDestinationTransfer = keccak256(abi.encodePacked( "address Token Contract Address", "address Sender's Address", "address Recipient's Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferViaSignature`: keccak256(address(this), from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationTransferFrom = keccak256(abi.encodePacked( "address Token Contract Address", "address Address Approved for Withdraw", "address Account to Withdraw From", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferFromViaSignature`: keccak256(address(this), signer, from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationApprove = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveViaSignature`: keccak256(address(this), from, spender, value, fee, deadline, sigId) bytes32 constant public sigDestinationApproveAndCall = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "bytes Data to Transfer", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveAndCallViaSignature`: keccak256(address(this), from, spender, value, extraData, fee, deadline, sigId) constructor () public { name = "ORO (GBP)"; symbol = "ORP"; rescueAccount = msg.sender; } /** * Utility internal function used to safely transfer `value` tokens `from` -> `to`. Throws if transfer is impossible. * @param from - account to make the transfer from * @param to - account to transfer `value` tokens to * @param value - tokens to transfer to account `to` */ function internalTransfer (address from, address to, uint value) internal { require(to != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(from, to, value); } /** * Utility internal function used to safely transfer `value1` tokens `from` -> `to1`, and `value2` tokens * `from` -> `to2`, minimizing gas usage (calling `internalTransfer` twice is more expensive). Throws if * transfers are impossible. * @param from - account to make the transfer from * @param to1 - account to transfer `value1` tokens to * @param value1 - tokens to transfer to account `to1` * @param to2 - account to transfer `value2` tokens to * @param value2 - tokens to transfer to account `to2` */ function internalDoubleTransfer (address from, address to1, uint value1, address to2, uint value2) internal { require(to1 != address(0x0) && to2 != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value1.add(value2)); balanceOf[to1] = balanceOf[to1].add(value1); emit Transfer(from, to1, value1); if (value2 > 0) { balanceOf[to2] = balanceOf[to2].add(value2); emit Transfer(from, to2, value2); } } /** * Internal method that makes sure that the given signature corresponds to a given data and is made by `signer`. * It utilizes three (four) standards of message signing in Ethereum, as at the moment of this smart contract * development there is no single signing standard defined. For example, Metamask and Geth both support * personal_sign standard, SignTypedData is only supported by Matamask, Trezor does not support "widely adopted" * Ethereum personal_sign but rather personal_sign with fixed prefix and so on. * Note that it is always possible to forge any of these signatures using the private key, the problem is that * third-party wallets must adopt a single standard for signing messages. * @param data - original data which had to be signed by `signer` * @param signer - account which made a signature * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use * @param sigDest - for which type of action this signature was made */ function requireSignature ( bytes32 data, address signer, uint256 deadline, uint256 sigId, bytes memory sig, sigStandard sigStd, sigDestination sigDest ) internal { bytes32 r; bytes32 s; uint8 v; assembly { // solium-disable-line security/no-inline-assembly r := mload(add(sig, 32)) s := mload(add(sig, 64)) v := byte(0, mload(add(sig, 96))) } if (v < 27) v += 27; require(block.timestamp <= deadline && !usedSigIds[signer][sigId]); // solium-disable-line security/no-block-members if (sigStd == sigStandard.typed) { // Typed signature. This is the most likely scenario to be used and accepted require( signer == ecrecover( keccak256(abi.encodePacked( sigDest == sigDestination.transfer ? sigDestinationTransfer : sigDest == sigDestination.approve ? sigDestinationApprove : sigDest == sigDestination.approveAndCall ? sigDestinationApproveAndCall : sigDestinationTransferFrom, data )), v, r, s ) ); } else if (sigStd == sigStandard.personal) { // Ethereum signed message signature (Geth and Trezor) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "32", data)), v, r, s) // Geth-adopted || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x20", data)), v, r, s) // Trezor-adopted ); } else { // == 2; Signed string hash signature (the most expensive but universal) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "64", hexToString(data))), v, r, s) // Geth || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x40", hexToString(data))), v, r, s) // Trezor ); } usedSigIds[signer][sigId] = true; } /** * Utility costly function to encode bytes HEX representation as string. * @param sig - signature as bytes32 to represent as string */ function hexToString (bytes32 sig) internal pure returns (bytes memory) { bytes memory str = new bytes(64); for (uint8 i = 0; i < 32; ++i) { str[2 * i] = byte((uint8(sig[i]) / 16 < 10 ? 48 : 87) + uint8(sig[i]) / 16); str[2 * i + 1] = byte((uint8(sig[i]) % 16 < 10 ? 48 : 87) + (uint8(sig[i]) % 16)); } return str; } /** * Transfer `value` tokens to `to` address from the account of sender. * @param to - the address of the recipient * @param value - the amount to send */ function transfer (address to, uint256 value) public returns (bool) { internalTransfer(msg.sender, to, value); return true; } /** * This function distincts transaction signer from transaction executor. It allows anyone to transfer tokens * from the `from` account by providing a valid signature, which can only be obtained from the `from` account * owner. * Note that passed parameter sigId is unique and cannot be passed twice (prevents replay attacks). When there's * a need to make signature once again (because the first one is lost or whatever), user should sign the message * with the same sigId, thus ensuring that the previous signature can't be used if the new one passes. * Use case: the user wants to send some tokens to another user or smart contract, but don't have Ether to do so. * @param from - the account giving its signature to transfer `value` tokens to `to` address * @param to - the account receiving `value` tokens * @param value - the value in tokens to transfer * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferViaSignature ( address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.transfer ); internalDoubleTransfer(from, to, value, feeRecipient, fee); return true; } /** * Allow `spender` to take `value` tokens from the transaction sender's account. * Beware that changing an allowance with this method brings the risk that `spender` 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 authorized to spend * @param value - the maximum amount they can spend */ function approve (address spender, uint256 value) public returns (bool) { allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * Same as `transferViaSignature`, but for `approve`. * Use case: the user wants to set an allowance for the smart contract or another user without having Ether on * their balance. * @param from - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address * @param value - the value in tokens to approve to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveViaSignature ( address from, address spender, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, spender, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.approve ); allowance[from][spender] = value; emit Approval(from, spender, value); internalTransfer(from, feeRecipient, fee); return true; } /** * Transfer `value` tokens to `to` address from the `from` account, using the previously set allowance. * @param from - the address to transfer tokens from * @param to - the address of the recipient * @param value - the amount to send */ function transferFrom (address from, address to, uint256 value) public returns (bool) { allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); internalTransfer(from, to, value); return true; } /** * Same as `transferViaSignature`, but for `transferFrom`. * Use case: the user wants to withdraw tokens from a smart contract or another user who allowed the user to * do so. Important note: the fee is subtracted from the `value`, and `to` address receives `value - fee`. * @param signer - the address allowed to call transferFrom, which signed all below parameters * @param from - the account to make withdrawal from * @param to - the address of the recipient * @param value - the value in tokens to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferFromViaSignature ( address signer, address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), signer, deadline, sigId, sig, sigStd, sigDestination.transferFrom ); allowance[from][signer] = allowance[from][signer].sub(value); internalDoubleTransfer(from, to, value.sub(fee), feeRecipient, fee); return true; } /** * Utility function, which acts the same as approve(...), but also calls `receiveApproval` function on a * `spender` address, which is usually the address of the smart contract. In the same call, smart contract can * withdraw tokens from the sender's account and receive additional `extraData` for processing. * @param spender - the address to be authorized to spend tokens * @param value - the max amount the `spender` can withdraw * @param extraData - some extra information to send to the approved contract */ function approveAndCall (address spender, uint256 value, bytes memory extraData) public returns (bool) { approve(spender, value); tokenRecipient(spender).receiveApproval(msg.sender, value, address(this), extraData); return true; } /** * Same as `approveViaSignature`, but for `approveAndCall`. * Use case: the user wants to send tokens to the smart contract and pass additional data within one transaction. * @param fromAddress - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address (in this case, smart contract only) * @param value - the value in tokens to approve to withdraw * @param extraData - additional data to pass to the `spender` smart contract * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveAndCallViaSignature ( address fromAddress, address spender, uint256 value, bytes calldata extraData, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), fromAddress, spender, value, extraData, fee, feeRecipient, deadline, sigId)), fromAddress, deadline, sigId, sig, sigStd, sigDestination.approveAndCall); allowance[fromAddress][spender] = value; emit Approval(fromAddress, spender, value); tokenRecipient(spender).receiveApproval(fromAddress, value, address(this), extraData); internalTransfer(fromAddress, feeRecipient, fee); return true; } /** * Mint some tokens to the sender's address. */ function mintTokens (uint newSupply) onlyOwner external { totalSupply = totalSupply.add(newSupply); balanceOf[msg.sender] = balanceOf[msg.sender].add(newSupply); emit Transfer(address(0x0), msg.sender, newSupply); } /** * ERC20 tokens are not designed to hold any other tokens (or Ether) on their balances. There were thousands * of cases when people accidentally transfer tokens to a contract address while there is no way to get them * back. This function adds a possibility to "rescue" tokens that were accidentally sent to this smart contract. * @param tokenContract - ERC20-compatible token * @param value - amount to rescue */ function rescueLostTokens (ERC20CompatibleToken tokenContract, uint256 value) external rescueAccountOnly { tokenContract.transfer(rescueAccount, value); } /** * Utility function that allows to change the rescueAccount address, which can "rescue" tokens accidentally sent to * this smart contract address. * @param newRescueAccount - account which will become authorized to rescue tokens */ function changeRescueAccount (address newRescueAccount) external rescueAccountOnly { rescueAccount = newRescueAccount; } }
approveAndCallViaSignature
function approveAndCallViaSignature ( address fromAddress, address spender, uint256 value, bytes calldata extraData, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), fromAddress, spender, value, extraData, fee, feeRecipient, deadline, sigId)), fromAddress, deadline, sigId, sig, sigStd, sigDestination.approveAndCall); allowance[fromAddress][spender] = value; emit Approval(fromAddress, spender, value); tokenRecipient(spender).receiveApproval(fromAddress, value, address(this), extraData); internalTransfer(fromAddress, feeRecipient, fee); return true; }
/** * Same as `approveViaSignature`, but for `approveAndCall`. * Use case: the user wants to send tokens to the smart contract and pass additional data within one transaction. * @param fromAddress - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address (in this case, smart contract only) * @param value - the value in tokens to approve to withdraw * @param extraData - additional data to pass to the `spender` smart contract * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */
NatSpecMultiLine
v0.7.0+commit.9e61f92b
MIT
ipfs://1c92a1cb9cad01da0fc8472ee8f3e46eb4a79231c12969194d28b064750262d8
{ "func_code_index": [ 19423, 20444 ] }
8,450
OROCoin
OROCoin.sol
0xbf7fd29146d50b014879518fbcd567243ab8b92b
Solidity
OROCoin
contract OROCoin is Ownable { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; mapping(address => mapping(uint => bool)) public usedSigIds; address public rescueAccount; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); modifier rescueAccountOnly {require(msg.sender == rescueAccount); _;} enum sigStandard { typed, personal, stringHex } enum sigDestination { transfer, approve, approveAndCall, transferFrom } bytes constant public ethSignedMessagePrefix = "\x19Ethereum Signed Message:\n"; bytes32 constant public sigDestinationTransfer = keccak256(abi.encodePacked( "address Token Contract Address", "address Sender's Address", "address Recipient's Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferViaSignature`: keccak256(address(this), from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationTransferFrom = keccak256(abi.encodePacked( "address Token Contract Address", "address Address Approved for Withdraw", "address Account to Withdraw From", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferFromViaSignature`: keccak256(address(this), signer, from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationApprove = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveViaSignature`: keccak256(address(this), from, spender, value, fee, deadline, sigId) bytes32 constant public sigDestinationApproveAndCall = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "bytes Data to Transfer", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveAndCallViaSignature`: keccak256(address(this), from, spender, value, extraData, fee, deadline, sigId) constructor () public { name = "ORO (GBP)"; symbol = "ORP"; rescueAccount = msg.sender; } /** * Utility internal function used to safely transfer `value` tokens `from` -> `to`. Throws if transfer is impossible. * @param from - account to make the transfer from * @param to - account to transfer `value` tokens to * @param value - tokens to transfer to account `to` */ function internalTransfer (address from, address to, uint value) internal { require(to != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(from, to, value); } /** * Utility internal function used to safely transfer `value1` tokens `from` -> `to1`, and `value2` tokens * `from` -> `to2`, minimizing gas usage (calling `internalTransfer` twice is more expensive). Throws if * transfers are impossible. * @param from - account to make the transfer from * @param to1 - account to transfer `value1` tokens to * @param value1 - tokens to transfer to account `to1` * @param to2 - account to transfer `value2` tokens to * @param value2 - tokens to transfer to account `to2` */ function internalDoubleTransfer (address from, address to1, uint value1, address to2, uint value2) internal { require(to1 != address(0x0) && to2 != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value1.add(value2)); balanceOf[to1] = balanceOf[to1].add(value1); emit Transfer(from, to1, value1); if (value2 > 0) { balanceOf[to2] = balanceOf[to2].add(value2); emit Transfer(from, to2, value2); } } /** * Internal method that makes sure that the given signature corresponds to a given data and is made by `signer`. * It utilizes three (four) standards of message signing in Ethereum, as at the moment of this smart contract * development there is no single signing standard defined. For example, Metamask and Geth both support * personal_sign standard, SignTypedData is only supported by Matamask, Trezor does not support "widely adopted" * Ethereum personal_sign but rather personal_sign with fixed prefix and so on. * Note that it is always possible to forge any of these signatures using the private key, the problem is that * third-party wallets must adopt a single standard for signing messages. * @param data - original data which had to be signed by `signer` * @param signer - account which made a signature * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use * @param sigDest - for which type of action this signature was made */ function requireSignature ( bytes32 data, address signer, uint256 deadline, uint256 sigId, bytes memory sig, sigStandard sigStd, sigDestination sigDest ) internal { bytes32 r; bytes32 s; uint8 v; assembly { // solium-disable-line security/no-inline-assembly r := mload(add(sig, 32)) s := mload(add(sig, 64)) v := byte(0, mload(add(sig, 96))) } if (v < 27) v += 27; require(block.timestamp <= deadline && !usedSigIds[signer][sigId]); // solium-disable-line security/no-block-members if (sigStd == sigStandard.typed) { // Typed signature. This is the most likely scenario to be used and accepted require( signer == ecrecover( keccak256(abi.encodePacked( sigDest == sigDestination.transfer ? sigDestinationTransfer : sigDest == sigDestination.approve ? sigDestinationApprove : sigDest == sigDestination.approveAndCall ? sigDestinationApproveAndCall : sigDestinationTransferFrom, data )), v, r, s ) ); } else if (sigStd == sigStandard.personal) { // Ethereum signed message signature (Geth and Trezor) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "32", data)), v, r, s) // Geth-adopted || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x20", data)), v, r, s) // Trezor-adopted ); } else { // == 2; Signed string hash signature (the most expensive but universal) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "64", hexToString(data))), v, r, s) // Geth || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x40", hexToString(data))), v, r, s) // Trezor ); } usedSigIds[signer][sigId] = true; } /** * Utility costly function to encode bytes HEX representation as string. * @param sig - signature as bytes32 to represent as string */ function hexToString (bytes32 sig) internal pure returns (bytes memory) { bytes memory str = new bytes(64); for (uint8 i = 0; i < 32; ++i) { str[2 * i] = byte((uint8(sig[i]) / 16 < 10 ? 48 : 87) + uint8(sig[i]) / 16); str[2 * i + 1] = byte((uint8(sig[i]) % 16 < 10 ? 48 : 87) + (uint8(sig[i]) % 16)); } return str; } /** * Transfer `value` tokens to `to` address from the account of sender. * @param to - the address of the recipient * @param value - the amount to send */ function transfer (address to, uint256 value) public returns (bool) { internalTransfer(msg.sender, to, value); return true; } /** * This function distincts transaction signer from transaction executor. It allows anyone to transfer tokens * from the `from` account by providing a valid signature, which can only be obtained from the `from` account * owner. * Note that passed parameter sigId is unique and cannot be passed twice (prevents replay attacks). When there's * a need to make signature once again (because the first one is lost or whatever), user should sign the message * with the same sigId, thus ensuring that the previous signature can't be used if the new one passes. * Use case: the user wants to send some tokens to another user or smart contract, but don't have Ether to do so. * @param from - the account giving its signature to transfer `value` tokens to `to` address * @param to - the account receiving `value` tokens * @param value - the value in tokens to transfer * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferViaSignature ( address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.transfer ); internalDoubleTransfer(from, to, value, feeRecipient, fee); return true; } /** * Allow `spender` to take `value` tokens from the transaction sender's account. * Beware that changing an allowance with this method brings the risk that `spender` 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 authorized to spend * @param value - the maximum amount they can spend */ function approve (address spender, uint256 value) public returns (bool) { allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * Same as `transferViaSignature`, but for `approve`. * Use case: the user wants to set an allowance for the smart contract or another user without having Ether on * their balance. * @param from - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address * @param value - the value in tokens to approve to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveViaSignature ( address from, address spender, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, spender, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.approve ); allowance[from][spender] = value; emit Approval(from, spender, value); internalTransfer(from, feeRecipient, fee); return true; } /** * Transfer `value` tokens to `to` address from the `from` account, using the previously set allowance. * @param from - the address to transfer tokens from * @param to - the address of the recipient * @param value - the amount to send */ function transferFrom (address from, address to, uint256 value) public returns (bool) { allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); internalTransfer(from, to, value); return true; } /** * Same as `transferViaSignature`, but for `transferFrom`. * Use case: the user wants to withdraw tokens from a smart contract or another user who allowed the user to * do so. Important note: the fee is subtracted from the `value`, and `to` address receives `value - fee`. * @param signer - the address allowed to call transferFrom, which signed all below parameters * @param from - the account to make withdrawal from * @param to - the address of the recipient * @param value - the value in tokens to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferFromViaSignature ( address signer, address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), signer, deadline, sigId, sig, sigStd, sigDestination.transferFrom ); allowance[from][signer] = allowance[from][signer].sub(value); internalDoubleTransfer(from, to, value.sub(fee), feeRecipient, fee); return true; } /** * Utility function, which acts the same as approve(...), but also calls `receiveApproval` function on a * `spender` address, which is usually the address of the smart contract. In the same call, smart contract can * withdraw tokens from the sender's account and receive additional `extraData` for processing. * @param spender - the address to be authorized to spend tokens * @param value - the max amount the `spender` can withdraw * @param extraData - some extra information to send to the approved contract */ function approveAndCall (address spender, uint256 value, bytes memory extraData) public returns (bool) { approve(spender, value); tokenRecipient(spender).receiveApproval(msg.sender, value, address(this), extraData); return true; } /** * Same as `approveViaSignature`, but for `approveAndCall`. * Use case: the user wants to send tokens to the smart contract and pass additional data within one transaction. * @param fromAddress - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address (in this case, smart contract only) * @param value - the value in tokens to approve to withdraw * @param extraData - additional data to pass to the `spender` smart contract * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveAndCallViaSignature ( address fromAddress, address spender, uint256 value, bytes calldata extraData, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), fromAddress, spender, value, extraData, fee, feeRecipient, deadline, sigId)), fromAddress, deadline, sigId, sig, sigStd, sigDestination.approveAndCall); allowance[fromAddress][spender] = value; emit Approval(fromAddress, spender, value); tokenRecipient(spender).receiveApproval(fromAddress, value, address(this), extraData); internalTransfer(fromAddress, feeRecipient, fee); return true; } /** * Mint some tokens to the sender's address. */ function mintTokens (uint newSupply) onlyOwner external { totalSupply = totalSupply.add(newSupply); balanceOf[msg.sender] = balanceOf[msg.sender].add(newSupply); emit Transfer(address(0x0), msg.sender, newSupply); } /** * ERC20 tokens are not designed to hold any other tokens (or Ether) on their balances. There were thousands * of cases when people accidentally transfer tokens to a contract address while there is no way to get them * back. This function adds a possibility to "rescue" tokens that were accidentally sent to this smart contract. * @param tokenContract - ERC20-compatible token * @param value - amount to rescue */ function rescueLostTokens (ERC20CompatibleToken tokenContract, uint256 value) external rescueAccountOnly { tokenContract.transfer(rescueAccount, value); } /** * Utility function that allows to change the rescueAccount address, which can "rescue" tokens accidentally sent to * this smart contract address. * @param newRescueAccount - account which will become authorized to rescue tokens */ function changeRescueAccount (address newRescueAccount) external rescueAccountOnly { rescueAccount = newRescueAccount; } }
mintTokens
function mintTokens (uint newSupply) onlyOwner external { totalSupply = totalSupply.add(newSupply); balanceOf[msg.sender] = balanceOf[msg.sender].add(newSupply); emit Transfer(address(0x0), msg.sender, newSupply); }
/** * Mint some tokens to the sender's address. */
NatSpecMultiLine
v0.7.0+commit.9e61f92b
MIT
ipfs://1c92a1cb9cad01da0fc8472ee8f3e46eb4a79231c12969194d28b064750262d8
{ "func_code_index": [ 20515, 20767 ] }
8,451
OROCoin
OROCoin.sol
0xbf7fd29146d50b014879518fbcd567243ab8b92b
Solidity
OROCoin
contract OROCoin is Ownable { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; mapping(address => mapping(uint => bool)) public usedSigIds; address public rescueAccount; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); modifier rescueAccountOnly {require(msg.sender == rescueAccount); _;} enum sigStandard { typed, personal, stringHex } enum sigDestination { transfer, approve, approveAndCall, transferFrom } bytes constant public ethSignedMessagePrefix = "\x19Ethereum Signed Message:\n"; bytes32 constant public sigDestinationTransfer = keccak256(abi.encodePacked( "address Token Contract Address", "address Sender's Address", "address Recipient's Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferViaSignature`: keccak256(address(this), from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationTransferFrom = keccak256(abi.encodePacked( "address Token Contract Address", "address Address Approved for Withdraw", "address Account to Withdraw From", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferFromViaSignature`: keccak256(address(this), signer, from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationApprove = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveViaSignature`: keccak256(address(this), from, spender, value, fee, deadline, sigId) bytes32 constant public sigDestinationApproveAndCall = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "bytes Data to Transfer", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveAndCallViaSignature`: keccak256(address(this), from, spender, value, extraData, fee, deadline, sigId) constructor () public { name = "ORO (GBP)"; symbol = "ORP"; rescueAccount = msg.sender; } /** * Utility internal function used to safely transfer `value` tokens `from` -> `to`. Throws if transfer is impossible. * @param from - account to make the transfer from * @param to - account to transfer `value` tokens to * @param value - tokens to transfer to account `to` */ function internalTransfer (address from, address to, uint value) internal { require(to != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(from, to, value); } /** * Utility internal function used to safely transfer `value1` tokens `from` -> `to1`, and `value2` tokens * `from` -> `to2`, minimizing gas usage (calling `internalTransfer` twice is more expensive). Throws if * transfers are impossible. * @param from - account to make the transfer from * @param to1 - account to transfer `value1` tokens to * @param value1 - tokens to transfer to account `to1` * @param to2 - account to transfer `value2` tokens to * @param value2 - tokens to transfer to account `to2` */ function internalDoubleTransfer (address from, address to1, uint value1, address to2, uint value2) internal { require(to1 != address(0x0) && to2 != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value1.add(value2)); balanceOf[to1] = balanceOf[to1].add(value1); emit Transfer(from, to1, value1); if (value2 > 0) { balanceOf[to2] = balanceOf[to2].add(value2); emit Transfer(from, to2, value2); } } /** * Internal method that makes sure that the given signature corresponds to a given data and is made by `signer`. * It utilizes three (four) standards of message signing in Ethereum, as at the moment of this smart contract * development there is no single signing standard defined. For example, Metamask and Geth both support * personal_sign standard, SignTypedData is only supported by Matamask, Trezor does not support "widely adopted" * Ethereum personal_sign but rather personal_sign with fixed prefix and so on. * Note that it is always possible to forge any of these signatures using the private key, the problem is that * third-party wallets must adopt a single standard for signing messages. * @param data - original data which had to be signed by `signer` * @param signer - account which made a signature * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use * @param sigDest - for which type of action this signature was made */ function requireSignature ( bytes32 data, address signer, uint256 deadline, uint256 sigId, bytes memory sig, sigStandard sigStd, sigDestination sigDest ) internal { bytes32 r; bytes32 s; uint8 v; assembly { // solium-disable-line security/no-inline-assembly r := mload(add(sig, 32)) s := mload(add(sig, 64)) v := byte(0, mload(add(sig, 96))) } if (v < 27) v += 27; require(block.timestamp <= deadline && !usedSigIds[signer][sigId]); // solium-disable-line security/no-block-members if (sigStd == sigStandard.typed) { // Typed signature. This is the most likely scenario to be used and accepted require( signer == ecrecover( keccak256(abi.encodePacked( sigDest == sigDestination.transfer ? sigDestinationTransfer : sigDest == sigDestination.approve ? sigDestinationApprove : sigDest == sigDestination.approveAndCall ? sigDestinationApproveAndCall : sigDestinationTransferFrom, data )), v, r, s ) ); } else if (sigStd == sigStandard.personal) { // Ethereum signed message signature (Geth and Trezor) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "32", data)), v, r, s) // Geth-adopted || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x20", data)), v, r, s) // Trezor-adopted ); } else { // == 2; Signed string hash signature (the most expensive but universal) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "64", hexToString(data))), v, r, s) // Geth || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x40", hexToString(data))), v, r, s) // Trezor ); } usedSigIds[signer][sigId] = true; } /** * Utility costly function to encode bytes HEX representation as string. * @param sig - signature as bytes32 to represent as string */ function hexToString (bytes32 sig) internal pure returns (bytes memory) { bytes memory str = new bytes(64); for (uint8 i = 0; i < 32; ++i) { str[2 * i] = byte((uint8(sig[i]) / 16 < 10 ? 48 : 87) + uint8(sig[i]) / 16); str[2 * i + 1] = byte((uint8(sig[i]) % 16 < 10 ? 48 : 87) + (uint8(sig[i]) % 16)); } return str; } /** * Transfer `value` tokens to `to` address from the account of sender. * @param to - the address of the recipient * @param value - the amount to send */ function transfer (address to, uint256 value) public returns (bool) { internalTransfer(msg.sender, to, value); return true; } /** * This function distincts transaction signer from transaction executor. It allows anyone to transfer tokens * from the `from` account by providing a valid signature, which can only be obtained from the `from` account * owner. * Note that passed parameter sigId is unique and cannot be passed twice (prevents replay attacks). When there's * a need to make signature once again (because the first one is lost or whatever), user should sign the message * with the same sigId, thus ensuring that the previous signature can't be used if the new one passes. * Use case: the user wants to send some tokens to another user or smart contract, but don't have Ether to do so. * @param from - the account giving its signature to transfer `value` tokens to `to` address * @param to - the account receiving `value` tokens * @param value - the value in tokens to transfer * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferViaSignature ( address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.transfer ); internalDoubleTransfer(from, to, value, feeRecipient, fee); return true; } /** * Allow `spender` to take `value` tokens from the transaction sender's account. * Beware that changing an allowance with this method brings the risk that `spender` 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 authorized to spend * @param value - the maximum amount they can spend */ function approve (address spender, uint256 value) public returns (bool) { allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * Same as `transferViaSignature`, but for `approve`. * Use case: the user wants to set an allowance for the smart contract or another user without having Ether on * their balance. * @param from - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address * @param value - the value in tokens to approve to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveViaSignature ( address from, address spender, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, spender, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.approve ); allowance[from][spender] = value; emit Approval(from, spender, value); internalTransfer(from, feeRecipient, fee); return true; } /** * Transfer `value` tokens to `to` address from the `from` account, using the previously set allowance. * @param from - the address to transfer tokens from * @param to - the address of the recipient * @param value - the amount to send */ function transferFrom (address from, address to, uint256 value) public returns (bool) { allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); internalTransfer(from, to, value); return true; } /** * Same as `transferViaSignature`, but for `transferFrom`. * Use case: the user wants to withdraw tokens from a smart contract or another user who allowed the user to * do so. Important note: the fee is subtracted from the `value`, and `to` address receives `value - fee`. * @param signer - the address allowed to call transferFrom, which signed all below parameters * @param from - the account to make withdrawal from * @param to - the address of the recipient * @param value - the value in tokens to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferFromViaSignature ( address signer, address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), signer, deadline, sigId, sig, sigStd, sigDestination.transferFrom ); allowance[from][signer] = allowance[from][signer].sub(value); internalDoubleTransfer(from, to, value.sub(fee), feeRecipient, fee); return true; } /** * Utility function, which acts the same as approve(...), but also calls `receiveApproval` function on a * `spender` address, which is usually the address of the smart contract. In the same call, smart contract can * withdraw tokens from the sender's account and receive additional `extraData` for processing. * @param spender - the address to be authorized to spend tokens * @param value - the max amount the `spender` can withdraw * @param extraData - some extra information to send to the approved contract */ function approveAndCall (address spender, uint256 value, bytes memory extraData) public returns (bool) { approve(spender, value); tokenRecipient(spender).receiveApproval(msg.sender, value, address(this), extraData); return true; } /** * Same as `approveViaSignature`, but for `approveAndCall`. * Use case: the user wants to send tokens to the smart contract and pass additional data within one transaction. * @param fromAddress - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address (in this case, smart contract only) * @param value - the value in tokens to approve to withdraw * @param extraData - additional data to pass to the `spender` smart contract * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveAndCallViaSignature ( address fromAddress, address spender, uint256 value, bytes calldata extraData, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), fromAddress, spender, value, extraData, fee, feeRecipient, deadline, sigId)), fromAddress, deadline, sigId, sig, sigStd, sigDestination.approveAndCall); allowance[fromAddress][spender] = value; emit Approval(fromAddress, spender, value); tokenRecipient(spender).receiveApproval(fromAddress, value, address(this), extraData); internalTransfer(fromAddress, feeRecipient, fee); return true; } /** * Mint some tokens to the sender's address. */ function mintTokens (uint newSupply) onlyOwner external { totalSupply = totalSupply.add(newSupply); balanceOf[msg.sender] = balanceOf[msg.sender].add(newSupply); emit Transfer(address(0x0), msg.sender, newSupply); } /** * ERC20 tokens are not designed to hold any other tokens (or Ether) on their balances. There were thousands * of cases when people accidentally transfer tokens to a contract address while there is no way to get them * back. This function adds a possibility to "rescue" tokens that were accidentally sent to this smart contract. * @param tokenContract - ERC20-compatible token * @param value - amount to rescue */ function rescueLostTokens (ERC20CompatibleToken tokenContract, uint256 value) external rescueAccountOnly { tokenContract.transfer(rescueAccount, value); } /** * Utility function that allows to change the rescueAccount address, which can "rescue" tokens accidentally sent to * this smart contract address. * @param newRescueAccount - account which will become authorized to rescue tokens */ function changeRescueAccount (address newRescueAccount) external rescueAccountOnly { rescueAccount = newRescueAccount; } }
rescueLostTokens
function rescueLostTokens (ERC20CompatibleToken tokenContract, uint256 value) external rescueAccountOnly { tokenContract.transfer(rescueAccount, value); }
/** * ERC20 tokens are not designed to hold any other tokens (or Ether) on their balances. There were thousands * of cases when people accidentally transfer tokens to a contract address while there is no way to get them * back. This function adds a possibility to "rescue" tokens that were accidentally sent to this smart contract. * @param tokenContract - ERC20-compatible token * @param value - amount to rescue */
NatSpecMultiLine
v0.7.0+commit.9e61f92b
MIT
ipfs://1c92a1cb9cad01da0fc8472ee8f3e46eb4a79231c12969194d28b064750262d8
{ "func_code_index": [ 21228, 21401 ] }
8,452
OROCoin
OROCoin.sol
0xbf7fd29146d50b014879518fbcd567243ab8b92b
Solidity
OROCoin
contract OROCoin is Ownable { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; mapping(address => mapping(uint => bool)) public usedSigIds; address public rescueAccount; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); modifier rescueAccountOnly {require(msg.sender == rescueAccount); _;} enum sigStandard { typed, personal, stringHex } enum sigDestination { transfer, approve, approveAndCall, transferFrom } bytes constant public ethSignedMessagePrefix = "\x19Ethereum Signed Message:\n"; bytes32 constant public sigDestinationTransfer = keccak256(abi.encodePacked( "address Token Contract Address", "address Sender's Address", "address Recipient's Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferViaSignature`: keccak256(address(this), from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationTransferFrom = keccak256(abi.encodePacked( "address Token Contract Address", "address Address Approved for Withdraw", "address Account to Withdraw From", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `transferFromViaSignature`: keccak256(address(this), signer, from, to, value, fee, deadline, sigId) bytes32 constant public sigDestinationApprove = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveViaSignature`: keccak256(address(this), from, spender, value, fee, deadline, sigId) bytes32 constant public sigDestinationApproveAndCall = keccak256(abi.encodePacked( "address Token Contract Address", "address Withdrawal Approval Address", "address Withdrawal Recipient Address", "uint256 Amount to Transfer (last six digits are decimals)", "bytes Data to Transfer", "uint256 Fee in Tokens Paid to Executor (last six digits are decimals)", "address Account which Receives Fee", "uint256 Signature Expiration Timestamp (unix timestamp)", "uint256 Signature ID" )); // `approveAndCallViaSignature`: keccak256(address(this), from, spender, value, extraData, fee, deadline, sigId) constructor () public { name = "ORO (GBP)"; symbol = "ORP"; rescueAccount = msg.sender; } /** * Utility internal function used to safely transfer `value` tokens `from` -> `to`. Throws if transfer is impossible. * @param from - account to make the transfer from * @param to - account to transfer `value` tokens to * @param value - tokens to transfer to account `to` */ function internalTransfer (address from, address to, uint value) internal { require(to != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(from, to, value); } /** * Utility internal function used to safely transfer `value1` tokens `from` -> `to1`, and `value2` tokens * `from` -> `to2`, minimizing gas usage (calling `internalTransfer` twice is more expensive). Throws if * transfers are impossible. * @param from - account to make the transfer from * @param to1 - account to transfer `value1` tokens to * @param value1 - tokens to transfer to account `to1` * @param to2 - account to transfer `value2` tokens to * @param value2 - tokens to transfer to account `to2` */ function internalDoubleTransfer (address from, address to1, uint value1, address to2, uint value2) internal { require(to1 != address(0x0) && to2 != address(0x0)); // Prevent people from accidentally burning their tokens balanceOf[from] = balanceOf[from].sub(value1.add(value2)); balanceOf[to1] = balanceOf[to1].add(value1); emit Transfer(from, to1, value1); if (value2 > 0) { balanceOf[to2] = balanceOf[to2].add(value2); emit Transfer(from, to2, value2); } } /** * Internal method that makes sure that the given signature corresponds to a given data and is made by `signer`. * It utilizes three (four) standards of message signing in Ethereum, as at the moment of this smart contract * development there is no single signing standard defined. For example, Metamask and Geth both support * personal_sign standard, SignTypedData is only supported by Matamask, Trezor does not support "widely adopted" * Ethereum personal_sign but rather personal_sign with fixed prefix and so on. * Note that it is always possible to forge any of these signatures using the private key, the problem is that * third-party wallets must adopt a single standard for signing messages. * @param data - original data which had to be signed by `signer` * @param signer - account which made a signature * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use * @param sigDest - for which type of action this signature was made */ function requireSignature ( bytes32 data, address signer, uint256 deadline, uint256 sigId, bytes memory sig, sigStandard sigStd, sigDestination sigDest ) internal { bytes32 r; bytes32 s; uint8 v; assembly { // solium-disable-line security/no-inline-assembly r := mload(add(sig, 32)) s := mload(add(sig, 64)) v := byte(0, mload(add(sig, 96))) } if (v < 27) v += 27; require(block.timestamp <= deadline && !usedSigIds[signer][sigId]); // solium-disable-line security/no-block-members if (sigStd == sigStandard.typed) { // Typed signature. This is the most likely scenario to be used and accepted require( signer == ecrecover( keccak256(abi.encodePacked( sigDest == sigDestination.transfer ? sigDestinationTransfer : sigDest == sigDestination.approve ? sigDestinationApprove : sigDest == sigDestination.approveAndCall ? sigDestinationApproveAndCall : sigDestinationTransferFrom, data )), v, r, s ) ); } else if (sigStd == sigStandard.personal) { // Ethereum signed message signature (Geth and Trezor) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "32", data)), v, r, s) // Geth-adopted || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x20", data)), v, r, s) // Trezor-adopted ); } else { // == 2; Signed string hash signature (the most expensive but universal) require( signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "64", hexToString(data))), v, r, s) // Geth || signer == ecrecover(keccak256(abi.encodePacked(ethSignedMessagePrefix, "\x40", hexToString(data))), v, r, s) // Trezor ); } usedSigIds[signer][sigId] = true; } /** * Utility costly function to encode bytes HEX representation as string. * @param sig - signature as bytes32 to represent as string */ function hexToString (bytes32 sig) internal pure returns (bytes memory) { bytes memory str = new bytes(64); for (uint8 i = 0; i < 32; ++i) { str[2 * i] = byte((uint8(sig[i]) / 16 < 10 ? 48 : 87) + uint8(sig[i]) / 16); str[2 * i + 1] = byte((uint8(sig[i]) % 16 < 10 ? 48 : 87) + (uint8(sig[i]) % 16)); } return str; } /** * Transfer `value` tokens to `to` address from the account of sender. * @param to - the address of the recipient * @param value - the amount to send */ function transfer (address to, uint256 value) public returns (bool) { internalTransfer(msg.sender, to, value); return true; } /** * This function distincts transaction signer from transaction executor. It allows anyone to transfer tokens * from the `from` account by providing a valid signature, which can only be obtained from the `from` account * owner. * Note that passed parameter sigId is unique and cannot be passed twice (prevents replay attacks). When there's * a need to make signature once again (because the first one is lost or whatever), user should sign the message * with the same sigId, thus ensuring that the previous signature can't be used if the new one passes. * Use case: the user wants to send some tokens to another user or smart contract, but don't have Ether to do so. * @param from - the account giving its signature to transfer `value` tokens to `to` address * @param to - the account receiving `value` tokens * @param value - the value in tokens to transfer * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferViaSignature ( address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.transfer ); internalDoubleTransfer(from, to, value, feeRecipient, fee); return true; } /** * Allow `spender` to take `value` tokens from the transaction sender's account. * Beware that changing an allowance with this method brings the risk that `spender` 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 authorized to spend * @param value - the maximum amount they can spend */ function approve (address spender, uint256 value) public returns (bool) { allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * Same as `transferViaSignature`, but for `approve`. * Use case: the user wants to set an allowance for the smart contract or another user without having Ether on * their balance. * @param from - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address * @param value - the value in tokens to approve to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveViaSignature ( address from, address spender, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, spender, value, fee, feeRecipient, deadline, sigId)), from, deadline, sigId, sig, sigStd, sigDestination.approve ); allowance[from][spender] = value; emit Approval(from, spender, value); internalTransfer(from, feeRecipient, fee); return true; } /** * Transfer `value` tokens to `to` address from the `from` account, using the previously set allowance. * @param from - the address to transfer tokens from * @param to - the address of the recipient * @param value - the amount to send */ function transferFrom (address from, address to, uint256 value) public returns (bool) { allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); internalTransfer(from, to, value); return true; } /** * Same as `transferViaSignature`, but for `transferFrom`. * Use case: the user wants to withdraw tokens from a smart contract or another user who allowed the user to * do so. Important note: the fee is subtracted from the `value`, and `to` address receives `value - fee`. * @param signer - the address allowed to call transferFrom, which signed all below parameters * @param from - the account to make withdrawal from * @param to - the address of the recipient * @param value - the value in tokens to withdraw * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function transferFromViaSignature ( address signer, address from, address to, uint256 value, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), from, to, value, fee, feeRecipient, deadline, sigId)), signer, deadline, sigId, sig, sigStd, sigDestination.transferFrom ); allowance[from][signer] = allowance[from][signer].sub(value); internalDoubleTransfer(from, to, value.sub(fee), feeRecipient, fee); return true; } /** * Utility function, which acts the same as approve(...), but also calls `receiveApproval` function on a * `spender` address, which is usually the address of the smart contract. In the same call, smart contract can * withdraw tokens from the sender's account and receive additional `extraData` for processing. * @param spender - the address to be authorized to spend tokens * @param value - the max amount the `spender` can withdraw * @param extraData - some extra information to send to the approved contract */ function approveAndCall (address spender, uint256 value, bytes memory extraData) public returns (bool) { approve(spender, value); tokenRecipient(spender).receiveApproval(msg.sender, value, address(this), extraData); return true; } /** * Same as `approveViaSignature`, but for `approveAndCall`. * Use case: the user wants to send tokens to the smart contract and pass additional data within one transaction. * @param fromAddress - the account to approve withdrawal from, which signed all below parameters * @param spender - the account allowed to withdraw tokens from `from` address (in this case, smart contract only) * @param value - the value in tokens to approve to withdraw * @param extraData - additional data to pass to the `spender` smart contract * @param fee - a fee to pay to `feeRecipient` * @param feeRecipient - account which will receive fee * @param deadline - until when the signature is valid * @param sigId - signature unique ID. Signatures made with the same signature ID cannot be submitted twice * @param sig - signature made by `from`, which is the proof of `from`'s agreement with the above parameters * @param sigStd - chosen standard for signature validation. The signer must explicitly tell which standard they use */ function approveAndCallViaSignature ( address fromAddress, address spender, uint256 value, bytes calldata extraData, uint256 fee, address feeRecipient, uint256 deadline, uint256 sigId, bytes calldata sig, sigStandard sigStd ) external returns (bool) { requireSignature( keccak256(abi.encodePacked(address(this), fromAddress, spender, value, extraData, fee, feeRecipient, deadline, sigId)), fromAddress, deadline, sigId, sig, sigStd, sigDestination.approveAndCall); allowance[fromAddress][spender] = value; emit Approval(fromAddress, spender, value); tokenRecipient(spender).receiveApproval(fromAddress, value, address(this), extraData); internalTransfer(fromAddress, feeRecipient, fee); return true; } /** * Mint some tokens to the sender's address. */ function mintTokens (uint newSupply) onlyOwner external { totalSupply = totalSupply.add(newSupply); balanceOf[msg.sender] = balanceOf[msg.sender].add(newSupply); emit Transfer(address(0x0), msg.sender, newSupply); } /** * ERC20 tokens are not designed to hold any other tokens (or Ether) on their balances. There were thousands * of cases when people accidentally transfer tokens to a contract address while there is no way to get them * back. This function adds a possibility to "rescue" tokens that were accidentally sent to this smart contract. * @param tokenContract - ERC20-compatible token * @param value - amount to rescue */ function rescueLostTokens (ERC20CompatibleToken tokenContract, uint256 value) external rescueAccountOnly { tokenContract.transfer(rescueAccount, value); } /** * Utility function that allows to change the rescueAccount address, which can "rescue" tokens accidentally sent to * this smart contract address. * @param newRescueAccount - account which will become authorized to rescue tokens */ function changeRescueAccount (address newRescueAccount) external rescueAccountOnly { rescueAccount = newRescueAccount; } }
changeRescueAccount
function changeRescueAccount (address newRescueAccount) external rescueAccountOnly { rescueAccount = newRescueAccount; }
/** * Utility function that allows to change the rescueAccount address, which can "rescue" tokens accidentally sent to * this smart contract address. * @param newRescueAccount - account which will become authorized to rescue tokens */
NatSpecMultiLine
v0.7.0+commit.9e61f92b
MIT
ipfs://1c92a1cb9cad01da0fc8472ee8f3e46eb4a79231c12969194d28b064750262d8
{ "func_code_index": [ 21764, 21903 ] }
8,453
Token
contracts/Token.sol
0xef811e8ea1c406cd1df7c953e45acfc4deb72e3d
Solidity
Token
contract Token is IERC20 { using SafeMath for uint256; string public constant name = "GICCOIN"; string public constant symbol = "GICC"; uint256 public constant decimals = 18; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; constructor(address banker) public { uint256 amount = 3 * (10 ** 8) * (10 ** decimals); _totalSupply = _totalSupply.add(amount); _balances[banker] = amount; emit Transfer(address(0), banker, amount); } /** * @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 A 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 to 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) { _approve(msg.sender, spender, value); return true; } /** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @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) { _transfer(from, to, value); _approve(from, msg.sender, _allowed[from][msg.sender].sub(value)); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when _allowed[msg.sender][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 * Emits an Approval event. * @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) { _approve(msg.sender, spender, _allowed[msg.sender][spender].add(addedValue)); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when _allowed[msg.sender][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 * Emits an Approval event. * @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) { _approve(msg.sender, spender, _allowed[msg.sender][spender].sub(subtractedValue)); 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(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } /** * @dev Approve an address to spend another addresses' tokens. * @param owner The address that owns the tokens. * @param spender The address that will spend the tokens. * @param value The number of tokens that can be spent. */ function _approve(address owner, address spender, uint256 value) internal { require(spender != address(0)); require(owner != address(0)); _allowed[owner][spender] = value; emit Approval(owner, spender, value); } }
totalSupply
function totalSupply() public view returns (uint256) { return _totalSupply; }
/** * @dev Total number of tokens in existence */
NatSpecMultiLine
v0.5.16+commit.9c3226ce
MIT
bzzr://fe85284af70a7db7a4e4c6638e7cf6e3157abdc6f5c0beef93872488ebe0c783
{ "func_code_index": [ 682, 778 ] }
8,454
Token
contracts/Token.sol
0xef811e8ea1c406cd1df7c953e45acfc4deb72e3d
Solidity
Token
contract Token is IERC20 { using SafeMath for uint256; string public constant name = "GICCOIN"; string public constant symbol = "GICC"; uint256 public constant decimals = 18; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; constructor(address banker) public { uint256 amount = 3 * (10 ** 8) * (10 ** decimals); _totalSupply = _totalSupply.add(amount); _balances[banker] = amount; emit Transfer(address(0), banker, amount); } /** * @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 A 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 to 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) { _approve(msg.sender, spender, value); return true; } /** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @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) { _transfer(from, to, value); _approve(from, msg.sender, _allowed[from][msg.sender].sub(value)); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when _allowed[msg.sender][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 * Emits an Approval event. * @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) { _approve(msg.sender, spender, _allowed[msg.sender][spender].add(addedValue)); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when _allowed[msg.sender][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 * Emits an Approval event. * @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) { _approve(msg.sender, spender, _allowed[msg.sender][spender].sub(subtractedValue)); 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(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } /** * @dev Approve an address to spend another addresses' tokens. * @param owner The address that owns the tokens. * @param spender The address that will spend the tokens. * @param value The number of tokens that can be spent. */ function _approve(address owner, address spender, uint256 value) internal { require(spender != address(0)); require(owner != address(0)); _allowed[owner][spender] = value; emit Approval(owner, spender, 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 A uint256 representing the amount owned by the passed address. */
NatSpecMultiLine
v0.5.16+commit.9c3226ce
MIT
bzzr://fe85284af70a7db7a4e4c6638e7cf6e3157abdc6f5c0beef93872488ebe0c783
{ "func_code_index": [ 992, 1103 ] }
8,455
Token
contracts/Token.sol
0xef811e8ea1c406cd1df7c953e45acfc4deb72e3d
Solidity
Token
contract Token is IERC20 { using SafeMath for uint256; string public constant name = "GICCOIN"; string public constant symbol = "GICC"; uint256 public constant decimals = 18; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; constructor(address banker) public { uint256 amount = 3 * (10 ** 8) * (10 ** decimals); _totalSupply = _totalSupply.add(amount); _balances[banker] = amount; emit Transfer(address(0), banker, amount); } /** * @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 A 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 to 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) { _approve(msg.sender, spender, value); return true; } /** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @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) { _transfer(from, to, value); _approve(from, msg.sender, _allowed[from][msg.sender].sub(value)); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when _allowed[msg.sender][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 * Emits an Approval event. * @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) { _approve(msg.sender, spender, _allowed[msg.sender][spender].add(addedValue)); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when _allowed[msg.sender][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 * Emits an Approval event. * @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) { _approve(msg.sender, spender, _allowed[msg.sender][spender].sub(subtractedValue)); 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(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } /** * @dev Approve an address to spend another addresses' tokens. * @param owner The address that owns the tokens. * @param spender The address that will spend the tokens. * @param value The number of tokens that can be spent. */ function _approve(address owner, address spender, uint256 value) internal { require(spender != address(0)); require(owner != address(0)); _allowed[owner][spender] = value; emit Approval(owner, spender, 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.5.16+commit.9c3226ce
MIT
bzzr://fe85284af70a7db7a4e4c6638e7cf6e3157abdc6f5c0beef93872488ebe0c783
{ "func_code_index": [ 1437, 1573 ] }
8,456
Token
contracts/Token.sol
0xef811e8ea1c406cd1df7c953e45acfc4deb72e3d
Solidity
Token
contract Token is IERC20 { using SafeMath for uint256; string public constant name = "GICCOIN"; string public constant symbol = "GICC"; uint256 public constant decimals = 18; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; constructor(address banker) public { uint256 amount = 3 * (10 ** 8) * (10 ** decimals); _totalSupply = _totalSupply.add(amount); _balances[banker] = amount; emit Transfer(address(0), banker, amount); } /** * @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 A 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 to 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) { _approve(msg.sender, spender, value); return true; } /** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @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) { _transfer(from, to, value); _approve(from, msg.sender, _allowed[from][msg.sender].sub(value)); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when _allowed[msg.sender][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 * Emits an Approval event. * @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) { _approve(msg.sender, spender, _allowed[msg.sender][spender].add(addedValue)); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when _allowed[msg.sender][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 * Emits an Approval event. * @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) { _approve(msg.sender, spender, _allowed[msg.sender][spender].sub(subtractedValue)); 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(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } /** * @dev Approve an address to spend another addresses' tokens. * @param owner The address that owns the tokens. * @param spender The address that will spend the tokens. * @param value The number of tokens that can be spent. */ function _approve(address owner, address spender, uint256 value) internal { require(spender != address(0)); require(owner != address(0)); _allowed[owner][spender] = value; emit Approval(owner, spender, value); } }
transfer
function transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, to, value); return true; }
/** * @dev Transfer token to a specified address * @param to The address to transfer to. * @param value The amount to be transferred. */
NatSpecMultiLine
v0.5.16+commit.9c3226ce
MIT
bzzr://fe85284af70a7db7a4e4c6638e7cf6e3157abdc6f5c0beef93872488ebe0c783
{ "func_code_index": [ 1742, 1887 ] }
8,457
Token
contracts/Token.sol
0xef811e8ea1c406cd1df7c953e45acfc4deb72e3d
Solidity
Token
contract Token is IERC20 { using SafeMath for uint256; string public constant name = "GICCOIN"; string public constant symbol = "GICC"; uint256 public constant decimals = 18; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; constructor(address banker) public { uint256 amount = 3 * (10 ** 8) * (10 ** decimals); _totalSupply = _totalSupply.add(amount); _balances[banker] = amount; emit Transfer(address(0), banker, amount); } /** * @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 A 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 to 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) { _approve(msg.sender, spender, value); return true; } /** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @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) { _transfer(from, to, value); _approve(from, msg.sender, _allowed[from][msg.sender].sub(value)); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when _allowed[msg.sender][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 * Emits an Approval event. * @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) { _approve(msg.sender, spender, _allowed[msg.sender][spender].add(addedValue)); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when _allowed[msg.sender][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 * Emits an Approval event. * @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) { _approve(msg.sender, spender, _allowed[msg.sender][spender].sub(subtractedValue)); 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(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } /** * @dev Approve an address to spend another addresses' tokens. * @param owner The address that owns the tokens. * @param spender The address that will spend the tokens. * @param value The number of tokens that can be spent. */ function _approve(address owner, address spender, uint256 value) internal { require(spender != address(0)); require(owner != address(0)); _allowed[owner][spender] = value; emit Approval(owner, spender, value); } }
approve
function approve(address spender, uint256 value) public returns (bool) { _approve(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.5.16+commit.9c3226ce
MIT
bzzr://fe85284af70a7db7a4e4c6638e7cf6e3157abdc6f5c0beef93872488ebe0c783
{ "func_code_index": [ 2529, 2682 ] }
8,458
Token
contracts/Token.sol
0xef811e8ea1c406cd1df7c953e45acfc4deb72e3d
Solidity
Token
contract Token is IERC20 { using SafeMath for uint256; string public constant name = "GICCOIN"; string public constant symbol = "GICC"; uint256 public constant decimals = 18; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; constructor(address banker) public { uint256 amount = 3 * (10 ** 8) * (10 ** decimals); _totalSupply = _totalSupply.add(amount); _balances[banker] = amount; emit Transfer(address(0), banker, amount); } /** * @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 A 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 to 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) { _approve(msg.sender, spender, value); return true; } /** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @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) { _transfer(from, to, value); _approve(from, msg.sender, _allowed[from][msg.sender].sub(value)); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when _allowed[msg.sender][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 * Emits an Approval event. * @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) { _approve(msg.sender, spender, _allowed[msg.sender][spender].add(addedValue)); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when _allowed[msg.sender][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 * Emits an Approval event. * @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) { _approve(msg.sender, spender, _allowed[msg.sender][spender].sub(subtractedValue)); 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(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } /** * @dev Approve an address to spend another addresses' tokens. * @param owner The address that owns the tokens. * @param spender The address that will spend the tokens. * @param value The number of tokens that can be spent. */ function _approve(address owner, address spender, uint256 value) internal { require(spender != address(0)); require(owner != address(0)); _allowed[owner][spender] = value; emit Approval(owner, spender, value); } }
transferFrom
function transferFrom(address from, address to, uint256 value) public returns (bool) { _transfer(from, to, value); _approve(from, msg.sender, _allowed[from][msg.sender].sub(value)); return true; }
/** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @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.5.16+commit.9c3226ce
MIT
bzzr://fe85284af70a7db7a4e4c6638e7cf6e3157abdc6f5c0beef93872488ebe0c783
{ "func_code_index": [ 3150, 3383 ] }
8,459
Token
contracts/Token.sol
0xef811e8ea1c406cd1df7c953e45acfc4deb72e3d
Solidity
Token
contract Token is IERC20 { using SafeMath for uint256; string public constant name = "GICCOIN"; string public constant symbol = "GICC"; uint256 public constant decimals = 18; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; constructor(address banker) public { uint256 amount = 3 * (10 ** 8) * (10 ** decimals); _totalSupply = _totalSupply.add(amount); _balances[banker] = amount; emit Transfer(address(0), banker, amount); } /** * @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 A 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 to 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) { _approve(msg.sender, spender, value); return true; } /** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @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) { _transfer(from, to, value); _approve(from, msg.sender, _allowed[from][msg.sender].sub(value)); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when _allowed[msg.sender][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 * Emits an Approval event. * @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) { _approve(msg.sender, spender, _allowed[msg.sender][spender].add(addedValue)); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when _allowed[msg.sender][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 * Emits an Approval event. * @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) { _approve(msg.sender, spender, _allowed[msg.sender][spender].sub(subtractedValue)); 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(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } /** * @dev Approve an address to spend another addresses' tokens. * @param owner The address that owns the tokens. * @param spender The address that will spend the tokens. * @param value The number of tokens that can be spent. */ function _approve(address owner, address spender, uint256 value) internal { require(spender != address(0)); require(owner != address(0)); _allowed[owner][spender] = value; emit Approval(owner, spender, value); } }
increaseAllowance
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(msg.sender, spender, _allowed[msg.sender][spender].add(addedValue)); return true; }
/** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when _allowed[msg.sender][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 * Emits an Approval event. * @param spender The address which will spend the funds. * @param addedValue The amount of tokens to increase the allowance by. */
NatSpecMultiLine
v0.5.16+commit.9c3226ce
MIT
bzzr://fe85284af70a7db7a4e4c6638e7cf6e3157abdc6f5c0beef93872488ebe0c783
{ "func_code_index": [ 3904, 4112 ] }
8,460
Token
contracts/Token.sol
0xef811e8ea1c406cd1df7c953e45acfc4deb72e3d
Solidity
Token
contract Token is IERC20 { using SafeMath for uint256; string public constant name = "GICCOIN"; string public constant symbol = "GICC"; uint256 public constant decimals = 18; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; constructor(address banker) public { uint256 amount = 3 * (10 ** 8) * (10 ** decimals); _totalSupply = _totalSupply.add(amount); _balances[banker] = amount; emit Transfer(address(0), banker, amount); } /** * @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 A 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 to 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) { _approve(msg.sender, spender, value); return true; } /** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @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) { _transfer(from, to, value); _approve(from, msg.sender, _allowed[from][msg.sender].sub(value)); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when _allowed[msg.sender][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 * Emits an Approval event. * @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) { _approve(msg.sender, spender, _allowed[msg.sender][spender].add(addedValue)); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when _allowed[msg.sender][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 * Emits an Approval event. * @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) { _approve(msg.sender, spender, _allowed[msg.sender][spender].sub(subtractedValue)); 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(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } /** * @dev Approve an address to spend another addresses' tokens. * @param owner The address that owns the tokens. * @param spender The address that will spend the tokens. * @param value The number of tokens that can be spent. */ function _approve(address owner, address spender, uint256 value) internal { require(spender != address(0)); require(owner != address(0)); _allowed[owner][spender] = value; emit Approval(owner, spender, value); } }
decreaseAllowance
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(msg.sender, spender, _allowed[msg.sender][spender].sub(subtractedValue)); return true; }
/** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when _allowed[msg.sender][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 * Emits an Approval event. * @param spender The address which will spend the funds. * @param subtractedValue The amount of tokens to decrease the allowance by. */
NatSpecMultiLine
v0.5.16+commit.9c3226ce
MIT
bzzr://fe85284af70a7db7a4e4c6638e7cf6e3157abdc6f5c0beef93872488ebe0c783
{ "func_code_index": [ 4638, 4856 ] }
8,461
Token
contracts/Token.sol
0xef811e8ea1c406cd1df7c953e45acfc4deb72e3d
Solidity
Token
contract Token is IERC20 { using SafeMath for uint256; string public constant name = "GICCOIN"; string public constant symbol = "GICC"; uint256 public constant decimals = 18; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; constructor(address banker) public { uint256 amount = 3 * (10 ** 8) * (10 ** decimals); _totalSupply = _totalSupply.add(amount); _balances[banker] = amount; emit Transfer(address(0), banker, amount); } /** * @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 A 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 to 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) { _approve(msg.sender, spender, value); return true; } /** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @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) { _transfer(from, to, value); _approve(from, msg.sender, _allowed[from][msg.sender].sub(value)); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when _allowed[msg.sender][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 * Emits an Approval event. * @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) { _approve(msg.sender, spender, _allowed[msg.sender][spender].add(addedValue)); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when _allowed[msg.sender][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 * Emits an Approval event. * @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) { _approve(msg.sender, spender, _allowed[msg.sender][spender].sub(subtractedValue)); 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(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } /** * @dev Approve an address to spend another addresses' tokens. * @param owner The address that owns the tokens. * @param spender The address that will spend the tokens. * @param value The number of tokens that can be spent. */ function _approve(address owner, address spender, uint256 value) internal { require(spender != address(0)); require(owner != address(0)); _allowed[owner][spender] = value; emit Approval(owner, spender, value); } }
_transfer
function _transfer(address from, address to, uint256 value) internal { 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.5.16+commit.9c3226ce
MIT
bzzr://fe85284af70a7db7a4e4c6638e7cf6e3157abdc6f5c0beef93872488ebe0c783
{ "func_code_index": [ 5078, 5345 ] }
8,462
Token
contracts/Token.sol
0xef811e8ea1c406cd1df7c953e45acfc4deb72e3d
Solidity
Token
contract Token is IERC20 { using SafeMath for uint256; string public constant name = "GICCOIN"; string public constant symbol = "GICC"; uint256 public constant decimals = 18; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; constructor(address banker) public { uint256 amount = 3 * (10 ** 8) * (10 ** decimals); _totalSupply = _totalSupply.add(amount); _balances[banker] = amount; emit Transfer(address(0), banker, amount); } /** * @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 A 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 to 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) { _approve(msg.sender, spender, value); return true; } /** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @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) { _transfer(from, to, value); _approve(from, msg.sender, _allowed[from][msg.sender].sub(value)); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when _allowed[msg.sender][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 * Emits an Approval event. * @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) { _approve(msg.sender, spender, _allowed[msg.sender][spender].add(addedValue)); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when _allowed[msg.sender][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 * Emits an Approval event. * @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) { _approve(msg.sender, spender, _allowed[msg.sender][spender].sub(subtractedValue)); 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(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } /** * @dev Approve an address to spend another addresses' tokens. * @param owner The address that owns the tokens. * @param spender The address that will spend the tokens. * @param value The number of tokens that can be spent. */ function _approve(address owner, address spender, uint256 value) internal { require(spender != address(0)); require(owner != address(0)); _allowed[owner][spender] = value; emit Approval(owner, spender, value); } }
_approve
function _approve(address owner, address spender, uint256 value) internal { require(spender != address(0)); require(owner != address(0)); _allowed[owner][spender] = value; emit Approval(owner, spender, value); }
/** * @dev Approve an address to spend another addresses' tokens. * @param owner The address that owns the tokens. * @param spender The address that will spend the tokens. * @param value The number of tokens that can be spent. */
NatSpecMultiLine
v0.5.16+commit.9c3226ce
MIT
bzzr://fe85284af70a7db7a4e4c6638e7cf6e3157abdc6f5c0beef93872488ebe0c783
{ "func_code_index": [ 5613, 5872 ] }
8,463
PSIToken
PSIToken.sol
0x7a9fe66f0f288e2598788f21e5ed4aa332eef122
Solidity
BasicToken
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); 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 constant returns (uint256 balance) { return balances[_owner]; } }
transfer
function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; }
/** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://a4e96efb982900a61947623ecbc780dc5fb29defd195e343933d25cdb3c2c158
{ "func_code_index": [ 268, 664 ] }
8,464
PSIToken
PSIToken.sol
0x7a9fe66f0f288e2598788f21e5ed4aa332eef122
Solidity
BasicToken
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); 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 constant returns (uint256 balance) { return balances[_owner]; } }
balanceOf
function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; }
/** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://a4e96efb982900a61947623ecbc780dc5fb29defd195e343933d25cdb3c2c158
{ "func_code_index": [ 870, 986 ] }
8,465
PSIToken
PSIToken.sol
0x7a9fe66f0f288e2598788f21e5ed4aa332eef122
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. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; 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 constant returns (uint256 remaining) { return allowed[_owner][_spender]; } }
transferFrom
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; }
/** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://a4e96efb982900a61947623ecbc780dc5fb29defd195e343933d25cdb3c2c158
{ "func_code_index": [ 401, 858 ] }
8,466
PSIToken
PSIToken.sol
0x7a9fe66f0f288e2598788f21e5ed4aa332eef122
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. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; 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 constant returns (uint256 remaining) { return allowed[_owner][_spender]; } }
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. * * 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
bzzr://a4e96efb982900a61947623ecbc780dc5fb29defd195e343933d25cdb3c2c158
{ "func_code_index": [ 1490, 1685 ] }
8,467
PSIToken
PSIToken.sol
0x7a9fe66f0f288e2598788f21e5ed4aa332eef122
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. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; 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 constant returns (uint256 remaining) { return allowed[_owner][_spender]; } }
allowance
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; }
/** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://a4e96efb982900a61947623ecbc780dc5fb29defd195e343933d25cdb3c2c158
{ "func_code_index": [ 2009, 2154 ] }
8,468
PSIToken
PSIToken.sol
0x7a9fe66f0f288e2598788f21e5ed4aa332eef122
Solidity
PSIToken
contract PSIToken is StandardToken { string public constant name = "PSI Token"; string public constant symbol = "PSI"; uint8 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 1000000000 * (10 ** uint256(decimals)); /** * @dev Constructor that gives msg.sender all of existing tokens. */ function PSIToken() public { totalSupply = INITIAL_SUPPLY; //Round A Investors 15% balances[0xa801fcD3CDf65206F567645A3E8c4537739334A2] = 150000000 * (10 ** uint256(decimals)); emit Transfer(msg.sender, 0xa801fcD3CDf65206F567645A3E8c4537739334A2, 150000000 * (10 ** uint256(decimals))); //Presales Mining 35% balances[0xE95aaFA9286337c89746c97fFBD084aD90AFF8Df] = 350000000 * (10 ** uint256(decimals)); emit Transfer(msg.sender,0xE95aaFA9286337c89746c97fFBD084aD90AFF8Df, 350000000 * (10 ** uint256(decimals))); //Community 10% balances[0xDCe73461af69C315B87dbb015F3e1341294d72c7] = 100000000 * (10 ** uint256(decimals)); emit Transfer(msg.sender, 0xDCe73461af69C315B87dbb015F3e1341294d72c7, 100000000 * (10 ** uint256(decimals))); //Platform Sales 23% balances[0x0d5A4EBbC1599006fdd7999F0e1537b3e60f0dc0] = 230000000 * (10 ** uint256(decimals)); emit Transfer(msg.sender, 0x0d5A4EBbC1599006fdd7999F0e1537b3e60f0dc0, 230000000 * (10 ** uint256(decimals))); //Core Teams 12% balances[0x63de19f0028F8402264052D9163AC66ca0c8A26c] = 120000000 * (10 ** uint256(decimals)); emit Transfer(msg.sender,0x63de19f0028F8402264052D9163AC66ca0c8A26c, 120000000 * (10 ** uint256(decimals))); //Expense 3% balances[0x403121629cfa4fC39aAc8Bf331AD627B31AbCa29] = 30000000 * (10 ** uint256(decimals)); emit Transfer(msg.sender, 0x403121629cfa4fC39aAc8Bf331AD627B31AbCa29, 30000000 * (10 ** uint256(decimals))); //Bounty 2% balances[0xBD1acB661e8211EE462114d85182560F30BE7A94] = 20000000 * (10 ** uint256(decimals)); emit Transfer(msg.sender, 0xBD1acB661e8211EE462114d85182560F30BE7A94, 20000000 * (10 ** uint256(decimals))); } }
PSIToken
function PSIToken() public { totalSupply = INITIAL_SUPPLY; //Round A Investors 15% balances[0xa801fcD3CDf65206F567645A3E8c4537739334A2] = 150000000 * (10 ** uint256(decimals)); emit Transfer(msg.sender, 0xa801fcD3CDf65206F567645A3E8c4537739334A2, 150000000 * (10 ** uint256(decimals))); //Presales Mining 35% balances[0xE95aaFA9286337c89746c97fFBD084aD90AFF8Df] = 350000000 * (10 ** uint256(decimals)); emit Transfer(msg.sender,0xE95aaFA9286337c89746c97fFBD084aD90AFF8Df, 350000000 * (10 ** uint256(decimals))); //Community 10% balances[0xDCe73461af69C315B87dbb015F3e1341294d72c7] = 100000000 * (10 ** uint256(decimals)); emit Transfer(msg.sender, 0xDCe73461af69C315B87dbb015F3e1341294d72c7, 100000000 * (10 ** uint256(decimals))); //Platform Sales 23% balances[0x0d5A4EBbC1599006fdd7999F0e1537b3e60f0dc0] = 230000000 * (10 ** uint256(decimals)); emit Transfer(msg.sender, 0x0d5A4EBbC1599006fdd7999F0e1537b3e60f0dc0, 230000000 * (10 ** uint256(decimals))); //Core Teams 12% balances[0x63de19f0028F8402264052D9163AC66ca0c8A26c] = 120000000 * (10 ** uint256(decimals)); emit Transfer(msg.sender,0x63de19f0028F8402264052D9163AC66ca0c8A26c, 120000000 * (10 ** uint256(decimals))); //Expense 3% balances[0x403121629cfa4fC39aAc8Bf331AD627B31AbCa29] = 30000000 * (10 ** uint256(decimals)); emit Transfer(msg.sender, 0x403121629cfa4fC39aAc8Bf331AD627B31AbCa29, 30000000 * (10 ** uint256(decimals))); //Bounty 2% balances[0xBD1acB661e8211EE462114d85182560F30BE7A94] = 20000000 * (10 ** uint256(decimals)); emit Transfer(msg.sender, 0xBD1acB661e8211EE462114d85182560F30BE7A94, 20000000 * (10 ** uint256(decimals))); }
/** * @dev Constructor that gives msg.sender all of existing tokens. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://a4e96efb982900a61947623ecbc780dc5fb29defd195e343933d25cdb3c2c158
{ "func_code_index": [ 341, 2109 ] }
8,469
LinguaFranca
@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol
0x9a7a5ff2c9563e96fbbed4dda94d5549b30f1efb
Solidity
ERC721Enumerable
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } }
/** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */
NatSpecMultiLine
supportsInterface
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); }
/** * @dev See {IERC165-supportsInterface}. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://ec30ad3b2c7be55c484ddb84aa17c0c44a22d432c6fab023a60ec5e2d7d4b3de
{ "func_code_index": [ 605, 834 ] }
8,470
LinguaFranca
@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol
0x9a7a5ff2c9563e96fbbed4dda94d5549b30f1efb
Solidity
ERC721Enumerable
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } }
/** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */
NatSpecMultiLine
tokenOfOwnerByIndex
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; }
/** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://ec30ad3b2c7be55c484ddb84aa17c0c44a22d432c6fab023a60ec5e2d7d4b3de
{ "func_code_index": [ 913, 1174 ] }
8,471
LinguaFranca
@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol
0x9a7a5ff2c9563e96fbbed4dda94d5549b30f1efb
Solidity
ERC721Enumerable
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } }
/** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */
NatSpecMultiLine
totalSupply
function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; }
/** * @dev See {IERC721Enumerable-totalSupply}. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://ec30ad3b2c7be55c484ddb84aa17c0c44a22d432c6fab023a60ec5e2d7d4b3de
{ "func_code_index": [ 1245, 1363 ] }
8,472
LinguaFranca
@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol
0x9a7a5ff2c9563e96fbbed4dda94d5549b30f1efb
Solidity
ERC721Enumerable
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } }
/** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */
NatSpecMultiLine
tokenByIndex
function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; }
/** * @dev See {IERC721Enumerable-tokenByIndex}. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://ec30ad3b2c7be55c484ddb84aa17c0c44a22d432c6fab023a60ec5e2d7d4b3de
{ "func_code_index": [ 1435, 1673 ] }
8,473
PENCECOIN
PENCECOIN.sol
0x6c4fee44acccb6e44af41862f509c74892f1445f
Solidity
PENCECOIN
contract PENCECOIN { // 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); /** * Constructor 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` on 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 on 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 on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, address(this), _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply emit Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply emit Burn(_from, _value); return true; } }
_transfer
function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != address(0x0)); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value >= balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; emit Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); }
/** * Internal transfer, only can be called by this contract */
NatSpecMultiLine
v0.5.11+commit.c082d0b4
None
bzzr://ee3158c552befdd2c08c79d872bb19979b45b87745e5e58f4c574c6c00606156
{ "func_code_index": [ 1649, 2506 ] }
8,474
PENCECOIN
PENCECOIN.sol
0x6c4fee44acccb6e44af41862f509c74892f1445f
Solidity
PENCECOIN
contract PENCECOIN { // 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); /** * Constructor 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` on 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 on 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 on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, address(this), _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply emit Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply emit Burn(_from, _value); return true; } }
transfer
function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; }
/** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */
NatSpecMultiLine
v0.5.11+commit.c082d0b4
None
bzzr://ee3158c552befdd2c08c79d872bb19979b45b87745e5e58f4c574c6c00606156
{ "func_code_index": [ 2712, 2869 ] }
8,475
PENCECOIN
PENCECOIN.sol
0x6c4fee44acccb6e44af41862f509c74892f1445f
Solidity
PENCECOIN
contract PENCECOIN { // 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); /** * Constructor 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` on 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 on 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 on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, address(this), _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply emit Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply emit Burn(_from, _value); return true; } }
transferFrom
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; }
/** * Transfer tokens from other address * * Send `_value` tokens to `_to` on 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.11+commit.c082d0b4
None
bzzr://ee3158c552befdd2c08c79d872bb19979b45b87745e5e58f4c574c6c00606156
{ "func_code_index": [ 3144, 3445 ] }
8,476
PENCECOIN
PENCECOIN.sol
0x6c4fee44acccb6e44af41862f509c74892f1445f
Solidity
PENCECOIN
contract PENCECOIN { // 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); /** * Constructor 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` on 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 on 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 on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, address(this), _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply emit Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply emit Burn(_from, _value); return true; } }
approve
function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; }
/** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens on your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */
NatSpecMultiLine
v0.5.11+commit.c082d0b4
None
bzzr://ee3158c552befdd2c08c79d872bb19979b45b87745e5e58f4c574c6c00606156
{ "func_code_index": [ 3709, 3939 ] }
8,477
PENCECOIN
PENCECOIN.sol
0x6c4fee44acccb6e44af41862f509c74892f1445f
Solidity
PENCECOIN
contract PENCECOIN { // 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); /** * Constructor 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` on 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 on 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 on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, address(this), _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply emit Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply emit Burn(_from, _value); return true; } }
approveAndCall
function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, address(this), _extraData); return true; } }
/** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens on 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.11+commit.c082d0b4
None
bzzr://ee3158c552befdd2c08c79d872bb19979b45b87745e5e58f4c574c6c00606156
{ "func_code_index": [ 4333, 4701 ] }
8,478
PENCECOIN
PENCECOIN.sol
0x6c4fee44acccb6e44af41862f509c74892f1445f
Solidity
PENCECOIN
contract PENCECOIN { // 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); /** * Constructor 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` on 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 on 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 on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, address(this), _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply emit Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply emit Burn(_from, _value); return true; } }
burn
function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply emit Burn(msg.sender, _value); return true; }
/** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */
NatSpecMultiLine
v0.5.11+commit.c082d0b4
None
bzzr://ee3158c552befdd2c08c79d872bb19979b45b87745e5e58f4c574c6c00606156
{ "func_code_index": [ 4871, 5250 ] }
8,479
PENCECOIN
PENCECOIN.sol
0x6c4fee44acccb6e44af41862f509c74892f1445f
Solidity
PENCECOIN
contract PENCECOIN { // 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); /** * Constructor 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` on 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 on 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 on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, address(this), _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply emit Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply emit Burn(_from, _value); return true; } }
burnFrom
function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply emit Burn(_from, _value); return true; }
/** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */
NatSpecMultiLine
v0.5.11+commit.c082d0b4
None
bzzr://ee3158c552befdd2c08c79d872bb19979b45b87745e5e58f4c574c6c00606156
{ "func_code_index": [ 5508, 6124 ] }
8,480
OpethZap
contracts/OpethZap.sol
0x859adef853012c8b00804b55a5bc2b7732b4b5a6
Solidity
OpethZap
contract OpethZap { using SafeMath for uint; using SafeERC20 for IERC20; IERC20 public immutable weth; IERC20 public immutable usdc; Uni public immutable uni; IOpeth public immutable opeth; address payable public immutable exchange; address[] public path; constructor( IERC20 _weth, IERC20 _usdc, Uni _uni, IOpeth _opeth, address payable _exchange ) public { weth = _weth; usdc = _usdc; uni = _uni; opeth = _opeth; exchange = _exchange; // ETH -> USDC -> oToken path = new address[](2); path[0] = address(_weth); path[1] = address(_usdc); _usdc.safeApprove(_exchange, uint(-1)); } function mintWithEth( address oToken, uint _opeth, uint _oTokenPayment, uint _maxPayment, uint _0xFee, bytes calldata _0xSwapData ) external payable { uint _oToken = _opeth.div(1e10); WETH9(address(weth)).deposit{value: _opeth}(); weth.safeApprove(address(opeth), _opeth); IERC20(oToken).safeApprove(address(opeth), _oToken); _mint(oToken, _opeth, _oTokenPayment, _maxPayment, _0xFee, _0xSwapData); } function mint( address oToken, uint _opeth, uint _oTokenPayment, uint _maxPayment, uint _0xFee, bytes calldata _0xSwapData ) external payable { uint _oToken = _opeth.div(1e10); (address underlying,,uint _underlying) = opeth.getOpethDetails(oToken, _oToken); IERC20(underlying).safeTransferFrom(msg.sender, address(this), _underlying); IERC20(underlying).safeApprove(address(opeth), _underlying); IERC20(oToken).safeApprove(address(opeth), _oToken); _mint(oToken, _opeth, _oTokenPayment, _maxPayment, _0xFee, _0xSwapData); } /** * @param oToken opyn put option * @param _oTokenPayment USDC required for purchasing oTokens * @param _maxPayment in ETH for purchasing USDC; caps slippage * @param _0xFee 0x protocol fee. Any extra is refunded * @param _0xSwapData 0x swap encoded data */ function _mint( address oToken, uint _opeth, uint _oTokenPayment, uint _maxPayment, uint _0xFee, bytes calldata _0xSwapData ) internal { // Swap ETH for USDC (for purchasing oToken) Uni(uni).swapETHForExactTokens{value: _maxPayment}( _oTokenPayment, path, address(this), now ); // Purchase oToken (bool success,) = exchange.call{value: _0xFee}(_0xSwapData); require(success, "SWAP_CALL_FAILED"); opeth.mintFor(msg.sender, oToken, _opeth); // refund dust eth, if any safeTransferETH(msg.sender, address(this).balance); } function safeTransferETH(address to, uint value) internal { if (value > 0) { (bool success,) = to.call{value:value}(new bytes(0)); require(success, 'ETH_TRANSFER_FAILED'); } } receive() external payable { require( msg.sender == address(uni) || msg.sender == exchange, "Cannot receive ETH" ); } // Cannot receive ETH with calldata that doesnt match any function fallback() external payable { revert("Cannot receive ETH"); } }
_mint
function _mint( address oToken, uint _opeth, uint _oTokenPayment, uint _maxPayment, uint _0xFee, bytes calldata _0xSwapData ) internal { // Swap ETH for USDC (for purchasing oToken) Uni(uni).swapETHForExactTokens{value: _maxPayment}( _oTokenPayment, path, address(this), now ); // Purchase oToken (bool success,) = exchange.call{value: _0xFee}(_0xSwapData); require(success, "SWAP_CALL_FAILED"); opeth.mintFor(msg.sender, oToken, _opeth); // refund dust eth, if any safeTransferETH(msg.sender, address(this).balance); }
/** * @param oToken opyn put option * @param _oTokenPayment USDC required for purchasing oTokens * @param _maxPayment in ETH for purchasing USDC; caps slippage * @param _0xFee 0x protocol fee. Any extra is refunded * @param _0xSwapData 0x swap encoded data */
NatSpecMultiLine
v0.6.12+commit.27d51765
{ "func_code_index": [ 2174, 2876 ] }
8,481
OpethZap
contracts/OpethZap.sol
0x859adef853012c8b00804b55a5bc2b7732b4b5a6
Solidity
OpethZap
contract OpethZap { using SafeMath for uint; using SafeERC20 for IERC20; IERC20 public immutable weth; IERC20 public immutable usdc; Uni public immutable uni; IOpeth public immutable opeth; address payable public immutable exchange; address[] public path; constructor( IERC20 _weth, IERC20 _usdc, Uni _uni, IOpeth _opeth, address payable _exchange ) public { weth = _weth; usdc = _usdc; uni = _uni; opeth = _opeth; exchange = _exchange; // ETH -> USDC -> oToken path = new address[](2); path[0] = address(_weth); path[1] = address(_usdc); _usdc.safeApprove(_exchange, uint(-1)); } function mintWithEth( address oToken, uint _opeth, uint _oTokenPayment, uint _maxPayment, uint _0xFee, bytes calldata _0xSwapData ) external payable { uint _oToken = _opeth.div(1e10); WETH9(address(weth)).deposit{value: _opeth}(); weth.safeApprove(address(opeth), _opeth); IERC20(oToken).safeApprove(address(opeth), _oToken); _mint(oToken, _opeth, _oTokenPayment, _maxPayment, _0xFee, _0xSwapData); } function mint( address oToken, uint _opeth, uint _oTokenPayment, uint _maxPayment, uint _0xFee, bytes calldata _0xSwapData ) external payable { uint _oToken = _opeth.div(1e10); (address underlying,,uint _underlying) = opeth.getOpethDetails(oToken, _oToken); IERC20(underlying).safeTransferFrom(msg.sender, address(this), _underlying); IERC20(underlying).safeApprove(address(opeth), _underlying); IERC20(oToken).safeApprove(address(opeth), _oToken); _mint(oToken, _opeth, _oTokenPayment, _maxPayment, _0xFee, _0xSwapData); } /** * @param oToken opyn put option * @param _oTokenPayment USDC required for purchasing oTokens * @param _maxPayment in ETH for purchasing USDC; caps slippage * @param _0xFee 0x protocol fee. Any extra is refunded * @param _0xSwapData 0x swap encoded data */ function _mint( address oToken, uint _opeth, uint _oTokenPayment, uint _maxPayment, uint _0xFee, bytes calldata _0xSwapData ) internal { // Swap ETH for USDC (for purchasing oToken) Uni(uni).swapETHForExactTokens{value: _maxPayment}( _oTokenPayment, path, address(this), now ); // Purchase oToken (bool success,) = exchange.call{value: _0xFee}(_0xSwapData); require(success, "SWAP_CALL_FAILED"); opeth.mintFor(msg.sender, oToken, _opeth); // refund dust eth, if any safeTransferETH(msg.sender, address(this).balance); } function safeTransferETH(address to, uint value) internal { if (value > 0) { (bool success,) = to.call{value:value}(new bytes(0)); require(success, 'ETH_TRANSFER_FAILED'); } } receive() external payable { require( msg.sender == address(uni) || msg.sender == exchange, "Cannot receive ETH" ); } // Cannot receive ETH with calldata that doesnt match any function fallback() external payable { revert("Cannot receive ETH"); } }
// Cannot receive ETH with calldata that doesnt match any function
LineComment
v0.6.12+commit.27d51765
{ "func_code_index": [ 3341, 3418 ] }
8,482
Ethernauts
Ethernauts.sol
0x29f2068dcf08164875951d21afb561dd406b66d0
Solidity
IERC165
interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
/** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */
NatSpecMultiLine
supportsInterface
function supportsInterface(bytes4 interfaceId) external view returns (bool);
/** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://e6e199a6501c1abd2f665aafb15edbfc6e4cfebb0396d5b40518ccd27f4ae406
{ "func_code_index": [ 374, 455 ] }
8,483
Ethernauts
Ethernauts.sol
0x29f2068dcf08164875951d21afb561dd406b66d0
Solidity
IERC721
interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; }
/** * @dev Required interface of an ERC721 compliant contract. */
NatSpecMultiLine
balanceOf
function balanceOf(address owner) external view returns (uint256 balance);
/** * @dev Returns the number of tokens in ``owner``'s account. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://e6e199a6501c1abd2f665aafb15edbfc6e4cfebb0396d5b40518ccd27f4ae406
{ "func_code_index": [ 719, 798 ] }
8,484
Ethernauts
Ethernauts.sol
0x29f2068dcf08164875951d21afb561dd406b66d0
Solidity
IERC721
interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; }
/** * @dev Required interface of an ERC721 compliant contract. */
NatSpecMultiLine
ownerOf
function ownerOf(uint256 tokenId) external view returns (address owner);
/** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://e6e199a6501c1abd2f665aafb15edbfc6e4cfebb0396d5b40518ccd27f4ae406
{ "func_code_index": [ 944, 1021 ] }
8,485
Ethernauts
Ethernauts.sol
0x29f2068dcf08164875951d21afb561dd406b66d0
Solidity
IERC721
interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; }
/** * @dev Required interface of an ERC721 compliant contract. */
NatSpecMultiLine
safeTransferFrom
function safeTransferFrom( address from, address to, uint256 tokenId ) external;
/** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://e6e199a6501c1abd2f665aafb15edbfc6e4cfebb0396d5b40518ccd27f4ae406
{ "func_code_index": [ 1733, 1850 ] }
8,486
Ethernauts
Ethernauts.sol
0x29f2068dcf08164875951d21afb561dd406b66d0
Solidity
IERC721
interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; }
/** * @dev Required interface of an ERC721 compliant contract. */
NatSpecMultiLine
transferFrom
function transferFrom( address from, address to, uint256 tokenId ) external;
/** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://e6e199a6501c1abd2f665aafb15edbfc6e4cfebb0396d5b40518ccd27f4ae406
{ "func_code_index": [ 2376, 2489 ] }
8,487
Ethernauts
Ethernauts.sol
0x29f2068dcf08164875951d21afb561dd406b66d0
Solidity
IERC721
interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; }
/** * @dev Required interface of an ERC721 compliant contract. */
NatSpecMultiLine
approve
function approve(address to, uint256 tokenId) external;
/** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://e6e199a6501c1abd2f665aafb15edbfc6e4cfebb0396d5b40518ccd27f4ae406
{ "func_code_index": [ 2962, 3022 ] }
8,488
Ethernauts
Ethernauts.sol
0x29f2068dcf08164875951d21afb561dd406b66d0
Solidity
IERC721
interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; }
/** * @dev Required interface of an ERC721 compliant contract. */
NatSpecMultiLine
getApproved
function getApproved(uint256 tokenId) external view returns (address operator);
/** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://e6e199a6501c1abd2f665aafb15edbfc6e4cfebb0396d5b40518ccd27f4ae406
{ "func_code_index": [ 3176, 3260 ] }
8,489
Ethernauts
Ethernauts.sol
0x29f2068dcf08164875951d21afb561dd406b66d0
Solidity
IERC721
interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; }
/** * @dev Required interface of an ERC721 compliant contract. */
NatSpecMultiLine
setApprovalForAll
function setApprovalForAll(address operator, bool _approved) external;
/** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://e6e199a6501c1abd2f665aafb15edbfc6e4cfebb0396d5b40518ccd27f4ae406
{ "func_code_index": [ 3587, 3662 ] }
8,490
Ethernauts
Ethernauts.sol
0x29f2068dcf08164875951d21afb561dd406b66d0
Solidity
IERC721
interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; }
/** * @dev Required interface of an ERC721 compliant contract. */
NatSpecMultiLine
isApprovedForAll
function isApprovedForAll(address owner, address operator) external view returns (bool);
/** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://e6e199a6501c1abd2f665aafb15edbfc6e4cfebb0396d5b40518ccd27f4ae406
{ "func_code_index": [ 3813, 3906 ] }
8,491
Ethernauts
Ethernauts.sol
0x29f2068dcf08164875951d21afb561dd406b66d0
Solidity
IERC721
interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; }
/** * @dev Required interface of an ERC721 compliant contract. */
NatSpecMultiLine
safeTransferFrom
function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external;
/** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://e6e199a6501c1abd2f665aafb15edbfc6e4cfebb0396d5b40518ccd27f4ae406
{ "func_code_index": [ 4483, 4630 ] }
8,492
Ethernauts
Ethernauts.sol
0x29f2068dcf08164875951d21afb561dd406b66d0
Solidity
Strings
library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
/** * @dev String operations. */
NatSpecMultiLine
toString
function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); }
/** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://e6e199a6501c1abd2f665aafb15edbfc6e4cfebb0396d5b40518ccd27f4ae406
{ "func_code_index": [ 184, 912 ] }
8,493
Ethernauts
Ethernauts.sol
0x29f2068dcf08164875951d21afb561dd406b66d0
Solidity
Strings
library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
/** * @dev String operations. */
NatSpecMultiLine
toHexString
function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); }
/** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://e6e199a6501c1abd2f665aafb15edbfc6e4cfebb0396d5b40518ccd27f4ae406
{ "func_code_index": [ 1017, 1362 ] }
8,494
Ethernauts
Ethernauts.sol
0x29f2068dcf08164875951d21afb561dd406b66d0
Solidity
Strings
library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
/** * @dev String operations. */
NatSpecMultiLine
toHexString
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); }
/** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://e6e199a6501c1abd2f665aafb15edbfc6e4cfebb0396d5b40518ccd27f4ae406
{ "func_code_index": [ 1485, 1941 ] }
8,495
Ethernauts
Ethernauts.sol
0x29f2068dcf08164875951d21afb561dd406b66d0
Solidity
Ownable
abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
/** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */
NatSpecMultiLine
owner
function owner() public view virtual returns (address) { return _owner; }
/** * @dev Returns the address of the current owner. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://e6e199a6501c1abd2f665aafb15edbfc6e4cfebb0396d5b40518ccd27f4ae406
{ "func_code_index": [ 399, 491 ] }
8,496
Ethernauts
Ethernauts.sol
0x29f2068dcf08164875951d21afb561dd406b66d0
Solidity
Ownable
abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
/** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */
NatSpecMultiLine
renounceOwnership
function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); }
/** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://e6e199a6501c1abd2f665aafb15edbfc6e4cfebb0396d5b40518ccd27f4ae406
{ "func_code_index": [ 1050, 1149 ] }
8,497
Ethernauts
Ethernauts.sol
0x29f2068dcf08164875951d21afb561dd406b66d0
Solidity
Ownable
abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
/** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */
NatSpecMultiLine
transferOwnership
function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); }
/** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://e6e199a6501c1abd2f665aafb15edbfc6e4cfebb0396d5b40518ccd27f4ae406
{ "func_code_index": [ 1299, 1496 ] }
8,498
Ethernauts
Ethernauts.sol
0x29f2068dcf08164875951d21afb561dd406b66d0
Solidity
IERC721Receiver
interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
/** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */
NatSpecMultiLine
onERC721Received
function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4);
/** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://e6e199a6501c1abd2f665aafb15edbfc6e4cfebb0396d5b40518ccd27f4ae406
{ "func_code_index": [ 528, 698 ] }
8,499