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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
VNETToken | VNETToken.sol | 0xa71074b6c4a31c1d1798b04801a89d78f6e26123 | 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]);
checkNotLocked(_from, _value);
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 view returns (uint256) {
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
*/ | NatSpecMultiLine | decreaseApproval | function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
| /**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/ | NatSpecMultiLine | v0.4.23+commit.124ca40d | bzzr://860909762eed448f609e635aaaf8ff4eb12d56d79187c6060d1736a6b1c0efd2 | {
"func_code_index": [
3548,
4003
]
} | 2,200 |
|
VNETToken | VNETToken.sol | 0xa71074b6c4a31c1d1798b04801a89d78f6e26123 | Solidity | AbstractToken | contract AbstractToken is Ownable, StandardToken {
string public name;
string public symbol;
uint256 public decimals;
string public value; // Stable Value
string public description; // Description
string public website; // Website
string public email; // Email
string public news; // Latest News
uint256 public cap; // Cap Limit
mapping (address => bool) public mintAgents; // Mint Agents
event Mint(address indexed _to, uint256 _amount);
event MintAgentChanged(address _addr, bool _state);
event NewsPublished(string _news);
/**
* @dev Set Info
*
* @param _description string
* @param _website string
* @param _email string
*/
function setInfo(string _description, string _website, string _email) external onlyOwner returns (bool) {
description = _description;
website = _website;
email = _email;
return true;
}
/**
* @dev Set News
*
* @param _news string
*/
function setNews(string _news) external onlyOwner returns (bool) {
news = _news;
emit NewsPublished(_news);
return true;
}
/**
* @dev Set a mint agent address
*
* @param _addr address The address that will receive the minted tokens.
* @param _state bool The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function setMintAgent(address _addr, bool _state) onlyOwner public returns (bool) {
mintAgents[_addr] = _state;
emit MintAgentChanged(_addr, _state);
return true;
}
/**
* @dev Constructor
*/
constructor() public {
setMintAgent(msg.sender, true);
}
} | /**
* @title Abstract Standard ERC20 token
*/ | NatSpecMultiLine | setInfo | function setInfo(string _description, string _website, string _email) external onlyOwner returns (bool) {
description = _description;
website = _website;
email = _email;
return true;
}
| /**
* @dev Set Info
*
* @param _description string
* @param _website string
* @param _email string
*/ | NatSpecMultiLine | v0.4.23+commit.124ca40d | bzzr://860909762eed448f609e635aaaf8ff4eb12d56d79187c6060d1736a6b1c0efd2 | {
"func_code_index": [
785,
1015
]
} | 2,201 |
|
VNETToken | VNETToken.sol | 0xa71074b6c4a31c1d1798b04801a89d78f6e26123 | Solidity | AbstractToken | contract AbstractToken is Ownable, StandardToken {
string public name;
string public symbol;
uint256 public decimals;
string public value; // Stable Value
string public description; // Description
string public website; // Website
string public email; // Email
string public news; // Latest News
uint256 public cap; // Cap Limit
mapping (address => bool) public mintAgents; // Mint Agents
event Mint(address indexed _to, uint256 _amount);
event MintAgentChanged(address _addr, bool _state);
event NewsPublished(string _news);
/**
* @dev Set Info
*
* @param _description string
* @param _website string
* @param _email string
*/
function setInfo(string _description, string _website, string _email) external onlyOwner returns (bool) {
description = _description;
website = _website;
email = _email;
return true;
}
/**
* @dev Set News
*
* @param _news string
*/
function setNews(string _news) external onlyOwner returns (bool) {
news = _news;
emit NewsPublished(_news);
return true;
}
/**
* @dev Set a mint agent address
*
* @param _addr address The address that will receive the minted tokens.
* @param _state bool The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function setMintAgent(address _addr, bool _state) onlyOwner public returns (bool) {
mintAgents[_addr] = _state;
emit MintAgentChanged(_addr, _state);
return true;
}
/**
* @dev Constructor
*/
constructor() public {
setMintAgent(msg.sender, true);
}
} | /**
* @title Abstract Standard ERC20 token
*/ | NatSpecMultiLine | setNews | function setNews(string _news) external onlyOwner returns (bool) {
news = _news;
emit NewsPublished(_news);
return true;
}
| /**
* @dev Set News
*
* @param _news string
*/ | NatSpecMultiLine | v0.4.23+commit.124ca40d | bzzr://860909762eed448f609e635aaaf8ff4eb12d56d79187c6060d1736a6b1c0efd2 | {
"func_code_index": [
1095,
1254
]
} | 2,202 |
|
VNETToken | VNETToken.sol | 0xa71074b6c4a31c1d1798b04801a89d78f6e26123 | Solidity | AbstractToken | contract AbstractToken is Ownable, StandardToken {
string public name;
string public symbol;
uint256 public decimals;
string public value; // Stable Value
string public description; // Description
string public website; // Website
string public email; // Email
string public news; // Latest News
uint256 public cap; // Cap Limit
mapping (address => bool) public mintAgents; // Mint Agents
event Mint(address indexed _to, uint256 _amount);
event MintAgentChanged(address _addr, bool _state);
event NewsPublished(string _news);
/**
* @dev Set Info
*
* @param _description string
* @param _website string
* @param _email string
*/
function setInfo(string _description, string _website, string _email) external onlyOwner returns (bool) {
description = _description;
website = _website;
email = _email;
return true;
}
/**
* @dev Set News
*
* @param _news string
*/
function setNews(string _news) external onlyOwner returns (bool) {
news = _news;
emit NewsPublished(_news);
return true;
}
/**
* @dev Set a mint agent address
*
* @param _addr address The address that will receive the minted tokens.
* @param _state bool The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function setMintAgent(address _addr, bool _state) onlyOwner public returns (bool) {
mintAgents[_addr] = _state;
emit MintAgentChanged(_addr, _state);
return true;
}
/**
* @dev Constructor
*/
constructor() public {
setMintAgent(msg.sender, true);
}
} | /**
* @title Abstract Standard ERC20 token
*/ | NatSpecMultiLine | setMintAgent | function setMintAgent(address _addr, bool _state) onlyOwner public returns (bool) {
mintAgents[_addr] = _state;
emit MintAgentChanged(_addr, _state);
return true;
}
| /**
* @dev Set a mint agent address
*
* @param _addr address The address that will receive the minted tokens.
* @param _state bool The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/ | NatSpecMultiLine | v0.4.23+commit.124ca40d | bzzr://860909762eed448f609e635aaaf8ff4eb12d56d79187c6060d1736a6b1c0efd2 | {
"func_code_index": [
1537,
1738
]
} | 2,203 |
|
VNETToken | VNETToken.sol | 0xa71074b6c4a31c1d1798b04801a89d78f6e26123 | Solidity | VNETToken | contract VNETToken is Ownable, AbstractToken {
event Donate(address indexed _from, uint256 _amount);
/**
* @dev Constructor
*/
constructor() public {
name = "VNET Token";
symbol = "VNET";
decimals = 6;
value = "1 Token = 100 GByte client newtwork traffic flow";
// 35 Billion Total
cap = 35000000000 * (10 ** decimals);
}
/**
* @dev Sending eth to this contract will be considered as a donation
*/
function () public payable {
emit Donate(msg.sender, msg.value);
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) external returns (bool) {
require(mintAgents[msg.sender] && totalSupply_.add(_amount) <= cap);
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
}
/**
* @dev Function to mint tokens, and lock some of them with a release time
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @param _lockedAmount The amount of tokens to be locked.
* @param _releaseTime The timestamp about to release, which could be set just once.
* @return A boolean that indicates if the operation was successful.
*/
function mintWithLock(address _to, uint256 _amount, uint256 _lockedAmount, uint256 _releaseTime) external returns (bool) {
require(mintAgents[msg.sender] && totalSupply_.add(_amount) <= cap);
require(_amount >= _lockedAmount);
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
lockedBalanceMap[_to] = lockedBalanceMap[_to] > 0 ? lockedBalanceMap[_to].add(_lockedAmount) : _lockedAmount;
releaseTimeMap[_to] = releaseTimeMap[_to] > 0 ? releaseTimeMap[_to] : _releaseTime;
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
emit BalanceLocked(_to, _lockedAmount);
return true;
}
} | /**
* @dev VNET Token for Vision Network Project
*/ | NatSpecMultiLine | function () public payable {
emit Donate(msg.sender, msg.value);
}
| /**
* @dev Sending eth to this contract will be considered as a donation
*/ | NatSpecMultiLine | v0.4.23+commit.124ca40d | bzzr://860909762eed448f609e635aaaf8ff4eb12d56d79187c6060d1736a6b1c0efd2 | {
"func_code_index": [
510,
595
]
} | 2,204 |
||
VNETToken | VNETToken.sol | 0xa71074b6c4a31c1d1798b04801a89d78f6e26123 | Solidity | VNETToken | contract VNETToken is Ownable, AbstractToken {
event Donate(address indexed _from, uint256 _amount);
/**
* @dev Constructor
*/
constructor() public {
name = "VNET Token";
symbol = "VNET";
decimals = 6;
value = "1 Token = 100 GByte client newtwork traffic flow";
// 35 Billion Total
cap = 35000000000 * (10 ** decimals);
}
/**
* @dev Sending eth to this contract will be considered as a donation
*/
function () public payable {
emit Donate(msg.sender, msg.value);
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) external returns (bool) {
require(mintAgents[msg.sender] && totalSupply_.add(_amount) <= cap);
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
}
/**
* @dev Function to mint tokens, and lock some of them with a release time
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @param _lockedAmount The amount of tokens to be locked.
* @param _releaseTime The timestamp about to release, which could be set just once.
* @return A boolean that indicates if the operation was successful.
*/
function mintWithLock(address _to, uint256 _amount, uint256 _lockedAmount, uint256 _releaseTime) external returns (bool) {
require(mintAgents[msg.sender] && totalSupply_.add(_amount) <= cap);
require(_amount >= _lockedAmount);
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
lockedBalanceMap[_to] = lockedBalanceMap[_to] > 0 ? lockedBalanceMap[_to].add(_lockedAmount) : _lockedAmount;
releaseTimeMap[_to] = releaseTimeMap[_to] > 0 ? releaseTimeMap[_to] : _releaseTime;
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
emit BalanceLocked(_to, _lockedAmount);
return true;
}
} | /**
* @dev VNET Token for Vision Network Project
*/ | NatSpecMultiLine | mint | function mint(address _to, uint256 _amount) external returns (bool) {
require(mintAgents[msg.sender] && totalSupply_.add(_amount) <= cap);
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
}
| /**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/ | NatSpecMultiLine | v0.4.23+commit.124ca40d | bzzr://860909762eed448f609e635aaaf8ff4eb12d56d79187c6060d1736a6b1c0efd2 | {
"func_code_index": [
848,
1219
]
} | 2,205 |
|
VNETToken | VNETToken.sol | 0xa71074b6c4a31c1d1798b04801a89d78f6e26123 | Solidity | VNETToken | contract VNETToken is Ownable, AbstractToken {
event Donate(address indexed _from, uint256 _amount);
/**
* @dev Constructor
*/
constructor() public {
name = "VNET Token";
symbol = "VNET";
decimals = 6;
value = "1 Token = 100 GByte client newtwork traffic flow";
// 35 Billion Total
cap = 35000000000 * (10 ** decimals);
}
/**
* @dev Sending eth to this contract will be considered as a donation
*/
function () public payable {
emit Donate(msg.sender, msg.value);
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) external returns (bool) {
require(mintAgents[msg.sender] && totalSupply_.add(_amount) <= cap);
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
}
/**
* @dev Function to mint tokens, and lock some of them with a release time
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @param _lockedAmount The amount of tokens to be locked.
* @param _releaseTime The timestamp about to release, which could be set just once.
* @return A boolean that indicates if the operation was successful.
*/
function mintWithLock(address _to, uint256 _amount, uint256 _lockedAmount, uint256 _releaseTime) external returns (bool) {
require(mintAgents[msg.sender] && totalSupply_.add(_amount) <= cap);
require(_amount >= _lockedAmount);
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
lockedBalanceMap[_to] = lockedBalanceMap[_to] > 0 ? lockedBalanceMap[_to].add(_lockedAmount) : _lockedAmount;
releaseTimeMap[_to] = releaseTimeMap[_to] > 0 ? releaseTimeMap[_to] : _releaseTime;
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
emit BalanceLocked(_to, _lockedAmount);
return true;
}
} | /**
* @dev VNET Token for Vision Network Project
*/ | NatSpecMultiLine | mintWithLock | function mintWithLock(address _to, uint256 _amount, uint256 _lockedAmount, uint256 _releaseTime) external returns (bool) {
require(mintAgents[msg.sender] && totalSupply_.add(_amount) <= cap);
require(_amount >= _lockedAmount);
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
lockedBalanceMap[_to] = lockedBalanceMap[_to] > 0 ? lockedBalanceMap[_to].add(_lockedAmount) : _lockedAmount;
releaseTimeMap[_to] = releaseTimeMap[_to] > 0 ? releaseTimeMap[_to] : _releaseTime;
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
emit BalanceLocked(_to, _lockedAmount);
return true;
}
| /**
* @dev Function to mint tokens, and lock some of them with a release time
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @param _lockedAmount The amount of tokens to be locked.
* @param _releaseTime The timestamp about to release, which could be set just once.
* @return A boolean that indicates if the operation was successful.
*/ | NatSpecMultiLine | v0.4.23+commit.124ca40d | bzzr://860909762eed448f609e635aaaf8ff4eb12d56d79187c6060d1736a6b1c0efd2 | {
"func_code_index": [
1669,
2398
]
} | 2,206 |
|
WORLDToken_StandardToken_U | WORLDToken_StandardToken_U.sol | 0x552151324171a0575c04074a60dfc9c5823a8c82 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
| /**
* @dev Multiplies two numbers, throws on overflow.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | None | bzzr://7c0ed797602230042ca79181c863ec732791698d82ccce20fbbc4c3b8ee290c5 | {
"func_code_index": [
95,
524
]
} | 2,207 |
WORLDToken_StandardToken_U | WORLDToken_StandardToken_U.sol | 0x552151324171a0575c04074a60dfc9c5823a8c82 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | div | function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
| /**
* @dev Integer division of two numbers, truncating the quotient.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | None | bzzr://7c0ed797602230042ca79181c863ec732791698d82ccce20fbbc4c3b8ee290c5 | {
"func_code_index": [
614,
914
]
} | 2,208 |
WORLDToken_StandardToken_U | WORLDToken_StandardToken_U.sol | 0x552151324171a0575c04074a60dfc9c5823a8c82 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | sub | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
| /**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | None | bzzr://7c0ed797602230042ca79181c863ec732791698d82ccce20fbbc4c3b8ee290c5 | {
"func_code_index": [
1034,
1162
]
} | 2,209 |
WORLDToken_StandardToken_U | WORLDToken_StandardToken_U.sol | 0x552151324171a0575c04074a60dfc9c5823a8c82 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | add | function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
| /**
* @dev Adds two numbers, throws on overflow.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | None | bzzr://7c0ed797602230042ca79181c863ec732791698d82ccce20fbbc4c3b8ee290c5 | {
"func_code_index": [
1232,
1378
]
} | 2,210 |
WORLDToken_StandardToken_U | WORLDToken_StandardToken_U.sol | 0x552151324171a0575c04074a60dfc9c5823a8c82 | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
uint256 totalSupply_;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return balances[_owner];
}
} | /**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/ | NatSpecMultiLine | totalSupply | function totalSupply() public view returns (uint256) {
return totalSupply_;
}
| /**
* @dev Total number of tokens in existence
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | None | bzzr://7c0ed797602230042ca79181c863ec732791698d82ccce20fbbc4c3b8ee290c5 | {
"func_code_index": [
211,
307
]
} | 2,211 |
WORLDToken_StandardToken_U | WORLDToken_StandardToken_U.sol | 0x552151324171a0575c04074a60dfc9c5823a8c82 | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
uint256 totalSupply_;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return balances[_owner];
}
} | /**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/ | NatSpecMultiLine | transfer | function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
| /**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | None | bzzr://7c0ed797602230042ca79181c863ec732791698d82ccce20fbbc4c3b8ee290c5 | {
"func_code_index": [
475,
835
]
} | 2,212 |
WORLDToken_StandardToken_U | WORLDToken_StandardToken_U.sol | 0x552151324171a0575c04074a60dfc9c5823a8c82 | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
uint256 totalSupply_;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return balances[_owner];
}
} | /**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/ | NatSpecMultiLine | balanceOf | function balanceOf(address _owner) public view returns (uint256) {
return balances[_owner];
}
| /**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | None | bzzr://7c0ed797602230042ca79181c863ec732791698d82ccce20fbbc4c3b8ee290c5 | {
"func_code_index": [
1051,
1163
]
} | 2,213 |
WORLDToken_StandardToken_U | WORLDToken_StandardToken_U.sol | 0x552151324171a0575c04074a60dfc9c5823a8c82 | 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) {
// avoid race condition
require((_value == 0) || (allowed[msg.sender][_spender] == 0), "reset allowance to 0 before change it's value.");
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed[_owner][_spender];
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* https://github.com/ethereum/EIPs/issues/20
* Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | transferFrom | function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
| /**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | None | bzzr://7c0ed797602230042ca79181c863ec732791698d82ccce20fbbc4c3b8ee290c5 | {
"func_code_index": [
410,
960
]
} | 2,214 |
WORLDToken_StandardToken_U | WORLDToken_StandardToken_U.sol | 0x552151324171a0575c04074a60dfc9c5823a8c82 | 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) {
// avoid race condition
require((_value == 0) || (allowed[msg.sender][_spender] == 0), "reset allowance to 0 before change it's value.");
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed[_owner][_spender];
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* https://github.com/ethereum/EIPs/issues/20
* Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | approve | function approve(address _spender, uint256 _value) public returns (bool) {
// avoid race condition
require((_value == 0) || (allowed[msg.sender][_spender] == 0), "reset allowance to 0 before change it's value.");
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.24+commit.e67f0147 | None | bzzr://7c0ed797602230042ca79181c863ec732791698d82ccce20fbbc4c3b8ee290c5 | {
"func_code_index": [
1596,
1963
]
} | 2,215 |
WORLDToken_StandardToken_U | WORLDToken_StandardToken_U.sol | 0x552151324171a0575c04074a60dfc9c5823a8c82 | 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) {
// avoid race condition
require((_value == 0) || (allowed[msg.sender][_spender] == 0), "reset allowance to 0 before change it's value.");
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed[_owner][_spender];
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* https://github.com/ethereum/EIPs/issues/20
* Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | allowance | function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed[_owner][_spender];
}
| /**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | None | bzzr://7c0ed797602230042ca79181c863ec732791698d82ccce20fbbc4c3b8ee290c5 | {
"func_code_index": [
2294,
2490
]
} | 2,216 |
liquidityProviderTokensStaking | liquidityProviderTokensStaking.sol | 0x90bd59d7537a604dc8f08faa478c22660d9fd256 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, "SafeMath: division by zero");
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | add | function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
| /**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/ | NatSpecMultiLine | v0.5.16+commit.9c3226ce | None | bzzr://092b39146afaf70203d8251300c3cf7d116099b185f06170f03fae8eb24bcd75 | {
"func_code_index": [
251,
437
]
} | 2,217 |
liquidityProviderTokensStaking | liquidityProviderTokensStaking.sol | 0x90bd59d7537a604dc8f08faa478c22660d9fd256 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, "SafeMath: division by zero");
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | sub | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
uint256 c = a - b;
return c;
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.5.16+commit.9c3226ce | None | bzzr://092b39146afaf70203d8251300c3cf7d116099b185f06170f03fae8eb24bcd75 | {
"func_code_index": [
707,
896
]
} | 2,218 |
liquidityProviderTokensStaking | liquidityProviderTokensStaking.sol | 0x90bd59d7537a604dc8f08faa478c22660d9fd256 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, "SafeMath: division by zero");
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
| /**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/ | NatSpecMultiLine | v0.5.16+commit.9c3226ce | None | bzzr://092b39146afaf70203d8251300c3cf7d116099b185f06170f03fae8eb24bcd75 | {
"func_code_index": [
1142,
1617
]
} | 2,219 |
liquidityProviderTokensStaking | liquidityProviderTokensStaking.sol | 0x90bd59d7537a604dc8f08faa478c22660d9fd256 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, "SafeMath: division by zero");
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | div | function div(uint256 a, uint256 b) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, "SafeMath: division by zero");
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
| /**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.5.16+commit.9c3226ce | None | bzzr://092b39146afaf70203d8251300c3cf7d116099b185f06170f03fae8eb24bcd75 | {
"func_code_index": [
2080,
2418
]
} | 2,220 |
CowsRegistry | CowsRegistry.sol | 0xc88c9e7e29cc77b16d3dd8e0c39b8a620e94bc70 | 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.10+commit.fc410830 | MIT | ipfs://438cc02cf55a74a39f87a6aa5c50972b2b65a00cda2a29313535535185d1e7ca | {
"func_code_index": [
399,
491
]
} | 2,221 |
CowsRegistry | CowsRegistry.sol | 0xc88c9e7e29cc77b16d3dd8e0c39b8a620e94bc70 | 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.10+commit.fc410830 | MIT | ipfs://438cc02cf55a74a39f87a6aa5c50972b2b65a00cda2a29313535535185d1e7ca | {
"func_code_index": [
1050,
1149
]
} | 2,222 |
CowsRegistry | CowsRegistry.sol | 0xc88c9e7e29cc77b16d3dd8e0c39b8a620e94bc70 | 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.10+commit.fc410830 | MIT | ipfs://438cc02cf55a74a39f87a6aa5c50972b2b65a00cda2a29313535535185d1e7ca | {
"func_code_index": [
1299,
1496
]
} | 2,223 |
AdminUpgradeabilityProxy | Address.sol | 0xce797549a7025561ae60569f68419f016e97d8c5 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | isContract | function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
| /**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/ | NatSpecMultiLine | v0.6.8+commit.0bbfe453 | MIT | ipfs://0e97f647ae7957c25ff392b2ef1138af51f4ab45d260533a2cba2576c9c45e69 | {
"func_code_index": [
606,
1033
]
} | 2,224 |
AdminUpgradeabilityProxy | Address.sol | 0xce797549a7025561ae60569f68419f016e97d8c5 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | sendValue | function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
| /**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/ | NatSpecMultiLine | v0.6.8+commit.0bbfe453 | MIT | ipfs://0e97f647ae7957c25ff392b2ef1138af51f4ab45d260533a2cba2576c9c45e69 | {
"func_code_index": [
1963,
2365
]
} | 2,225 |
AdminUpgradeabilityProxy | Address.sol | 0xce797549a7025561ae60569f68419f016e97d8c5 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionCall | function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
| /**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.8+commit.0bbfe453 | MIT | ipfs://0e97f647ae7957c25ff392b2ef1138af51f4ab45d260533a2cba2576c9c45e69 | {
"func_code_index": [
3121,
3299
]
} | 2,226 |
AdminUpgradeabilityProxy | Address.sol | 0xce797549a7025561ae60569f68419f016e97d8c5 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionCall | function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.8+commit.0bbfe453 | MIT | ipfs://0e97f647ae7957c25ff392b2ef1138af51f4ab45d260533a2cba2576c9c45e69 | {
"func_code_index": [
3524,
3724
]
} | 2,227 |
AdminUpgradeabilityProxy | Address.sol | 0xce797549a7025561ae60569f68419f016e97d8c5 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionCallWithValue | function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.8+commit.0bbfe453 | MIT | ipfs://0e97f647ae7957c25ff392b2ef1138af51f4ab45d260533a2cba2576c9c45e69 | {
"func_code_index": [
4094,
4325
]
} | 2,228 |
AdminUpgradeabilityProxy | Address.sol | 0xce797549a7025561ae60569f68419f016e97d8c5 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionCallWithValue | function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
| /**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.8+commit.0bbfe453 | MIT | ipfs://0e97f647ae7957c25ff392b2ef1138af51f4ab45d260533a2cba2576c9c45e69 | {
"func_code_index": [
4576,
5111
]
} | 2,229 |
AdminUpgradeabilityProxy | Address.sol | 0xce797549a7025561ae60569f68419f016e97d8c5 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionStaticCall | function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/ | NatSpecMultiLine | v0.6.8+commit.0bbfe453 | MIT | ipfs://0e97f647ae7957c25ff392b2ef1138af51f4ab45d260533a2cba2576c9c45e69 | {
"func_code_index": [
5291,
5495
]
} | 2,230 |
AdminUpgradeabilityProxy | Address.sol | 0xce797549a7025561ae60569f68419f016e97d8c5 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionStaticCall | function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/ | NatSpecMultiLine | v0.6.8+commit.0bbfe453 | MIT | ipfs://0e97f647ae7957c25ff392b2ef1138af51f4ab45d260533a2cba2576c9c45e69 | {
"func_code_index": [
5682,
6109
]
} | 2,231 |
TokenERC20 | TokenERC20.sol | 0x13ab12f2e72aae20b19e3206affad7bb000b06f3 | Solidity | TokenERC20 | contract TokenERC20 {
// 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 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;
// 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 != 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` 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; 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 _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, 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
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
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;
// Give the creator all initial tokens
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.20-nightly.2018.1.17+commit.4715167e | bzzr://93548ab05ad7719610271327b685a9401d3c3afdc4b3a085d1b3663ad41b78b8 | {
"func_code_index": [
807,
1251
]
} | 2,232 |
|||
TokenERC20 | TokenERC20.sol | 0x13ab12f2e72aae20b19e3206affad7bb000b06f3 | Solidity | TokenERC20 | contract TokenERC20 {
// 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 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;
// 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 != 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` 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; 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 _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, 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
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
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.20-nightly.2018.1.17+commit.4715167e | bzzr://93548ab05ad7719610271327b685a9401d3c3afdc4b3a085d1b3663ad41b78b8 | {
"func_code_index": [
1328,
2172
]
} | 2,233 |
|||
TokenERC20 | TokenERC20.sol | 0x13ab12f2e72aae20b19e3206affad7bb000b06f3 | Solidity | TokenERC20 | contract TokenERC20 {
// 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 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;
// 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 != 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` 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; 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 _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, 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
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
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.20-nightly.2018.1.17+commit.4715167e | bzzr://93548ab05ad7719610271327b685a9401d3c3afdc4b3a085d1b3663ad41b78b8 | {
"func_code_index": [
2339,
2441
]
} | 2,234 |
|||
TokenERC20 | TokenERC20.sol | 0x13ab12f2e72aae20b19e3206affad7bb000b06f3 | Solidity | TokenERC20 | contract TokenERC20 {
// 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 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;
// 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 != 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` 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; 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 _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, 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
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
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.4.20-nightly.2018.1.17+commit.4715167e | bzzr://93548ab05ad7719610271327b685a9401d3c3afdc4b3a085d1b3663ad41b78b8 | {
"func_code_index": [
2670,
2959
]
} | 2,235 |
|||
TokenERC20 | TokenERC20.sol | 0x13ab12f2e72aae20b19e3206affad7bb000b06f3 | Solidity | TokenERC20 | contract TokenERC20 {
// 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 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;
// 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 != 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` 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; 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 _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, 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
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
Burn(_from, _value); return true; } } | approve | function approve(address _spender, uint256 _value) public returns (bool success) { allowance[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.4.20-nightly.2018.1.17+commit.4715167e | bzzr://93548ab05ad7719610271327b685a9401d3c3afdc4b3a085d1b3663ad41b78b8 | {
"func_code_index": [
3184,
3332
]
} | 2,236 |
|||
TokenERC20 | TokenERC20.sol | 0x13ab12f2e72aae20b19e3206affad7bb000b06f3 | Solidity | TokenERC20 | contract TokenERC20 {
// 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 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;
// 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 != 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` 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; 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 _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, 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
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
Burn(_from, _value); return true; } } | approveAndCall | 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; } }
| /** * 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.4.20-nightly.2018.1.17+commit.4715167e | bzzr://93548ab05ad7719610271327b685a9401d3c3afdc4b3a085d1b3663ad41b78b8 | {
"func_code_index": [
3681,
3962
]
} | 2,237 |
|||
TokenERC20 | TokenERC20.sol | 0x13ab12f2e72aae20b19e3206affad7bb000b06f3 | Solidity | TokenERC20 | contract TokenERC20 {
// 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 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;
// 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 != 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` 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; 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 _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, 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
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
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
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.4.20-nightly.2018.1.17+commit.4715167e | bzzr://93548ab05ad7719610271327b685a9401d3c3afdc4b3a085d1b3663ad41b78b8 | {
"func_code_index": [
4099,
4451
]
} | 2,238 |
|||
TokenERC20 | TokenERC20.sol | 0x13ab12f2e72aae20b19e3206affad7bb000b06f3 | Solidity | TokenERC20 | contract TokenERC20 {
// 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 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;
// 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 != 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` 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; 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 _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, 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
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
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
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.4.20-nightly.2018.1.17+commit.4715167e | bzzr://93548ab05ad7719610271327b685a9401d3c3afdc4b3a085d1b3663ad41b78b8 | {
"func_code_index": [
4670,
5229
]
} | 2,239 |
|||
Presale | Presale.sol | 0x2bca686de0b312ab453b676502f3108f4ab83106 | Solidity | Ownable | contract Ownable {
//Variables
address public owner;
address public newOwner;
// Modifiers
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() public {
owner = msg.sender;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function transferOwnership(address _newOwner) public onlyOwner {
require(_newOwner != address(0));
newOwner = _newOwner;
}
function acceptOwnership() public {
if (msg.sender == newOwner) {
owner = newOwner;
}
}
} | Ownable | function Ownable() public {
owner = msg.sender;
}
| /**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/ | NatSpecMultiLine | v0.4.17+commit.bdeb9e52 | bzzr://fe61060f479015f88f84fd83293fdbc8a757fe73f6b4e3ad9f2be3141d07dafb | {
"func_code_index": [
422,
490
]
} | 2,240 |
|||
Presale | Presale.sol | 0x2bca686de0b312ab453b676502f3108f4ab83106 | Solidity | Ownable | contract Ownable {
//Variables
address public owner;
address public newOwner;
// Modifiers
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() public {
owner = msg.sender;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function transferOwnership(address _newOwner) public onlyOwner {
require(_newOwner != address(0));
newOwner = _newOwner;
}
function acceptOwnership() public {
if (msg.sender == newOwner) {
owner = newOwner;
}
}
} | transferOwnership | function transferOwnership(address _newOwner) public onlyOwner {
require(_newOwner != address(0));
newOwner = _newOwner;
}
| /**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/ | NatSpecMultiLine | v0.4.17+commit.bdeb9e52 | bzzr://fe61060f479015f88f84fd83293fdbc8a757fe73f6b4e3ad9f2be3141d07dafb | {
"func_code_index": [
665,
815
]
} | 2,241 |
|||
Presale | Presale.sol | 0x2bca686de0b312ab453b676502f3108f4ab83106 | 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);
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];
}
} | /**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/ | NatSpecMultiLine | transfer | function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
| /**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/ | NatSpecMultiLine | v0.4.17+commit.bdeb9e52 | bzzr://fe61060f479015f88f84fd83293fdbc8a757fe73f6b4e3ad9f2be3141d07dafb | {
"func_code_index": [
282,
705
]
} | 2,242 |
|
Presale | Presale.sol | 0x2bca686de0b312ab453b676502f3108f4ab83106 | 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);
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];
}
} | /**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/ | NatSpecMultiLine | 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.17+commit.bdeb9e52 | bzzr://fe61060f479015f88f84fd83293fdbc8a757fe73f6b4e3ad9f2be3141d07dafb | {
"func_code_index": [
921,
1045
]
} | 2,243 |
|
Presale | Presale.sol | 0x2bca686de0b312ab453b676502f3108f4ab83106 | 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);
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;
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 should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
*/
function increaseApproval (address _spender, uint _addedValue) public returns (bool success) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval (address _spender, uint _subtractedValue) public returns (bool success) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | 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);
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.17+commit.bdeb9e52 | bzzr://fe61060f479015f88f84fd83293fdbc8a757fe73f6b4e3ad9f2be3141d07dafb | {
"func_code_index": [
401,
853
]
} | 2,244 |
|||
Presale | Presale.sol | 0x2bca686de0b312ab453b676502f3108f4ab83106 | 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);
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;
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 should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
*/
function increaseApproval (address _spender, uint _addedValue) public returns (bool success) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval (address _spender, uint _subtractedValue) public returns (bool success) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | approve | function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
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.17+commit.bdeb9e52 | bzzr://fe61060f479015f88f84fd83293fdbc8a757fe73f6b4e3ad9f2be3141d07dafb | {
"func_code_index": [
1485,
1675
]
} | 2,245 |
|||
Presale | Presale.sol | 0x2bca686de0b312ab453b676502f3108f4ab83106 | 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);
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;
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 should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
*/
function increaseApproval (address _spender, uint _addedValue) public returns (bool success) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval (address _spender, uint _subtractedValue) public returns (bool success) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | 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.17+commit.bdeb9e52 | bzzr://fe61060f479015f88f84fd83293fdbc8a757fe73f6b4e3ad9f2be3141d07dafb | {
"func_code_index": [
1999,
2144
]
} | 2,246 |
|||
Presale | Presale.sol | 0x2bca686de0b312ab453b676502f3108f4ab83106 | 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);
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;
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 should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
*/
function increaseApproval (address _spender, uint _addedValue) public returns (bool success) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval (address _spender, uint _subtractedValue) public returns (bool success) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | increaseApproval | function increaseApproval (address _spender, uint _addedValue) public returns (bool success) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
| /**
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
*/ | NatSpecMultiLine | v0.4.17+commit.bdeb9e52 | bzzr://fe61060f479015f88f84fd83293fdbc8a757fe73f6b4e3ad9f2be3141d07dafb | {
"func_code_index": [
2389,
2662
]
} | 2,247 |
|||
Presale | Presale.sol | 0x2bca686de0b312ab453b676502f3108f4ab83106 | Solidity | MintableToken | contract MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
totalSupply = totalSupply.add(_amount);
balances[_to] = balances[_to].add(_amount);
Mint(_to, _amount);
Transfer(0x0, _to, _amount);
return true;
}
/**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/
function finishMinting() onlyOwner public returns (bool) {
mintingFinished = true;
MintFinished();
return true;
}
} | mint | function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
totalSupply = totalSupply.add(_amount);
balances[_to] = balances[_to].add(_amount);
Mint(_to, _amount);
Transfer(0x0, _to, _amount);
return true;
}
| /**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/ | NatSpecMultiLine | v0.4.17+commit.bdeb9e52 | bzzr://fe61060f479015f88f84fd83293fdbc8a757fe73f6b4e3ad9f2be3141d07dafb | {
"func_code_index": [
481,
745
]
} | 2,248 |
|||
Presale | Presale.sol | 0x2bca686de0b312ab453b676502f3108f4ab83106 | Solidity | MintableToken | contract MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
totalSupply = totalSupply.add(_amount);
balances[_to] = balances[_to].add(_amount);
Mint(_to, _amount);
Transfer(0x0, _to, _amount);
return true;
}
/**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/
function finishMinting() onlyOwner public returns (bool) {
mintingFinished = true;
MintFinished();
return true;
}
} | finishMinting | function finishMinting() onlyOwner public returns (bool) {
mintingFinished = true;
MintFinished();
return true;
}
| /**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/ | NatSpecMultiLine | v0.4.17+commit.bdeb9e52 | bzzr://fe61060f479015f88f84fd83293fdbc8a757fe73f6b4e3ad9f2be3141d07dafb | {
"func_code_index": [
862,
996
]
} | 2,249 |
|||
Presale | Presale.sol | 0x2bca686de0b312ab453b676502f3108f4ab83106 | Solidity | LamdenTau | contract LamdenTau is MintableToken {
string public constant name = "Lamden Tau";
string public constant symbol = "TAU";
uint8 public constant decimals = 18;
// locks transfers until minting is over, which ends at the end of the sale
// thus, the behavior of this token is locked transfers during sale, and unlocked after :)
function transfer(address _to, uint256 _value) public returns (bool) {
require(mintingFinished);
bool success = super.transfer(_to, _value);
return success;
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(mintingFinished);
bool success = super.transferFrom(_from, _to, _value);
return success;
}
} | transfer | function transfer(address _to, uint256 _value) public returns (bool) {
require(mintingFinished);
bool success = super.transfer(_to, _value);
return success;
}
| // locks transfers until minting is over, which ends at the end of the sale
// thus, the behavior of this token is locked transfers during sale, and unlocked after :) | LineComment | v0.4.17+commit.bdeb9e52 | bzzr://fe61060f479015f88f84fd83293fdbc8a757fe73f6b4e3ad9f2be3141d07dafb | {
"func_code_index": [
353,
542
]
} | 2,250 |
|||
Presale | Presale.sol | 0x2bca686de0b312ab453b676502f3108f4ab83106 | Solidity | Crowdsale | contract Crowdsale {
using SafeMath for uint256;
// The token being sold
MintableToken public token;
// start and end timestamps where investments are allowed (both inclusive)
uint256 public startTime;
uint256 public endTime;
// address where funds are collected
address public wallet;
// how many token units a buyer gets per wei
uint256 public rate;
// amount of raised money in wei
uint256 public weiRaised;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
function Crowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) {
require(_startTime >= now);
require(_endTime >= _startTime);
require(_rate > 0);
require(_wallet != 0x0);
token = createTokenContract();
startTime = _startTime;
endTime = _endTime;
rate = _rate;
wallet = _wallet;
}
// creates the token to be sold.
// override this method to have crowdsale of a specific mintable token.
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
// fallback function can be used to buy tokens
function () payable {
buyTokens(msg.sender);
}
// low level token purchase function
function buyTokens(address beneficiary) public payable {
require(beneficiary != 0x0);
require(validPurchase());
uint256 weiAmount = msg.value;
// calculate token amount to be created
uint256 tokens = weiAmount.mul(rate);
// update state
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
// send ether to the fund collection wallet
// override to create custom fund forwarding mechanisms
function forwardFunds() internal {
wallet.transfer(msg.value);
}
// @return true if the transaction can buy tokens
function validPurchase() internal constant returns (bool) {
bool withinPeriod = now >= startTime && now <= endTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
}
// @return true if crowdsale event has ended
function hasEnded() public constant returns (bool) {
return now > endTime;
}
} | createTokenContract | function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
| // creates the token to be sold.
// override this method to have crowdsale of a specific mintable token. | LineComment | v0.4.17+commit.bdeb9e52 | bzzr://fe61060f479015f88f84fd83293fdbc8a757fe73f6b4e3ad9f2be3141d07dafb | {
"func_code_index": [
1280,
1386
]
} | 2,251 |
|||
Presale | Presale.sol | 0x2bca686de0b312ab453b676502f3108f4ab83106 | Solidity | Crowdsale | contract Crowdsale {
using SafeMath for uint256;
// The token being sold
MintableToken public token;
// start and end timestamps where investments are allowed (both inclusive)
uint256 public startTime;
uint256 public endTime;
// address where funds are collected
address public wallet;
// how many token units a buyer gets per wei
uint256 public rate;
// amount of raised money in wei
uint256 public weiRaised;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
function Crowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) {
require(_startTime >= now);
require(_endTime >= _startTime);
require(_rate > 0);
require(_wallet != 0x0);
token = createTokenContract();
startTime = _startTime;
endTime = _endTime;
rate = _rate;
wallet = _wallet;
}
// creates the token to be sold.
// override this method to have crowdsale of a specific mintable token.
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
// fallback function can be used to buy tokens
function () payable {
buyTokens(msg.sender);
}
// low level token purchase function
function buyTokens(address beneficiary) public payable {
require(beneficiary != 0x0);
require(validPurchase());
uint256 weiAmount = msg.value;
// calculate token amount to be created
uint256 tokens = weiAmount.mul(rate);
// update state
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
// send ether to the fund collection wallet
// override to create custom fund forwarding mechanisms
function forwardFunds() internal {
wallet.transfer(msg.value);
}
// @return true if the transaction can buy tokens
function validPurchase() internal constant returns (bool) {
bool withinPeriod = now >= startTime && now <= endTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
}
// @return true if crowdsale event has ended
function hasEnded() public constant returns (bool) {
return now > endTime;
}
} | function () payable {
buyTokens(msg.sender);
}
| // fallback function can be used to buy tokens | LineComment | v0.4.17+commit.bdeb9e52 | bzzr://fe61060f479015f88f84fd83293fdbc8a757fe73f6b4e3ad9f2be3141d07dafb | {
"func_code_index": [
1441,
1498
]
} | 2,252 |
||||
Presale | Presale.sol | 0x2bca686de0b312ab453b676502f3108f4ab83106 | Solidity | Crowdsale | contract Crowdsale {
using SafeMath for uint256;
// The token being sold
MintableToken public token;
// start and end timestamps where investments are allowed (both inclusive)
uint256 public startTime;
uint256 public endTime;
// address where funds are collected
address public wallet;
// how many token units a buyer gets per wei
uint256 public rate;
// amount of raised money in wei
uint256 public weiRaised;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
function Crowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) {
require(_startTime >= now);
require(_endTime >= _startTime);
require(_rate > 0);
require(_wallet != 0x0);
token = createTokenContract();
startTime = _startTime;
endTime = _endTime;
rate = _rate;
wallet = _wallet;
}
// creates the token to be sold.
// override this method to have crowdsale of a specific mintable token.
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
// fallback function can be used to buy tokens
function () payable {
buyTokens(msg.sender);
}
// low level token purchase function
function buyTokens(address beneficiary) public payable {
require(beneficiary != 0x0);
require(validPurchase());
uint256 weiAmount = msg.value;
// calculate token amount to be created
uint256 tokens = weiAmount.mul(rate);
// update state
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
// send ether to the fund collection wallet
// override to create custom fund forwarding mechanisms
function forwardFunds() internal {
wallet.transfer(msg.value);
}
// @return true if the transaction can buy tokens
function validPurchase() internal constant returns (bool) {
bool withinPeriod = now >= startTime && now <= endTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
}
// @return true if crowdsale event has ended
function hasEnded() public constant returns (bool) {
return now > endTime;
}
} | buyTokens | function buyTokens(address beneficiary) public payable {
require(beneficiary != 0x0);
require(validPurchase());
uint256 weiAmount = msg.value;
// calculate token amount to be created
uint256 tokens = weiAmount.mul(rate);
// update state
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
| // low level token purchase function | LineComment | v0.4.17+commit.bdeb9e52 | bzzr://fe61060f479015f88f84fd83293fdbc8a757fe73f6b4e3ad9f2be3141d07dafb | {
"func_code_index": [
1541,
1991
]
} | 2,253 |
|||
Presale | Presale.sol | 0x2bca686de0b312ab453b676502f3108f4ab83106 | Solidity | Crowdsale | contract Crowdsale {
using SafeMath for uint256;
// The token being sold
MintableToken public token;
// start and end timestamps where investments are allowed (both inclusive)
uint256 public startTime;
uint256 public endTime;
// address where funds are collected
address public wallet;
// how many token units a buyer gets per wei
uint256 public rate;
// amount of raised money in wei
uint256 public weiRaised;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
function Crowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) {
require(_startTime >= now);
require(_endTime >= _startTime);
require(_rate > 0);
require(_wallet != 0x0);
token = createTokenContract();
startTime = _startTime;
endTime = _endTime;
rate = _rate;
wallet = _wallet;
}
// creates the token to be sold.
// override this method to have crowdsale of a specific mintable token.
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
// fallback function can be used to buy tokens
function () payable {
buyTokens(msg.sender);
}
// low level token purchase function
function buyTokens(address beneficiary) public payable {
require(beneficiary != 0x0);
require(validPurchase());
uint256 weiAmount = msg.value;
// calculate token amount to be created
uint256 tokens = weiAmount.mul(rate);
// update state
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
// send ether to the fund collection wallet
// override to create custom fund forwarding mechanisms
function forwardFunds() internal {
wallet.transfer(msg.value);
}
// @return true if the transaction can buy tokens
function validPurchase() internal constant returns (bool) {
bool withinPeriod = now >= startTime && now <= endTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
}
// @return true if crowdsale event has ended
function hasEnded() public constant returns (bool) {
return now > endTime;
}
} | forwardFunds | function forwardFunds() internal {
wallet.transfer(msg.value);
}
| // send ether to the fund collection wallet
// override to create custom fund forwarding mechanisms | LineComment | v0.4.17+commit.bdeb9e52 | bzzr://fe61060f479015f88f84fd83293fdbc8a757fe73f6b4e3ad9f2be3141d07dafb | {
"func_code_index": [
2100,
2175
]
} | 2,254 |
|||
Presale | Presale.sol | 0x2bca686de0b312ab453b676502f3108f4ab83106 | Solidity | Crowdsale | contract Crowdsale {
using SafeMath for uint256;
// The token being sold
MintableToken public token;
// start and end timestamps where investments are allowed (both inclusive)
uint256 public startTime;
uint256 public endTime;
// address where funds are collected
address public wallet;
// how many token units a buyer gets per wei
uint256 public rate;
// amount of raised money in wei
uint256 public weiRaised;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
function Crowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) {
require(_startTime >= now);
require(_endTime >= _startTime);
require(_rate > 0);
require(_wallet != 0x0);
token = createTokenContract();
startTime = _startTime;
endTime = _endTime;
rate = _rate;
wallet = _wallet;
}
// creates the token to be sold.
// override this method to have crowdsale of a specific mintable token.
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
// fallback function can be used to buy tokens
function () payable {
buyTokens(msg.sender);
}
// low level token purchase function
function buyTokens(address beneficiary) public payable {
require(beneficiary != 0x0);
require(validPurchase());
uint256 weiAmount = msg.value;
// calculate token amount to be created
uint256 tokens = weiAmount.mul(rate);
// update state
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
// send ether to the fund collection wallet
// override to create custom fund forwarding mechanisms
function forwardFunds() internal {
wallet.transfer(msg.value);
}
// @return true if the transaction can buy tokens
function validPurchase() internal constant returns (bool) {
bool withinPeriod = now >= startTime && now <= endTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
}
// @return true if crowdsale event has ended
function hasEnded() public constant returns (bool) {
return now > endTime;
}
} | validPurchase | function validPurchase() internal constant returns (bool) {
bool withinPeriod = now >= startTime && now <= endTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
}
| // @return true if the transaction can buy tokens | LineComment | v0.4.17+commit.bdeb9e52 | bzzr://fe61060f479015f88f84fd83293fdbc8a757fe73f6b4e3ad9f2be3141d07dafb | {
"func_code_index": [
2231,
2448
]
} | 2,255 |
|||
Presale | Presale.sol | 0x2bca686de0b312ab453b676502f3108f4ab83106 | Solidity | Crowdsale | contract Crowdsale {
using SafeMath for uint256;
// The token being sold
MintableToken public token;
// start and end timestamps where investments are allowed (both inclusive)
uint256 public startTime;
uint256 public endTime;
// address where funds are collected
address public wallet;
// how many token units a buyer gets per wei
uint256 public rate;
// amount of raised money in wei
uint256 public weiRaised;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
function Crowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) {
require(_startTime >= now);
require(_endTime >= _startTime);
require(_rate > 0);
require(_wallet != 0x0);
token = createTokenContract();
startTime = _startTime;
endTime = _endTime;
rate = _rate;
wallet = _wallet;
}
// creates the token to be sold.
// override this method to have crowdsale of a specific mintable token.
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
// fallback function can be used to buy tokens
function () payable {
buyTokens(msg.sender);
}
// low level token purchase function
function buyTokens(address beneficiary) public payable {
require(beneficiary != 0x0);
require(validPurchase());
uint256 weiAmount = msg.value;
// calculate token amount to be created
uint256 tokens = weiAmount.mul(rate);
// update state
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
// send ether to the fund collection wallet
// override to create custom fund forwarding mechanisms
function forwardFunds() internal {
wallet.transfer(msg.value);
}
// @return true if the transaction can buy tokens
function validPurchase() internal constant returns (bool) {
bool withinPeriod = now >= startTime && now <= endTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
}
// @return true if crowdsale event has ended
function hasEnded() public constant returns (bool) {
return now > endTime;
}
} | hasEnded | function hasEnded() public constant returns (bool) {
return now > endTime;
}
| // @return true if crowdsale event has ended | LineComment | v0.4.17+commit.bdeb9e52 | bzzr://fe61060f479015f88f84fd83293fdbc8a757fe73f6b4e3ad9f2be3141d07dafb | {
"func_code_index": [
2499,
2586
]
} | 2,256 |
|||
Presale | Presale.sol | 0x2bca686de0b312ab453b676502f3108f4ab83106 | Solidity | CappedCrowdsale | contract CappedCrowdsale is Crowdsale {
using SafeMath for uint256;
uint256 public cap;
function CappedCrowdsale(uint256 _cap) {
require(_cap > 0);
cap = _cap;
}
// overriding Crowdsale#validPurchase to add extra cap logic
// @return true if investors can buy at the moment
function validPurchase() internal constant returns (bool) {
bool withinCap = weiRaised.add(msg.value) <= cap;
return super.validPurchase() && withinCap;
}
// overriding Crowdsale#hasEnded to add cap logic
// @return true if crowdsale event has ended
function hasEnded() public constant returns (bool) {
bool capReached = weiRaised >= cap;
return super.hasEnded() || capReached;
}
} | validPurchase | function validPurchase() internal constant returns (bool) {
bool withinCap = weiRaised.add(msg.value) <= cap;
return super.validPurchase() && withinCap;
}
| // overriding Crowdsale#validPurchase to add extra cap logic
// @return true if investors can buy at the moment | LineComment | v0.4.17+commit.bdeb9e52 | bzzr://fe61060f479015f88f84fd83293fdbc8a757fe73f6b4e3ad9f2be3141d07dafb | {
"func_code_index": [
309,
479
]
} | 2,257 |
|||
Presale | Presale.sol | 0x2bca686de0b312ab453b676502f3108f4ab83106 | Solidity | CappedCrowdsale | contract CappedCrowdsale is Crowdsale {
using SafeMath for uint256;
uint256 public cap;
function CappedCrowdsale(uint256 _cap) {
require(_cap > 0);
cap = _cap;
}
// overriding Crowdsale#validPurchase to add extra cap logic
// @return true if investors can buy at the moment
function validPurchase() internal constant returns (bool) {
bool withinCap = weiRaised.add(msg.value) <= cap;
return super.validPurchase() && withinCap;
}
// overriding Crowdsale#hasEnded to add cap logic
// @return true if crowdsale event has ended
function hasEnded() public constant returns (bool) {
bool capReached = weiRaised >= cap;
return super.hasEnded() || capReached;
}
} | hasEnded | function hasEnded() public constant returns (bool) {
bool capReached = weiRaised >= cap;
return super.hasEnded() || capReached;
}
| // overriding Crowdsale#hasEnded to add cap logic
// @return true if crowdsale event has ended | LineComment | v0.4.17+commit.bdeb9e52 | bzzr://fe61060f479015f88f84fd83293fdbc8a757fe73f6b4e3ad9f2be3141d07dafb | {
"func_code_index": [
583,
728
]
} | 2,258 |
|||
Presale | Presale.sol | 0x2bca686de0b312ab453b676502f3108f4ab83106 | Solidity | Presale | contract Presale is CappedCrowdsale, Ownable {
using SafeMath for uint256;
mapping (address => bool) public whitelist;
bool public isFinalized = false;
event Finalized();
address public team = 0x7D72dc07876435d3B2eE498E53A803958bc55b42;
uint256 public teamShare = 150000000 * (10 ** 18);
address public seed = 0x3669ad54675E94e14196528786645c858b8391F1;
uint256 public seedShare = 1805067 * (10 ** 18);
bool public hasAllocated = false;
address public mediator = 0x0;
function Presale(uint256 _startTime, uint256 _endTime, uint256 _rate, uint256 _cap, address _wallet, address _tokenAddress)
Crowdsale(_startTime, _endTime, _rate, _wallet)
CappedCrowdsale(_cap)
{
token = LamdenTau(_tokenAddress);
}
// Crowdsale overrides
function createTokenContract() internal returns (MintableToken) {
return LamdenTau(0x0);
}
function validPurchase() internal constant returns (bool) {
bool withinCap = weiRaised.add(msg.value) <= cap;
bool valid = super.validPurchase() && withinCap && whitelist[msg.sender];
return valid;
}
// * * *
// Finalizer functions. Redefined from FinalizableCrowdsale to prevent diamond inheritence complexities
function finalize() onlyOwner public {
require(mediator != 0x0);
require(!isFinalized);
require(hasEnded());
finalization();
Finalized();
isFinalized = true;
}
function finalization() internal {
// set the ownership to the mediator so it can pass it onto the sale contract
// at the time that the sale contract is deployed
token.transferOwnership(mediator);
Mediator m = Mediator(mediator);
m.acceptToken();
}
// * * *
// Contract Specific functions
function assignMediator(address _m) public onlyOwner returns(bool) {
mediator = _m;
return true;
}
function whitelistUser(address _a) public onlyOwner returns(bool){
whitelist[_a] = true;
return whitelist[_a];
}
function whitelistUsers(address[] users) external onlyOwner {
for (uint i = 0; i < users.length; i++) {
whitelist[users[i]] = true;
}
}
function unWhitelistUser(address _a) public onlyOwner returns(bool){
whitelist[_a] = false;
return whitelist[_a];
}
function unWhitelistUsers(address[] users) external onlyOwner {
for (uint i = 0; i < users.length; i++) {
whitelist[users[i]] = false;
}
}
function allocateTokens() public onlyOwner returns(bool) {
require(hasAllocated == false);
token.mint(team, teamShare);
token.mint(seed, seedShare);
hasAllocated = true;
return hasAllocated;
}
function acceptToken() public onlyOwner returns(bool) {
token.acceptOwnership();
return true;
}
function changeEndTime(uint256 _e) public onlyOwner returns(uint256) {
require(_e > startTime);
endTime = _e;
return endTime;
}
// * * *
} | createTokenContract | function createTokenContract() internal returns (MintableToken) {
return LamdenTau(0x0);
}
| // Crowdsale overrides | LineComment | v0.4.17+commit.bdeb9e52 | bzzr://fe61060f479015f88f84fd83293fdbc8a757fe73f6b4e3ad9f2be3141d07dafb | {
"func_code_index": [
846,
955
]
} | 2,259 |
|||
Presale | Presale.sol | 0x2bca686de0b312ab453b676502f3108f4ab83106 | Solidity | Presale | contract Presale is CappedCrowdsale, Ownable {
using SafeMath for uint256;
mapping (address => bool) public whitelist;
bool public isFinalized = false;
event Finalized();
address public team = 0x7D72dc07876435d3B2eE498E53A803958bc55b42;
uint256 public teamShare = 150000000 * (10 ** 18);
address public seed = 0x3669ad54675E94e14196528786645c858b8391F1;
uint256 public seedShare = 1805067 * (10 ** 18);
bool public hasAllocated = false;
address public mediator = 0x0;
function Presale(uint256 _startTime, uint256 _endTime, uint256 _rate, uint256 _cap, address _wallet, address _tokenAddress)
Crowdsale(_startTime, _endTime, _rate, _wallet)
CappedCrowdsale(_cap)
{
token = LamdenTau(_tokenAddress);
}
// Crowdsale overrides
function createTokenContract() internal returns (MintableToken) {
return LamdenTau(0x0);
}
function validPurchase() internal constant returns (bool) {
bool withinCap = weiRaised.add(msg.value) <= cap;
bool valid = super.validPurchase() && withinCap && whitelist[msg.sender];
return valid;
}
// * * *
// Finalizer functions. Redefined from FinalizableCrowdsale to prevent diamond inheritence complexities
function finalize() onlyOwner public {
require(mediator != 0x0);
require(!isFinalized);
require(hasEnded());
finalization();
Finalized();
isFinalized = true;
}
function finalization() internal {
// set the ownership to the mediator so it can pass it onto the sale contract
// at the time that the sale contract is deployed
token.transferOwnership(mediator);
Mediator m = Mediator(mediator);
m.acceptToken();
}
// * * *
// Contract Specific functions
function assignMediator(address _m) public onlyOwner returns(bool) {
mediator = _m;
return true;
}
function whitelistUser(address _a) public onlyOwner returns(bool){
whitelist[_a] = true;
return whitelist[_a];
}
function whitelistUsers(address[] users) external onlyOwner {
for (uint i = 0; i < users.length; i++) {
whitelist[users[i]] = true;
}
}
function unWhitelistUser(address _a) public onlyOwner returns(bool){
whitelist[_a] = false;
return whitelist[_a];
}
function unWhitelistUsers(address[] users) external onlyOwner {
for (uint i = 0; i < users.length; i++) {
whitelist[users[i]] = false;
}
}
function allocateTokens() public onlyOwner returns(bool) {
require(hasAllocated == false);
token.mint(team, teamShare);
token.mint(seed, seedShare);
hasAllocated = true;
return hasAllocated;
}
function acceptToken() public onlyOwner returns(bool) {
token.acceptOwnership();
return true;
}
function changeEndTime(uint256 _e) public onlyOwner returns(uint256) {
require(_e > startTime);
endTime = _e;
return endTime;
}
// * * *
} | finalize | function finalize() onlyOwner public {
require(mediator != 0x0);
require(!isFinalized);
require(hasEnded());
finalization();
Finalized();
isFinalized = true;
}
| // * * *
// Finalizer functions. Redefined from FinalizableCrowdsale to prevent diamond inheritence complexities | LineComment | v0.4.17+commit.bdeb9e52 | bzzr://fe61060f479015f88f84fd83293fdbc8a757fe73f6b4e3ad9f2be3141d07dafb | {
"func_code_index": [
1330,
1551
]
} | 2,260 |
|||
Presale | Presale.sol | 0x2bca686de0b312ab453b676502f3108f4ab83106 | Solidity | Presale | contract Presale is CappedCrowdsale, Ownable {
using SafeMath for uint256;
mapping (address => bool) public whitelist;
bool public isFinalized = false;
event Finalized();
address public team = 0x7D72dc07876435d3B2eE498E53A803958bc55b42;
uint256 public teamShare = 150000000 * (10 ** 18);
address public seed = 0x3669ad54675E94e14196528786645c858b8391F1;
uint256 public seedShare = 1805067 * (10 ** 18);
bool public hasAllocated = false;
address public mediator = 0x0;
function Presale(uint256 _startTime, uint256 _endTime, uint256 _rate, uint256 _cap, address _wallet, address _tokenAddress)
Crowdsale(_startTime, _endTime, _rate, _wallet)
CappedCrowdsale(_cap)
{
token = LamdenTau(_tokenAddress);
}
// Crowdsale overrides
function createTokenContract() internal returns (MintableToken) {
return LamdenTau(0x0);
}
function validPurchase() internal constant returns (bool) {
bool withinCap = weiRaised.add(msg.value) <= cap;
bool valid = super.validPurchase() && withinCap && whitelist[msg.sender];
return valid;
}
// * * *
// Finalizer functions. Redefined from FinalizableCrowdsale to prevent diamond inheritence complexities
function finalize() onlyOwner public {
require(mediator != 0x0);
require(!isFinalized);
require(hasEnded());
finalization();
Finalized();
isFinalized = true;
}
function finalization() internal {
// set the ownership to the mediator so it can pass it onto the sale contract
// at the time that the sale contract is deployed
token.transferOwnership(mediator);
Mediator m = Mediator(mediator);
m.acceptToken();
}
// * * *
// Contract Specific functions
function assignMediator(address _m) public onlyOwner returns(bool) {
mediator = _m;
return true;
}
function whitelistUser(address _a) public onlyOwner returns(bool){
whitelist[_a] = true;
return whitelist[_a];
}
function whitelistUsers(address[] users) external onlyOwner {
for (uint i = 0; i < users.length; i++) {
whitelist[users[i]] = true;
}
}
function unWhitelistUser(address _a) public onlyOwner returns(bool){
whitelist[_a] = false;
return whitelist[_a];
}
function unWhitelistUsers(address[] users) external onlyOwner {
for (uint i = 0; i < users.length; i++) {
whitelist[users[i]] = false;
}
}
function allocateTokens() public onlyOwner returns(bool) {
require(hasAllocated == false);
token.mint(team, teamShare);
token.mint(seed, seedShare);
hasAllocated = true;
return hasAllocated;
}
function acceptToken() public onlyOwner returns(bool) {
token.acceptOwnership();
return true;
}
function changeEndTime(uint256 _e) public onlyOwner returns(uint256) {
require(_e > startTime);
endTime = _e;
return endTime;
}
// * * *
} | assignMediator | function assignMediator(address _m) public onlyOwner returns(bool) {
mediator = _m;
return true;
}
| // * * *
// Contract Specific functions | LineComment | v0.4.17+commit.bdeb9e52 | bzzr://fe61060f479015f88f84fd83293fdbc8a757fe73f6b4e3ad9f2be3141d07dafb | {
"func_code_index": [
1916,
2042
]
} | 2,261 |
|||
Presale | Presale.sol | 0x2bca686de0b312ab453b676502f3108f4ab83106 | Solidity | Sale | contract Sale is CappedCrowdsale, Ownable {
using SafeMath for uint256;
// Initialization Variables
uint256 public amountPerDay; // 30 eth
uint256 public constant UNIX_DAY = 86400;
bool public isFinalized = false;
event Finalized();
mapping (address => bool) public whitelist;
mapping (address => uint256) public amountContributedBy;
// * * *
// Constructor
function Sale(uint256 _startTime, uint256 _endTime, uint256 _rate, uint256 _cap, address _wallet, uint256 _amountPerDay, address _tokenAddress)
Crowdsale(_startTime, _endTime, _rate, _wallet)
CappedCrowdsale(_cap)
{
amountPerDay = _amountPerDay;
token = LamdenTau(_tokenAddress);
}
// * * *
// Crowdsale overrides
function createTokenContract() internal returns (MintableToken) {
return LamdenTau(0x0);
}
function validPurchase() internal constant returns (bool) {
bool withinCap = weiRaised.add(msg.value) <= cap;
bool withinContributionLimit = msg.value <= currentPersonalLimit(msg.sender);
bool valid = super.validPurchase() && withinCap && whitelist[msg.sender] && withinContributionLimit;
return valid;
}
function buyTokens(address beneficiary) public payable {
super.buyTokens(beneficiary);
amountContributedBy[msg.sender] = amountContributedBy[msg.sender].add(msg.value);
}
// * * *
// Finalizer functions
function finalize() onlyOwner public {
require(!isFinalized);
require(hasEnded());
finalization();
Finalized();
isFinalized = true;
}
function finalization() internal {
token.finishMinting();
}
// * * *
// Contract Specific functions
function daysSinceLaunch() public constant returns(uint256) {
return now.sub(startTime).div(UNIX_DAY);
}
function currentContributionLimit() public constant returns(uint256) {
return amountPerDay.mul(2 ** daysSinceLaunch());
}
function currentPersonalLimit(address _a) public constant returns(uint256) {
return currentContributionLimit().sub(amountContributedBy[_a]);
}
function claimToken(address _m) public onlyOwner returns(bool) {
Mediator m = Mediator(_m);
m.passOff();
token.acceptOwnership();
return true;
}
function whitelistUser(address _a) onlyOwner public returns(bool) {
whitelist[_a] = true;
return whitelist[_a];
}
function whitelistUsers(address[] users) external onlyOwner {
for (uint i = 0; i < users.length; i++) {
whitelist[users[i]] = true;
}
}
function unWhitelistUser(address _a) public onlyOwner returns(bool){
whitelist[_a] = false;
return whitelist[_a];
}
function unWhitelistUsers(address[] users) external onlyOwner {
for (uint i = 0; i < users.length; i++) {
whitelist[users[i]] = false;
}
}
function changeEndTime(uint256 _e) public onlyOwner returns(uint256) {
require(_e > startTime);
endTime = _e;
return endTime;
}
// * * *
} | Sale | function Sale(uint256 _startTime, uint256 _endTime, uint256 _rate, uint256 _cap, address _wallet, uint256 _amountPerDay, address _tokenAddress)
Crowdsale(_startTime, _endTime, _rate, _wallet)
CappedCrowdsale(_cap)
{
amountPerDay = _amountPerDay;
token = LamdenTau(_tokenAddress);
}
| // * * *
// Constructor | LineComment | v0.4.17+commit.bdeb9e52 | bzzr://fe61060f479015f88f84fd83293fdbc8a757fe73f6b4e3ad9f2be3141d07dafb | {
"func_code_index": [
417,
741
]
} | 2,262 |
|||
Presale | Presale.sol | 0x2bca686de0b312ab453b676502f3108f4ab83106 | Solidity | Sale | contract Sale is CappedCrowdsale, Ownable {
using SafeMath for uint256;
// Initialization Variables
uint256 public amountPerDay; // 30 eth
uint256 public constant UNIX_DAY = 86400;
bool public isFinalized = false;
event Finalized();
mapping (address => bool) public whitelist;
mapping (address => uint256) public amountContributedBy;
// * * *
// Constructor
function Sale(uint256 _startTime, uint256 _endTime, uint256 _rate, uint256 _cap, address _wallet, uint256 _amountPerDay, address _tokenAddress)
Crowdsale(_startTime, _endTime, _rate, _wallet)
CappedCrowdsale(_cap)
{
amountPerDay = _amountPerDay;
token = LamdenTau(_tokenAddress);
}
// * * *
// Crowdsale overrides
function createTokenContract() internal returns (MintableToken) {
return LamdenTau(0x0);
}
function validPurchase() internal constant returns (bool) {
bool withinCap = weiRaised.add(msg.value) <= cap;
bool withinContributionLimit = msg.value <= currentPersonalLimit(msg.sender);
bool valid = super.validPurchase() && withinCap && whitelist[msg.sender] && withinContributionLimit;
return valid;
}
function buyTokens(address beneficiary) public payable {
super.buyTokens(beneficiary);
amountContributedBy[msg.sender] = amountContributedBy[msg.sender].add(msg.value);
}
// * * *
// Finalizer functions
function finalize() onlyOwner public {
require(!isFinalized);
require(hasEnded());
finalization();
Finalized();
isFinalized = true;
}
function finalization() internal {
token.finishMinting();
}
// * * *
// Contract Specific functions
function daysSinceLaunch() public constant returns(uint256) {
return now.sub(startTime).div(UNIX_DAY);
}
function currentContributionLimit() public constant returns(uint256) {
return amountPerDay.mul(2 ** daysSinceLaunch());
}
function currentPersonalLimit(address _a) public constant returns(uint256) {
return currentContributionLimit().sub(amountContributedBy[_a]);
}
function claimToken(address _m) public onlyOwner returns(bool) {
Mediator m = Mediator(_m);
m.passOff();
token.acceptOwnership();
return true;
}
function whitelistUser(address _a) onlyOwner public returns(bool) {
whitelist[_a] = true;
return whitelist[_a];
}
function whitelistUsers(address[] users) external onlyOwner {
for (uint i = 0; i < users.length; i++) {
whitelist[users[i]] = true;
}
}
function unWhitelistUser(address _a) public onlyOwner returns(bool){
whitelist[_a] = false;
return whitelist[_a];
}
function unWhitelistUsers(address[] users) external onlyOwner {
for (uint i = 0; i < users.length; i++) {
whitelist[users[i]] = false;
}
}
function changeEndTime(uint256 _e) public onlyOwner returns(uint256) {
require(_e > startTime);
endTime = _e;
return endTime;
}
// * * *
} | createTokenContract | function createTokenContract() internal returns (MintableToken) {
return LamdenTau(0x0);
}
| // * * *
// Crowdsale overrides | LineComment | v0.4.17+commit.bdeb9e52 | bzzr://fe61060f479015f88f84fd83293fdbc8a757fe73f6b4e3ad9f2be3141d07dafb | {
"func_code_index": [
790,
899
]
} | 2,263 |
|||
Presale | Presale.sol | 0x2bca686de0b312ab453b676502f3108f4ab83106 | Solidity | Sale | contract Sale is CappedCrowdsale, Ownable {
using SafeMath for uint256;
// Initialization Variables
uint256 public amountPerDay; // 30 eth
uint256 public constant UNIX_DAY = 86400;
bool public isFinalized = false;
event Finalized();
mapping (address => bool) public whitelist;
mapping (address => uint256) public amountContributedBy;
// * * *
// Constructor
function Sale(uint256 _startTime, uint256 _endTime, uint256 _rate, uint256 _cap, address _wallet, uint256 _amountPerDay, address _tokenAddress)
Crowdsale(_startTime, _endTime, _rate, _wallet)
CappedCrowdsale(_cap)
{
amountPerDay = _amountPerDay;
token = LamdenTau(_tokenAddress);
}
// * * *
// Crowdsale overrides
function createTokenContract() internal returns (MintableToken) {
return LamdenTau(0x0);
}
function validPurchase() internal constant returns (bool) {
bool withinCap = weiRaised.add(msg.value) <= cap;
bool withinContributionLimit = msg.value <= currentPersonalLimit(msg.sender);
bool valid = super.validPurchase() && withinCap && whitelist[msg.sender] && withinContributionLimit;
return valid;
}
function buyTokens(address beneficiary) public payable {
super.buyTokens(beneficiary);
amountContributedBy[msg.sender] = amountContributedBy[msg.sender].add(msg.value);
}
// * * *
// Finalizer functions
function finalize() onlyOwner public {
require(!isFinalized);
require(hasEnded());
finalization();
Finalized();
isFinalized = true;
}
function finalization() internal {
token.finishMinting();
}
// * * *
// Contract Specific functions
function daysSinceLaunch() public constant returns(uint256) {
return now.sub(startTime).div(UNIX_DAY);
}
function currentContributionLimit() public constant returns(uint256) {
return amountPerDay.mul(2 ** daysSinceLaunch());
}
function currentPersonalLimit(address _a) public constant returns(uint256) {
return currentContributionLimit().sub(amountContributedBy[_a]);
}
function claimToken(address _m) public onlyOwner returns(bool) {
Mediator m = Mediator(_m);
m.passOff();
token.acceptOwnership();
return true;
}
function whitelistUser(address _a) onlyOwner public returns(bool) {
whitelist[_a] = true;
return whitelist[_a];
}
function whitelistUsers(address[] users) external onlyOwner {
for (uint i = 0; i < users.length; i++) {
whitelist[users[i]] = true;
}
}
function unWhitelistUser(address _a) public onlyOwner returns(bool){
whitelist[_a] = false;
return whitelist[_a];
}
function unWhitelistUsers(address[] users) external onlyOwner {
for (uint i = 0; i < users.length; i++) {
whitelist[users[i]] = false;
}
}
function changeEndTime(uint256 _e) public onlyOwner returns(uint256) {
require(_e > startTime);
endTime = _e;
return endTime;
}
// * * *
} | finalize | function finalize() onlyOwner public {
require(!isFinalized);
require(hasEnded());
finalization();
Finalized();
isFinalized = true;
}
| // * * *
// Finalizer functions | LineComment | v0.4.17+commit.bdeb9e52 | bzzr://fe61060f479015f88f84fd83293fdbc8a757fe73f6b4e3ad9f2be3141d07dafb | {
"func_code_index": [
1502,
1684
]
} | 2,264 |
|||
Presale | Presale.sol | 0x2bca686de0b312ab453b676502f3108f4ab83106 | Solidity | Sale | contract Sale is CappedCrowdsale, Ownable {
using SafeMath for uint256;
// Initialization Variables
uint256 public amountPerDay; // 30 eth
uint256 public constant UNIX_DAY = 86400;
bool public isFinalized = false;
event Finalized();
mapping (address => bool) public whitelist;
mapping (address => uint256) public amountContributedBy;
// * * *
// Constructor
function Sale(uint256 _startTime, uint256 _endTime, uint256 _rate, uint256 _cap, address _wallet, uint256 _amountPerDay, address _tokenAddress)
Crowdsale(_startTime, _endTime, _rate, _wallet)
CappedCrowdsale(_cap)
{
amountPerDay = _amountPerDay;
token = LamdenTau(_tokenAddress);
}
// * * *
// Crowdsale overrides
function createTokenContract() internal returns (MintableToken) {
return LamdenTau(0x0);
}
function validPurchase() internal constant returns (bool) {
bool withinCap = weiRaised.add(msg.value) <= cap;
bool withinContributionLimit = msg.value <= currentPersonalLimit(msg.sender);
bool valid = super.validPurchase() && withinCap && whitelist[msg.sender] && withinContributionLimit;
return valid;
}
function buyTokens(address beneficiary) public payable {
super.buyTokens(beneficiary);
amountContributedBy[msg.sender] = amountContributedBy[msg.sender].add(msg.value);
}
// * * *
// Finalizer functions
function finalize() onlyOwner public {
require(!isFinalized);
require(hasEnded());
finalization();
Finalized();
isFinalized = true;
}
function finalization() internal {
token.finishMinting();
}
// * * *
// Contract Specific functions
function daysSinceLaunch() public constant returns(uint256) {
return now.sub(startTime).div(UNIX_DAY);
}
function currentContributionLimit() public constant returns(uint256) {
return amountPerDay.mul(2 ** daysSinceLaunch());
}
function currentPersonalLimit(address _a) public constant returns(uint256) {
return currentContributionLimit().sub(amountContributedBy[_a]);
}
function claimToken(address _m) public onlyOwner returns(bool) {
Mediator m = Mediator(_m);
m.passOff();
token.acceptOwnership();
return true;
}
function whitelistUser(address _a) onlyOwner public returns(bool) {
whitelist[_a] = true;
return whitelist[_a];
}
function whitelistUsers(address[] users) external onlyOwner {
for (uint i = 0; i < users.length; i++) {
whitelist[users[i]] = true;
}
}
function unWhitelistUser(address _a) public onlyOwner returns(bool){
whitelist[_a] = false;
return whitelist[_a];
}
function unWhitelistUsers(address[] users) external onlyOwner {
for (uint i = 0; i < users.length; i++) {
whitelist[users[i]] = false;
}
}
function changeEndTime(uint256 _e) public onlyOwner returns(uint256) {
require(_e > startTime);
endTime = _e;
return endTime;
}
// * * *
} | daysSinceLaunch | function daysSinceLaunch() public constant returns(uint256) {
return now.sub(startTime).div(UNIX_DAY);
}
| // * * *
// Contract Specific functions | LineComment | v0.4.17+commit.bdeb9e52 | bzzr://fe61060f479015f88f84fd83293fdbc8a757fe73f6b4e3ad9f2be3141d07dafb | {
"func_code_index": [
1827,
1950
]
} | 2,265 |
|||
YaoChainToken | YaoChainToken.sol | 0x58dd024f550acf4cc885f2bc51d320b3afba8552 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint remaining) {}
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
} | totalSupply | function totalSupply() constant returns (uint supply) {}
| /// @return total amount of tokens | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://e0bac22a44dd9ffcf0ea72724217e01a92e73aa7e686e858b3568550a242edf4 | {
"func_code_index": [
60,
121
]
} | 2,266 |
|||
YaoChainToken | YaoChainToken.sol | 0x58dd024f550acf4cc885f2bc51d320b3afba8552 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint remaining) {}
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
} | balanceOf | function balanceOf(address _owner) constant returns (uint balance) {}
| /// @param _owner The address from which the balance will be retrieved
/// @return The balance | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://e0bac22a44dd9ffcf0ea72724217e01a92e73aa7e686e858b3568550a242edf4 | {
"func_code_index": [
229,
303
]
} | 2,267 |
|||
YaoChainToken | YaoChainToken.sol | 0x58dd024f550acf4cc885f2bc51d320b3afba8552 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint remaining) {}
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
} | transfer | function transfer(address _to, uint _value) returns (bool success) {}
| /// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://e0bac22a44dd9ffcf0ea72724217e01a92e73aa7e686e858b3568550a242edf4 | {
"func_code_index": [
540,
614
]
} | 2,268 |
|||
YaoChainToken | YaoChainToken.sol | 0x58dd024f550acf4cc885f2bc51d320b3afba8552 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint remaining) {}
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
} | transferFrom | function transferFrom(address _from, address _to, uint _value) returns (bool success) {}
| /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://e0bac22a44dd9ffcf0ea72724217e01a92e73aa7e686e858b3568550a242edf4 | {
"func_code_index": [
937,
1030
]
} | 2,269 |
|||
YaoChainToken | YaoChainToken.sol | 0x58dd024f550acf4cc885f2bc51d320b3afba8552 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint remaining) {}
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
} | approve | function approve(address _spender, uint _value) returns (bool success) {}
| /// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://e0bac22a44dd9ffcf0ea72724217e01a92e73aa7e686e858b3568550a242edf4 | {
"func_code_index": [
1314,
1392
]
} | 2,270 |
|||
YaoChainToken | YaoChainToken.sol | 0x58dd024f550acf4cc885f2bc51d320b3afba8552 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint remaining) {}
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
} | allowance | function allowance(address _owner, address _spender) constant returns (uint remaining) {}
| /// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://e0bac22a44dd9ffcf0ea72724217e01a92e73aa7e686e858b3568550a242edf4 | {
"func_code_index": [
1600,
1694
]
} | 2,271 |
|||
YaoChainToken | YaoChainToken.sol | 0x58dd024f550acf4cc885f2bc51d320b3afba8552 | Solidity | UnboundedRegularToken | contract UnboundedRegularToken is RegularToken {
uint constant MAX_UINT = 2**256 - 1;
/// @dev ERC20 transferFrom, modified such that an allowance of MAX_UINT represents an unlimited amount.
/// @param _from Address to transfer from.
/// @param _to Address to transfer to.
/// @param _value Amount to transfer.
/// @return Success of transfer.
function transferFrom(address _from, address _to, uint _value)
public
returns (bool)
{
uint allowance = allowed[_from][msg.sender];
if (balances[_from] >= _value
&& allowance >= _value
&& balances[_to] + _value >= balances[_to]
) {
balances[_to] += _value;
balances[_from] -= _value;
if (allowance < MAX_UINT) {
allowed[_from][msg.sender] -= _value;
}
Transfer(_from, _to, _value);
return true;
} else {
return false;
}
}
} | transferFrom | function transferFrom(address _from, address _to, uint _value)
public
returns (bool)
{
uint allowance = allowed[_from][msg.sender];
if (balances[_from] >= _value
&& allowance >= _value
&& balances[_to] + _value >= balances[_to]
) {
balances[_to] += _value;
balances[_from] -= _value;
if (allowance < MAX_UINT) {
allowed[_from][msg.sender] -= _value;
}
Transfer(_from, _to, _value);
return true;
} else {
return false;
}
}
| /// @dev ERC20 transferFrom, modified such that an allowance of MAX_UINT represents an unlimited amount.
/// @param _from Address to transfer from.
/// @param _to Address to transfer to.
/// @param _value Amount to transfer.
/// @return Success of transfer. | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://e0bac22a44dd9ffcf0ea72724217e01a92e73aa7e686e858b3568550a242edf4 | {
"func_code_index": [
383,
1016
]
} | 2,272 |
|||
CrossAssetSwap | CrossAssetSwap.sol | 0x95470f8e330d20788e76e8da3063c9a19555ac0c | 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 () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), 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 {
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;
}
} | /**
* @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.0+commit.c7dfd78e | MIT | ipfs://58155467ed651020d1f8c07012ccbc9978eba79dd5a5f5d2da3f60329adb57fa | {
"func_code_index": [
497,
589
]
} | 2,273 |
CrossAssetSwap | CrossAssetSwap.sol | 0x95470f8e330d20788e76e8da3063c9a19555ac0c | 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 () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), 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 {
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;
}
} | /**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/ | NatSpecMultiLine | renounceOwnership | function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
| /**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://58155467ed651020d1f8c07012ccbc9978eba79dd5a5f5d2da3f60329adb57fa | {
"func_code_index": [
1148,
1301
]
} | 2,274 |
CrossAssetSwap | CrossAssetSwap.sol | 0x95470f8e330d20788e76e8da3063c9a19555ac0c | 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 () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), 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 {
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;
}
} | /**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/ | NatSpecMultiLine | transferOwnership | function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
| /**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://58155467ed651020d1f8c07012ccbc9978eba79dd5a5f5d2da3f60329adb57fa | {
"func_code_index": [
1451,
1700
]
} | 2,275 |
CrossAssetSwap | CrossAssetSwap.sol | 0x95470f8e330d20788e76e8da3063c9a19555ac0c | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
} | balanceOf | function balanceOf(address account) external view returns (uint256);
| /**
* @dev Returns the amount of tokens owned by `account`.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://58155467ed651020d1f8c07012ccbc9978eba79dd5a5f5d2da3f60329adb57fa | {
"func_code_index": [
106,
179
]
} | 2,276 |
||
CrossAssetSwap | CrossAssetSwap.sol | 0x95470f8e330d20788e76e8da3063c9a19555ac0c | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
} | transfer | function transfer(address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://58155467ed651020d1f8c07012ccbc9978eba79dd5a5f5d2da3f60329adb57fa | {
"func_code_index": [
421,
503
]
} | 2,277 |
||
CrossAssetSwap | CrossAssetSwap.sol | 0x95470f8e330d20788e76e8da3063c9a19555ac0c | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
} | transferFrom | function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://58155467ed651020d1f8c07012ccbc9978eba79dd5a5f5d2da3f60329adb57fa | {
"func_code_index": [
816,
918
]
} | 2,278 |
||
CrossAssetSwap | CrossAssetSwap.sol | 0x95470f8e330d20788e76e8da3063c9a19555ac0c | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
} | approve | function approve(address spender, uint256 amount) external returns (bool);
| /**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://58155467ed651020d1f8c07012ccbc9978eba79dd5a5f5d2da3f60329adb57fa | {
"func_code_index": [
1582,
1661
]
} | 2,279 |
||
CrossAssetSwap | CrossAssetSwap.sol | 0x95470f8e330d20788e76e8da3063c9a19555ac0c | Solidity | IERC721 | interface IERC721 {
/// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE
/// TO CONFIRM THAT `_to` IS CAPABLE OF RECEIVING NFTS OR ELSE
/// THEY MAY BE PERMANENTLY LOST
/// @dev Throws unless `msg.sender` is the current owner, an authorized
/// operator, or the approved address for this NFT. Throws if `_from` is
/// not the current owner. Throws if `_to` is the zero address. Throws if
/// `_tokenId` is not a valid NFT.
/// @param _from The current owner of the NFT
/// @param _to The new owner
/// @param _tokenId The NFT to transfer
function transferFrom(address _from, address _to, uint256 _tokenId) external payable;
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) external;
function setApprovalForAll(address operator, bool approved) external;
function approve(address to, uint256 tokenId) external;
function isApprovedForAll(address owner, address operator) external returns (bool);
} | transferFrom | function transferFrom(address _from, address _to, uint256 _tokenId) external payable;
| /// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE
/// TO CONFIRM THAT `_to` IS CAPABLE OF RECEIVING NFTS OR ELSE
/// THEY MAY BE PERMANENTLY LOST
/// @dev Throws unless `msg.sender` is the current owner, an authorized
/// operator, or the approved address for this NFT. Throws if `_from` is
/// not the current owner. Throws if `_to` is the zero address. Throws if
/// `_tokenId` is not a valid NFT.
/// @param _from The current owner of the NFT
/// @param _to The new owner
/// @param _tokenId The NFT to transfer | NatSpecSingleLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://58155467ed651020d1f8c07012ccbc9978eba79dd5a5f5d2da3f60329adb57fa | {
"func_code_index": [
611,
701
]
} | 2,280 |
||
CrossAssetSwap | CrossAssetSwap.sol | 0x95470f8e330d20788e76e8da3063c9a19555ac0c | Solidity | CrossAssetSwap | contract CrossAssetSwap is Ownable {
struct ERC20Details {
address[] tokenAddrs;
uint256[] amounts;
}
struct ERC721Details {
address tokenAddr;
uint256[] ids;
MarketRegistry.SellDetails[] sellDetails;
}
struct ERC1155Details {
address tokenAddr;
uint256[] ids;
uint256[] amounts;
MarketRegistry.SellDetails[] sellDetails;
}
MarketRegistry public marketRegistry;
ExchangeRegistry public exchangeRegistry;
address public constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
address public constant MAINTAINER = 0x073Ab1C0CAd3677cDe9BDb0cDEEDC2085c029579;
uint256 public FEES = 300;
constructor(address _marketRegistry, address _exchangeRegistry) {
marketRegistry = MarketRegistry(_marketRegistry);
exchangeRegistry = ExchangeRegistry(_exchangeRegistry);
}
function updateFees(uint256 newFees) external {
require(msg.sender == MAINTAINER, "updateFees: invalid caller.");
FEES = newFees;
}
function _transferHelper(
ERC20Details memory _inputERC20s,
ERC721Details[] memory inputERC721s,
ERC1155Details[] memory inputERC1155s
) internal returns (address[] memory _erc20AddrsIn, uint256[] memory _erc20AmountsIn) {
address[] memory _addrsIn1;
address[] memory _addrsIn2;
uint256[] memory _amountsIn1;
uint256[] memory _amountsIn2;
// transfer ERC20 tokens from the sender to this contract
for (uint256 i = 0; i < _inputERC20s.tokenAddrs.length; i++) {
require(
IERC20(_inputERC20s.tokenAddrs[i]).transferFrom(
msg.sender,
address(this),
_inputERC20s.amounts[i]
),
"_transferHelper: transfer failed"
);
}
// transfer ERC721 tokens from the sender to this contract
for (uint256 i = 0; i < inputERC721s.length; i++) {
for (uint256 j = 0; j < inputERC721s[i].ids.length; j++) {
IERC721(inputERC721s[i].tokenAddr).transferFrom(
msg.sender,
address(this),
inputERC721s[i].ids[j]
);
}
(_addrsIn1, _amountsIn1) = _sellNFT(inputERC721s[i].sellDetails);
}
// transfer ERC1155 tokens from the sender to this contract
for (uint256 i = 0; i < inputERC1155s.length; i++) {
IERC1155(inputERC1155s[i].tokenAddr).safeBatchTransferFrom(
msg.sender,
address(this),
inputERC1155s[i].ids,
inputERC1155s[i].amounts,
""
);
(_addrsIn2, _amountsIn2) = _sellNFT(inputERC1155s[i].sellDetails);
}
// return _erc20AddrsIn, _erc20AmountsIn
{
uint256 totalLen = msg.value > 0
? _inputERC20s.tokenAddrs.length+_addrsIn1.length+_addrsIn2.length+1
: _inputERC20s.tokenAddrs.length+_addrsIn1.length+_addrsIn2.length;
_erc20AddrsIn = new address[](totalLen);
_erc20AmountsIn = new uint256[](totalLen);
if (msg.value > 0) {
_erc20AddrsIn[totalLen-1] = ETH;
_erc20AmountsIn[totalLen-1] = msg.value;
}
// populate the arrays
for (uint256 i = 0; i < _inputERC20s.tokenAddrs.length; i++) {
_erc20AddrsIn[i] = _inputERC20s.tokenAddrs[i];
_erc20AmountsIn[i] = _inputERC20s.amounts[i];
}
totalLen = _inputERC20s.tokenAddrs.length-1;
for (uint256 i = 0; i < _addrsIn1.length; i++) {
_erc20AddrsIn[_inputERC20s.tokenAddrs.length+i] = _addrsIn1[i];
_erc20AmountsIn[_inputERC20s.tokenAddrs.length+i] = _amountsIn1[i];
}
totalLen = _inputERC20s.tokenAddrs.length+_addrsIn1.length-1;
for (uint256 i = 0; i < _addrsIn2.length; i++) {
_erc20AddrsIn[totalLen+i] = _addrsIn2[i];
_erc20AmountsIn[totalLen+i] = _amountsIn2[i];
}
}
}
// swaps any combination of ERC-20/721/1155
// User needs to approve assets before invoking swap
function multiAssetSwap(
ERC20Details memory inputERC20s,
ERC721Details[] memory inputERC721s,
ERC1155Details[] memory inputERC1155s,
MarketRegistry.BuyDetails[] memory buyDetails,
ExchangeRegistry.SwapDetails[] memory swapDetails,
address[] memory addrs // [changeIn, exchange, recipient]
) payable external {
address[] memory _erc20AddrsIn;
uint256[] memory _erc20AmountsIn;
// transfer all tokens
(_erc20AddrsIn, _erc20AmountsIn) = _transferHelper(
inputERC20s,
inputERC721s,
inputERC1155s
);
// execute all swaps
_swap(
swapDetails,
buyDetails,
_erc20AmountsIn,
_erc20AddrsIn,
addrs[0],
addrs[1],
addrs[2]
);
}
event Data(ERC721Details[]);
function buyNftForERC20(
MarketRegistry.BuyDetails[] memory buyDetails,
ExchangeRegistry.SwapDetails[] memory swapDetails,
ERC20Details memory inputErc20Details,
address[] memory addrs // [changeIn, exchange, recipient]
) external {
// transfer the fees
require(
IERC20(inputErc20Details.tokenAddrs[0]).transferFrom(msg.sender, MAINTAINER, FEES*inputErc20Details.amounts[0]/10000),
"buyNftForERC20: fees transfer failed"
);
// transfer the inputErc20 to the contract
require(
IERC20(inputErc20Details.tokenAddrs[0]).transferFrom(msg.sender, address(this), (10000-FEES)*inputErc20Details.amounts[0]/10000),
"buyNftForERC20: transfer failed"
);
// swap to desired assets if needed
for (uint256 i=0; i < swapDetails.length; i++) {
(address proxy, ) = exchangeRegistry.exchanges(swapDetails[i].exchangeId);
(bool success, ) = proxy.delegatecall(swapDetails[i].swapData);
require(success, "buyNftForERC20: swap failed.");
}
// buy NFTs
_buyNFT(buyDetails);
// Note: We know it as a fact that only input ERC20 can be the dust asset
// return remaining input ERC20
if(addrs[0] == inputErc20Details.tokenAddrs[0]) {
IERC20(inputErc20Details.tokenAddrs[0]).transfer(msg.sender, IERC20(inputErc20Details.tokenAddrs[0]).balanceOf(address(this)));
}
// return remaining ETH
else if(addrs[0] == ETH) {
(bool success, ) = addrs[1].delegatecall(abi.encodeWithSignature("swapExactERC20ForETH(address,address,uint256)", inputErc20Details.tokenAddrs[0], addrs[2], IERC20(inputErc20Details.tokenAddrs[0]).balanceOf(address(this))));
require(success, "buyNftForERC20: return failed.");
}
// return remaining ERC20
else {
(bool success, ) = addrs[1].delegatecall(abi.encodeWithSignature("swapExactERC20ForERC20(address,address,address,uint256)", inputErc20Details.tokenAddrs[0], addrs[0], addrs[2], IERC20(inputErc20Details.tokenAddrs[0]).balanceOf(address(this))));
require(success, "buyNftForERC20: return failed.");
}
}
function buyNftForEth(
MarketRegistry.BuyDetails[] memory buyDetails,
ExchangeRegistry.SwapDetails[] memory swapDetails,
address[] memory addrs // [changeIn, exchange, recipient]
) external payable {
bool success;
(success, ) = MAINTAINER.call{value:FEES*address(this).balance/10000}('');
require(success, "buyNftForEth: fees failed.");
// swap to desired assets if needed
for (uint256 i=0; i < swapDetails.length; i++) {
(address proxy, ) = exchangeRegistry.exchanges(swapDetails[i].exchangeId);
(success, ) = proxy.delegatecall(swapDetails[i].swapData);
require(success, "buyNftForEth: swap failed.");
}
// buy NFT
_buyNFT(buyDetails);
// Note: We know it as a fact that only Eth can be the dust asset
// return remaining ETH
if(addrs[0] == ETH) {
(success, ) = msg.sender.call{value:address(this).balance}('');
require(success, "buyNftForEth: return failed.");
}
// return remaining ERC20
else {
(success, ) = addrs[1].delegatecall(abi.encodeWithSignature("swapExactETHForERC20(address,address,uint256)", addrs[0], addrs[2], 0));
require(success, "buyNftForEth: return failed.");
}
}
function _sellNFT(
MarketRegistry.SellDetails[] memory _sellDetails
) internal returns(address[] memory erc20Addrs, uint256[] memory erc20Amounts) {
erc20Addrs = new address[](_sellDetails.length);
erc20Amounts = new uint256[](_sellDetails.length);
// sell ERC1155 assets to respective markets
for (uint256 i = 0; i < _sellDetails.length; i++) {
// fetch the market details
(, , address _proxy, bool _isActive) = marketRegistry.markets(_sellDetails[i].marketId);
// the market should be active
require(_isActive, "_sellNFT: InActive Market");
// sell the specified asset
(bool success, bytes memory data) = _proxy.delegatecall(_sellDetails[i].sellData);
// check if the delegatecall passed successfully
require(success, "_sellNFT: sell failed.");
// populate return values
(erc20Addrs[i], erc20Amounts[i]) = abi.decode(
data,
(address, uint256)
);
}
}
function _buyNFT(
MarketRegistry.BuyDetails[] memory _buyDetails
) internal {
for (uint256 i = 0; i < _buyDetails.length; i++) {
// get market details
(, , address _proxy, bool _isActive) = marketRegistry.markets(_buyDetails[i].marketId);
// market should be active
require(_isActive, "function: InActive Market");
// buy NFT with ETH or ERC20
(bool success, ) = _proxy.delegatecall(_buyDetails[i].buyData);
// check if the delegatecall passed successfully
require(success, "_buyNFT: buy failed.");
}
}
function _returnChange(
address _changeIn,
address _erc20AddrIn,
address _recipient,
address _proxy,
uint256 _erc20AmountIn
) internal {
bool success;
// in case desired changeIn is NOT the equivalent ERC20
if (_changeIn != _erc20AddrIn) {
// get market address
// (address proxy, ) = exchangeRegistry.exchanges(_exchangeId);
// in case input asset is ETH
if(_erc20AddrIn == ETH) {
(success, ) = _proxy.delegatecall(abi.encodeWithSignature("swapExactETHForERC20(address,address,uint256)", _changeIn, _recipient, 0));
require(success, "_returnChange: return failed.");
}
// in case changeIn is ETH
else if(_changeIn == ETH) {
// Convert all the _erc20Amount to _changeIn ERC20
(success, ) = _proxy.delegatecall(abi.encodeWithSignature("swapExactERC20ForETH(address,address,uint256)", _erc20AddrIn, _recipient, _erc20AmountIn));
require(success, "_returnChange: return failed.");
}
// in case changeIn is some other ERC20
else {
// execute exchange
(success, ) = _proxy.delegatecall(abi.encodeWithSignature("swapExactERC20ForERC20(address,address,address,uint256)", _erc20AddrIn, _changeIn, _recipient, _erc20AmountIn));
require(success, "_returnChange: return failed.");
}
}
// in case desired changeIn is the equivalent ERC20
else {
IERC20(_changeIn).transfer(_recipient, _erc20AmountIn);
}
}
function _swap(
ExchangeRegistry.SwapDetails[] memory _swapDetails,
MarketRegistry.BuyDetails[] memory _buyDetails,
uint256[] memory _erc20AmountsIn,
address[] memory _erc20AddrsIn,
address _changeIn,
address _exchange,
address _recipient
) internal {
bool success;
// in case user does NOT want to buy any NFTs
if(_buyDetails.length == 0) {
for(uint256 i = 0; i < _erc20AddrsIn.length; i++) {
_returnChange(
_changeIn,
_erc20AddrsIn[i],
_recipient,
_exchange,
_erc20AmountsIn[i]
);
}
}
// in case user wants to buy NFTs
else {
for (uint256 i = 0; i < _swapDetails.length; i++) {
// get market address
(address proxy, ) = exchangeRegistry.exchanges(_swapDetails[i].exchangeId);
// execute swap
(success, ) = proxy.delegatecall(_swapDetails[i].swapData);
require(success, "_swap: swap failed.");
}
// buy the NFTs
_buyNFT(_buyDetails);
// return remaining amount to the user
for (uint256 i = 0; i < _erc20AddrsIn.length; i++) {
_returnChange(
_changeIn,
_erc20AddrsIn[i],
_recipient,
_exchange,
_erc20AddrsIn[i] == ETH
? address(this).balance
: IERC20(_erc20AddrsIn[i]).balanceOf(address(this))
);
}
}
}
function _executeSingleTrxSwap(
bytes memory _data,
address _from
) internal {
// decode the trade details
MarketRegistry.SellDetails[] memory _sellDetails;
ExchangeRegistry.SwapDetails[] memory _swapDetails;
MarketRegistry.BuyDetails[] memory _buyDetails;
address[] memory addrs; // [changeIn, exchange, recipient]
(_sellDetails, _swapDetails, _buyDetails, addrs) = abi.decode(
_data,
(MarketRegistry.SellDetails[], ExchangeRegistry.SwapDetails[], MarketRegistry.BuyDetails[], address[])
);
// _sellDetails should not be empty
require(_sellDetails.length > 0, "_executeSingleTrxSwap: no sell details");
// if recipient is zero address, then set _from as recipient
if(addrs[2] == address(0)) {
addrs[2] = _from;
}
// sell input assets
(address[] memory _erc20AddrsIn, uint256[] memory _erc20AmountsIn) = _sellNFT(_sellDetails);
// swap ERC20 equivalents to desired intermediate assets
_swap(_swapDetails, _buyDetails, _erc20AmountsIn, _erc20AddrsIn, addrs[0], addrs[1], addrs[2]);
}
function onERC1155Received(
address,
address,
uint256,
uint256,
bytes calldata
) public virtual returns (bytes4) {
return this.onERC1155Received.selector;
}
function onERC1155BatchReceived(
address,
address _from,
uint256[] calldata,
uint256[] calldata,
bytes calldata _data
) public virtual returns (bytes4) {
// return with function selector if data is empty
if(keccak256(abi.encodePacked((_data))) == keccak256(abi.encodePacked(("")))) {
return this.onERC1155BatchReceived.selector;
}
// execute single transaction swap
_executeSingleTrxSwap(_data, _from);
// return the function selector
return this.onERC1155BatchReceived.selector;
}
function onERC721Received(
address,
address _from,
uint256 _tokenId,
bytes calldata _data
) external virtual returns (bytes4) {
// return with function selector if data is empty
if(keccak256(abi.encodePacked((_data))) == keccak256(abi.encodePacked(("")))) {
return this.onERC721Received.selector;
}
// execute single transaction swap
_executeSingleTrxSwap(_data, _from);
return this.onERC721Received.selector;
}
function supportsInterface(bytes4 interfaceId)
external
virtual
view
returns (bool)
{
return interfaceId == this.supportsInterface.selector;
}
receive() external payable {}
// Emergency function: In case any ERC20 tokens get stuck in the contract unintentionally
// Only owner can retrieve the asset balance to a recipient address
function rescueERC20(address asset, address recipient) onlyOwner external returns(uint256 amountRescued) {
amountRescued = IERC20(asset).balanceOf(address(this));
IERC20(asset).transfer(recipient, amountRescued);
}
// Emergency function: In case any ERC721 tokens get stuck in the contract unintentionally
// Only owner can retrieve the asset balance to a recipient address
function rescueERC721(address asset, uint256[] calldata ids, address recipient) onlyOwner external {
for (uint256 i = 0; i < ids.length; i++) {
IERC721(asset).transferFrom(address(this), recipient, ids[i]);
}
}
// Emergency function: In case any ERC1155 tokens get stuck in the contract unintentionally
// Only owner can retrieve the asset balance to a recipient address
function rescueERC1155(address asset, uint256[] calldata ids, uint256[] calldata amounts, address recipient) onlyOwner external {
for (uint256 i = 0; i < ids.length; i++) {
IERC1155(asset).safeTransferFrom(address(this), recipient, ids[i], amounts[i], "");
}
}
} | multiAssetSwap | function multiAssetSwap(
ERC20Details memory inputERC20s,
ERC721Details[] memory inputERC721s,
ERC1155Details[] memory inputERC1155s,
MarketRegistry.BuyDetails[] memory buyDetails,
ExchangeRegistry.SwapDetails[] memory swapDetails,
address[] memory addrs // [changeIn, exchange, recipient]
) payable external {
address[] memory _erc20AddrsIn;
uint256[] memory _erc20AmountsIn;
// transfer all tokens
(_erc20AddrsIn, _erc20AmountsIn) = _transferHelper(
inputERC20s,
inputERC721s,
inputERC1155s
);
// execute all swaps
_swap(
swapDetails,
buyDetails,
_erc20AmountsIn,
_erc20AddrsIn,
addrs[0],
addrs[1],
addrs[2]
);
}
| // swaps any combination of ERC-20/721/1155
// User needs to approve assets before invoking swap | LineComment | v0.8.0+commit.c7dfd78e | MIT | ipfs://58155467ed651020d1f8c07012ccbc9978eba79dd5a5f5d2da3f60329adb57fa | {
"func_code_index": [
4432,
5329
]
} | 2,281 |
||
CrossAssetSwap | CrossAssetSwap.sol | 0x95470f8e330d20788e76e8da3063c9a19555ac0c | Solidity | CrossAssetSwap | contract CrossAssetSwap is Ownable {
struct ERC20Details {
address[] tokenAddrs;
uint256[] amounts;
}
struct ERC721Details {
address tokenAddr;
uint256[] ids;
MarketRegistry.SellDetails[] sellDetails;
}
struct ERC1155Details {
address tokenAddr;
uint256[] ids;
uint256[] amounts;
MarketRegistry.SellDetails[] sellDetails;
}
MarketRegistry public marketRegistry;
ExchangeRegistry public exchangeRegistry;
address public constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
address public constant MAINTAINER = 0x073Ab1C0CAd3677cDe9BDb0cDEEDC2085c029579;
uint256 public FEES = 300;
constructor(address _marketRegistry, address _exchangeRegistry) {
marketRegistry = MarketRegistry(_marketRegistry);
exchangeRegistry = ExchangeRegistry(_exchangeRegistry);
}
function updateFees(uint256 newFees) external {
require(msg.sender == MAINTAINER, "updateFees: invalid caller.");
FEES = newFees;
}
function _transferHelper(
ERC20Details memory _inputERC20s,
ERC721Details[] memory inputERC721s,
ERC1155Details[] memory inputERC1155s
) internal returns (address[] memory _erc20AddrsIn, uint256[] memory _erc20AmountsIn) {
address[] memory _addrsIn1;
address[] memory _addrsIn2;
uint256[] memory _amountsIn1;
uint256[] memory _amountsIn2;
// transfer ERC20 tokens from the sender to this contract
for (uint256 i = 0; i < _inputERC20s.tokenAddrs.length; i++) {
require(
IERC20(_inputERC20s.tokenAddrs[i]).transferFrom(
msg.sender,
address(this),
_inputERC20s.amounts[i]
),
"_transferHelper: transfer failed"
);
}
// transfer ERC721 tokens from the sender to this contract
for (uint256 i = 0; i < inputERC721s.length; i++) {
for (uint256 j = 0; j < inputERC721s[i].ids.length; j++) {
IERC721(inputERC721s[i].tokenAddr).transferFrom(
msg.sender,
address(this),
inputERC721s[i].ids[j]
);
}
(_addrsIn1, _amountsIn1) = _sellNFT(inputERC721s[i].sellDetails);
}
// transfer ERC1155 tokens from the sender to this contract
for (uint256 i = 0; i < inputERC1155s.length; i++) {
IERC1155(inputERC1155s[i].tokenAddr).safeBatchTransferFrom(
msg.sender,
address(this),
inputERC1155s[i].ids,
inputERC1155s[i].amounts,
""
);
(_addrsIn2, _amountsIn2) = _sellNFT(inputERC1155s[i].sellDetails);
}
// return _erc20AddrsIn, _erc20AmountsIn
{
uint256 totalLen = msg.value > 0
? _inputERC20s.tokenAddrs.length+_addrsIn1.length+_addrsIn2.length+1
: _inputERC20s.tokenAddrs.length+_addrsIn1.length+_addrsIn2.length;
_erc20AddrsIn = new address[](totalLen);
_erc20AmountsIn = new uint256[](totalLen);
if (msg.value > 0) {
_erc20AddrsIn[totalLen-1] = ETH;
_erc20AmountsIn[totalLen-1] = msg.value;
}
// populate the arrays
for (uint256 i = 0; i < _inputERC20s.tokenAddrs.length; i++) {
_erc20AddrsIn[i] = _inputERC20s.tokenAddrs[i];
_erc20AmountsIn[i] = _inputERC20s.amounts[i];
}
totalLen = _inputERC20s.tokenAddrs.length-1;
for (uint256 i = 0; i < _addrsIn1.length; i++) {
_erc20AddrsIn[_inputERC20s.tokenAddrs.length+i] = _addrsIn1[i];
_erc20AmountsIn[_inputERC20s.tokenAddrs.length+i] = _amountsIn1[i];
}
totalLen = _inputERC20s.tokenAddrs.length+_addrsIn1.length-1;
for (uint256 i = 0; i < _addrsIn2.length; i++) {
_erc20AddrsIn[totalLen+i] = _addrsIn2[i];
_erc20AmountsIn[totalLen+i] = _amountsIn2[i];
}
}
}
// swaps any combination of ERC-20/721/1155
// User needs to approve assets before invoking swap
function multiAssetSwap(
ERC20Details memory inputERC20s,
ERC721Details[] memory inputERC721s,
ERC1155Details[] memory inputERC1155s,
MarketRegistry.BuyDetails[] memory buyDetails,
ExchangeRegistry.SwapDetails[] memory swapDetails,
address[] memory addrs // [changeIn, exchange, recipient]
) payable external {
address[] memory _erc20AddrsIn;
uint256[] memory _erc20AmountsIn;
// transfer all tokens
(_erc20AddrsIn, _erc20AmountsIn) = _transferHelper(
inputERC20s,
inputERC721s,
inputERC1155s
);
// execute all swaps
_swap(
swapDetails,
buyDetails,
_erc20AmountsIn,
_erc20AddrsIn,
addrs[0],
addrs[1],
addrs[2]
);
}
event Data(ERC721Details[]);
function buyNftForERC20(
MarketRegistry.BuyDetails[] memory buyDetails,
ExchangeRegistry.SwapDetails[] memory swapDetails,
ERC20Details memory inputErc20Details,
address[] memory addrs // [changeIn, exchange, recipient]
) external {
// transfer the fees
require(
IERC20(inputErc20Details.tokenAddrs[0]).transferFrom(msg.sender, MAINTAINER, FEES*inputErc20Details.amounts[0]/10000),
"buyNftForERC20: fees transfer failed"
);
// transfer the inputErc20 to the contract
require(
IERC20(inputErc20Details.tokenAddrs[0]).transferFrom(msg.sender, address(this), (10000-FEES)*inputErc20Details.amounts[0]/10000),
"buyNftForERC20: transfer failed"
);
// swap to desired assets if needed
for (uint256 i=0; i < swapDetails.length; i++) {
(address proxy, ) = exchangeRegistry.exchanges(swapDetails[i].exchangeId);
(bool success, ) = proxy.delegatecall(swapDetails[i].swapData);
require(success, "buyNftForERC20: swap failed.");
}
// buy NFTs
_buyNFT(buyDetails);
// Note: We know it as a fact that only input ERC20 can be the dust asset
// return remaining input ERC20
if(addrs[0] == inputErc20Details.tokenAddrs[0]) {
IERC20(inputErc20Details.tokenAddrs[0]).transfer(msg.sender, IERC20(inputErc20Details.tokenAddrs[0]).balanceOf(address(this)));
}
// return remaining ETH
else if(addrs[0] == ETH) {
(bool success, ) = addrs[1].delegatecall(abi.encodeWithSignature("swapExactERC20ForETH(address,address,uint256)", inputErc20Details.tokenAddrs[0], addrs[2], IERC20(inputErc20Details.tokenAddrs[0]).balanceOf(address(this))));
require(success, "buyNftForERC20: return failed.");
}
// return remaining ERC20
else {
(bool success, ) = addrs[1].delegatecall(abi.encodeWithSignature("swapExactERC20ForERC20(address,address,address,uint256)", inputErc20Details.tokenAddrs[0], addrs[0], addrs[2], IERC20(inputErc20Details.tokenAddrs[0]).balanceOf(address(this))));
require(success, "buyNftForERC20: return failed.");
}
}
function buyNftForEth(
MarketRegistry.BuyDetails[] memory buyDetails,
ExchangeRegistry.SwapDetails[] memory swapDetails,
address[] memory addrs // [changeIn, exchange, recipient]
) external payable {
bool success;
(success, ) = MAINTAINER.call{value:FEES*address(this).balance/10000}('');
require(success, "buyNftForEth: fees failed.");
// swap to desired assets if needed
for (uint256 i=0; i < swapDetails.length; i++) {
(address proxy, ) = exchangeRegistry.exchanges(swapDetails[i].exchangeId);
(success, ) = proxy.delegatecall(swapDetails[i].swapData);
require(success, "buyNftForEth: swap failed.");
}
// buy NFT
_buyNFT(buyDetails);
// Note: We know it as a fact that only Eth can be the dust asset
// return remaining ETH
if(addrs[0] == ETH) {
(success, ) = msg.sender.call{value:address(this).balance}('');
require(success, "buyNftForEth: return failed.");
}
// return remaining ERC20
else {
(success, ) = addrs[1].delegatecall(abi.encodeWithSignature("swapExactETHForERC20(address,address,uint256)", addrs[0], addrs[2], 0));
require(success, "buyNftForEth: return failed.");
}
}
function _sellNFT(
MarketRegistry.SellDetails[] memory _sellDetails
) internal returns(address[] memory erc20Addrs, uint256[] memory erc20Amounts) {
erc20Addrs = new address[](_sellDetails.length);
erc20Amounts = new uint256[](_sellDetails.length);
// sell ERC1155 assets to respective markets
for (uint256 i = 0; i < _sellDetails.length; i++) {
// fetch the market details
(, , address _proxy, bool _isActive) = marketRegistry.markets(_sellDetails[i].marketId);
// the market should be active
require(_isActive, "_sellNFT: InActive Market");
// sell the specified asset
(bool success, bytes memory data) = _proxy.delegatecall(_sellDetails[i].sellData);
// check if the delegatecall passed successfully
require(success, "_sellNFT: sell failed.");
// populate return values
(erc20Addrs[i], erc20Amounts[i]) = abi.decode(
data,
(address, uint256)
);
}
}
function _buyNFT(
MarketRegistry.BuyDetails[] memory _buyDetails
) internal {
for (uint256 i = 0; i < _buyDetails.length; i++) {
// get market details
(, , address _proxy, bool _isActive) = marketRegistry.markets(_buyDetails[i].marketId);
// market should be active
require(_isActive, "function: InActive Market");
// buy NFT with ETH or ERC20
(bool success, ) = _proxy.delegatecall(_buyDetails[i].buyData);
// check if the delegatecall passed successfully
require(success, "_buyNFT: buy failed.");
}
}
function _returnChange(
address _changeIn,
address _erc20AddrIn,
address _recipient,
address _proxy,
uint256 _erc20AmountIn
) internal {
bool success;
// in case desired changeIn is NOT the equivalent ERC20
if (_changeIn != _erc20AddrIn) {
// get market address
// (address proxy, ) = exchangeRegistry.exchanges(_exchangeId);
// in case input asset is ETH
if(_erc20AddrIn == ETH) {
(success, ) = _proxy.delegatecall(abi.encodeWithSignature("swapExactETHForERC20(address,address,uint256)", _changeIn, _recipient, 0));
require(success, "_returnChange: return failed.");
}
// in case changeIn is ETH
else if(_changeIn == ETH) {
// Convert all the _erc20Amount to _changeIn ERC20
(success, ) = _proxy.delegatecall(abi.encodeWithSignature("swapExactERC20ForETH(address,address,uint256)", _erc20AddrIn, _recipient, _erc20AmountIn));
require(success, "_returnChange: return failed.");
}
// in case changeIn is some other ERC20
else {
// execute exchange
(success, ) = _proxy.delegatecall(abi.encodeWithSignature("swapExactERC20ForERC20(address,address,address,uint256)", _erc20AddrIn, _changeIn, _recipient, _erc20AmountIn));
require(success, "_returnChange: return failed.");
}
}
// in case desired changeIn is the equivalent ERC20
else {
IERC20(_changeIn).transfer(_recipient, _erc20AmountIn);
}
}
function _swap(
ExchangeRegistry.SwapDetails[] memory _swapDetails,
MarketRegistry.BuyDetails[] memory _buyDetails,
uint256[] memory _erc20AmountsIn,
address[] memory _erc20AddrsIn,
address _changeIn,
address _exchange,
address _recipient
) internal {
bool success;
// in case user does NOT want to buy any NFTs
if(_buyDetails.length == 0) {
for(uint256 i = 0; i < _erc20AddrsIn.length; i++) {
_returnChange(
_changeIn,
_erc20AddrsIn[i],
_recipient,
_exchange,
_erc20AmountsIn[i]
);
}
}
// in case user wants to buy NFTs
else {
for (uint256 i = 0; i < _swapDetails.length; i++) {
// get market address
(address proxy, ) = exchangeRegistry.exchanges(_swapDetails[i].exchangeId);
// execute swap
(success, ) = proxy.delegatecall(_swapDetails[i].swapData);
require(success, "_swap: swap failed.");
}
// buy the NFTs
_buyNFT(_buyDetails);
// return remaining amount to the user
for (uint256 i = 0; i < _erc20AddrsIn.length; i++) {
_returnChange(
_changeIn,
_erc20AddrsIn[i],
_recipient,
_exchange,
_erc20AddrsIn[i] == ETH
? address(this).balance
: IERC20(_erc20AddrsIn[i]).balanceOf(address(this))
);
}
}
}
function _executeSingleTrxSwap(
bytes memory _data,
address _from
) internal {
// decode the trade details
MarketRegistry.SellDetails[] memory _sellDetails;
ExchangeRegistry.SwapDetails[] memory _swapDetails;
MarketRegistry.BuyDetails[] memory _buyDetails;
address[] memory addrs; // [changeIn, exchange, recipient]
(_sellDetails, _swapDetails, _buyDetails, addrs) = abi.decode(
_data,
(MarketRegistry.SellDetails[], ExchangeRegistry.SwapDetails[], MarketRegistry.BuyDetails[], address[])
);
// _sellDetails should not be empty
require(_sellDetails.length > 0, "_executeSingleTrxSwap: no sell details");
// if recipient is zero address, then set _from as recipient
if(addrs[2] == address(0)) {
addrs[2] = _from;
}
// sell input assets
(address[] memory _erc20AddrsIn, uint256[] memory _erc20AmountsIn) = _sellNFT(_sellDetails);
// swap ERC20 equivalents to desired intermediate assets
_swap(_swapDetails, _buyDetails, _erc20AmountsIn, _erc20AddrsIn, addrs[0], addrs[1], addrs[2]);
}
function onERC1155Received(
address,
address,
uint256,
uint256,
bytes calldata
) public virtual returns (bytes4) {
return this.onERC1155Received.selector;
}
function onERC1155BatchReceived(
address,
address _from,
uint256[] calldata,
uint256[] calldata,
bytes calldata _data
) public virtual returns (bytes4) {
// return with function selector if data is empty
if(keccak256(abi.encodePacked((_data))) == keccak256(abi.encodePacked(("")))) {
return this.onERC1155BatchReceived.selector;
}
// execute single transaction swap
_executeSingleTrxSwap(_data, _from);
// return the function selector
return this.onERC1155BatchReceived.selector;
}
function onERC721Received(
address,
address _from,
uint256 _tokenId,
bytes calldata _data
) external virtual returns (bytes4) {
// return with function selector if data is empty
if(keccak256(abi.encodePacked((_data))) == keccak256(abi.encodePacked(("")))) {
return this.onERC721Received.selector;
}
// execute single transaction swap
_executeSingleTrxSwap(_data, _from);
return this.onERC721Received.selector;
}
function supportsInterface(bytes4 interfaceId)
external
virtual
view
returns (bool)
{
return interfaceId == this.supportsInterface.selector;
}
receive() external payable {}
// Emergency function: In case any ERC20 tokens get stuck in the contract unintentionally
// Only owner can retrieve the asset balance to a recipient address
function rescueERC20(address asset, address recipient) onlyOwner external returns(uint256 amountRescued) {
amountRescued = IERC20(asset).balanceOf(address(this));
IERC20(asset).transfer(recipient, amountRescued);
}
// Emergency function: In case any ERC721 tokens get stuck in the contract unintentionally
// Only owner can retrieve the asset balance to a recipient address
function rescueERC721(address asset, uint256[] calldata ids, address recipient) onlyOwner external {
for (uint256 i = 0; i < ids.length; i++) {
IERC721(asset).transferFrom(address(this), recipient, ids[i]);
}
}
// Emergency function: In case any ERC1155 tokens get stuck in the contract unintentionally
// Only owner can retrieve the asset balance to a recipient address
function rescueERC1155(address asset, uint256[] calldata ids, uint256[] calldata amounts, address recipient) onlyOwner external {
for (uint256 i = 0; i < ids.length; i++) {
IERC1155(asset).safeTransferFrom(address(this), recipient, ids[i], amounts[i], "");
}
}
} | rescueERC20 | function rescueERC20(address asset, address recipient) onlyOwner external returns(uint256 amountRescued) {
amountRescued = IERC20(asset).balanceOf(address(this));
IERC20(asset).transfer(recipient, amountRescued);
}
| // Emergency function: In case any ERC20 tokens get stuck in the contract unintentionally
// Only owner can retrieve the asset balance to a recipient address | LineComment | v0.8.0+commit.c7dfd78e | MIT | ipfs://58155467ed651020d1f8c07012ccbc9978eba79dd5a5f5d2da3f60329adb57fa | {
"func_code_index": [
17325,
17568
]
} | 2,282 |
||
CrossAssetSwap | CrossAssetSwap.sol | 0x95470f8e330d20788e76e8da3063c9a19555ac0c | Solidity | CrossAssetSwap | contract CrossAssetSwap is Ownable {
struct ERC20Details {
address[] tokenAddrs;
uint256[] amounts;
}
struct ERC721Details {
address tokenAddr;
uint256[] ids;
MarketRegistry.SellDetails[] sellDetails;
}
struct ERC1155Details {
address tokenAddr;
uint256[] ids;
uint256[] amounts;
MarketRegistry.SellDetails[] sellDetails;
}
MarketRegistry public marketRegistry;
ExchangeRegistry public exchangeRegistry;
address public constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
address public constant MAINTAINER = 0x073Ab1C0CAd3677cDe9BDb0cDEEDC2085c029579;
uint256 public FEES = 300;
constructor(address _marketRegistry, address _exchangeRegistry) {
marketRegistry = MarketRegistry(_marketRegistry);
exchangeRegistry = ExchangeRegistry(_exchangeRegistry);
}
function updateFees(uint256 newFees) external {
require(msg.sender == MAINTAINER, "updateFees: invalid caller.");
FEES = newFees;
}
function _transferHelper(
ERC20Details memory _inputERC20s,
ERC721Details[] memory inputERC721s,
ERC1155Details[] memory inputERC1155s
) internal returns (address[] memory _erc20AddrsIn, uint256[] memory _erc20AmountsIn) {
address[] memory _addrsIn1;
address[] memory _addrsIn2;
uint256[] memory _amountsIn1;
uint256[] memory _amountsIn2;
// transfer ERC20 tokens from the sender to this contract
for (uint256 i = 0; i < _inputERC20s.tokenAddrs.length; i++) {
require(
IERC20(_inputERC20s.tokenAddrs[i]).transferFrom(
msg.sender,
address(this),
_inputERC20s.amounts[i]
),
"_transferHelper: transfer failed"
);
}
// transfer ERC721 tokens from the sender to this contract
for (uint256 i = 0; i < inputERC721s.length; i++) {
for (uint256 j = 0; j < inputERC721s[i].ids.length; j++) {
IERC721(inputERC721s[i].tokenAddr).transferFrom(
msg.sender,
address(this),
inputERC721s[i].ids[j]
);
}
(_addrsIn1, _amountsIn1) = _sellNFT(inputERC721s[i].sellDetails);
}
// transfer ERC1155 tokens from the sender to this contract
for (uint256 i = 0; i < inputERC1155s.length; i++) {
IERC1155(inputERC1155s[i].tokenAddr).safeBatchTransferFrom(
msg.sender,
address(this),
inputERC1155s[i].ids,
inputERC1155s[i].amounts,
""
);
(_addrsIn2, _amountsIn2) = _sellNFT(inputERC1155s[i].sellDetails);
}
// return _erc20AddrsIn, _erc20AmountsIn
{
uint256 totalLen = msg.value > 0
? _inputERC20s.tokenAddrs.length+_addrsIn1.length+_addrsIn2.length+1
: _inputERC20s.tokenAddrs.length+_addrsIn1.length+_addrsIn2.length;
_erc20AddrsIn = new address[](totalLen);
_erc20AmountsIn = new uint256[](totalLen);
if (msg.value > 0) {
_erc20AddrsIn[totalLen-1] = ETH;
_erc20AmountsIn[totalLen-1] = msg.value;
}
// populate the arrays
for (uint256 i = 0; i < _inputERC20s.tokenAddrs.length; i++) {
_erc20AddrsIn[i] = _inputERC20s.tokenAddrs[i];
_erc20AmountsIn[i] = _inputERC20s.amounts[i];
}
totalLen = _inputERC20s.tokenAddrs.length-1;
for (uint256 i = 0; i < _addrsIn1.length; i++) {
_erc20AddrsIn[_inputERC20s.tokenAddrs.length+i] = _addrsIn1[i];
_erc20AmountsIn[_inputERC20s.tokenAddrs.length+i] = _amountsIn1[i];
}
totalLen = _inputERC20s.tokenAddrs.length+_addrsIn1.length-1;
for (uint256 i = 0; i < _addrsIn2.length; i++) {
_erc20AddrsIn[totalLen+i] = _addrsIn2[i];
_erc20AmountsIn[totalLen+i] = _amountsIn2[i];
}
}
}
// swaps any combination of ERC-20/721/1155
// User needs to approve assets before invoking swap
function multiAssetSwap(
ERC20Details memory inputERC20s,
ERC721Details[] memory inputERC721s,
ERC1155Details[] memory inputERC1155s,
MarketRegistry.BuyDetails[] memory buyDetails,
ExchangeRegistry.SwapDetails[] memory swapDetails,
address[] memory addrs // [changeIn, exchange, recipient]
) payable external {
address[] memory _erc20AddrsIn;
uint256[] memory _erc20AmountsIn;
// transfer all tokens
(_erc20AddrsIn, _erc20AmountsIn) = _transferHelper(
inputERC20s,
inputERC721s,
inputERC1155s
);
// execute all swaps
_swap(
swapDetails,
buyDetails,
_erc20AmountsIn,
_erc20AddrsIn,
addrs[0],
addrs[1],
addrs[2]
);
}
event Data(ERC721Details[]);
function buyNftForERC20(
MarketRegistry.BuyDetails[] memory buyDetails,
ExchangeRegistry.SwapDetails[] memory swapDetails,
ERC20Details memory inputErc20Details,
address[] memory addrs // [changeIn, exchange, recipient]
) external {
// transfer the fees
require(
IERC20(inputErc20Details.tokenAddrs[0]).transferFrom(msg.sender, MAINTAINER, FEES*inputErc20Details.amounts[0]/10000),
"buyNftForERC20: fees transfer failed"
);
// transfer the inputErc20 to the contract
require(
IERC20(inputErc20Details.tokenAddrs[0]).transferFrom(msg.sender, address(this), (10000-FEES)*inputErc20Details.amounts[0]/10000),
"buyNftForERC20: transfer failed"
);
// swap to desired assets if needed
for (uint256 i=0; i < swapDetails.length; i++) {
(address proxy, ) = exchangeRegistry.exchanges(swapDetails[i].exchangeId);
(bool success, ) = proxy.delegatecall(swapDetails[i].swapData);
require(success, "buyNftForERC20: swap failed.");
}
// buy NFTs
_buyNFT(buyDetails);
// Note: We know it as a fact that only input ERC20 can be the dust asset
// return remaining input ERC20
if(addrs[0] == inputErc20Details.tokenAddrs[0]) {
IERC20(inputErc20Details.tokenAddrs[0]).transfer(msg.sender, IERC20(inputErc20Details.tokenAddrs[0]).balanceOf(address(this)));
}
// return remaining ETH
else if(addrs[0] == ETH) {
(bool success, ) = addrs[1].delegatecall(abi.encodeWithSignature("swapExactERC20ForETH(address,address,uint256)", inputErc20Details.tokenAddrs[0], addrs[2], IERC20(inputErc20Details.tokenAddrs[0]).balanceOf(address(this))));
require(success, "buyNftForERC20: return failed.");
}
// return remaining ERC20
else {
(bool success, ) = addrs[1].delegatecall(abi.encodeWithSignature("swapExactERC20ForERC20(address,address,address,uint256)", inputErc20Details.tokenAddrs[0], addrs[0], addrs[2], IERC20(inputErc20Details.tokenAddrs[0]).balanceOf(address(this))));
require(success, "buyNftForERC20: return failed.");
}
}
function buyNftForEth(
MarketRegistry.BuyDetails[] memory buyDetails,
ExchangeRegistry.SwapDetails[] memory swapDetails,
address[] memory addrs // [changeIn, exchange, recipient]
) external payable {
bool success;
(success, ) = MAINTAINER.call{value:FEES*address(this).balance/10000}('');
require(success, "buyNftForEth: fees failed.");
// swap to desired assets if needed
for (uint256 i=0; i < swapDetails.length; i++) {
(address proxy, ) = exchangeRegistry.exchanges(swapDetails[i].exchangeId);
(success, ) = proxy.delegatecall(swapDetails[i].swapData);
require(success, "buyNftForEth: swap failed.");
}
// buy NFT
_buyNFT(buyDetails);
// Note: We know it as a fact that only Eth can be the dust asset
// return remaining ETH
if(addrs[0] == ETH) {
(success, ) = msg.sender.call{value:address(this).balance}('');
require(success, "buyNftForEth: return failed.");
}
// return remaining ERC20
else {
(success, ) = addrs[1].delegatecall(abi.encodeWithSignature("swapExactETHForERC20(address,address,uint256)", addrs[0], addrs[2], 0));
require(success, "buyNftForEth: return failed.");
}
}
function _sellNFT(
MarketRegistry.SellDetails[] memory _sellDetails
) internal returns(address[] memory erc20Addrs, uint256[] memory erc20Amounts) {
erc20Addrs = new address[](_sellDetails.length);
erc20Amounts = new uint256[](_sellDetails.length);
// sell ERC1155 assets to respective markets
for (uint256 i = 0; i < _sellDetails.length; i++) {
// fetch the market details
(, , address _proxy, bool _isActive) = marketRegistry.markets(_sellDetails[i].marketId);
// the market should be active
require(_isActive, "_sellNFT: InActive Market");
// sell the specified asset
(bool success, bytes memory data) = _proxy.delegatecall(_sellDetails[i].sellData);
// check if the delegatecall passed successfully
require(success, "_sellNFT: sell failed.");
// populate return values
(erc20Addrs[i], erc20Amounts[i]) = abi.decode(
data,
(address, uint256)
);
}
}
function _buyNFT(
MarketRegistry.BuyDetails[] memory _buyDetails
) internal {
for (uint256 i = 0; i < _buyDetails.length; i++) {
// get market details
(, , address _proxy, bool _isActive) = marketRegistry.markets(_buyDetails[i].marketId);
// market should be active
require(_isActive, "function: InActive Market");
// buy NFT with ETH or ERC20
(bool success, ) = _proxy.delegatecall(_buyDetails[i].buyData);
// check if the delegatecall passed successfully
require(success, "_buyNFT: buy failed.");
}
}
function _returnChange(
address _changeIn,
address _erc20AddrIn,
address _recipient,
address _proxy,
uint256 _erc20AmountIn
) internal {
bool success;
// in case desired changeIn is NOT the equivalent ERC20
if (_changeIn != _erc20AddrIn) {
// get market address
// (address proxy, ) = exchangeRegistry.exchanges(_exchangeId);
// in case input asset is ETH
if(_erc20AddrIn == ETH) {
(success, ) = _proxy.delegatecall(abi.encodeWithSignature("swapExactETHForERC20(address,address,uint256)", _changeIn, _recipient, 0));
require(success, "_returnChange: return failed.");
}
// in case changeIn is ETH
else if(_changeIn == ETH) {
// Convert all the _erc20Amount to _changeIn ERC20
(success, ) = _proxy.delegatecall(abi.encodeWithSignature("swapExactERC20ForETH(address,address,uint256)", _erc20AddrIn, _recipient, _erc20AmountIn));
require(success, "_returnChange: return failed.");
}
// in case changeIn is some other ERC20
else {
// execute exchange
(success, ) = _proxy.delegatecall(abi.encodeWithSignature("swapExactERC20ForERC20(address,address,address,uint256)", _erc20AddrIn, _changeIn, _recipient, _erc20AmountIn));
require(success, "_returnChange: return failed.");
}
}
// in case desired changeIn is the equivalent ERC20
else {
IERC20(_changeIn).transfer(_recipient, _erc20AmountIn);
}
}
function _swap(
ExchangeRegistry.SwapDetails[] memory _swapDetails,
MarketRegistry.BuyDetails[] memory _buyDetails,
uint256[] memory _erc20AmountsIn,
address[] memory _erc20AddrsIn,
address _changeIn,
address _exchange,
address _recipient
) internal {
bool success;
// in case user does NOT want to buy any NFTs
if(_buyDetails.length == 0) {
for(uint256 i = 0; i < _erc20AddrsIn.length; i++) {
_returnChange(
_changeIn,
_erc20AddrsIn[i],
_recipient,
_exchange,
_erc20AmountsIn[i]
);
}
}
// in case user wants to buy NFTs
else {
for (uint256 i = 0; i < _swapDetails.length; i++) {
// get market address
(address proxy, ) = exchangeRegistry.exchanges(_swapDetails[i].exchangeId);
// execute swap
(success, ) = proxy.delegatecall(_swapDetails[i].swapData);
require(success, "_swap: swap failed.");
}
// buy the NFTs
_buyNFT(_buyDetails);
// return remaining amount to the user
for (uint256 i = 0; i < _erc20AddrsIn.length; i++) {
_returnChange(
_changeIn,
_erc20AddrsIn[i],
_recipient,
_exchange,
_erc20AddrsIn[i] == ETH
? address(this).balance
: IERC20(_erc20AddrsIn[i]).balanceOf(address(this))
);
}
}
}
function _executeSingleTrxSwap(
bytes memory _data,
address _from
) internal {
// decode the trade details
MarketRegistry.SellDetails[] memory _sellDetails;
ExchangeRegistry.SwapDetails[] memory _swapDetails;
MarketRegistry.BuyDetails[] memory _buyDetails;
address[] memory addrs; // [changeIn, exchange, recipient]
(_sellDetails, _swapDetails, _buyDetails, addrs) = abi.decode(
_data,
(MarketRegistry.SellDetails[], ExchangeRegistry.SwapDetails[], MarketRegistry.BuyDetails[], address[])
);
// _sellDetails should not be empty
require(_sellDetails.length > 0, "_executeSingleTrxSwap: no sell details");
// if recipient is zero address, then set _from as recipient
if(addrs[2] == address(0)) {
addrs[2] = _from;
}
// sell input assets
(address[] memory _erc20AddrsIn, uint256[] memory _erc20AmountsIn) = _sellNFT(_sellDetails);
// swap ERC20 equivalents to desired intermediate assets
_swap(_swapDetails, _buyDetails, _erc20AmountsIn, _erc20AddrsIn, addrs[0], addrs[1], addrs[2]);
}
function onERC1155Received(
address,
address,
uint256,
uint256,
bytes calldata
) public virtual returns (bytes4) {
return this.onERC1155Received.selector;
}
function onERC1155BatchReceived(
address,
address _from,
uint256[] calldata,
uint256[] calldata,
bytes calldata _data
) public virtual returns (bytes4) {
// return with function selector if data is empty
if(keccak256(abi.encodePacked((_data))) == keccak256(abi.encodePacked(("")))) {
return this.onERC1155BatchReceived.selector;
}
// execute single transaction swap
_executeSingleTrxSwap(_data, _from);
// return the function selector
return this.onERC1155BatchReceived.selector;
}
function onERC721Received(
address,
address _from,
uint256 _tokenId,
bytes calldata _data
) external virtual returns (bytes4) {
// return with function selector if data is empty
if(keccak256(abi.encodePacked((_data))) == keccak256(abi.encodePacked(("")))) {
return this.onERC721Received.selector;
}
// execute single transaction swap
_executeSingleTrxSwap(_data, _from);
return this.onERC721Received.selector;
}
function supportsInterface(bytes4 interfaceId)
external
virtual
view
returns (bool)
{
return interfaceId == this.supportsInterface.selector;
}
receive() external payable {}
// Emergency function: In case any ERC20 tokens get stuck in the contract unintentionally
// Only owner can retrieve the asset balance to a recipient address
function rescueERC20(address asset, address recipient) onlyOwner external returns(uint256 amountRescued) {
amountRescued = IERC20(asset).balanceOf(address(this));
IERC20(asset).transfer(recipient, amountRescued);
}
// Emergency function: In case any ERC721 tokens get stuck in the contract unintentionally
// Only owner can retrieve the asset balance to a recipient address
function rescueERC721(address asset, uint256[] calldata ids, address recipient) onlyOwner external {
for (uint256 i = 0; i < ids.length; i++) {
IERC721(asset).transferFrom(address(this), recipient, ids[i]);
}
}
// Emergency function: In case any ERC1155 tokens get stuck in the contract unintentionally
// Only owner can retrieve the asset balance to a recipient address
function rescueERC1155(address asset, uint256[] calldata ids, uint256[] calldata amounts, address recipient) onlyOwner external {
for (uint256 i = 0; i < ids.length; i++) {
IERC1155(asset).safeTransferFrom(address(this), recipient, ids[i], amounts[i], "");
}
}
} | rescueERC721 | function rescueERC721(address asset, uint256[] calldata ids, address recipient) onlyOwner external {
for (uint256 i = 0; i < ids.length; i++) {
IERC721(asset).transferFrom(address(this), recipient, ids[i]);
}
}
| // Emergency function: In case any ERC721 tokens get stuck in the contract unintentionally
// Only owner can retrieve the asset balance to a recipient address | LineComment | v0.8.0+commit.c7dfd78e | MIT | ipfs://58155467ed651020d1f8c07012ccbc9978eba79dd5a5f5d2da3f60329adb57fa | {
"func_code_index": [
17740,
17991
]
} | 2,283 |
||
CrossAssetSwap | CrossAssetSwap.sol | 0x95470f8e330d20788e76e8da3063c9a19555ac0c | Solidity | CrossAssetSwap | contract CrossAssetSwap is Ownable {
struct ERC20Details {
address[] tokenAddrs;
uint256[] amounts;
}
struct ERC721Details {
address tokenAddr;
uint256[] ids;
MarketRegistry.SellDetails[] sellDetails;
}
struct ERC1155Details {
address tokenAddr;
uint256[] ids;
uint256[] amounts;
MarketRegistry.SellDetails[] sellDetails;
}
MarketRegistry public marketRegistry;
ExchangeRegistry public exchangeRegistry;
address public constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
address public constant MAINTAINER = 0x073Ab1C0CAd3677cDe9BDb0cDEEDC2085c029579;
uint256 public FEES = 300;
constructor(address _marketRegistry, address _exchangeRegistry) {
marketRegistry = MarketRegistry(_marketRegistry);
exchangeRegistry = ExchangeRegistry(_exchangeRegistry);
}
function updateFees(uint256 newFees) external {
require(msg.sender == MAINTAINER, "updateFees: invalid caller.");
FEES = newFees;
}
function _transferHelper(
ERC20Details memory _inputERC20s,
ERC721Details[] memory inputERC721s,
ERC1155Details[] memory inputERC1155s
) internal returns (address[] memory _erc20AddrsIn, uint256[] memory _erc20AmountsIn) {
address[] memory _addrsIn1;
address[] memory _addrsIn2;
uint256[] memory _amountsIn1;
uint256[] memory _amountsIn2;
// transfer ERC20 tokens from the sender to this contract
for (uint256 i = 0; i < _inputERC20s.tokenAddrs.length; i++) {
require(
IERC20(_inputERC20s.tokenAddrs[i]).transferFrom(
msg.sender,
address(this),
_inputERC20s.amounts[i]
),
"_transferHelper: transfer failed"
);
}
// transfer ERC721 tokens from the sender to this contract
for (uint256 i = 0; i < inputERC721s.length; i++) {
for (uint256 j = 0; j < inputERC721s[i].ids.length; j++) {
IERC721(inputERC721s[i].tokenAddr).transferFrom(
msg.sender,
address(this),
inputERC721s[i].ids[j]
);
}
(_addrsIn1, _amountsIn1) = _sellNFT(inputERC721s[i].sellDetails);
}
// transfer ERC1155 tokens from the sender to this contract
for (uint256 i = 0; i < inputERC1155s.length; i++) {
IERC1155(inputERC1155s[i].tokenAddr).safeBatchTransferFrom(
msg.sender,
address(this),
inputERC1155s[i].ids,
inputERC1155s[i].amounts,
""
);
(_addrsIn2, _amountsIn2) = _sellNFT(inputERC1155s[i].sellDetails);
}
// return _erc20AddrsIn, _erc20AmountsIn
{
uint256 totalLen = msg.value > 0
? _inputERC20s.tokenAddrs.length+_addrsIn1.length+_addrsIn2.length+1
: _inputERC20s.tokenAddrs.length+_addrsIn1.length+_addrsIn2.length;
_erc20AddrsIn = new address[](totalLen);
_erc20AmountsIn = new uint256[](totalLen);
if (msg.value > 0) {
_erc20AddrsIn[totalLen-1] = ETH;
_erc20AmountsIn[totalLen-1] = msg.value;
}
// populate the arrays
for (uint256 i = 0; i < _inputERC20s.tokenAddrs.length; i++) {
_erc20AddrsIn[i] = _inputERC20s.tokenAddrs[i];
_erc20AmountsIn[i] = _inputERC20s.amounts[i];
}
totalLen = _inputERC20s.tokenAddrs.length-1;
for (uint256 i = 0; i < _addrsIn1.length; i++) {
_erc20AddrsIn[_inputERC20s.tokenAddrs.length+i] = _addrsIn1[i];
_erc20AmountsIn[_inputERC20s.tokenAddrs.length+i] = _amountsIn1[i];
}
totalLen = _inputERC20s.tokenAddrs.length+_addrsIn1.length-1;
for (uint256 i = 0; i < _addrsIn2.length; i++) {
_erc20AddrsIn[totalLen+i] = _addrsIn2[i];
_erc20AmountsIn[totalLen+i] = _amountsIn2[i];
}
}
}
// swaps any combination of ERC-20/721/1155
// User needs to approve assets before invoking swap
function multiAssetSwap(
ERC20Details memory inputERC20s,
ERC721Details[] memory inputERC721s,
ERC1155Details[] memory inputERC1155s,
MarketRegistry.BuyDetails[] memory buyDetails,
ExchangeRegistry.SwapDetails[] memory swapDetails,
address[] memory addrs // [changeIn, exchange, recipient]
) payable external {
address[] memory _erc20AddrsIn;
uint256[] memory _erc20AmountsIn;
// transfer all tokens
(_erc20AddrsIn, _erc20AmountsIn) = _transferHelper(
inputERC20s,
inputERC721s,
inputERC1155s
);
// execute all swaps
_swap(
swapDetails,
buyDetails,
_erc20AmountsIn,
_erc20AddrsIn,
addrs[0],
addrs[1],
addrs[2]
);
}
event Data(ERC721Details[]);
function buyNftForERC20(
MarketRegistry.BuyDetails[] memory buyDetails,
ExchangeRegistry.SwapDetails[] memory swapDetails,
ERC20Details memory inputErc20Details,
address[] memory addrs // [changeIn, exchange, recipient]
) external {
// transfer the fees
require(
IERC20(inputErc20Details.tokenAddrs[0]).transferFrom(msg.sender, MAINTAINER, FEES*inputErc20Details.amounts[0]/10000),
"buyNftForERC20: fees transfer failed"
);
// transfer the inputErc20 to the contract
require(
IERC20(inputErc20Details.tokenAddrs[0]).transferFrom(msg.sender, address(this), (10000-FEES)*inputErc20Details.amounts[0]/10000),
"buyNftForERC20: transfer failed"
);
// swap to desired assets if needed
for (uint256 i=0; i < swapDetails.length; i++) {
(address proxy, ) = exchangeRegistry.exchanges(swapDetails[i].exchangeId);
(bool success, ) = proxy.delegatecall(swapDetails[i].swapData);
require(success, "buyNftForERC20: swap failed.");
}
// buy NFTs
_buyNFT(buyDetails);
// Note: We know it as a fact that only input ERC20 can be the dust asset
// return remaining input ERC20
if(addrs[0] == inputErc20Details.tokenAddrs[0]) {
IERC20(inputErc20Details.tokenAddrs[0]).transfer(msg.sender, IERC20(inputErc20Details.tokenAddrs[0]).balanceOf(address(this)));
}
// return remaining ETH
else if(addrs[0] == ETH) {
(bool success, ) = addrs[1].delegatecall(abi.encodeWithSignature("swapExactERC20ForETH(address,address,uint256)", inputErc20Details.tokenAddrs[0], addrs[2], IERC20(inputErc20Details.tokenAddrs[0]).balanceOf(address(this))));
require(success, "buyNftForERC20: return failed.");
}
// return remaining ERC20
else {
(bool success, ) = addrs[1].delegatecall(abi.encodeWithSignature("swapExactERC20ForERC20(address,address,address,uint256)", inputErc20Details.tokenAddrs[0], addrs[0], addrs[2], IERC20(inputErc20Details.tokenAddrs[0]).balanceOf(address(this))));
require(success, "buyNftForERC20: return failed.");
}
}
function buyNftForEth(
MarketRegistry.BuyDetails[] memory buyDetails,
ExchangeRegistry.SwapDetails[] memory swapDetails,
address[] memory addrs // [changeIn, exchange, recipient]
) external payable {
bool success;
(success, ) = MAINTAINER.call{value:FEES*address(this).balance/10000}('');
require(success, "buyNftForEth: fees failed.");
// swap to desired assets if needed
for (uint256 i=0; i < swapDetails.length; i++) {
(address proxy, ) = exchangeRegistry.exchanges(swapDetails[i].exchangeId);
(success, ) = proxy.delegatecall(swapDetails[i].swapData);
require(success, "buyNftForEth: swap failed.");
}
// buy NFT
_buyNFT(buyDetails);
// Note: We know it as a fact that only Eth can be the dust asset
// return remaining ETH
if(addrs[0] == ETH) {
(success, ) = msg.sender.call{value:address(this).balance}('');
require(success, "buyNftForEth: return failed.");
}
// return remaining ERC20
else {
(success, ) = addrs[1].delegatecall(abi.encodeWithSignature("swapExactETHForERC20(address,address,uint256)", addrs[0], addrs[2], 0));
require(success, "buyNftForEth: return failed.");
}
}
function _sellNFT(
MarketRegistry.SellDetails[] memory _sellDetails
) internal returns(address[] memory erc20Addrs, uint256[] memory erc20Amounts) {
erc20Addrs = new address[](_sellDetails.length);
erc20Amounts = new uint256[](_sellDetails.length);
// sell ERC1155 assets to respective markets
for (uint256 i = 0; i < _sellDetails.length; i++) {
// fetch the market details
(, , address _proxy, bool _isActive) = marketRegistry.markets(_sellDetails[i].marketId);
// the market should be active
require(_isActive, "_sellNFT: InActive Market");
// sell the specified asset
(bool success, bytes memory data) = _proxy.delegatecall(_sellDetails[i].sellData);
// check if the delegatecall passed successfully
require(success, "_sellNFT: sell failed.");
// populate return values
(erc20Addrs[i], erc20Amounts[i]) = abi.decode(
data,
(address, uint256)
);
}
}
function _buyNFT(
MarketRegistry.BuyDetails[] memory _buyDetails
) internal {
for (uint256 i = 0; i < _buyDetails.length; i++) {
// get market details
(, , address _proxy, bool _isActive) = marketRegistry.markets(_buyDetails[i].marketId);
// market should be active
require(_isActive, "function: InActive Market");
// buy NFT with ETH or ERC20
(bool success, ) = _proxy.delegatecall(_buyDetails[i].buyData);
// check if the delegatecall passed successfully
require(success, "_buyNFT: buy failed.");
}
}
function _returnChange(
address _changeIn,
address _erc20AddrIn,
address _recipient,
address _proxy,
uint256 _erc20AmountIn
) internal {
bool success;
// in case desired changeIn is NOT the equivalent ERC20
if (_changeIn != _erc20AddrIn) {
// get market address
// (address proxy, ) = exchangeRegistry.exchanges(_exchangeId);
// in case input asset is ETH
if(_erc20AddrIn == ETH) {
(success, ) = _proxy.delegatecall(abi.encodeWithSignature("swapExactETHForERC20(address,address,uint256)", _changeIn, _recipient, 0));
require(success, "_returnChange: return failed.");
}
// in case changeIn is ETH
else if(_changeIn == ETH) {
// Convert all the _erc20Amount to _changeIn ERC20
(success, ) = _proxy.delegatecall(abi.encodeWithSignature("swapExactERC20ForETH(address,address,uint256)", _erc20AddrIn, _recipient, _erc20AmountIn));
require(success, "_returnChange: return failed.");
}
// in case changeIn is some other ERC20
else {
// execute exchange
(success, ) = _proxy.delegatecall(abi.encodeWithSignature("swapExactERC20ForERC20(address,address,address,uint256)", _erc20AddrIn, _changeIn, _recipient, _erc20AmountIn));
require(success, "_returnChange: return failed.");
}
}
// in case desired changeIn is the equivalent ERC20
else {
IERC20(_changeIn).transfer(_recipient, _erc20AmountIn);
}
}
function _swap(
ExchangeRegistry.SwapDetails[] memory _swapDetails,
MarketRegistry.BuyDetails[] memory _buyDetails,
uint256[] memory _erc20AmountsIn,
address[] memory _erc20AddrsIn,
address _changeIn,
address _exchange,
address _recipient
) internal {
bool success;
// in case user does NOT want to buy any NFTs
if(_buyDetails.length == 0) {
for(uint256 i = 0; i < _erc20AddrsIn.length; i++) {
_returnChange(
_changeIn,
_erc20AddrsIn[i],
_recipient,
_exchange,
_erc20AmountsIn[i]
);
}
}
// in case user wants to buy NFTs
else {
for (uint256 i = 0; i < _swapDetails.length; i++) {
// get market address
(address proxy, ) = exchangeRegistry.exchanges(_swapDetails[i].exchangeId);
// execute swap
(success, ) = proxy.delegatecall(_swapDetails[i].swapData);
require(success, "_swap: swap failed.");
}
// buy the NFTs
_buyNFT(_buyDetails);
// return remaining amount to the user
for (uint256 i = 0; i < _erc20AddrsIn.length; i++) {
_returnChange(
_changeIn,
_erc20AddrsIn[i],
_recipient,
_exchange,
_erc20AddrsIn[i] == ETH
? address(this).balance
: IERC20(_erc20AddrsIn[i]).balanceOf(address(this))
);
}
}
}
function _executeSingleTrxSwap(
bytes memory _data,
address _from
) internal {
// decode the trade details
MarketRegistry.SellDetails[] memory _sellDetails;
ExchangeRegistry.SwapDetails[] memory _swapDetails;
MarketRegistry.BuyDetails[] memory _buyDetails;
address[] memory addrs; // [changeIn, exchange, recipient]
(_sellDetails, _swapDetails, _buyDetails, addrs) = abi.decode(
_data,
(MarketRegistry.SellDetails[], ExchangeRegistry.SwapDetails[], MarketRegistry.BuyDetails[], address[])
);
// _sellDetails should not be empty
require(_sellDetails.length > 0, "_executeSingleTrxSwap: no sell details");
// if recipient is zero address, then set _from as recipient
if(addrs[2] == address(0)) {
addrs[2] = _from;
}
// sell input assets
(address[] memory _erc20AddrsIn, uint256[] memory _erc20AmountsIn) = _sellNFT(_sellDetails);
// swap ERC20 equivalents to desired intermediate assets
_swap(_swapDetails, _buyDetails, _erc20AmountsIn, _erc20AddrsIn, addrs[0], addrs[1], addrs[2]);
}
function onERC1155Received(
address,
address,
uint256,
uint256,
bytes calldata
) public virtual returns (bytes4) {
return this.onERC1155Received.selector;
}
function onERC1155BatchReceived(
address,
address _from,
uint256[] calldata,
uint256[] calldata,
bytes calldata _data
) public virtual returns (bytes4) {
// return with function selector if data is empty
if(keccak256(abi.encodePacked((_data))) == keccak256(abi.encodePacked(("")))) {
return this.onERC1155BatchReceived.selector;
}
// execute single transaction swap
_executeSingleTrxSwap(_data, _from);
// return the function selector
return this.onERC1155BatchReceived.selector;
}
function onERC721Received(
address,
address _from,
uint256 _tokenId,
bytes calldata _data
) external virtual returns (bytes4) {
// return with function selector if data is empty
if(keccak256(abi.encodePacked((_data))) == keccak256(abi.encodePacked(("")))) {
return this.onERC721Received.selector;
}
// execute single transaction swap
_executeSingleTrxSwap(_data, _from);
return this.onERC721Received.selector;
}
function supportsInterface(bytes4 interfaceId)
external
virtual
view
returns (bool)
{
return interfaceId == this.supportsInterface.selector;
}
receive() external payable {}
// Emergency function: In case any ERC20 tokens get stuck in the contract unintentionally
// Only owner can retrieve the asset balance to a recipient address
function rescueERC20(address asset, address recipient) onlyOwner external returns(uint256 amountRescued) {
amountRescued = IERC20(asset).balanceOf(address(this));
IERC20(asset).transfer(recipient, amountRescued);
}
// Emergency function: In case any ERC721 tokens get stuck in the contract unintentionally
// Only owner can retrieve the asset balance to a recipient address
function rescueERC721(address asset, uint256[] calldata ids, address recipient) onlyOwner external {
for (uint256 i = 0; i < ids.length; i++) {
IERC721(asset).transferFrom(address(this), recipient, ids[i]);
}
}
// Emergency function: In case any ERC1155 tokens get stuck in the contract unintentionally
// Only owner can retrieve the asset balance to a recipient address
function rescueERC1155(address asset, uint256[] calldata ids, uint256[] calldata amounts, address recipient) onlyOwner external {
for (uint256 i = 0; i < ids.length; i++) {
IERC1155(asset).safeTransferFrom(address(this), recipient, ids[i], amounts[i], "");
}
}
} | rescueERC1155 | function rescueERC1155(address asset, uint256[] calldata ids, uint256[] calldata amounts, address recipient) onlyOwner external {
for (uint256 i = 0; i < ids.length; i++) {
IERC1155(asset).safeTransferFrom(address(this), recipient, ids[i], amounts[i], "");
}
}
| // Emergency function: In case any ERC1155 tokens get stuck in the contract unintentionally
// Only owner can retrieve the asset balance to a recipient address | LineComment | v0.8.0+commit.c7dfd78e | MIT | ipfs://58155467ed651020d1f8c07012ccbc9978eba79dd5a5f5d2da3f60329adb57fa | {
"func_code_index": [
18164,
18465
]
} | 2,284 |
||
ThugWhales | @openzeppelin/contracts/access/Ownable.sol | 0x2b73f11f7f58e3d25b84adc0a6693072207f7dac | 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 | MIT | ipfs://d21251a8341395a27461909f282f0da3735590433e375c49fa1ff0968d33db07 | {
"func_code_index": [
399,
491
]
} | 2,285 |
ThugWhales | @openzeppelin/contracts/access/Ownable.sol | 0x2b73f11f7f58e3d25b84adc0a6693072207f7dac | 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 | MIT | ipfs://d21251a8341395a27461909f282f0da3735590433e375c49fa1ff0968d33db07 | {
"func_code_index": [
1050,
1149
]
} | 2,286 |
ThugWhales | @openzeppelin/contracts/access/Ownable.sol | 0x2b73f11f7f58e3d25b84adc0a6693072207f7dac | 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 | MIT | ipfs://d21251a8341395a27461909f282f0da3735590433e375c49fa1ff0968d33db07 | {
"func_code_index": [
1299,
1496
]
} | 2,287 |
ThugWhales | @openzeppelin/contracts/access/Ownable.sol | 0x2b73f11f7f58e3d25b84adc0a6693072207f7dac | Solidity | ThugWhales | contract ThugWhales is ERC721Enumerable, Ownable {
using Strings for uint256;
string baseURI;
string public baseExtension = ".json";
string public notRevealedUri;
uint256 public cost = 0.05 ether;
uint256 public maxSupply = 2222;
uint256 public maxMintAmount = 10;
uint256 public nftPerAddressLimit = 10;
bool public paused = false;
bool public revealed = false;
bool public onlyWhitelisted = true;
address[] public whitelistedAddresses;
constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI,
string memory _initNotRevealedUri
) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
setNotRevealedURI(_initNotRevealedUri);
}
// internal
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
// public
function mint(uint256 _mintAmount) public payable {
require(!paused);
uint256 supply = totalSupply();
require(_mintAmount > 0);
require(_mintAmount <= maxMintAmount);
require(supply + _mintAmount <= maxSupply);
if (msg.sender != owner()) {
if (onlyWhitelisted == true) {
require(isWhitelisted(msg.sender), "User is not Whitelisted");
uint256 ownerTokenCount = balanceOf(msg.sender);
require(ownerTokenCount < nftPerAddressLimit);
}
require(msg.value >= cost * _mintAmount);
}
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(msg.sender, supply + i);
}
}
function isWhitelisted(address _user) public view returns (bool) {
for (uint256 i = 0; i < whitelistedAddresses.length; i++) {
if (whitelistedAddresses[i] == _user) {
return true;
}
}
return false;
}
function walletOfOwner(address _owner)
public
view
returns (uint256[] memory)
{
uint256 ownerTokenCount = balanceOf(_owner);
uint256[] memory tokenIds = new uint256[](ownerTokenCount);
for (uint256 i; i < ownerTokenCount; i++) {
tokenIds[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokenIds;
}
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
if (revealed == false) {
return notRevealedUri;
}
string memory currentBaseURI = _baseURI();
return
bytes(currentBaseURI).length > 0
? string(
abi.encodePacked(
currentBaseURI,
tokenId.toString(),
baseExtension
)
)
: "";
}
//only owner
function reveal() public onlyOwner {
revealed = true;
}
function setNftPerAddressLimit(uint256 _limit) public onlyOwner {
nftPerAddressLimit = _limit;
}
function setCost(uint256 _newCost) public onlyOwner {
cost = _newCost;
}
function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner {
maxMintAmount = _newmaxMintAmount;
}
function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner {
notRevealedUri = _notRevealedURI;
}
function setBaseURI(string memory _newBaseURI) public onlyOwner {
baseURI = _newBaseURI;
}
function setBaseExtension(string memory _newBaseExtension)
public
onlyOwner
{
baseExtension = _newBaseExtension;
}
function setOnlyWhitelisted(bool _state) public onlyOwner {
onlyWhitelisted = _state;
}
function pause(bool _state) public onlyOwner {
paused = _state;
}
function whitelistUsers(address[] calldata _users) public onlyOwner {
delete whitelistedAddresses;
whitelistedAddresses = _users;
}
function withdraw() public payable onlyOwner {
(bool success, ) = payable(msg.sender).call{
value: address(this).balance
}("");
require(success);
}
} | _baseURI | function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
| // internal | LineComment | v0.8.7+commit.e28d00a7 | MIT | ipfs://d21251a8341395a27461909f282f0da3735590433e375c49fa1ff0968d33db07 | {
"func_code_index": [
805,
918
]
} | 2,288 |
||
ThugWhales | @openzeppelin/contracts/access/Ownable.sol | 0x2b73f11f7f58e3d25b84adc0a6693072207f7dac | Solidity | ThugWhales | contract ThugWhales is ERC721Enumerable, Ownable {
using Strings for uint256;
string baseURI;
string public baseExtension = ".json";
string public notRevealedUri;
uint256 public cost = 0.05 ether;
uint256 public maxSupply = 2222;
uint256 public maxMintAmount = 10;
uint256 public nftPerAddressLimit = 10;
bool public paused = false;
bool public revealed = false;
bool public onlyWhitelisted = true;
address[] public whitelistedAddresses;
constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI,
string memory _initNotRevealedUri
) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
setNotRevealedURI(_initNotRevealedUri);
}
// internal
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
// public
function mint(uint256 _mintAmount) public payable {
require(!paused);
uint256 supply = totalSupply();
require(_mintAmount > 0);
require(_mintAmount <= maxMintAmount);
require(supply + _mintAmount <= maxSupply);
if (msg.sender != owner()) {
if (onlyWhitelisted == true) {
require(isWhitelisted(msg.sender), "User is not Whitelisted");
uint256 ownerTokenCount = balanceOf(msg.sender);
require(ownerTokenCount < nftPerAddressLimit);
}
require(msg.value >= cost * _mintAmount);
}
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(msg.sender, supply + i);
}
}
function isWhitelisted(address _user) public view returns (bool) {
for (uint256 i = 0; i < whitelistedAddresses.length; i++) {
if (whitelistedAddresses[i] == _user) {
return true;
}
}
return false;
}
function walletOfOwner(address _owner)
public
view
returns (uint256[] memory)
{
uint256 ownerTokenCount = balanceOf(_owner);
uint256[] memory tokenIds = new uint256[](ownerTokenCount);
for (uint256 i; i < ownerTokenCount; i++) {
tokenIds[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokenIds;
}
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
if (revealed == false) {
return notRevealedUri;
}
string memory currentBaseURI = _baseURI();
return
bytes(currentBaseURI).length > 0
? string(
abi.encodePacked(
currentBaseURI,
tokenId.toString(),
baseExtension
)
)
: "";
}
//only owner
function reveal() public onlyOwner {
revealed = true;
}
function setNftPerAddressLimit(uint256 _limit) public onlyOwner {
nftPerAddressLimit = _limit;
}
function setCost(uint256 _newCost) public onlyOwner {
cost = _newCost;
}
function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner {
maxMintAmount = _newmaxMintAmount;
}
function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner {
notRevealedUri = _notRevealedURI;
}
function setBaseURI(string memory _newBaseURI) public onlyOwner {
baseURI = _newBaseURI;
}
function setBaseExtension(string memory _newBaseExtension)
public
onlyOwner
{
baseExtension = _newBaseExtension;
}
function setOnlyWhitelisted(bool _state) public onlyOwner {
onlyWhitelisted = _state;
}
function pause(bool _state) public onlyOwner {
paused = _state;
}
function whitelistUsers(address[] calldata _users) public onlyOwner {
delete whitelistedAddresses;
whitelistedAddresses = _users;
}
function withdraw() public payable onlyOwner {
(bool success, ) = payable(msg.sender).call{
value: address(this).balance
}("");
require(success);
}
} | mint | function mint(uint256 _mintAmount) public payable {
require(!paused);
uint256 supply = totalSupply();
require(_mintAmount > 0);
require(_mintAmount <= maxMintAmount);
require(supply + _mintAmount <= maxSupply);
if (msg.sender != owner()) {
if (onlyWhitelisted == true) {
require(isWhitelisted(msg.sender), "User is not Whitelisted");
uint256 ownerTokenCount = balanceOf(msg.sender);
require(ownerTokenCount < nftPerAddressLimit);
}
require(msg.value >= cost * _mintAmount);
}
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(msg.sender, supply + i);
}
}
| // public | LineComment | v0.8.7+commit.e28d00a7 | MIT | ipfs://d21251a8341395a27461909f282f0da3735590433e375c49fa1ff0968d33db07 | {
"func_code_index": [
936,
1693
]
} | 2,289 |
||
ThugWhales | @openzeppelin/contracts/access/Ownable.sol | 0x2b73f11f7f58e3d25b84adc0a6693072207f7dac | Solidity | ThugWhales | contract ThugWhales is ERC721Enumerable, Ownable {
using Strings for uint256;
string baseURI;
string public baseExtension = ".json";
string public notRevealedUri;
uint256 public cost = 0.05 ether;
uint256 public maxSupply = 2222;
uint256 public maxMintAmount = 10;
uint256 public nftPerAddressLimit = 10;
bool public paused = false;
bool public revealed = false;
bool public onlyWhitelisted = true;
address[] public whitelistedAddresses;
constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI,
string memory _initNotRevealedUri
) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
setNotRevealedURI(_initNotRevealedUri);
}
// internal
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
// public
function mint(uint256 _mintAmount) public payable {
require(!paused);
uint256 supply = totalSupply();
require(_mintAmount > 0);
require(_mintAmount <= maxMintAmount);
require(supply + _mintAmount <= maxSupply);
if (msg.sender != owner()) {
if (onlyWhitelisted == true) {
require(isWhitelisted(msg.sender), "User is not Whitelisted");
uint256 ownerTokenCount = balanceOf(msg.sender);
require(ownerTokenCount < nftPerAddressLimit);
}
require(msg.value >= cost * _mintAmount);
}
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(msg.sender, supply + i);
}
}
function isWhitelisted(address _user) public view returns (bool) {
for (uint256 i = 0; i < whitelistedAddresses.length; i++) {
if (whitelistedAddresses[i] == _user) {
return true;
}
}
return false;
}
function walletOfOwner(address _owner)
public
view
returns (uint256[] memory)
{
uint256 ownerTokenCount = balanceOf(_owner);
uint256[] memory tokenIds = new uint256[](ownerTokenCount);
for (uint256 i; i < ownerTokenCount; i++) {
tokenIds[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokenIds;
}
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
if (revealed == false) {
return notRevealedUri;
}
string memory currentBaseURI = _baseURI();
return
bytes(currentBaseURI).length > 0
? string(
abi.encodePacked(
currentBaseURI,
tokenId.toString(),
baseExtension
)
)
: "";
}
//only owner
function reveal() public onlyOwner {
revealed = true;
}
function setNftPerAddressLimit(uint256 _limit) public onlyOwner {
nftPerAddressLimit = _limit;
}
function setCost(uint256 _newCost) public onlyOwner {
cost = _newCost;
}
function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner {
maxMintAmount = _newmaxMintAmount;
}
function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner {
notRevealedUri = _notRevealedURI;
}
function setBaseURI(string memory _newBaseURI) public onlyOwner {
baseURI = _newBaseURI;
}
function setBaseExtension(string memory _newBaseExtension)
public
onlyOwner
{
baseExtension = _newBaseExtension;
}
function setOnlyWhitelisted(bool _state) public onlyOwner {
onlyWhitelisted = _state;
}
function pause(bool _state) public onlyOwner {
paused = _state;
}
function whitelistUsers(address[] calldata _users) public onlyOwner {
delete whitelistedAddresses;
whitelistedAddresses = _users;
}
function withdraw() public payable onlyOwner {
(bool success, ) = payable(msg.sender).call{
value: address(this).balance
}("");
require(success);
}
} | reveal | function reveal() public onlyOwner {
revealed = true;
}
| //only owner | LineComment | v0.8.7+commit.e28d00a7 | MIT | ipfs://d21251a8341395a27461909f282f0da3735590433e375c49fa1ff0968d33db07 | {
"func_code_index": [
3127,
3201
]
} | 2,290 |
||
Bleeps | src/base/IERC4494.sol | 0xc72d6d47c64460e6ed9d9af9e01c2ab4f37bef78 | Solidity | IERC4494 | interface IERC4494 {
function DOMAIN_SEPARATOR() external view returns (bytes32);
/// @notice Allows to retrieve current nonce for token
/// @param tokenId token id
/// @return current token nonce
function nonces(uint256 tokenId) external view returns (uint256);
/// @notice function to be called by anyone to approve `spender` using a Permit signature
/// @dev Anyone can call this to approve `spender`, even a third-party
/// @param spender the actor to approve
/// @param tokenId the token id
/// @param deadline the deadline for the permit to be used
/// @param signature permit
function permit(
address spender,
uint256 tokenId,
uint256 deadline,
bytes memory signature
) external;
} | nonces | function nonces(uint256 tokenId) external view returns (uint256);
| /// @notice Allows to retrieve current nonce for token
/// @param tokenId token id
/// @return current token nonce | NatSpecSingleLine | v0.8.9+commit.e5eed63a | MIT | {
"func_code_index": [
214,
283
]
} | 2,291 |
|||
Bleeps | src/base/IERC4494.sol | 0xc72d6d47c64460e6ed9d9af9e01c2ab4f37bef78 | Solidity | IERC4494 | interface IERC4494 {
function DOMAIN_SEPARATOR() external view returns (bytes32);
/// @notice Allows to retrieve current nonce for token
/// @param tokenId token id
/// @return current token nonce
function nonces(uint256 tokenId) external view returns (uint256);
/// @notice function to be called by anyone to approve `spender` using a Permit signature
/// @dev Anyone can call this to approve `spender`, even a third-party
/// @param spender the actor to approve
/// @param tokenId the token id
/// @param deadline the deadline for the permit to be used
/// @param signature permit
function permit(
address spender,
uint256 tokenId,
uint256 deadline,
bytes memory signature
) external;
} | permit | function permit(
address spender,
uint256 tokenId,
uint256 deadline,
bytes memory signature
) external;
| /// @notice function to be called by anyone to approve `spender` using a Permit signature
/// @dev Anyone can call this to approve `spender`, even a third-party
/// @param spender the actor to approve
/// @param tokenId the token id
/// @param deadline the deadline for the permit to be used
/// @param signature permit | NatSpecSingleLine | v0.8.9+commit.e5eed63a | MIT | {
"func_code_index": [
629,
772
]
} | 2,292 |
|||
Bleeps | src/base/IERC4494.sol | 0xc72d6d47c64460e6ed9d9af9e01c2ab4f37bef78 | Solidity | IERC4494Alternative | interface IERC4494Alternative {
function DOMAIN_SEPARATOR() external view returns (bytes32);
/// @notice Allows to retrieve current nonce for token
/// @param tokenId token id
/// @return current token nonce
function tokenNonces(uint256 tokenId) external view returns (uint256);
/// @notice function to be called by anyone to approve `spender` using a Permit signature
/// @dev Anyone can call this to approve `spender`, even a third-party
/// @param spender the actor to approve
/// @param tokenId the token id
/// @param deadline the deadline for the permit to be used
/// @param signature permit
function permit(
address spender,
uint256 tokenId,
uint256 deadline,
bytes memory signature
) external;
} | tokenNonces | function tokenNonces(uint256 tokenId) external view returns (uint256);
| /// @notice Allows to retrieve current nonce for token
/// @param tokenId token id
/// @return current token nonce | NatSpecSingleLine | v0.8.9+commit.e5eed63a | MIT | {
"func_code_index": [
225,
299
]
} | 2,293 |
|||
Bleeps | src/base/IERC4494.sol | 0xc72d6d47c64460e6ed9d9af9e01c2ab4f37bef78 | Solidity | IERC4494Alternative | interface IERC4494Alternative {
function DOMAIN_SEPARATOR() external view returns (bytes32);
/// @notice Allows to retrieve current nonce for token
/// @param tokenId token id
/// @return current token nonce
function tokenNonces(uint256 tokenId) external view returns (uint256);
/// @notice function to be called by anyone to approve `spender` using a Permit signature
/// @dev Anyone can call this to approve `spender`, even a third-party
/// @param spender the actor to approve
/// @param tokenId the token id
/// @param deadline the deadline for the permit to be used
/// @param signature permit
function permit(
address spender,
uint256 tokenId,
uint256 deadline,
bytes memory signature
) external;
} | permit | function permit(
address spender,
uint256 tokenId,
uint256 deadline,
bytes memory signature
) external;
| /// @notice function to be called by anyone to approve `spender` using a Permit signature
/// @dev Anyone can call this to approve `spender`, even a third-party
/// @param spender the actor to approve
/// @param tokenId the token id
/// @param deadline the deadline for the permit to be used
/// @param signature permit | NatSpecSingleLine | v0.8.9+commit.e5eed63a | MIT | {
"func_code_index": [
645,
788
]
} | 2,294 |
|||
HappyNewYearToken | HappyNewYearToken.sol | 0x8189952b0b8d88622a4b0b592f0b7115d81e16fc | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
| /**
* @dev Multiplies two numbers, throws on overflow.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://d2f40a04f505f0a60799ef6425f5cd1eeb5aac4b3177331311d5620122d01b0e | {
"func_code_index": [
95,
302
]
} | 2,295 |
|||
HappyNewYearToken | HappyNewYearToken.sol | 0x8189952b0b8d88622a4b0b592f0b7115d81e16fc | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | div | function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
| /**
* @dev Integer division of two numbers, truncating the quotient.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://d2f40a04f505f0a60799ef6425f5cd1eeb5aac4b3177331311d5620122d01b0e | {
"func_code_index": [
392,
692
]
} | 2,296 |
|||
HappyNewYearToken | HappyNewYearToken.sol | 0x8189952b0b8d88622a4b0b592f0b7115d81e16fc | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | sub | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
| /**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://d2f40a04f505f0a60799ef6425f5cd1eeb5aac4b3177331311d5620122d01b0e | {
"func_code_index": [
812,
940
]
} | 2,297 |
|||
HappyNewYearToken | HappyNewYearToken.sol | 0x8189952b0b8d88622a4b0b592f0b7115d81e16fc | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | add | function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
| /**
* @dev Adds two numbers, throws on overflow.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://d2f40a04f505f0a60799ef6425f5cd1eeb5aac4b3177331311d5620122d01b0e | {
"func_code_index": [
1010,
1156
]
} | 2,298 |
|||
Bleeps | src/base/ERC721BaseWithERC4494Permit.sol | 0xc72d6d47c64460e6ed9d9af9e01c2ab4f37bef78 | Solidity | ERC721BaseWithERC4494Permit | abstract contract ERC721BaseWithERC4494Permit is ERC721Base {
using Address for address;
bytes32 public constant PERMIT_TYPEHASH =
keccak256("Permit(address spender,uint256 tokenId,uint256 nonce,uint256 deadline)");
bytes32 public constant PERMIT_FOR_ALL_TYPEHASH =
keccak256("PermitForAll(address spender,uint256 nonce,uint256 deadline)");
bytes32 public constant DOMAIN_TYPEHASH =
keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
uint256 private immutable _deploymentChainId;
bytes32 private immutable _deploymentDomainSeparator;
mapping(address => uint256) internal _userNonces;
constructor() {
uint256 chainId;
//solhint-disable-next-line no-inline-assembly
assembly {
chainId := chainid()
}
_deploymentChainId = chainId;
_deploymentDomainSeparator = _calculateDomainSeparator(chainId);
}
/// @dev Return the DOMAIN_SEPARATOR.
function DOMAIN_SEPARATOR() external view returns (bytes32) {
return _DOMAIN_SEPARATOR();
}
function nonces(address account) external view virtual returns (uint256 nonce) {
return accountNonces(account);
}
function nonces(uint256 id) external view virtual returns (uint256 nonce) {
return tokenNonces(id);
}
function tokenNonces(uint256 id) public view returns (uint256 nonce) {
(address owner, uint256 blockNumber) = _ownerAndBlockNumberOf(id);
require(owner != address(0), "NONEXISTENT_TOKEN");
return blockNumber;
}
function accountNonces(address owner) public view returns (uint256 nonce) {
return _userNonces[owner];
}
function permit(
address spender,
uint256 tokenId,
uint256 deadline,
bytes memory sig
) external {
require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED");
(address owner, uint256 blockNumber) = _ownerAndBlockNumberOf(tokenId);
require(owner != address(0), "NONEXISTENT_TOKEN");
// We use blockNumber as nonce as we already store it per tokens. It can thus act as an increasing transfer counter.
// while technically multiple transfer could happen in the same block, the signed message would be using a previous block.
// And the transfer would use then a more recent blockNumber, invalidating that message when transfer is executed.
_requireValidPermit(owner, spender, tokenId, deadline, blockNumber, sig);
_approveFor(owner, blockNumber, spender, tokenId);
}
function permitForAll(
address signer,
address spender,
uint256 deadline,
bytes memory sig
) external {
require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED");
_requireValidPermitForAll(signer, spender, deadline, _userNonces[signer]++, sig);
_setApprovalForAll(signer, spender, true);
}
/// @notice Check if the contract supports an interface.
/// @param id The id of the interface.
/// @return Whether the interface is supported.
function supportsInterface(bytes4 id) public pure virtual override returns (bool) {
return
super.supportsInterface(id) ||
id == type(IERC4494).interfaceId ||
id == type(IERC4494Alternative).interfaceId;
}
// -------------------------------------------------------- INTERNAL --------------------------------------------------------------------
function _requireValidPermit(
address signer,
address spender,
uint256 id,
uint256 deadline,
uint256 nonce,
bytes memory sig
) internal view {
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
_DOMAIN_SEPARATOR(),
keccak256(abi.encode(PERMIT_TYPEHASH, spender, id, nonce, deadline))
)
);
require(SignatureChecker.isValidSignatureNow(signer, digest, sig), "INVALID_SIGNATURE");
}
function _requireValidPermitForAll(
address signer,
address spender,
uint256 deadline,
uint256 nonce,
bytes memory sig
) internal view {
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
_DOMAIN_SEPARATOR(),
keccak256(abi.encode(PERMIT_FOR_ALL_TYPEHASH, spender, nonce, deadline))
)
);
require(SignatureChecker.isValidSignatureNow(signer, digest, sig), "INVALID_SIGNATURE");
}
/// @dev Return the DOMAIN_SEPARATOR.
function _DOMAIN_SEPARATOR() internal view returns (bytes32) {
uint256 chainId;
//solhint-disable-next-line no-inline-assembly
assembly {
chainId := chainid()
}
// in case a fork happen, to support the chain that had to change its chainId,, we compute the domain operator
return chainId == _deploymentChainId ? _deploymentDomainSeparator : _calculateDomainSeparator(chainId);
}
/// @dev Calculate the DOMAIN_SEPARATOR.
function _calculateDomainSeparator(uint256 chainId) private view returns (bytes32) {
return keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name())), chainId, address(this)));
}
} | DOMAIN_SEPARATOR | function DOMAIN_SEPARATOR() external view returns (bytes32) {
return _DOMAIN_SEPARATOR();
}
| /// @dev Return the DOMAIN_SEPARATOR. | NatSpecSingleLine | v0.8.9+commit.e5eed63a | MIT | {
"func_code_index": [
993,
1100
]
} | 2,299 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.