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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
PlayerOneToken | PlayerOneToken.sol | 0xedf2f194c8d885b3b28098ef8e0b6700a2d95de0 | Solidity | PlayerOneToken | contract PlayerOneToken is ERC20Interface, Owned {
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "PLR1";
name = "Player One Token";
decimals = 12;
_totalSupply = 5000000000 * 10**uint(decimals);
balances[owner] = _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public view returns (uint) {
return _totalSupply.sub(balances[address(0)]);
}
// ------------------------------------------------------------------------
// Get the token balance for account `tokenOwner`
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to `to` account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
require(!isContract(to));
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
function isContract(address _addr) public view returns (bool){
uint32 size;
assembly {
size := extcodesize(_addr)
}
return (size > 0);
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer `tokens` from the `from` account to the `to` account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the `from` account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account. The `spender` contract function
// `receiveApproval(...)` is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () external payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and a
// fixed supply
// ---------------------------------------------------------------------------- | LineComment | function () external payable {
revert();
}
| // ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------ | LineComment | v0.5.12+commit.7709ece9 | None | bzzr://2d9b13d046cef584da94e0dd7f45c7c37b0a6b58d61536070c4b09e5beeee8da | {
"func_code_index": [
5206,
5267
]
} | 5,007 |
|
PlayerOneToken | PlayerOneToken.sol | 0xedf2f194c8d885b3b28098ef8e0b6700a2d95de0 | Solidity | PlayerOneToken | contract PlayerOneToken is ERC20Interface, Owned {
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "PLR1";
name = "Player One Token";
decimals = 12;
_totalSupply = 5000000000 * 10**uint(decimals);
balances[owner] = _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public view returns (uint) {
return _totalSupply.sub(balances[address(0)]);
}
// ------------------------------------------------------------------------
// Get the token balance for account `tokenOwner`
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to `to` account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
require(!isContract(to));
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
function isContract(address _addr) public view returns (bool){
uint32 size;
assembly {
size := extcodesize(_addr)
}
return (size > 0);
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer `tokens` from the `from` account to the `to` account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the `from` account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account. The `spender` contract function
// `receiveApproval(...)` is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () external payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and a
// fixed supply
// ---------------------------------------------------------------------------- | LineComment | transferAnyERC20Token | function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
| // ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------ | LineComment | v0.5.12+commit.7709ece9 | None | bzzr://2d9b13d046cef584da94e0dd7f45c7c37b0a6b58d61536070c4b09e5beeee8da | {
"func_code_index": [
5500,
5689
]
} | 5,008 |
myfichain | myfichain.sol | 0xd67a6cd797a8fdc77b12335d7dacdfd14ea7c7fd | Solidity | myfichain | contract myfichain is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
function myfichain() public {
symbol = "MYFI";
name = "MyFiChain";
decimals = 18;
_totalSupply = 10000000000000000000000000000;
balances[0xAbB082211930DA475879BF315AFaDDD55913C6a8] = _totalSupply;
Transfer(address(0), 0xAbB082211930DA475879BF315AFaDDD55913C6a8, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | totalSupply | function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
| // ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | bzzr://3f5f091a8b4128e586be9a7066f28fc920c390255ce7726353df3ccf63304757 | {
"func_code_index": [
798,
919
]
} | 5,009 |
|||
myfichain | myfichain.sol | 0xd67a6cd797a8fdc77b12335d7dacdfd14ea7c7fd | Solidity | myfichain | contract myfichain is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
function myfichain() public {
symbol = "MYFI";
name = "MyFiChain";
decimals = 18;
_totalSupply = 10000000000000000000000000000;
balances[0xAbB082211930DA475879BF315AFaDDD55913C6a8] = _totalSupply;
Transfer(address(0), 0xAbB082211930DA475879BF315AFaDDD55913C6a8, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | balanceOf | function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
| // ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | bzzr://3f5f091a8b4128e586be9a7066f28fc920c390255ce7726353df3ccf63304757 | {
"func_code_index": [
1139,
1268
]
} | 5,010 |
|||
myfichain | myfichain.sol | 0xd67a6cd797a8fdc77b12335d7dacdfd14ea7c7fd | Solidity | myfichain | contract myfichain is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
function myfichain() public {
symbol = "MYFI";
name = "MyFiChain";
decimals = 18;
_totalSupply = 10000000000000000000000000000;
balances[0xAbB082211930DA475879BF315AFaDDD55913C6a8] = _totalSupply;
Transfer(address(0), 0xAbB082211930DA475879BF315AFaDDD55913C6a8, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | transfer | function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(msg.sender, to, tokens);
return true;
}
| // ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | bzzr://3f5f091a8b4128e586be9a7066f28fc920c390255ce7726353df3ccf63304757 | {
"func_code_index": [
1612,
1889
]
} | 5,011 |
|||
myfichain | myfichain.sol | 0xd67a6cd797a8fdc77b12335d7dacdfd14ea7c7fd | Solidity | myfichain | contract myfichain is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
function myfichain() public {
symbol = "MYFI";
name = "MyFiChain";
decimals = 18;
_totalSupply = 10000000000000000000000000000;
balances[0xAbB082211930DA475879BF315AFaDDD55913C6a8] = _totalSupply;
Transfer(address(0), 0xAbB082211930DA475879BF315AFaDDD55913C6a8, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | approve | function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
return true;
}
| // ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | bzzr://3f5f091a8b4128e586be9a7066f28fc920c390255ce7726353df3ccf63304757 | {
"func_code_index": [
2397,
2605
]
} | 5,012 |
|||
myfichain | myfichain.sol | 0xd67a6cd797a8fdc77b12335d7dacdfd14ea7c7fd | Solidity | myfichain | contract myfichain is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
function myfichain() public {
symbol = "MYFI";
name = "MyFiChain";
decimals = 18;
_totalSupply = 10000000000000000000000000000;
balances[0xAbB082211930DA475879BF315AFaDDD55913C6a8] = _totalSupply;
Transfer(address(0), 0xAbB082211930DA475879BF315AFaDDD55913C6a8, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | transferFrom | function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(from, to, tokens);
return true;
}
| // ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | bzzr://3f5f091a8b4128e586be9a7066f28fc920c390255ce7726353df3ccf63304757 | {
"func_code_index": [
3136,
3494
]
} | 5,013 |
|||
myfichain | myfichain.sol | 0xd67a6cd797a8fdc77b12335d7dacdfd14ea7c7fd | Solidity | myfichain | contract myfichain is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
function myfichain() public {
symbol = "MYFI";
name = "MyFiChain";
decimals = 18;
_totalSupply = 10000000000000000000000000000;
balances[0xAbB082211930DA475879BF315AFaDDD55913C6a8] = _totalSupply;
Transfer(address(0), 0xAbB082211930DA475879BF315AFaDDD55913C6a8, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | allowance | function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
| // ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | bzzr://3f5f091a8b4128e586be9a7066f28fc920c390255ce7726353df3ccf63304757 | {
"func_code_index": [
3777,
3933
]
} | 5,014 |
|||
myfichain | myfichain.sol | 0xd67a6cd797a8fdc77b12335d7dacdfd14ea7c7fd | Solidity | myfichain | contract myfichain is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
function myfichain() public {
symbol = "MYFI";
name = "MyFiChain";
decimals = 18;
_totalSupply = 10000000000000000000000000000;
balances[0xAbB082211930DA475879BF315AFaDDD55913C6a8] = _totalSupply;
Transfer(address(0), 0xAbB082211930DA475879BF315AFaDDD55913C6a8, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | approveAndCall | function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
| // ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | bzzr://3f5f091a8b4128e586be9a7066f28fc920c390255ce7726353df3ccf63304757 | {
"func_code_index": [
4288,
4605
]
} | 5,015 |
|||
myfichain | myfichain.sol | 0xd67a6cd797a8fdc77b12335d7dacdfd14ea7c7fd | Solidity | myfichain | contract myfichain is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
function myfichain() public {
symbol = "MYFI";
name = "MyFiChain";
decimals = 18;
_totalSupply = 10000000000000000000000000000;
balances[0xAbB082211930DA475879BF315AFaDDD55913C6a8] = _totalSupply;
Transfer(address(0), 0xAbB082211930DA475879BF315AFaDDD55913C6a8, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | function () public payable {
revert();
}
| // ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | bzzr://3f5f091a8b4128e586be9a7066f28fc920c390255ce7726353df3ccf63304757 | {
"func_code_index": [
4797,
4856
]
} | 5,016 |
||||
myfichain | myfichain.sol | 0xd67a6cd797a8fdc77b12335d7dacdfd14ea7c7fd | Solidity | myfichain | contract myfichain is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
function myfichain() public {
symbol = "MYFI";
name = "MyFiChain";
decimals = 18;
_totalSupply = 10000000000000000000000000000;
balances[0xAbB082211930DA475879BF315AFaDDD55913C6a8] = _totalSupply;
Transfer(address(0), 0xAbB082211930DA475879BF315AFaDDD55913C6a8, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | transferAnyERC20Token | function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
| // ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | bzzr://3f5f091a8b4128e586be9a7066f28fc920c390255ce7726353df3ccf63304757 | {
"func_code_index": [
5089,
5278
]
} | 5,017 |
|||
WanchainContribution | WanchainContribution.sol | 0xaac3090257be280087d8bdc530265203d105b120 | Solidity | Owned | contract Owned {
/// @dev `owner` is the only address that can call a function with this
/// modifier
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
address public owner;
/// @notice The Constructor assigns the message sender to be `owner`
function Owned() {
owner = msg.sender;
}
address public newOwner;
/// @notice `owner` can step down and assign some other address to this role
/// @param _newOwner The address of the new owner. 0x0 can be used to create
/// an unowned neutral vault, however that cannot be undone
function changeOwner(address _newOwner) onlyOwner {
newOwner = _newOwner;
}
function acceptOwnership() {
if (msg.sender == newOwner) {
owner = newOwner;
}
}
} | /// @dev `Owned` is a base level contract that assigns an `owner` that can be
/// later changed | NatSpecSingleLine | Owned | function Owned() {
owner = msg.sender;
}
| /// @notice The Constructor assigns the message sender to be `owner` | NatSpecSingleLine | v0.4.13+commit.fb4cb1a | bzzr://cf354415565dbcba55ca7d803241ed623e9875b86e7d49619e734c70d0b4d0bf | {
"func_code_index": [
306,
365
]
} | 5,018 |
|
WanchainContribution | WanchainContribution.sol | 0xaac3090257be280087d8bdc530265203d105b120 | Solidity | Owned | contract Owned {
/// @dev `owner` is the only address that can call a function with this
/// modifier
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
address public owner;
/// @notice The Constructor assigns the message sender to be `owner`
function Owned() {
owner = msg.sender;
}
address public newOwner;
/// @notice `owner` can step down and assign some other address to this role
/// @param _newOwner The address of the new owner. 0x0 can be used to create
/// an unowned neutral vault, however that cannot be undone
function changeOwner(address _newOwner) onlyOwner {
newOwner = _newOwner;
}
function acceptOwnership() {
if (msg.sender == newOwner) {
owner = newOwner;
}
}
} | /// @dev `Owned` is a base level contract that assigns an `owner` that can be
/// later changed | NatSpecSingleLine | changeOwner | function changeOwner(address _newOwner) onlyOwner {
newOwner = _newOwner;
}
| /// @notice `owner` can step down and assign some other address to this role
/// @param _newOwner The address of the new owner. 0x0 can be used to create
/// an unowned neutral vault, however that cannot be undone | NatSpecSingleLine | v0.4.13+commit.fb4cb1a | bzzr://cf354415565dbcba55ca7d803241ed623e9875b86e7d49619e734c70d0b4d0bf | {
"func_code_index": [
630,
724
]
} | 5,019 |
|
WanchainContribution | WanchainContribution.sol | 0xaac3090257be280087d8bdc530265203d105b120 | Solidity | ERC20Protocol | contract ERC20Protocol {
/* This is a slight change to the ERC20 base standard.
function totalSupply() constant returns (uint supply);
is replaced with:
uint public totalSupply;
This automatically creates a getter function for the totalSupply.
This is moved to the base contract since public getter functions are not
currently recognised as an implementation of the matching abstract
function by the compiler.
*/
/// total amount of tokens
uint public totalSupply;
/// @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 `_spender` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of tokens to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, 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.13+commit.fb4cb1a | bzzr://cf354415565dbcba55ca7d803241ed623e9875b86e7d49619e734c70d0b4d0bf | {
"func_code_index": [
628,
700
]
} | 5,020 |
|||
WanchainContribution | WanchainContribution.sol | 0xaac3090257be280087d8bdc530265203d105b120 | Solidity | ERC20Protocol | contract ERC20Protocol {
/* This is a slight change to the ERC20 base standard.
function totalSupply() constant returns (uint supply);
is replaced with:
uint public totalSupply;
This automatically creates a getter function for the totalSupply.
This is moved to the base contract since public getter functions are not
currently recognised as an implementation of the matching abstract
function by the compiler.
*/
/// total amount of tokens
uint public totalSupply;
/// @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 `_spender` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of tokens to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, 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.13+commit.fb4cb1a | bzzr://cf354415565dbcba55ca7d803241ed623e9875b86e7d49619e734c70d0b4d0bf | {
"func_code_index": [
937,
1009
]
} | 5,021 |
|||
WanchainContribution | WanchainContribution.sol | 0xaac3090257be280087d8bdc530265203d105b120 | Solidity | ERC20Protocol | contract ERC20Protocol {
/* This is a slight change to the ERC20 base standard.
function totalSupply() constant returns (uint supply);
is replaced with:
uint public totalSupply;
This automatically creates a getter function for the totalSupply.
This is moved to the base contract since public getter functions are not
currently recognised as an implementation of the matching abstract
function by the compiler.
*/
/// total amount of tokens
uint public totalSupply;
/// @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 `_spender` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of tokens to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, 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.13+commit.fb4cb1a | bzzr://cf354415565dbcba55ca7d803241ed623e9875b86e7d49619e734c70d0b4d0bf | {
"func_code_index": [
1332,
1423
]
} | 5,022 |
|||
WanchainContribution | WanchainContribution.sol | 0xaac3090257be280087d8bdc530265203d105b120 | Solidity | ERC20Protocol | contract ERC20Protocol {
/* This is a slight change to the ERC20 base standard.
function totalSupply() constant returns (uint supply);
is replaced with:
uint public totalSupply;
This automatically creates a getter function for the totalSupply.
This is moved to the base contract since public getter functions are not
currently recognised as an implementation of the matching abstract
function by the compiler.
*/
/// total amount of tokens
uint public totalSupply;
/// @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 `_spender` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of tokens to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, 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 `_spender` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of tokens to be approved for transfer
/// @return Whether the approval was successful or not | NatSpecSingleLine | v0.4.13+commit.fb4cb1a | bzzr://cf354415565dbcba55ca7d803241ed623e9875b86e7d49619e734c70d0b4d0bf | {
"func_code_index": [
1713,
1789
]
} | 5,023 |
|||
WanchainContribution | WanchainContribution.sol | 0xaac3090257be280087d8bdc530265203d105b120 | Solidity | ERC20Protocol | contract ERC20Protocol {
/* This is a slight change to the ERC20 base standard.
function totalSupply() constant returns (uint supply);
is replaced with:
uint public totalSupply;
This automatically creates a getter function for the totalSupply.
This is moved to the base contract since public getter functions are not
currently recognised as an implementation of the matching abstract
function by the compiler.
*/
/// total amount of tokens
uint public totalSupply;
/// @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 `_spender` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of tokens to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, 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.13+commit.fb4cb1a | bzzr://cf354415565dbcba55ca7d803241ed623e9875b86e7d49619e734c70d0b4d0bf | {
"func_code_index": [
1997,
2089
]
} | 5,024 |
|||
WanchainContribution | WanchainContribution.sol | 0xaac3090257be280087d8bdc530265203d105b120 | Solidity | WanToken | contract WanToken is StandardToken {
using SafeMath for uint;
/// Constant token specific fields
string public constant name = "WanCoin";
string public constant symbol = "WAN";
uint public constant decimals = 18;
/// Wanchain total tokens supply
uint public constant MAX_TOTAL_TOKEN_AMOUNT = 210000000 ether;
/// Fields that are only changed in constructor
/// Wanchain contribution contract
address public minter;
/// ICO start time
uint public startTime;
/// ICO end time
uint public endTime;
/// Fields that can be changed by functions
mapping (address => uint) public lockedBalances;
/*
* MODIFIERS
*/
modifier onlyMinter {
assert(msg.sender == minter);
_;
}
modifier isLaterThan (uint x){
assert(now > x);
_;
}
modifier maxWanTokenAmountNotReached (uint amount){
assert(totalSupply.add(amount) <= MAX_TOTAL_TOKEN_AMOUNT);
_;
}
/**
* CONSTRUCTOR
*
* @dev Initialize the Wanchain Token
* @param _minter The Wanchain Contribution Contract
* @param _startTime ICO start time
* @param _endTime ICO End Time
*/
function WanToken(address _minter, uint _startTime, uint _endTime){
minter = _minter;
startTime = _startTime;
endTime = _endTime;
}
/**
* EXTERNAL FUNCTION
*
* @dev Contribution contract instance mint token
* @param receipent The destination account owned mint tokens
* @param amount The amount of mint token
* be sent to this address.
*/
function mintToken(address receipent, uint amount)
external
onlyMinter
maxWanTokenAmountNotReached(amount)
returns (bool)
{
require(now <= endTime);
lockedBalances[receipent] = lockedBalances[receipent].add(amount);
totalSupply = totalSupply.add(amount);
return true;
}
/*
* PUBLIC FUNCTIONS
*/
/// @dev Locking period has passed - Locked tokens have turned into tradeable
/// All tokens owned by receipent will be tradeable
function claimTokens(address receipent)
public
onlyMinter
{
balances[receipent] = balances[receipent].add(lockedBalances[receipent]);
lockedBalances[receipent] = 0;
}
/*
* CONSTANT METHODS
*/
function lockedBalanceOf(address _owner) constant returns (uint balance) {
return lockedBalances[_owner];
}
} | /// @title Wanchain Token Contract
/// For more information about this token sale, please visit https://wanchain.org
/// @author Cathy - <[email protected]> | NatSpecSingleLine | WanToken | function WanToken(address _minter, uint _startTime, uint _endTime){
minter = _minter;
startTime = _startTime;
endTime = _endTime;
}
| /**
* CONSTRUCTOR
*
* @dev Initialize the Wanchain Token
* @param _minter The Wanchain Contribution Contract
* @param _startTime ICO start time
* @param _endTime ICO End Time
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://cf354415565dbcba55ca7d803241ed623e9875b86e7d49619e734c70d0b4d0bf | {
"func_code_index": [
1263,
1431
]
} | 5,025 |
|
WanchainContribution | WanchainContribution.sol | 0xaac3090257be280087d8bdc530265203d105b120 | Solidity | WanToken | contract WanToken is StandardToken {
using SafeMath for uint;
/// Constant token specific fields
string public constant name = "WanCoin";
string public constant symbol = "WAN";
uint public constant decimals = 18;
/// Wanchain total tokens supply
uint public constant MAX_TOTAL_TOKEN_AMOUNT = 210000000 ether;
/// Fields that are only changed in constructor
/// Wanchain contribution contract
address public minter;
/// ICO start time
uint public startTime;
/// ICO end time
uint public endTime;
/// Fields that can be changed by functions
mapping (address => uint) public lockedBalances;
/*
* MODIFIERS
*/
modifier onlyMinter {
assert(msg.sender == minter);
_;
}
modifier isLaterThan (uint x){
assert(now > x);
_;
}
modifier maxWanTokenAmountNotReached (uint amount){
assert(totalSupply.add(amount) <= MAX_TOTAL_TOKEN_AMOUNT);
_;
}
/**
* CONSTRUCTOR
*
* @dev Initialize the Wanchain Token
* @param _minter The Wanchain Contribution Contract
* @param _startTime ICO start time
* @param _endTime ICO End Time
*/
function WanToken(address _minter, uint _startTime, uint _endTime){
minter = _minter;
startTime = _startTime;
endTime = _endTime;
}
/**
* EXTERNAL FUNCTION
*
* @dev Contribution contract instance mint token
* @param receipent The destination account owned mint tokens
* @param amount The amount of mint token
* be sent to this address.
*/
function mintToken(address receipent, uint amount)
external
onlyMinter
maxWanTokenAmountNotReached(amount)
returns (bool)
{
require(now <= endTime);
lockedBalances[receipent] = lockedBalances[receipent].add(amount);
totalSupply = totalSupply.add(amount);
return true;
}
/*
* PUBLIC FUNCTIONS
*/
/// @dev Locking period has passed - Locked tokens have turned into tradeable
/// All tokens owned by receipent will be tradeable
function claimTokens(address receipent)
public
onlyMinter
{
balances[receipent] = balances[receipent].add(lockedBalances[receipent]);
lockedBalances[receipent] = 0;
}
/*
* CONSTANT METHODS
*/
function lockedBalanceOf(address _owner) constant returns (uint balance) {
return lockedBalances[_owner];
}
} | /// @title Wanchain Token Contract
/// For more information about this token sale, please visit https://wanchain.org
/// @author Cathy - <[email protected]> | NatSpecSingleLine | mintToken | function mintToken(address receipent, uint amount)
external
onlyMinter
maxWanTokenAmountNotReached(amount)
returns (bool)
{
require(now <= endTime);
lockedBalances[receipent] = lockedBalances[receipent].add(amount);
totalSupply = totalSupply.add(amount);
return true;
}
| /**
* EXTERNAL FUNCTION
*
* @dev Contribution contract instance mint token
* @param receipent The destination account owned mint tokens
* @param amount The amount of mint token
* be sent to this address.
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://cf354415565dbcba55ca7d803241ed623e9875b86e7d49619e734c70d0b4d0bf | {
"func_code_index": [
1698,
2054
]
} | 5,026 |
|
WanchainContribution | WanchainContribution.sol | 0xaac3090257be280087d8bdc530265203d105b120 | Solidity | WanToken | contract WanToken is StandardToken {
using SafeMath for uint;
/// Constant token specific fields
string public constant name = "WanCoin";
string public constant symbol = "WAN";
uint public constant decimals = 18;
/// Wanchain total tokens supply
uint public constant MAX_TOTAL_TOKEN_AMOUNT = 210000000 ether;
/// Fields that are only changed in constructor
/// Wanchain contribution contract
address public minter;
/// ICO start time
uint public startTime;
/// ICO end time
uint public endTime;
/// Fields that can be changed by functions
mapping (address => uint) public lockedBalances;
/*
* MODIFIERS
*/
modifier onlyMinter {
assert(msg.sender == minter);
_;
}
modifier isLaterThan (uint x){
assert(now > x);
_;
}
modifier maxWanTokenAmountNotReached (uint amount){
assert(totalSupply.add(amount) <= MAX_TOTAL_TOKEN_AMOUNT);
_;
}
/**
* CONSTRUCTOR
*
* @dev Initialize the Wanchain Token
* @param _minter The Wanchain Contribution Contract
* @param _startTime ICO start time
* @param _endTime ICO End Time
*/
function WanToken(address _minter, uint _startTime, uint _endTime){
minter = _minter;
startTime = _startTime;
endTime = _endTime;
}
/**
* EXTERNAL FUNCTION
*
* @dev Contribution contract instance mint token
* @param receipent The destination account owned mint tokens
* @param amount The amount of mint token
* be sent to this address.
*/
function mintToken(address receipent, uint amount)
external
onlyMinter
maxWanTokenAmountNotReached(amount)
returns (bool)
{
require(now <= endTime);
lockedBalances[receipent] = lockedBalances[receipent].add(amount);
totalSupply = totalSupply.add(amount);
return true;
}
/*
* PUBLIC FUNCTIONS
*/
/// @dev Locking period has passed - Locked tokens have turned into tradeable
/// All tokens owned by receipent will be tradeable
function claimTokens(address receipent)
public
onlyMinter
{
balances[receipent] = balances[receipent].add(lockedBalances[receipent]);
lockedBalances[receipent] = 0;
}
/*
* CONSTANT METHODS
*/
function lockedBalanceOf(address _owner) constant returns (uint balance) {
return lockedBalances[_owner];
}
} | /// @title Wanchain Token Contract
/// For more information about this token sale, please visit https://wanchain.org
/// @author Cathy - <[email protected]> | NatSpecSingleLine | claimTokens | function claimTokens(address receipent)
public
onlyMinter
{
balances[receipent] = balances[receipent].add(lockedBalances[receipent]);
lockedBalances[receipent] = 0;
}
| /// @dev Locking period has passed - Locked tokens have turned into tradeable
/// All tokens owned by receipent will be tradeable | NatSpecSingleLine | v0.4.13+commit.fb4cb1a | bzzr://cf354415565dbcba55ca7d803241ed623e9875b86e7d49619e734c70d0b4d0bf | {
"func_code_index": [
2246,
2463
]
} | 5,027 |
|
WanchainContribution | WanchainContribution.sol | 0xaac3090257be280087d8bdc530265203d105b120 | Solidity | WanToken | contract WanToken is StandardToken {
using SafeMath for uint;
/// Constant token specific fields
string public constant name = "WanCoin";
string public constant symbol = "WAN";
uint public constant decimals = 18;
/// Wanchain total tokens supply
uint public constant MAX_TOTAL_TOKEN_AMOUNT = 210000000 ether;
/// Fields that are only changed in constructor
/// Wanchain contribution contract
address public minter;
/// ICO start time
uint public startTime;
/// ICO end time
uint public endTime;
/// Fields that can be changed by functions
mapping (address => uint) public lockedBalances;
/*
* MODIFIERS
*/
modifier onlyMinter {
assert(msg.sender == minter);
_;
}
modifier isLaterThan (uint x){
assert(now > x);
_;
}
modifier maxWanTokenAmountNotReached (uint amount){
assert(totalSupply.add(amount) <= MAX_TOTAL_TOKEN_AMOUNT);
_;
}
/**
* CONSTRUCTOR
*
* @dev Initialize the Wanchain Token
* @param _minter The Wanchain Contribution Contract
* @param _startTime ICO start time
* @param _endTime ICO End Time
*/
function WanToken(address _minter, uint _startTime, uint _endTime){
minter = _minter;
startTime = _startTime;
endTime = _endTime;
}
/**
* EXTERNAL FUNCTION
*
* @dev Contribution contract instance mint token
* @param receipent The destination account owned mint tokens
* @param amount The amount of mint token
* be sent to this address.
*/
function mintToken(address receipent, uint amount)
external
onlyMinter
maxWanTokenAmountNotReached(amount)
returns (bool)
{
require(now <= endTime);
lockedBalances[receipent] = lockedBalances[receipent].add(amount);
totalSupply = totalSupply.add(amount);
return true;
}
/*
* PUBLIC FUNCTIONS
*/
/// @dev Locking period has passed - Locked tokens have turned into tradeable
/// All tokens owned by receipent will be tradeable
function claimTokens(address receipent)
public
onlyMinter
{
balances[receipent] = balances[receipent].add(lockedBalances[receipent]);
lockedBalances[receipent] = 0;
}
/*
* CONSTANT METHODS
*/
function lockedBalanceOf(address _owner) constant returns (uint balance) {
return lockedBalances[_owner];
}
} | /// @title Wanchain Token Contract
/// For more information about this token sale, please visit https://wanchain.org
/// @author Cathy - <[email protected]> | NatSpecSingleLine | lockedBalanceOf | function lockedBalanceOf(address _owner) constant returns (uint balance) {
return lockedBalances[_owner];
}
| /*
* CONSTANT METHODS
*/ | Comment | v0.4.13+commit.fb4cb1a | bzzr://cf354415565dbcba55ca7d803241ed623e9875b86e7d49619e734c70d0b4d0bf | {
"func_code_index": [
2508,
2634
]
} | 5,028 |
|
WanchainContribution | WanchainContribution.sol | 0xaac3090257be280087d8bdc530265203d105b120 | Solidity | WanchainContribution | contract WanchainContribution is Owned {
using SafeMath for uint;
/// Constant fields
/// Wanchain total tokens supply
uint public constant WAN_TOTAL_SUPPLY = 210000000 ether;
uint public constant EARLY_CONTRIBUTION_DURATION = 24 hours;
uint public constant MAX_CONTRIBUTION_DURATION = 3 weeks;
/// Exchange rates for first phase
uint public constant PRICE_RATE_FIRST = 880;
/// Exchange rates for second phase
uint public constant PRICE_RATE_SECOND = 790;
/// Exchange rates for last phase
uint public constant PRICE_RATE_LAST = 750;
/// ----------------------------------------------------------------------------------------------------
/// | | | | |
/// | PUBLIC SALE (PRESALE + OPEN SALE) | DEV TEAM | FOUNDATION | MINER |
/// | 51% | 20% | 19% | 10% |
/// ----------------------------------------------------------------------------------------------------
/// OPEN_SALE_STAKE + PRESALE_STAKE = 51; 51% sale for public
uint public constant OPEN_SALE_STAKE = 510; // 51% for open sale
// Reserved stakes
uint public constant DEV_TEAM_STAKE = 200; // 20%
uint public constant FOUNDATION_STAKE = 190; // 19%
uint public constant MINERS_STAKE = 100; // 10%
uint public constant DIVISOR_STAKE = 1000;
uint public constant PRESALE_RESERVERED_AMOUNT = 41506655 ether; //presale prize amount(40000*880)
/// Holder address for presale and reserved tokens
/// TODO: change addressed before deployed to main net
// Addresses of Patrons
address public constant DEV_TEAM_HOLDER = 0x0001cdC69b1eb8bCCE29311C01092Bdcc92f8f8F;
address public constant FOUNDATION_HOLDER = 0x00dB4023b32008C45E62Add57De256a9399752D4;
address public constant MINERS_HOLDER = 0x00f870D11eA43AA1c4C715c61dC045E32d232787;
address public constant PRESALE_HOLDER = 0x00577c25A81fA2401C5246F4a7D5ebaFfA4b00Aa;
uint public MAX_OPEN_SOLD = WAN_TOTAL_SUPPLY * OPEN_SALE_STAKE / DIVISOR_STAKE - PRESALE_RESERVERED_AMOUNT;
/// Fields that are only changed in constructor
/// All deposited ETH will be instantly forwarded to this address.
address public wanport;
/// Early Adopters reserved start time
uint public earlyReserveBeginTime;
/// Contribution start time
uint public startTime;
/// Contribution end time
uint public endTime;
/// Fields that can be changed by functions
/// Accumulator for open sold tokens
uint public openSoldTokens;
/// Due to an emergency, set this to true to halt the contribution
bool public halted;
/// ERC20 compilant wanchain token contact instance
WanToken public wanToken;
/// Quota for early adopters sale, Quota
mapping (address => uint256) public earlyUserQuotas;
/// tags show address can join in open sale
mapping (address => uint256) public fullWhiteList;
uint256 public normalBuyLimit = 65 ether;
/*
* EVENTS
*/
event NewSale(address indexed destAddress, uint ethCost, uint gotTokens);
//event PartnerAddressQuota(address indexed partnerAddress, uint quota);
/*
* MODIFIERS
*/
modifier onlyWallet {
require(msg.sender == wanport);
_;
}
modifier notHalted() {
require(!halted);
_;
}
modifier initialized() {
require(address(wanport) != 0x0);
_;
}
modifier notEarlierThan(uint x) {
require(now >= x);
_;
}
modifier earlierThan(uint x) {
require(now < x);
_;
}
modifier ceilingNotReached() {
require(openSoldTokens < MAX_OPEN_SOLD);
_;
}
modifier isSaleEnded() {
require(now > endTime || openSoldTokens >= MAX_OPEN_SOLD);
_;
}
/**
* CONSTRUCTOR
*
* @dev Initialize the Wanchain contribution contract
* @param _wanport The escrow account address, all ethers will be sent to this address.
* @param _bootTime ICO boot time
*/
function WanchainContribution(address _wanport, uint _bootTime){
require(_wanport != 0x0);
halted = false;
wanport = _wanport;
earlyReserveBeginTime = _bootTime;
startTime = earlyReserveBeginTime + EARLY_CONTRIBUTION_DURATION;
endTime = startTime + MAX_CONTRIBUTION_DURATION;
openSoldTokens = 0;
/// Create wanchain token contract instance
wanToken = new WanToken(this,startTime, endTime);
/// Reserve tokens according wanchain ICO rules
uint stakeMultiplier = WAN_TOTAL_SUPPLY / DIVISOR_STAKE;
wanToken.mintToken(DEV_TEAM_HOLDER, DEV_TEAM_STAKE * stakeMultiplier);
wanToken.mintToken(FOUNDATION_HOLDER, FOUNDATION_STAKE * stakeMultiplier);
wanToken.mintToken(MINERS_HOLDER, MINERS_STAKE * stakeMultiplier);
wanToken.mintToken(PRESALE_HOLDER, PRESALE_RESERVERED_AMOUNT);
}
/**
* Fallback function
*
* @dev If anybody sends Ether directly to this contract, consider he is getting wan token
*/
function () public payable {
buyWanCoin(msg.sender);
}
/*
* PUBLIC FUNCTIONS
*/
/// @dev Exchange msg.value ether to WAN for account recepient
/// @param receipient WAN tokens receiver
function buyWanCoin(address receipient)
public
payable
notHalted
initialized
ceilingNotReached
notEarlierThan(earlyReserveBeginTime)
earlierThan(endTime)
returns (bool)
{
require(receipient != 0x0);
require(msg.value >= 0.1 ether);
// Do not allow contracts to game the system
require(!isContract(msg.sender));
if( now < startTime && now >= earlyReserveBeginTime)
buyEarlyAdopters(receipient);
else {
require( tx.gasprice <= 50000000000 wei );
require(msg.value <= normalBuyLimit);
buyNormal(receipient);
}
return true;
}
function setNormalBuyLimit(uint256 limit)
public
initialized
onlyOwner
earlierThan(endTime)
{
normalBuyLimit = limit;
}
/// @dev batch set quota for early user quota
function setEarlyWhitelistQuotas(address[] users, uint earlyCap, uint openTag)
public
onlyOwner
earlierThan(earlyReserveBeginTime)
{
for( uint i = 0; i < users.length; i++) {
earlyUserQuotas[users[i]] = earlyCap;
fullWhiteList[users[i]] = openTag;
}
}
/// @dev batch set quota for early user quota
function setLaterWhiteList(address[] users, uint openTag)
public
onlyOwner
earlierThan(endTime)
{
require(saleNotEnd());
for( uint i = 0; i < users.length; i++) {
fullWhiteList[users[i]] = openTag;
}
}
/// @dev Emergency situation that requires contribution period to stop.
/// Contributing not possible anymore.
function halt() public onlyWallet{
halted = true;
}
/// @dev Emergency situation resolved.
/// Contributing becomes possible again withing the outlined restrictions.
function unHalt() public onlyWallet{
halted = false;
}
/// @dev Emergency situation
function changeWalletAddress(address newAddress) onlyWallet {
wanport = newAddress;
}
/// @return true if sale not ended, false otherwise.
function saleNotEnd() constant returns (bool) {
return now < endTime && openSoldTokens < MAX_OPEN_SOLD;
}
/// CONSTANT METHODS
/// @dev Get current exchange rate
function priceRate() public constant returns (uint) {
// Three price tiers
if (earlyReserveBeginTime <= now && now < startTime + 1 weeks)
return PRICE_RATE_FIRST;
if (startTime + 1 weeks <= now && now < startTime + 2 weeks)
return PRICE_RATE_SECOND;
if (startTime + 2 weeks <= now && now < endTime)
return PRICE_RATE_LAST;
// Should not be called before or after contribution period
assert(false);
}
function claimTokens(address receipent)
public
isSaleEnded
{
wanToken.claimTokens(receipent);
}
/*
* INTERNAL FUNCTIONS
*/
/// @dev Buy wanchain tokens for early adopters
function buyEarlyAdopters(address receipient) internal {
uint quotaAvailable = earlyUserQuotas[receipient];
require(quotaAvailable > 0);
uint toFund = quotaAvailable.min256(msg.value);
uint tokenAvailable4Adopter = toFund.mul(PRICE_RATE_FIRST);
earlyUserQuotas[receipient] = earlyUserQuotas[receipient].sub(toFund);
buyCommon(receipient, toFund, tokenAvailable4Adopter);
}
/// @dev Buy wanchain token normally
function buyNormal(address receipient) internal {
uint inWhiteListTag = fullWhiteList[receipient];
require(inWhiteListTag > 0);
// protect partner quota in stage one
uint tokenAvailable = MAX_OPEN_SOLD.sub(openSoldTokens);
require(tokenAvailable > 0);
uint toFund;
uint toCollect;
(toFund, toCollect) = costAndBuyTokens(tokenAvailable);
buyCommon(receipient, toFund, toCollect);
}
/// @dev Utility function for bug wanchain token
function buyCommon(address receipient, uint toFund, uint wanTokenCollect) internal {
require(msg.value >= toFund); // double check
if(toFund > 0) {
require(wanToken.mintToken(receipient, wanTokenCollect));
wanport.transfer(toFund);
openSoldTokens = openSoldTokens.add(wanTokenCollect);
NewSale(receipient, toFund, wanTokenCollect);
}
uint toReturn = msg.value.sub(toFund);
if(toReturn > 0) {
msg.sender.transfer(toReturn);
}
}
/// @dev Utility function for calculate available tokens and cost ethers
function costAndBuyTokens(uint availableToken) constant internal returns (uint costValue, uint getTokens){
// all conditions has checked in the caller functions
uint exchangeRate = priceRate();
getTokens = exchangeRate * msg.value;
if(availableToken >= getTokens){
costValue = msg.value;
} else {
costValue = availableToken / exchangeRate;
getTokens = availableToken;
}
}
/// @dev Internal function to determine if an address is a contract
/// @param _addr The address being queried
/// @return True if `_addr` is a contract
function isContract(address _addr) constant internal returns(bool) {
uint size;
if (_addr == 0) return false;
assembly {
size := extcodesize(_addr)
}
return size > 0;
}
} | /// @title Wanchain Contribution Contract
/// ICO Rules according: https://www.wanchain.org/crowdsale
/// For more information about this token sale, please visit https://wanchain.org
/// @author Zane Liang - <[email protected]> | NatSpecSingleLine | WanchainContribution | function WanchainContribution(address _wanport, uint _bootTime){
require(_wanport != 0x0);
halted = false;
wanport = _wanport;
earlyReserveBeginTime = _bootTime;
startTime = earlyReserveBeginTime + EARLY_CONTRIBUTION_DURATION;
endTime = startTime + MAX_CONTRIBUTION_DURATION;
openSoldTokens = 0;
/// Create wanchain token contract instance
wanToken = new WanToken(this,startTime, endTime);
/// Reserve tokens according wanchain ICO rules
uint stakeMultiplier = WAN_TOTAL_SUPPLY / DIVISOR_STAKE;
wanToken.mintToken(DEV_TEAM_HOLDER, DEV_TEAM_STAKE * stakeMultiplier);
wanToken.mintToken(FOUNDATION_HOLDER, FOUNDATION_STAKE * stakeMultiplier);
wanToken.mintToken(MINERS_HOLDER, MINERS_STAKE * stakeMultiplier);
wanToken.mintToken(PRESALE_HOLDER, PRESALE_RESERVERED_AMOUNT);
}
| /**
* CONSTRUCTOR
*
* @dev Initialize the Wanchain contribution contract
* @param _wanport The escrow account address, all ethers will be sent to this address.
* @param _bootTime ICO boot time
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://cf354415565dbcba55ca7d803241ed623e9875b86e7d49619e734c70d0b4d0bf | {
"func_code_index": [
4351,
5282
]
} | 5,029 |
|
WanchainContribution | WanchainContribution.sol | 0xaac3090257be280087d8bdc530265203d105b120 | Solidity | WanchainContribution | contract WanchainContribution is Owned {
using SafeMath for uint;
/// Constant fields
/// Wanchain total tokens supply
uint public constant WAN_TOTAL_SUPPLY = 210000000 ether;
uint public constant EARLY_CONTRIBUTION_DURATION = 24 hours;
uint public constant MAX_CONTRIBUTION_DURATION = 3 weeks;
/// Exchange rates for first phase
uint public constant PRICE_RATE_FIRST = 880;
/// Exchange rates for second phase
uint public constant PRICE_RATE_SECOND = 790;
/// Exchange rates for last phase
uint public constant PRICE_RATE_LAST = 750;
/// ----------------------------------------------------------------------------------------------------
/// | | | | |
/// | PUBLIC SALE (PRESALE + OPEN SALE) | DEV TEAM | FOUNDATION | MINER |
/// | 51% | 20% | 19% | 10% |
/// ----------------------------------------------------------------------------------------------------
/// OPEN_SALE_STAKE + PRESALE_STAKE = 51; 51% sale for public
uint public constant OPEN_SALE_STAKE = 510; // 51% for open sale
// Reserved stakes
uint public constant DEV_TEAM_STAKE = 200; // 20%
uint public constant FOUNDATION_STAKE = 190; // 19%
uint public constant MINERS_STAKE = 100; // 10%
uint public constant DIVISOR_STAKE = 1000;
uint public constant PRESALE_RESERVERED_AMOUNT = 41506655 ether; //presale prize amount(40000*880)
/// Holder address for presale and reserved tokens
/// TODO: change addressed before deployed to main net
// Addresses of Patrons
address public constant DEV_TEAM_HOLDER = 0x0001cdC69b1eb8bCCE29311C01092Bdcc92f8f8F;
address public constant FOUNDATION_HOLDER = 0x00dB4023b32008C45E62Add57De256a9399752D4;
address public constant MINERS_HOLDER = 0x00f870D11eA43AA1c4C715c61dC045E32d232787;
address public constant PRESALE_HOLDER = 0x00577c25A81fA2401C5246F4a7D5ebaFfA4b00Aa;
uint public MAX_OPEN_SOLD = WAN_TOTAL_SUPPLY * OPEN_SALE_STAKE / DIVISOR_STAKE - PRESALE_RESERVERED_AMOUNT;
/// Fields that are only changed in constructor
/// All deposited ETH will be instantly forwarded to this address.
address public wanport;
/// Early Adopters reserved start time
uint public earlyReserveBeginTime;
/// Contribution start time
uint public startTime;
/// Contribution end time
uint public endTime;
/// Fields that can be changed by functions
/// Accumulator for open sold tokens
uint public openSoldTokens;
/// Due to an emergency, set this to true to halt the contribution
bool public halted;
/// ERC20 compilant wanchain token contact instance
WanToken public wanToken;
/// Quota for early adopters sale, Quota
mapping (address => uint256) public earlyUserQuotas;
/// tags show address can join in open sale
mapping (address => uint256) public fullWhiteList;
uint256 public normalBuyLimit = 65 ether;
/*
* EVENTS
*/
event NewSale(address indexed destAddress, uint ethCost, uint gotTokens);
//event PartnerAddressQuota(address indexed partnerAddress, uint quota);
/*
* MODIFIERS
*/
modifier onlyWallet {
require(msg.sender == wanport);
_;
}
modifier notHalted() {
require(!halted);
_;
}
modifier initialized() {
require(address(wanport) != 0x0);
_;
}
modifier notEarlierThan(uint x) {
require(now >= x);
_;
}
modifier earlierThan(uint x) {
require(now < x);
_;
}
modifier ceilingNotReached() {
require(openSoldTokens < MAX_OPEN_SOLD);
_;
}
modifier isSaleEnded() {
require(now > endTime || openSoldTokens >= MAX_OPEN_SOLD);
_;
}
/**
* CONSTRUCTOR
*
* @dev Initialize the Wanchain contribution contract
* @param _wanport The escrow account address, all ethers will be sent to this address.
* @param _bootTime ICO boot time
*/
function WanchainContribution(address _wanport, uint _bootTime){
require(_wanport != 0x0);
halted = false;
wanport = _wanport;
earlyReserveBeginTime = _bootTime;
startTime = earlyReserveBeginTime + EARLY_CONTRIBUTION_DURATION;
endTime = startTime + MAX_CONTRIBUTION_DURATION;
openSoldTokens = 0;
/// Create wanchain token contract instance
wanToken = new WanToken(this,startTime, endTime);
/// Reserve tokens according wanchain ICO rules
uint stakeMultiplier = WAN_TOTAL_SUPPLY / DIVISOR_STAKE;
wanToken.mintToken(DEV_TEAM_HOLDER, DEV_TEAM_STAKE * stakeMultiplier);
wanToken.mintToken(FOUNDATION_HOLDER, FOUNDATION_STAKE * stakeMultiplier);
wanToken.mintToken(MINERS_HOLDER, MINERS_STAKE * stakeMultiplier);
wanToken.mintToken(PRESALE_HOLDER, PRESALE_RESERVERED_AMOUNT);
}
/**
* Fallback function
*
* @dev If anybody sends Ether directly to this contract, consider he is getting wan token
*/
function () public payable {
buyWanCoin(msg.sender);
}
/*
* PUBLIC FUNCTIONS
*/
/// @dev Exchange msg.value ether to WAN for account recepient
/// @param receipient WAN tokens receiver
function buyWanCoin(address receipient)
public
payable
notHalted
initialized
ceilingNotReached
notEarlierThan(earlyReserveBeginTime)
earlierThan(endTime)
returns (bool)
{
require(receipient != 0x0);
require(msg.value >= 0.1 ether);
// Do not allow contracts to game the system
require(!isContract(msg.sender));
if( now < startTime && now >= earlyReserveBeginTime)
buyEarlyAdopters(receipient);
else {
require( tx.gasprice <= 50000000000 wei );
require(msg.value <= normalBuyLimit);
buyNormal(receipient);
}
return true;
}
function setNormalBuyLimit(uint256 limit)
public
initialized
onlyOwner
earlierThan(endTime)
{
normalBuyLimit = limit;
}
/// @dev batch set quota for early user quota
function setEarlyWhitelistQuotas(address[] users, uint earlyCap, uint openTag)
public
onlyOwner
earlierThan(earlyReserveBeginTime)
{
for( uint i = 0; i < users.length; i++) {
earlyUserQuotas[users[i]] = earlyCap;
fullWhiteList[users[i]] = openTag;
}
}
/// @dev batch set quota for early user quota
function setLaterWhiteList(address[] users, uint openTag)
public
onlyOwner
earlierThan(endTime)
{
require(saleNotEnd());
for( uint i = 0; i < users.length; i++) {
fullWhiteList[users[i]] = openTag;
}
}
/// @dev Emergency situation that requires contribution period to stop.
/// Contributing not possible anymore.
function halt() public onlyWallet{
halted = true;
}
/// @dev Emergency situation resolved.
/// Contributing becomes possible again withing the outlined restrictions.
function unHalt() public onlyWallet{
halted = false;
}
/// @dev Emergency situation
function changeWalletAddress(address newAddress) onlyWallet {
wanport = newAddress;
}
/// @return true if sale not ended, false otherwise.
function saleNotEnd() constant returns (bool) {
return now < endTime && openSoldTokens < MAX_OPEN_SOLD;
}
/// CONSTANT METHODS
/// @dev Get current exchange rate
function priceRate() public constant returns (uint) {
// Three price tiers
if (earlyReserveBeginTime <= now && now < startTime + 1 weeks)
return PRICE_RATE_FIRST;
if (startTime + 1 weeks <= now && now < startTime + 2 weeks)
return PRICE_RATE_SECOND;
if (startTime + 2 weeks <= now && now < endTime)
return PRICE_RATE_LAST;
// Should not be called before or after contribution period
assert(false);
}
function claimTokens(address receipent)
public
isSaleEnded
{
wanToken.claimTokens(receipent);
}
/*
* INTERNAL FUNCTIONS
*/
/// @dev Buy wanchain tokens for early adopters
function buyEarlyAdopters(address receipient) internal {
uint quotaAvailable = earlyUserQuotas[receipient];
require(quotaAvailable > 0);
uint toFund = quotaAvailable.min256(msg.value);
uint tokenAvailable4Adopter = toFund.mul(PRICE_RATE_FIRST);
earlyUserQuotas[receipient] = earlyUserQuotas[receipient].sub(toFund);
buyCommon(receipient, toFund, tokenAvailable4Adopter);
}
/// @dev Buy wanchain token normally
function buyNormal(address receipient) internal {
uint inWhiteListTag = fullWhiteList[receipient];
require(inWhiteListTag > 0);
// protect partner quota in stage one
uint tokenAvailable = MAX_OPEN_SOLD.sub(openSoldTokens);
require(tokenAvailable > 0);
uint toFund;
uint toCollect;
(toFund, toCollect) = costAndBuyTokens(tokenAvailable);
buyCommon(receipient, toFund, toCollect);
}
/// @dev Utility function for bug wanchain token
function buyCommon(address receipient, uint toFund, uint wanTokenCollect) internal {
require(msg.value >= toFund); // double check
if(toFund > 0) {
require(wanToken.mintToken(receipient, wanTokenCollect));
wanport.transfer(toFund);
openSoldTokens = openSoldTokens.add(wanTokenCollect);
NewSale(receipient, toFund, wanTokenCollect);
}
uint toReturn = msg.value.sub(toFund);
if(toReturn > 0) {
msg.sender.transfer(toReturn);
}
}
/// @dev Utility function for calculate available tokens and cost ethers
function costAndBuyTokens(uint availableToken) constant internal returns (uint costValue, uint getTokens){
// all conditions has checked in the caller functions
uint exchangeRate = priceRate();
getTokens = exchangeRate * msg.value;
if(availableToken >= getTokens){
costValue = msg.value;
} else {
costValue = availableToken / exchangeRate;
getTokens = availableToken;
}
}
/// @dev Internal function to determine if an address is a contract
/// @param _addr The address being queried
/// @return True if `_addr` is a contract
function isContract(address _addr) constant internal returns(bool) {
uint size;
if (_addr == 0) return false;
assembly {
size := extcodesize(_addr)
}
return size > 0;
}
} | /// @title Wanchain Contribution Contract
/// ICO Rules according: https://www.wanchain.org/crowdsale
/// For more information about this token sale, please visit https://wanchain.org
/// @author Zane Liang - <[email protected]> | NatSpecSingleLine | function () public payable {
buyWanCoin(msg.sender);
}
| /**
* Fallback function
*
* @dev If anybody sends Ether directly to this contract, consider he is getting wan token
*/ | NatSpecMultiLine | v0.4.13+commit.fb4cb1a | bzzr://cf354415565dbcba55ca7d803241ed623e9875b86e7d49619e734c70d0b4d0bf | {
"func_code_index": [
5436,
5507
]
} | 5,030 |
||
WanchainContribution | WanchainContribution.sol | 0xaac3090257be280087d8bdc530265203d105b120 | Solidity | WanchainContribution | contract WanchainContribution is Owned {
using SafeMath for uint;
/// Constant fields
/// Wanchain total tokens supply
uint public constant WAN_TOTAL_SUPPLY = 210000000 ether;
uint public constant EARLY_CONTRIBUTION_DURATION = 24 hours;
uint public constant MAX_CONTRIBUTION_DURATION = 3 weeks;
/// Exchange rates for first phase
uint public constant PRICE_RATE_FIRST = 880;
/// Exchange rates for second phase
uint public constant PRICE_RATE_SECOND = 790;
/// Exchange rates for last phase
uint public constant PRICE_RATE_LAST = 750;
/// ----------------------------------------------------------------------------------------------------
/// | | | | |
/// | PUBLIC SALE (PRESALE + OPEN SALE) | DEV TEAM | FOUNDATION | MINER |
/// | 51% | 20% | 19% | 10% |
/// ----------------------------------------------------------------------------------------------------
/// OPEN_SALE_STAKE + PRESALE_STAKE = 51; 51% sale for public
uint public constant OPEN_SALE_STAKE = 510; // 51% for open sale
// Reserved stakes
uint public constant DEV_TEAM_STAKE = 200; // 20%
uint public constant FOUNDATION_STAKE = 190; // 19%
uint public constant MINERS_STAKE = 100; // 10%
uint public constant DIVISOR_STAKE = 1000;
uint public constant PRESALE_RESERVERED_AMOUNT = 41506655 ether; //presale prize amount(40000*880)
/// Holder address for presale and reserved tokens
/// TODO: change addressed before deployed to main net
// Addresses of Patrons
address public constant DEV_TEAM_HOLDER = 0x0001cdC69b1eb8bCCE29311C01092Bdcc92f8f8F;
address public constant FOUNDATION_HOLDER = 0x00dB4023b32008C45E62Add57De256a9399752D4;
address public constant MINERS_HOLDER = 0x00f870D11eA43AA1c4C715c61dC045E32d232787;
address public constant PRESALE_HOLDER = 0x00577c25A81fA2401C5246F4a7D5ebaFfA4b00Aa;
uint public MAX_OPEN_SOLD = WAN_TOTAL_SUPPLY * OPEN_SALE_STAKE / DIVISOR_STAKE - PRESALE_RESERVERED_AMOUNT;
/// Fields that are only changed in constructor
/// All deposited ETH will be instantly forwarded to this address.
address public wanport;
/// Early Adopters reserved start time
uint public earlyReserveBeginTime;
/// Contribution start time
uint public startTime;
/// Contribution end time
uint public endTime;
/// Fields that can be changed by functions
/// Accumulator for open sold tokens
uint public openSoldTokens;
/// Due to an emergency, set this to true to halt the contribution
bool public halted;
/// ERC20 compilant wanchain token contact instance
WanToken public wanToken;
/// Quota for early adopters sale, Quota
mapping (address => uint256) public earlyUserQuotas;
/// tags show address can join in open sale
mapping (address => uint256) public fullWhiteList;
uint256 public normalBuyLimit = 65 ether;
/*
* EVENTS
*/
event NewSale(address indexed destAddress, uint ethCost, uint gotTokens);
//event PartnerAddressQuota(address indexed partnerAddress, uint quota);
/*
* MODIFIERS
*/
modifier onlyWallet {
require(msg.sender == wanport);
_;
}
modifier notHalted() {
require(!halted);
_;
}
modifier initialized() {
require(address(wanport) != 0x0);
_;
}
modifier notEarlierThan(uint x) {
require(now >= x);
_;
}
modifier earlierThan(uint x) {
require(now < x);
_;
}
modifier ceilingNotReached() {
require(openSoldTokens < MAX_OPEN_SOLD);
_;
}
modifier isSaleEnded() {
require(now > endTime || openSoldTokens >= MAX_OPEN_SOLD);
_;
}
/**
* CONSTRUCTOR
*
* @dev Initialize the Wanchain contribution contract
* @param _wanport The escrow account address, all ethers will be sent to this address.
* @param _bootTime ICO boot time
*/
function WanchainContribution(address _wanport, uint _bootTime){
require(_wanport != 0x0);
halted = false;
wanport = _wanport;
earlyReserveBeginTime = _bootTime;
startTime = earlyReserveBeginTime + EARLY_CONTRIBUTION_DURATION;
endTime = startTime + MAX_CONTRIBUTION_DURATION;
openSoldTokens = 0;
/// Create wanchain token contract instance
wanToken = new WanToken(this,startTime, endTime);
/// Reserve tokens according wanchain ICO rules
uint stakeMultiplier = WAN_TOTAL_SUPPLY / DIVISOR_STAKE;
wanToken.mintToken(DEV_TEAM_HOLDER, DEV_TEAM_STAKE * stakeMultiplier);
wanToken.mintToken(FOUNDATION_HOLDER, FOUNDATION_STAKE * stakeMultiplier);
wanToken.mintToken(MINERS_HOLDER, MINERS_STAKE * stakeMultiplier);
wanToken.mintToken(PRESALE_HOLDER, PRESALE_RESERVERED_AMOUNT);
}
/**
* Fallback function
*
* @dev If anybody sends Ether directly to this contract, consider he is getting wan token
*/
function () public payable {
buyWanCoin(msg.sender);
}
/*
* PUBLIC FUNCTIONS
*/
/// @dev Exchange msg.value ether to WAN for account recepient
/// @param receipient WAN tokens receiver
function buyWanCoin(address receipient)
public
payable
notHalted
initialized
ceilingNotReached
notEarlierThan(earlyReserveBeginTime)
earlierThan(endTime)
returns (bool)
{
require(receipient != 0x0);
require(msg.value >= 0.1 ether);
// Do not allow contracts to game the system
require(!isContract(msg.sender));
if( now < startTime && now >= earlyReserveBeginTime)
buyEarlyAdopters(receipient);
else {
require( tx.gasprice <= 50000000000 wei );
require(msg.value <= normalBuyLimit);
buyNormal(receipient);
}
return true;
}
function setNormalBuyLimit(uint256 limit)
public
initialized
onlyOwner
earlierThan(endTime)
{
normalBuyLimit = limit;
}
/// @dev batch set quota for early user quota
function setEarlyWhitelistQuotas(address[] users, uint earlyCap, uint openTag)
public
onlyOwner
earlierThan(earlyReserveBeginTime)
{
for( uint i = 0; i < users.length; i++) {
earlyUserQuotas[users[i]] = earlyCap;
fullWhiteList[users[i]] = openTag;
}
}
/// @dev batch set quota for early user quota
function setLaterWhiteList(address[] users, uint openTag)
public
onlyOwner
earlierThan(endTime)
{
require(saleNotEnd());
for( uint i = 0; i < users.length; i++) {
fullWhiteList[users[i]] = openTag;
}
}
/// @dev Emergency situation that requires contribution period to stop.
/// Contributing not possible anymore.
function halt() public onlyWallet{
halted = true;
}
/// @dev Emergency situation resolved.
/// Contributing becomes possible again withing the outlined restrictions.
function unHalt() public onlyWallet{
halted = false;
}
/// @dev Emergency situation
function changeWalletAddress(address newAddress) onlyWallet {
wanport = newAddress;
}
/// @return true if sale not ended, false otherwise.
function saleNotEnd() constant returns (bool) {
return now < endTime && openSoldTokens < MAX_OPEN_SOLD;
}
/// CONSTANT METHODS
/// @dev Get current exchange rate
function priceRate() public constant returns (uint) {
// Three price tiers
if (earlyReserveBeginTime <= now && now < startTime + 1 weeks)
return PRICE_RATE_FIRST;
if (startTime + 1 weeks <= now && now < startTime + 2 weeks)
return PRICE_RATE_SECOND;
if (startTime + 2 weeks <= now && now < endTime)
return PRICE_RATE_LAST;
// Should not be called before or after contribution period
assert(false);
}
function claimTokens(address receipent)
public
isSaleEnded
{
wanToken.claimTokens(receipent);
}
/*
* INTERNAL FUNCTIONS
*/
/// @dev Buy wanchain tokens for early adopters
function buyEarlyAdopters(address receipient) internal {
uint quotaAvailable = earlyUserQuotas[receipient];
require(quotaAvailable > 0);
uint toFund = quotaAvailable.min256(msg.value);
uint tokenAvailable4Adopter = toFund.mul(PRICE_RATE_FIRST);
earlyUserQuotas[receipient] = earlyUserQuotas[receipient].sub(toFund);
buyCommon(receipient, toFund, tokenAvailable4Adopter);
}
/// @dev Buy wanchain token normally
function buyNormal(address receipient) internal {
uint inWhiteListTag = fullWhiteList[receipient];
require(inWhiteListTag > 0);
// protect partner quota in stage one
uint tokenAvailable = MAX_OPEN_SOLD.sub(openSoldTokens);
require(tokenAvailable > 0);
uint toFund;
uint toCollect;
(toFund, toCollect) = costAndBuyTokens(tokenAvailable);
buyCommon(receipient, toFund, toCollect);
}
/// @dev Utility function for bug wanchain token
function buyCommon(address receipient, uint toFund, uint wanTokenCollect) internal {
require(msg.value >= toFund); // double check
if(toFund > 0) {
require(wanToken.mintToken(receipient, wanTokenCollect));
wanport.transfer(toFund);
openSoldTokens = openSoldTokens.add(wanTokenCollect);
NewSale(receipient, toFund, wanTokenCollect);
}
uint toReturn = msg.value.sub(toFund);
if(toReturn > 0) {
msg.sender.transfer(toReturn);
}
}
/// @dev Utility function for calculate available tokens and cost ethers
function costAndBuyTokens(uint availableToken) constant internal returns (uint costValue, uint getTokens){
// all conditions has checked in the caller functions
uint exchangeRate = priceRate();
getTokens = exchangeRate * msg.value;
if(availableToken >= getTokens){
costValue = msg.value;
} else {
costValue = availableToken / exchangeRate;
getTokens = availableToken;
}
}
/// @dev Internal function to determine if an address is a contract
/// @param _addr The address being queried
/// @return True if `_addr` is a contract
function isContract(address _addr) constant internal returns(bool) {
uint size;
if (_addr == 0) return false;
assembly {
size := extcodesize(_addr)
}
return size > 0;
}
} | /// @title Wanchain Contribution Contract
/// ICO Rules according: https://www.wanchain.org/crowdsale
/// For more information about this token sale, please visit https://wanchain.org
/// @author Zane Liang - <[email protected]> | NatSpecSingleLine | buyWanCoin | function buyWanCoin(address receipient)
public
payable
notHalted
initialized
ceilingNotReached
notEarlierThan(earlyReserveBeginTime)
earlierThan(endTime)
returns (bool)
{
require(receipient != 0x0);
require(msg.value >= 0.1 ether);
// Do not allow contracts to game the system
require(!isContract(msg.sender));
if( now < startTime && now >= earlyReserveBeginTime)
buyEarlyAdopters(receipient);
else {
require( tx.gasprice <= 50000000000 wei );
require(msg.value <= normalBuyLimit);
buyNormal(receipient);
}
return true;
}
| /// @dev Exchange msg.value ether to WAN for account recepient
/// @param receipient WAN tokens receiver | NatSpecSingleLine | v0.4.13+commit.fb4cb1a | bzzr://cf354415565dbcba55ca7d803241ed623e9875b86e7d49619e734c70d0b4d0bf | {
"func_code_index": [
5669,
6422
]
} | 5,031 |
|
WanchainContribution | WanchainContribution.sol | 0xaac3090257be280087d8bdc530265203d105b120 | Solidity | WanchainContribution | contract WanchainContribution is Owned {
using SafeMath for uint;
/// Constant fields
/// Wanchain total tokens supply
uint public constant WAN_TOTAL_SUPPLY = 210000000 ether;
uint public constant EARLY_CONTRIBUTION_DURATION = 24 hours;
uint public constant MAX_CONTRIBUTION_DURATION = 3 weeks;
/// Exchange rates for first phase
uint public constant PRICE_RATE_FIRST = 880;
/// Exchange rates for second phase
uint public constant PRICE_RATE_SECOND = 790;
/// Exchange rates for last phase
uint public constant PRICE_RATE_LAST = 750;
/// ----------------------------------------------------------------------------------------------------
/// | | | | |
/// | PUBLIC SALE (PRESALE + OPEN SALE) | DEV TEAM | FOUNDATION | MINER |
/// | 51% | 20% | 19% | 10% |
/// ----------------------------------------------------------------------------------------------------
/// OPEN_SALE_STAKE + PRESALE_STAKE = 51; 51% sale for public
uint public constant OPEN_SALE_STAKE = 510; // 51% for open sale
// Reserved stakes
uint public constant DEV_TEAM_STAKE = 200; // 20%
uint public constant FOUNDATION_STAKE = 190; // 19%
uint public constant MINERS_STAKE = 100; // 10%
uint public constant DIVISOR_STAKE = 1000;
uint public constant PRESALE_RESERVERED_AMOUNT = 41506655 ether; //presale prize amount(40000*880)
/// Holder address for presale and reserved tokens
/// TODO: change addressed before deployed to main net
// Addresses of Patrons
address public constant DEV_TEAM_HOLDER = 0x0001cdC69b1eb8bCCE29311C01092Bdcc92f8f8F;
address public constant FOUNDATION_HOLDER = 0x00dB4023b32008C45E62Add57De256a9399752D4;
address public constant MINERS_HOLDER = 0x00f870D11eA43AA1c4C715c61dC045E32d232787;
address public constant PRESALE_HOLDER = 0x00577c25A81fA2401C5246F4a7D5ebaFfA4b00Aa;
uint public MAX_OPEN_SOLD = WAN_TOTAL_SUPPLY * OPEN_SALE_STAKE / DIVISOR_STAKE - PRESALE_RESERVERED_AMOUNT;
/// Fields that are only changed in constructor
/// All deposited ETH will be instantly forwarded to this address.
address public wanport;
/// Early Adopters reserved start time
uint public earlyReserveBeginTime;
/// Contribution start time
uint public startTime;
/// Contribution end time
uint public endTime;
/// Fields that can be changed by functions
/// Accumulator for open sold tokens
uint public openSoldTokens;
/// Due to an emergency, set this to true to halt the contribution
bool public halted;
/// ERC20 compilant wanchain token contact instance
WanToken public wanToken;
/// Quota for early adopters sale, Quota
mapping (address => uint256) public earlyUserQuotas;
/// tags show address can join in open sale
mapping (address => uint256) public fullWhiteList;
uint256 public normalBuyLimit = 65 ether;
/*
* EVENTS
*/
event NewSale(address indexed destAddress, uint ethCost, uint gotTokens);
//event PartnerAddressQuota(address indexed partnerAddress, uint quota);
/*
* MODIFIERS
*/
modifier onlyWallet {
require(msg.sender == wanport);
_;
}
modifier notHalted() {
require(!halted);
_;
}
modifier initialized() {
require(address(wanport) != 0x0);
_;
}
modifier notEarlierThan(uint x) {
require(now >= x);
_;
}
modifier earlierThan(uint x) {
require(now < x);
_;
}
modifier ceilingNotReached() {
require(openSoldTokens < MAX_OPEN_SOLD);
_;
}
modifier isSaleEnded() {
require(now > endTime || openSoldTokens >= MAX_OPEN_SOLD);
_;
}
/**
* CONSTRUCTOR
*
* @dev Initialize the Wanchain contribution contract
* @param _wanport The escrow account address, all ethers will be sent to this address.
* @param _bootTime ICO boot time
*/
function WanchainContribution(address _wanport, uint _bootTime){
require(_wanport != 0x0);
halted = false;
wanport = _wanport;
earlyReserveBeginTime = _bootTime;
startTime = earlyReserveBeginTime + EARLY_CONTRIBUTION_DURATION;
endTime = startTime + MAX_CONTRIBUTION_DURATION;
openSoldTokens = 0;
/// Create wanchain token contract instance
wanToken = new WanToken(this,startTime, endTime);
/// Reserve tokens according wanchain ICO rules
uint stakeMultiplier = WAN_TOTAL_SUPPLY / DIVISOR_STAKE;
wanToken.mintToken(DEV_TEAM_HOLDER, DEV_TEAM_STAKE * stakeMultiplier);
wanToken.mintToken(FOUNDATION_HOLDER, FOUNDATION_STAKE * stakeMultiplier);
wanToken.mintToken(MINERS_HOLDER, MINERS_STAKE * stakeMultiplier);
wanToken.mintToken(PRESALE_HOLDER, PRESALE_RESERVERED_AMOUNT);
}
/**
* Fallback function
*
* @dev If anybody sends Ether directly to this contract, consider he is getting wan token
*/
function () public payable {
buyWanCoin(msg.sender);
}
/*
* PUBLIC FUNCTIONS
*/
/// @dev Exchange msg.value ether to WAN for account recepient
/// @param receipient WAN tokens receiver
function buyWanCoin(address receipient)
public
payable
notHalted
initialized
ceilingNotReached
notEarlierThan(earlyReserveBeginTime)
earlierThan(endTime)
returns (bool)
{
require(receipient != 0x0);
require(msg.value >= 0.1 ether);
// Do not allow contracts to game the system
require(!isContract(msg.sender));
if( now < startTime && now >= earlyReserveBeginTime)
buyEarlyAdopters(receipient);
else {
require( tx.gasprice <= 50000000000 wei );
require(msg.value <= normalBuyLimit);
buyNormal(receipient);
}
return true;
}
function setNormalBuyLimit(uint256 limit)
public
initialized
onlyOwner
earlierThan(endTime)
{
normalBuyLimit = limit;
}
/// @dev batch set quota for early user quota
function setEarlyWhitelistQuotas(address[] users, uint earlyCap, uint openTag)
public
onlyOwner
earlierThan(earlyReserveBeginTime)
{
for( uint i = 0; i < users.length; i++) {
earlyUserQuotas[users[i]] = earlyCap;
fullWhiteList[users[i]] = openTag;
}
}
/// @dev batch set quota for early user quota
function setLaterWhiteList(address[] users, uint openTag)
public
onlyOwner
earlierThan(endTime)
{
require(saleNotEnd());
for( uint i = 0; i < users.length; i++) {
fullWhiteList[users[i]] = openTag;
}
}
/// @dev Emergency situation that requires contribution period to stop.
/// Contributing not possible anymore.
function halt() public onlyWallet{
halted = true;
}
/// @dev Emergency situation resolved.
/// Contributing becomes possible again withing the outlined restrictions.
function unHalt() public onlyWallet{
halted = false;
}
/// @dev Emergency situation
function changeWalletAddress(address newAddress) onlyWallet {
wanport = newAddress;
}
/// @return true if sale not ended, false otherwise.
function saleNotEnd() constant returns (bool) {
return now < endTime && openSoldTokens < MAX_OPEN_SOLD;
}
/// CONSTANT METHODS
/// @dev Get current exchange rate
function priceRate() public constant returns (uint) {
// Three price tiers
if (earlyReserveBeginTime <= now && now < startTime + 1 weeks)
return PRICE_RATE_FIRST;
if (startTime + 1 weeks <= now && now < startTime + 2 weeks)
return PRICE_RATE_SECOND;
if (startTime + 2 weeks <= now && now < endTime)
return PRICE_RATE_LAST;
// Should not be called before or after contribution period
assert(false);
}
function claimTokens(address receipent)
public
isSaleEnded
{
wanToken.claimTokens(receipent);
}
/*
* INTERNAL FUNCTIONS
*/
/// @dev Buy wanchain tokens for early adopters
function buyEarlyAdopters(address receipient) internal {
uint quotaAvailable = earlyUserQuotas[receipient];
require(quotaAvailable > 0);
uint toFund = quotaAvailable.min256(msg.value);
uint tokenAvailable4Adopter = toFund.mul(PRICE_RATE_FIRST);
earlyUserQuotas[receipient] = earlyUserQuotas[receipient].sub(toFund);
buyCommon(receipient, toFund, tokenAvailable4Adopter);
}
/// @dev Buy wanchain token normally
function buyNormal(address receipient) internal {
uint inWhiteListTag = fullWhiteList[receipient];
require(inWhiteListTag > 0);
// protect partner quota in stage one
uint tokenAvailable = MAX_OPEN_SOLD.sub(openSoldTokens);
require(tokenAvailable > 0);
uint toFund;
uint toCollect;
(toFund, toCollect) = costAndBuyTokens(tokenAvailable);
buyCommon(receipient, toFund, toCollect);
}
/// @dev Utility function for bug wanchain token
function buyCommon(address receipient, uint toFund, uint wanTokenCollect) internal {
require(msg.value >= toFund); // double check
if(toFund > 0) {
require(wanToken.mintToken(receipient, wanTokenCollect));
wanport.transfer(toFund);
openSoldTokens = openSoldTokens.add(wanTokenCollect);
NewSale(receipient, toFund, wanTokenCollect);
}
uint toReturn = msg.value.sub(toFund);
if(toReturn > 0) {
msg.sender.transfer(toReturn);
}
}
/// @dev Utility function for calculate available tokens and cost ethers
function costAndBuyTokens(uint availableToken) constant internal returns (uint costValue, uint getTokens){
// all conditions has checked in the caller functions
uint exchangeRate = priceRate();
getTokens = exchangeRate * msg.value;
if(availableToken >= getTokens){
costValue = msg.value;
} else {
costValue = availableToken / exchangeRate;
getTokens = availableToken;
}
}
/// @dev Internal function to determine if an address is a contract
/// @param _addr The address being queried
/// @return True if `_addr` is a contract
function isContract(address _addr) constant internal returns(bool) {
uint size;
if (_addr == 0) return false;
assembly {
size := extcodesize(_addr)
}
return size > 0;
}
} | /// @title Wanchain Contribution Contract
/// ICO Rules according: https://www.wanchain.org/crowdsale
/// For more information about this token sale, please visit https://wanchain.org
/// @author Zane Liang - <[email protected]> | NatSpecSingleLine | setEarlyWhitelistQuotas | function setEarlyWhitelistQuotas(address[] users, uint earlyCap, uint openTag)
public
onlyOwner
earlierThan(earlyReserveBeginTime)
{
for( uint i = 0; i < users.length; i++) {
earlyUserQuotas[users[i]] = earlyCap;
fullWhiteList[users[i]] = openTag;
}
}
| /// @dev batch set quota for early user quota | NatSpecSingleLine | v0.4.13+commit.fb4cb1a | bzzr://cf354415565dbcba55ca7d803241ed623e9875b86e7d49619e734c70d0b4d0bf | {
"func_code_index": [
6660,
6997
]
} | 5,032 |
|
WanchainContribution | WanchainContribution.sol | 0xaac3090257be280087d8bdc530265203d105b120 | Solidity | WanchainContribution | contract WanchainContribution is Owned {
using SafeMath for uint;
/// Constant fields
/// Wanchain total tokens supply
uint public constant WAN_TOTAL_SUPPLY = 210000000 ether;
uint public constant EARLY_CONTRIBUTION_DURATION = 24 hours;
uint public constant MAX_CONTRIBUTION_DURATION = 3 weeks;
/// Exchange rates for first phase
uint public constant PRICE_RATE_FIRST = 880;
/// Exchange rates for second phase
uint public constant PRICE_RATE_SECOND = 790;
/// Exchange rates for last phase
uint public constant PRICE_RATE_LAST = 750;
/// ----------------------------------------------------------------------------------------------------
/// | | | | |
/// | PUBLIC SALE (PRESALE + OPEN SALE) | DEV TEAM | FOUNDATION | MINER |
/// | 51% | 20% | 19% | 10% |
/// ----------------------------------------------------------------------------------------------------
/// OPEN_SALE_STAKE + PRESALE_STAKE = 51; 51% sale for public
uint public constant OPEN_SALE_STAKE = 510; // 51% for open sale
// Reserved stakes
uint public constant DEV_TEAM_STAKE = 200; // 20%
uint public constant FOUNDATION_STAKE = 190; // 19%
uint public constant MINERS_STAKE = 100; // 10%
uint public constant DIVISOR_STAKE = 1000;
uint public constant PRESALE_RESERVERED_AMOUNT = 41506655 ether; //presale prize amount(40000*880)
/// Holder address for presale and reserved tokens
/// TODO: change addressed before deployed to main net
// Addresses of Patrons
address public constant DEV_TEAM_HOLDER = 0x0001cdC69b1eb8bCCE29311C01092Bdcc92f8f8F;
address public constant FOUNDATION_HOLDER = 0x00dB4023b32008C45E62Add57De256a9399752D4;
address public constant MINERS_HOLDER = 0x00f870D11eA43AA1c4C715c61dC045E32d232787;
address public constant PRESALE_HOLDER = 0x00577c25A81fA2401C5246F4a7D5ebaFfA4b00Aa;
uint public MAX_OPEN_SOLD = WAN_TOTAL_SUPPLY * OPEN_SALE_STAKE / DIVISOR_STAKE - PRESALE_RESERVERED_AMOUNT;
/// Fields that are only changed in constructor
/// All deposited ETH will be instantly forwarded to this address.
address public wanport;
/// Early Adopters reserved start time
uint public earlyReserveBeginTime;
/// Contribution start time
uint public startTime;
/// Contribution end time
uint public endTime;
/// Fields that can be changed by functions
/// Accumulator for open sold tokens
uint public openSoldTokens;
/// Due to an emergency, set this to true to halt the contribution
bool public halted;
/// ERC20 compilant wanchain token contact instance
WanToken public wanToken;
/// Quota for early adopters sale, Quota
mapping (address => uint256) public earlyUserQuotas;
/// tags show address can join in open sale
mapping (address => uint256) public fullWhiteList;
uint256 public normalBuyLimit = 65 ether;
/*
* EVENTS
*/
event NewSale(address indexed destAddress, uint ethCost, uint gotTokens);
//event PartnerAddressQuota(address indexed partnerAddress, uint quota);
/*
* MODIFIERS
*/
modifier onlyWallet {
require(msg.sender == wanport);
_;
}
modifier notHalted() {
require(!halted);
_;
}
modifier initialized() {
require(address(wanport) != 0x0);
_;
}
modifier notEarlierThan(uint x) {
require(now >= x);
_;
}
modifier earlierThan(uint x) {
require(now < x);
_;
}
modifier ceilingNotReached() {
require(openSoldTokens < MAX_OPEN_SOLD);
_;
}
modifier isSaleEnded() {
require(now > endTime || openSoldTokens >= MAX_OPEN_SOLD);
_;
}
/**
* CONSTRUCTOR
*
* @dev Initialize the Wanchain contribution contract
* @param _wanport The escrow account address, all ethers will be sent to this address.
* @param _bootTime ICO boot time
*/
function WanchainContribution(address _wanport, uint _bootTime){
require(_wanport != 0x0);
halted = false;
wanport = _wanport;
earlyReserveBeginTime = _bootTime;
startTime = earlyReserveBeginTime + EARLY_CONTRIBUTION_DURATION;
endTime = startTime + MAX_CONTRIBUTION_DURATION;
openSoldTokens = 0;
/// Create wanchain token contract instance
wanToken = new WanToken(this,startTime, endTime);
/// Reserve tokens according wanchain ICO rules
uint stakeMultiplier = WAN_TOTAL_SUPPLY / DIVISOR_STAKE;
wanToken.mintToken(DEV_TEAM_HOLDER, DEV_TEAM_STAKE * stakeMultiplier);
wanToken.mintToken(FOUNDATION_HOLDER, FOUNDATION_STAKE * stakeMultiplier);
wanToken.mintToken(MINERS_HOLDER, MINERS_STAKE * stakeMultiplier);
wanToken.mintToken(PRESALE_HOLDER, PRESALE_RESERVERED_AMOUNT);
}
/**
* Fallback function
*
* @dev If anybody sends Ether directly to this contract, consider he is getting wan token
*/
function () public payable {
buyWanCoin(msg.sender);
}
/*
* PUBLIC FUNCTIONS
*/
/// @dev Exchange msg.value ether to WAN for account recepient
/// @param receipient WAN tokens receiver
function buyWanCoin(address receipient)
public
payable
notHalted
initialized
ceilingNotReached
notEarlierThan(earlyReserveBeginTime)
earlierThan(endTime)
returns (bool)
{
require(receipient != 0x0);
require(msg.value >= 0.1 ether);
// Do not allow contracts to game the system
require(!isContract(msg.sender));
if( now < startTime && now >= earlyReserveBeginTime)
buyEarlyAdopters(receipient);
else {
require( tx.gasprice <= 50000000000 wei );
require(msg.value <= normalBuyLimit);
buyNormal(receipient);
}
return true;
}
function setNormalBuyLimit(uint256 limit)
public
initialized
onlyOwner
earlierThan(endTime)
{
normalBuyLimit = limit;
}
/// @dev batch set quota for early user quota
function setEarlyWhitelistQuotas(address[] users, uint earlyCap, uint openTag)
public
onlyOwner
earlierThan(earlyReserveBeginTime)
{
for( uint i = 0; i < users.length; i++) {
earlyUserQuotas[users[i]] = earlyCap;
fullWhiteList[users[i]] = openTag;
}
}
/// @dev batch set quota for early user quota
function setLaterWhiteList(address[] users, uint openTag)
public
onlyOwner
earlierThan(endTime)
{
require(saleNotEnd());
for( uint i = 0; i < users.length; i++) {
fullWhiteList[users[i]] = openTag;
}
}
/// @dev Emergency situation that requires contribution period to stop.
/// Contributing not possible anymore.
function halt() public onlyWallet{
halted = true;
}
/// @dev Emergency situation resolved.
/// Contributing becomes possible again withing the outlined restrictions.
function unHalt() public onlyWallet{
halted = false;
}
/// @dev Emergency situation
function changeWalletAddress(address newAddress) onlyWallet {
wanport = newAddress;
}
/// @return true if sale not ended, false otherwise.
function saleNotEnd() constant returns (bool) {
return now < endTime && openSoldTokens < MAX_OPEN_SOLD;
}
/// CONSTANT METHODS
/// @dev Get current exchange rate
function priceRate() public constant returns (uint) {
// Three price tiers
if (earlyReserveBeginTime <= now && now < startTime + 1 weeks)
return PRICE_RATE_FIRST;
if (startTime + 1 weeks <= now && now < startTime + 2 weeks)
return PRICE_RATE_SECOND;
if (startTime + 2 weeks <= now && now < endTime)
return PRICE_RATE_LAST;
// Should not be called before or after contribution period
assert(false);
}
function claimTokens(address receipent)
public
isSaleEnded
{
wanToken.claimTokens(receipent);
}
/*
* INTERNAL FUNCTIONS
*/
/// @dev Buy wanchain tokens for early adopters
function buyEarlyAdopters(address receipient) internal {
uint quotaAvailable = earlyUserQuotas[receipient];
require(quotaAvailable > 0);
uint toFund = quotaAvailable.min256(msg.value);
uint tokenAvailable4Adopter = toFund.mul(PRICE_RATE_FIRST);
earlyUserQuotas[receipient] = earlyUserQuotas[receipient].sub(toFund);
buyCommon(receipient, toFund, tokenAvailable4Adopter);
}
/// @dev Buy wanchain token normally
function buyNormal(address receipient) internal {
uint inWhiteListTag = fullWhiteList[receipient];
require(inWhiteListTag > 0);
// protect partner quota in stage one
uint tokenAvailable = MAX_OPEN_SOLD.sub(openSoldTokens);
require(tokenAvailable > 0);
uint toFund;
uint toCollect;
(toFund, toCollect) = costAndBuyTokens(tokenAvailable);
buyCommon(receipient, toFund, toCollect);
}
/// @dev Utility function for bug wanchain token
function buyCommon(address receipient, uint toFund, uint wanTokenCollect) internal {
require(msg.value >= toFund); // double check
if(toFund > 0) {
require(wanToken.mintToken(receipient, wanTokenCollect));
wanport.transfer(toFund);
openSoldTokens = openSoldTokens.add(wanTokenCollect);
NewSale(receipient, toFund, wanTokenCollect);
}
uint toReturn = msg.value.sub(toFund);
if(toReturn > 0) {
msg.sender.transfer(toReturn);
}
}
/// @dev Utility function for calculate available tokens and cost ethers
function costAndBuyTokens(uint availableToken) constant internal returns (uint costValue, uint getTokens){
// all conditions has checked in the caller functions
uint exchangeRate = priceRate();
getTokens = exchangeRate * msg.value;
if(availableToken >= getTokens){
costValue = msg.value;
} else {
costValue = availableToken / exchangeRate;
getTokens = availableToken;
}
}
/// @dev Internal function to determine if an address is a contract
/// @param _addr The address being queried
/// @return True if `_addr` is a contract
function isContract(address _addr) constant internal returns(bool) {
uint size;
if (_addr == 0) return false;
assembly {
size := extcodesize(_addr)
}
return size > 0;
}
} | /// @title Wanchain Contribution Contract
/// ICO Rules according: https://www.wanchain.org/crowdsale
/// For more information about this token sale, please visit https://wanchain.org
/// @author Zane Liang - <[email protected]> | NatSpecSingleLine | setLaterWhiteList | function setLaterWhiteList(address[] users, uint openTag)
public
onlyOwner
earlierThan(endTime)
{
require(saleNotEnd());
for( uint i = 0; i < users.length; i++) {
fullWhiteList[users[i]] = openTag;
}
}
| /// @dev batch set quota for early user quota | NatSpecSingleLine | v0.4.13+commit.fb4cb1a | bzzr://cf354415565dbcba55ca7d803241ed623e9875b86e7d49619e734c70d0b4d0bf | {
"func_code_index": [
7051,
7334
]
} | 5,033 |
|
WanchainContribution | WanchainContribution.sol | 0xaac3090257be280087d8bdc530265203d105b120 | Solidity | WanchainContribution | contract WanchainContribution is Owned {
using SafeMath for uint;
/// Constant fields
/// Wanchain total tokens supply
uint public constant WAN_TOTAL_SUPPLY = 210000000 ether;
uint public constant EARLY_CONTRIBUTION_DURATION = 24 hours;
uint public constant MAX_CONTRIBUTION_DURATION = 3 weeks;
/// Exchange rates for first phase
uint public constant PRICE_RATE_FIRST = 880;
/// Exchange rates for second phase
uint public constant PRICE_RATE_SECOND = 790;
/// Exchange rates for last phase
uint public constant PRICE_RATE_LAST = 750;
/// ----------------------------------------------------------------------------------------------------
/// | | | | |
/// | PUBLIC SALE (PRESALE + OPEN SALE) | DEV TEAM | FOUNDATION | MINER |
/// | 51% | 20% | 19% | 10% |
/// ----------------------------------------------------------------------------------------------------
/// OPEN_SALE_STAKE + PRESALE_STAKE = 51; 51% sale for public
uint public constant OPEN_SALE_STAKE = 510; // 51% for open sale
// Reserved stakes
uint public constant DEV_TEAM_STAKE = 200; // 20%
uint public constant FOUNDATION_STAKE = 190; // 19%
uint public constant MINERS_STAKE = 100; // 10%
uint public constant DIVISOR_STAKE = 1000;
uint public constant PRESALE_RESERVERED_AMOUNT = 41506655 ether; //presale prize amount(40000*880)
/// Holder address for presale and reserved tokens
/// TODO: change addressed before deployed to main net
// Addresses of Patrons
address public constant DEV_TEAM_HOLDER = 0x0001cdC69b1eb8bCCE29311C01092Bdcc92f8f8F;
address public constant FOUNDATION_HOLDER = 0x00dB4023b32008C45E62Add57De256a9399752D4;
address public constant MINERS_HOLDER = 0x00f870D11eA43AA1c4C715c61dC045E32d232787;
address public constant PRESALE_HOLDER = 0x00577c25A81fA2401C5246F4a7D5ebaFfA4b00Aa;
uint public MAX_OPEN_SOLD = WAN_TOTAL_SUPPLY * OPEN_SALE_STAKE / DIVISOR_STAKE - PRESALE_RESERVERED_AMOUNT;
/// Fields that are only changed in constructor
/// All deposited ETH will be instantly forwarded to this address.
address public wanport;
/// Early Adopters reserved start time
uint public earlyReserveBeginTime;
/// Contribution start time
uint public startTime;
/// Contribution end time
uint public endTime;
/// Fields that can be changed by functions
/// Accumulator for open sold tokens
uint public openSoldTokens;
/// Due to an emergency, set this to true to halt the contribution
bool public halted;
/// ERC20 compilant wanchain token contact instance
WanToken public wanToken;
/// Quota for early adopters sale, Quota
mapping (address => uint256) public earlyUserQuotas;
/// tags show address can join in open sale
mapping (address => uint256) public fullWhiteList;
uint256 public normalBuyLimit = 65 ether;
/*
* EVENTS
*/
event NewSale(address indexed destAddress, uint ethCost, uint gotTokens);
//event PartnerAddressQuota(address indexed partnerAddress, uint quota);
/*
* MODIFIERS
*/
modifier onlyWallet {
require(msg.sender == wanport);
_;
}
modifier notHalted() {
require(!halted);
_;
}
modifier initialized() {
require(address(wanport) != 0x0);
_;
}
modifier notEarlierThan(uint x) {
require(now >= x);
_;
}
modifier earlierThan(uint x) {
require(now < x);
_;
}
modifier ceilingNotReached() {
require(openSoldTokens < MAX_OPEN_SOLD);
_;
}
modifier isSaleEnded() {
require(now > endTime || openSoldTokens >= MAX_OPEN_SOLD);
_;
}
/**
* CONSTRUCTOR
*
* @dev Initialize the Wanchain contribution contract
* @param _wanport The escrow account address, all ethers will be sent to this address.
* @param _bootTime ICO boot time
*/
function WanchainContribution(address _wanport, uint _bootTime){
require(_wanport != 0x0);
halted = false;
wanport = _wanport;
earlyReserveBeginTime = _bootTime;
startTime = earlyReserveBeginTime + EARLY_CONTRIBUTION_DURATION;
endTime = startTime + MAX_CONTRIBUTION_DURATION;
openSoldTokens = 0;
/// Create wanchain token contract instance
wanToken = new WanToken(this,startTime, endTime);
/// Reserve tokens according wanchain ICO rules
uint stakeMultiplier = WAN_TOTAL_SUPPLY / DIVISOR_STAKE;
wanToken.mintToken(DEV_TEAM_HOLDER, DEV_TEAM_STAKE * stakeMultiplier);
wanToken.mintToken(FOUNDATION_HOLDER, FOUNDATION_STAKE * stakeMultiplier);
wanToken.mintToken(MINERS_HOLDER, MINERS_STAKE * stakeMultiplier);
wanToken.mintToken(PRESALE_HOLDER, PRESALE_RESERVERED_AMOUNT);
}
/**
* Fallback function
*
* @dev If anybody sends Ether directly to this contract, consider he is getting wan token
*/
function () public payable {
buyWanCoin(msg.sender);
}
/*
* PUBLIC FUNCTIONS
*/
/// @dev Exchange msg.value ether to WAN for account recepient
/// @param receipient WAN tokens receiver
function buyWanCoin(address receipient)
public
payable
notHalted
initialized
ceilingNotReached
notEarlierThan(earlyReserveBeginTime)
earlierThan(endTime)
returns (bool)
{
require(receipient != 0x0);
require(msg.value >= 0.1 ether);
// Do not allow contracts to game the system
require(!isContract(msg.sender));
if( now < startTime && now >= earlyReserveBeginTime)
buyEarlyAdopters(receipient);
else {
require( tx.gasprice <= 50000000000 wei );
require(msg.value <= normalBuyLimit);
buyNormal(receipient);
}
return true;
}
function setNormalBuyLimit(uint256 limit)
public
initialized
onlyOwner
earlierThan(endTime)
{
normalBuyLimit = limit;
}
/// @dev batch set quota for early user quota
function setEarlyWhitelistQuotas(address[] users, uint earlyCap, uint openTag)
public
onlyOwner
earlierThan(earlyReserveBeginTime)
{
for( uint i = 0; i < users.length; i++) {
earlyUserQuotas[users[i]] = earlyCap;
fullWhiteList[users[i]] = openTag;
}
}
/// @dev batch set quota for early user quota
function setLaterWhiteList(address[] users, uint openTag)
public
onlyOwner
earlierThan(endTime)
{
require(saleNotEnd());
for( uint i = 0; i < users.length; i++) {
fullWhiteList[users[i]] = openTag;
}
}
/// @dev Emergency situation that requires contribution period to stop.
/// Contributing not possible anymore.
function halt() public onlyWallet{
halted = true;
}
/// @dev Emergency situation resolved.
/// Contributing becomes possible again withing the outlined restrictions.
function unHalt() public onlyWallet{
halted = false;
}
/// @dev Emergency situation
function changeWalletAddress(address newAddress) onlyWallet {
wanport = newAddress;
}
/// @return true if sale not ended, false otherwise.
function saleNotEnd() constant returns (bool) {
return now < endTime && openSoldTokens < MAX_OPEN_SOLD;
}
/// CONSTANT METHODS
/// @dev Get current exchange rate
function priceRate() public constant returns (uint) {
// Three price tiers
if (earlyReserveBeginTime <= now && now < startTime + 1 weeks)
return PRICE_RATE_FIRST;
if (startTime + 1 weeks <= now && now < startTime + 2 weeks)
return PRICE_RATE_SECOND;
if (startTime + 2 weeks <= now && now < endTime)
return PRICE_RATE_LAST;
// Should not be called before or after contribution period
assert(false);
}
function claimTokens(address receipent)
public
isSaleEnded
{
wanToken.claimTokens(receipent);
}
/*
* INTERNAL FUNCTIONS
*/
/// @dev Buy wanchain tokens for early adopters
function buyEarlyAdopters(address receipient) internal {
uint quotaAvailable = earlyUserQuotas[receipient];
require(quotaAvailable > 0);
uint toFund = quotaAvailable.min256(msg.value);
uint tokenAvailable4Adopter = toFund.mul(PRICE_RATE_FIRST);
earlyUserQuotas[receipient] = earlyUserQuotas[receipient].sub(toFund);
buyCommon(receipient, toFund, tokenAvailable4Adopter);
}
/// @dev Buy wanchain token normally
function buyNormal(address receipient) internal {
uint inWhiteListTag = fullWhiteList[receipient];
require(inWhiteListTag > 0);
// protect partner quota in stage one
uint tokenAvailable = MAX_OPEN_SOLD.sub(openSoldTokens);
require(tokenAvailable > 0);
uint toFund;
uint toCollect;
(toFund, toCollect) = costAndBuyTokens(tokenAvailable);
buyCommon(receipient, toFund, toCollect);
}
/// @dev Utility function for bug wanchain token
function buyCommon(address receipient, uint toFund, uint wanTokenCollect) internal {
require(msg.value >= toFund); // double check
if(toFund > 0) {
require(wanToken.mintToken(receipient, wanTokenCollect));
wanport.transfer(toFund);
openSoldTokens = openSoldTokens.add(wanTokenCollect);
NewSale(receipient, toFund, wanTokenCollect);
}
uint toReturn = msg.value.sub(toFund);
if(toReturn > 0) {
msg.sender.transfer(toReturn);
}
}
/// @dev Utility function for calculate available tokens and cost ethers
function costAndBuyTokens(uint availableToken) constant internal returns (uint costValue, uint getTokens){
// all conditions has checked in the caller functions
uint exchangeRate = priceRate();
getTokens = exchangeRate * msg.value;
if(availableToken >= getTokens){
costValue = msg.value;
} else {
costValue = availableToken / exchangeRate;
getTokens = availableToken;
}
}
/// @dev Internal function to determine if an address is a contract
/// @param _addr The address being queried
/// @return True if `_addr` is a contract
function isContract(address _addr) constant internal returns(bool) {
uint size;
if (_addr == 0) return false;
assembly {
size := extcodesize(_addr)
}
return size > 0;
}
} | /// @title Wanchain Contribution Contract
/// ICO Rules according: https://www.wanchain.org/crowdsale
/// For more information about this token sale, please visit https://wanchain.org
/// @author Zane Liang - <[email protected]> | NatSpecSingleLine | halt | function halt() public onlyWallet{
halted = true;
}
| /// @dev Emergency situation that requires contribution period to stop.
/// Contributing not possible anymore. | NatSpecSingleLine | v0.4.13+commit.fb4cb1a | bzzr://cf354415565dbcba55ca7d803241ed623e9875b86e7d49619e734c70d0b4d0bf | {
"func_code_index": [
7458,
7528
]
} | 5,034 |
|
WanchainContribution | WanchainContribution.sol | 0xaac3090257be280087d8bdc530265203d105b120 | Solidity | WanchainContribution | contract WanchainContribution is Owned {
using SafeMath for uint;
/// Constant fields
/// Wanchain total tokens supply
uint public constant WAN_TOTAL_SUPPLY = 210000000 ether;
uint public constant EARLY_CONTRIBUTION_DURATION = 24 hours;
uint public constant MAX_CONTRIBUTION_DURATION = 3 weeks;
/// Exchange rates for first phase
uint public constant PRICE_RATE_FIRST = 880;
/// Exchange rates for second phase
uint public constant PRICE_RATE_SECOND = 790;
/// Exchange rates for last phase
uint public constant PRICE_RATE_LAST = 750;
/// ----------------------------------------------------------------------------------------------------
/// | | | | |
/// | PUBLIC SALE (PRESALE + OPEN SALE) | DEV TEAM | FOUNDATION | MINER |
/// | 51% | 20% | 19% | 10% |
/// ----------------------------------------------------------------------------------------------------
/// OPEN_SALE_STAKE + PRESALE_STAKE = 51; 51% sale for public
uint public constant OPEN_SALE_STAKE = 510; // 51% for open sale
// Reserved stakes
uint public constant DEV_TEAM_STAKE = 200; // 20%
uint public constant FOUNDATION_STAKE = 190; // 19%
uint public constant MINERS_STAKE = 100; // 10%
uint public constant DIVISOR_STAKE = 1000;
uint public constant PRESALE_RESERVERED_AMOUNT = 41506655 ether; //presale prize amount(40000*880)
/// Holder address for presale and reserved tokens
/// TODO: change addressed before deployed to main net
// Addresses of Patrons
address public constant DEV_TEAM_HOLDER = 0x0001cdC69b1eb8bCCE29311C01092Bdcc92f8f8F;
address public constant FOUNDATION_HOLDER = 0x00dB4023b32008C45E62Add57De256a9399752D4;
address public constant MINERS_HOLDER = 0x00f870D11eA43AA1c4C715c61dC045E32d232787;
address public constant PRESALE_HOLDER = 0x00577c25A81fA2401C5246F4a7D5ebaFfA4b00Aa;
uint public MAX_OPEN_SOLD = WAN_TOTAL_SUPPLY * OPEN_SALE_STAKE / DIVISOR_STAKE - PRESALE_RESERVERED_AMOUNT;
/// Fields that are only changed in constructor
/// All deposited ETH will be instantly forwarded to this address.
address public wanport;
/// Early Adopters reserved start time
uint public earlyReserveBeginTime;
/// Contribution start time
uint public startTime;
/// Contribution end time
uint public endTime;
/// Fields that can be changed by functions
/// Accumulator for open sold tokens
uint public openSoldTokens;
/// Due to an emergency, set this to true to halt the contribution
bool public halted;
/// ERC20 compilant wanchain token contact instance
WanToken public wanToken;
/// Quota for early adopters sale, Quota
mapping (address => uint256) public earlyUserQuotas;
/// tags show address can join in open sale
mapping (address => uint256) public fullWhiteList;
uint256 public normalBuyLimit = 65 ether;
/*
* EVENTS
*/
event NewSale(address indexed destAddress, uint ethCost, uint gotTokens);
//event PartnerAddressQuota(address indexed partnerAddress, uint quota);
/*
* MODIFIERS
*/
modifier onlyWallet {
require(msg.sender == wanport);
_;
}
modifier notHalted() {
require(!halted);
_;
}
modifier initialized() {
require(address(wanport) != 0x0);
_;
}
modifier notEarlierThan(uint x) {
require(now >= x);
_;
}
modifier earlierThan(uint x) {
require(now < x);
_;
}
modifier ceilingNotReached() {
require(openSoldTokens < MAX_OPEN_SOLD);
_;
}
modifier isSaleEnded() {
require(now > endTime || openSoldTokens >= MAX_OPEN_SOLD);
_;
}
/**
* CONSTRUCTOR
*
* @dev Initialize the Wanchain contribution contract
* @param _wanport The escrow account address, all ethers will be sent to this address.
* @param _bootTime ICO boot time
*/
function WanchainContribution(address _wanport, uint _bootTime){
require(_wanport != 0x0);
halted = false;
wanport = _wanport;
earlyReserveBeginTime = _bootTime;
startTime = earlyReserveBeginTime + EARLY_CONTRIBUTION_DURATION;
endTime = startTime + MAX_CONTRIBUTION_DURATION;
openSoldTokens = 0;
/// Create wanchain token contract instance
wanToken = new WanToken(this,startTime, endTime);
/// Reserve tokens according wanchain ICO rules
uint stakeMultiplier = WAN_TOTAL_SUPPLY / DIVISOR_STAKE;
wanToken.mintToken(DEV_TEAM_HOLDER, DEV_TEAM_STAKE * stakeMultiplier);
wanToken.mintToken(FOUNDATION_HOLDER, FOUNDATION_STAKE * stakeMultiplier);
wanToken.mintToken(MINERS_HOLDER, MINERS_STAKE * stakeMultiplier);
wanToken.mintToken(PRESALE_HOLDER, PRESALE_RESERVERED_AMOUNT);
}
/**
* Fallback function
*
* @dev If anybody sends Ether directly to this contract, consider he is getting wan token
*/
function () public payable {
buyWanCoin(msg.sender);
}
/*
* PUBLIC FUNCTIONS
*/
/// @dev Exchange msg.value ether to WAN for account recepient
/// @param receipient WAN tokens receiver
function buyWanCoin(address receipient)
public
payable
notHalted
initialized
ceilingNotReached
notEarlierThan(earlyReserveBeginTime)
earlierThan(endTime)
returns (bool)
{
require(receipient != 0x0);
require(msg.value >= 0.1 ether);
// Do not allow contracts to game the system
require(!isContract(msg.sender));
if( now < startTime && now >= earlyReserveBeginTime)
buyEarlyAdopters(receipient);
else {
require( tx.gasprice <= 50000000000 wei );
require(msg.value <= normalBuyLimit);
buyNormal(receipient);
}
return true;
}
function setNormalBuyLimit(uint256 limit)
public
initialized
onlyOwner
earlierThan(endTime)
{
normalBuyLimit = limit;
}
/// @dev batch set quota for early user quota
function setEarlyWhitelistQuotas(address[] users, uint earlyCap, uint openTag)
public
onlyOwner
earlierThan(earlyReserveBeginTime)
{
for( uint i = 0; i < users.length; i++) {
earlyUserQuotas[users[i]] = earlyCap;
fullWhiteList[users[i]] = openTag;
}
}
/// @dev batch set quota for early user quota
function setLaterWhiteList(address[] users, uint openTag)
public
onlyOwner
earlierThan(endTime)
{
require(saleNotEnd());
for( uint i = 0; i < users.length; i++) {
fullWhiteList[users[i]] = openTag;
}
}
/// @dev Emergency situation that requires contribution period to stop.
/// Contributing not possible anymore.
function halt() public onlyWallet{
halted = true;
}
/// @dev Emergency situation resolved.
/// Contributing becomes possible again withing the outlined restrictions.
function unHalt() public onlyWallet{
halted = false;
}
/// @dev Emergency situation
function changeWalletAddress(address newAddress) onlyWallet {
wanport = newAddress;
}
/// @return true if sale not ended, false otherwise.
function saleNotEnd() constant returns (bool) {
return now < endTime && openSoldTokens < MAX_OPEN_SOLD;
}
/// CONSTANT METHODS
/// @dev Get current exchange rate
function priceRate() public constant returns (uint) {
// Three price tiers
if (earlyReserveBeginTime <= now && now < startTime + 1 weeks)
return PRICE_RATE_FIRST;
if (startTime + 1 weeks <= now && now < startTime + 2 weeks)
return PRICE_RATE_SECOND;
if (startTime + 2 weeks <= now && now < endTime)
return PRICE_RATE_LAST;
// Should not be called before or after contribution period
assert(false);
}
function claimTokens(address receipent)
public
isSaleEnded
{
wanToken.claimTokens(receipent);
}
/*
* INTERNAL FUNCTIONS
*/
/// @dev Buy wanchain tokens for early adopters
function buyEarlyAdopters(address receipient) internal {
uint quotaAvailable = earlyUserQuotas[receipient];
require(quotaAvailable > 0);
uint toFund = quotaAvailable.min256(msg.value);
uint tokenAvailable4Adopter = toFund.mul(PRICE_RATE_FIRST);
earlyUserQuotas[receipient] = earlyUserQuotas[receipient].sub(toFund);
buyCommon(receipient, toFund, tokenAvailable4Adopter);
}
/// @dev Buy wanchain token normally
function buyNormal(address receipient) internal {
uint inWhiteListTag = fullWhiteList[receipient];
require(inWhiteListTag > 0);
// protect partner quota in stage one
uint tokenAvailable = MAX_OPEN_SOLD.sub(openSoldTokens);
require(tokenAvailable > 0);
uint toFund;
uint toCollect;
(toFund, toCollect) = costAndBuyTokens(tokenAvailable);
buyCommon(receipient, toFund, toCollect);
}
/// @dev Utility function for bug wanchain token
function buyCommon(address receipient, uint toFund, uint wanTokenCollect) internal {
require(msg.value >= toFund); // double check
if(toFund > 0) {
require(wanToken.mintToken(receipient, wanTokenCollect));
wanport.transfer(toFund);
openSoldTokens = openSoldTokens.add(wanTokenCollect);
NewSale(receipient, toFund, wanTokenCollect);
}
uint toReturn = msg.value.sub(toFund);
if(toReturn > 0) {
msg.sender.transfer(toReturn);
}
}
/// @dev Utility function for calculate available tokens and cost ethers
function costAndBuyTokens(uint availableToken) constant internal returns (uint costValue, uint getTokens){
// all conditions has checked in the caller functions
uint exchangeRate = priceRate();
getTokens = exchangeRate * msg.value;
if(availableToken >= getTokens){
costValue = msg.value;
} else {
costValue = availableToken / exchangeRate;
getTokens = availableToken;
}
}
/// @dev Internal function to determine if an address is a contract
/// @param _addr The address being queried
/// @return True if `_addr` is a contract
function isContract(address _addr) constant internal returns(bool) {
uint size;
if (_addr == 0) return false;
assembly {
size := extcodesize(_addr)
}
return size > 0;
}
} | /// @title Wanchain Contribution Contract
/// ICO Rules according: https://www.wanchain.org/crowdsale
/// For more information about this token sale, please visit https://wanchain.org
/// @author Zane Liang - <[email protected]> | NatSpecSingleLine | unHalt | function unHalt() public onlyWallet{
halted = false;
}
| /// @dev Emergency situation resolved.
/// Contributing becomes possible again withing the outlined restrictions. | NatSpecSingleLine | v0.4.13+commit.fb4cb1a | bzzr://cf354415565dbcba55ca7d803241ed623e9875b86e7d49619e734c70d0b4d0bf | {
"func_code_index": [
7655,
7728
]
} | 5,035 |
|
WanchainContribution | WanchainContribution.sol | 0xaac3090257be280087d8bdc530265203d105b120 | Solidity | WanchainContribution | contract WanchainContribution is Owned {
using SafeMath for uint;
/// Constant fields
/// Wanchain total tokens supply
uint public constant WAN_TOTAL_SUPPLY = 210000000 ether;
uint public constant EARLY_CONTRIBUTION_DURATION = 24 hours;
uint public constant MAX_CONTRIBUTION_DURATION = 3 weeks;
/// Exchange rates for first phase
uint public constant PRICE_RATE_FIRST = 880;
/// Exchange rates for second phase
uint public constant PRICE_RATE_SECOND = 790;
/// Exchange rates for last phase
uint public constant PRICE_RATE_LAST = 750;
/// ----------------------------------------------------------------------------------------------------
/// | | | | |
/// | PUBLIC SALE (PRESALE + OPEN SALE) | DEV TEAM | FOUNDATION | MINER |
/// | 51% | 20% | 19% | 10% |
/// ----------------------------------------------------------------------------------------------------
/// OPEN_SALE_STAKE + PRESALE_STAKE = 51; 51% sale for public
uint public constant OPEN_SALE_STAKE = 510; // 51% for open sale
// Reserved stakes
uint public constant DEV_TEAM_STAKE = 200; // 20%
uint public constant FOUNDATION_STAKE = 190; // 19%
uint public constant MINERS_STAKE = 100; // 10%
uint public constant DIVISOR_STAKE = 1000;
uint public constant PRESALE_RESERVERED_AMOUNT = 41506655 ether; //presale prize amount(40000*880)
/// Holder address for presale and reserved tokens
/// TODO: change addressed before deployed to main net
// Addresses of Patrons
address public constant DEV_TEAM_HOLDER = 0x0001cdC69b1eb8bCCE29311C01092Bdcc92f8f8F;
address public constant FOUNDATION_HOLDER = 0x00dB4023b32008C45E62Add57De256a9399752D4;
address public constant MINERS_HOLDER = 0x00f870D11eA43AA1c4C715c61dC045E32d232787;
address public constant PRESALE_HOLDER = 0x00577c25A81fA2401C5246F4a7D5ebaFfA4b00Aa;
uint public MAX_OPEN_SOLD = WAN_TOTAL_SUPPLY * OPEN_SALE_STAKE / DIVISOR_STAKE - PRESALE_RESERVERED_AMOUNT;
/// Fields that are only changed in constructor
/// All deposited ETH will be instantly forwarded to this address.
address public wanport;
/// Early Adopters reserved start time
uint public earlyReserveBeginTime;
/// Contribution start time
uint public startTime;
/// Contribution end time
uint public endTime;
/// Fields that can be changed by functions
/// Accumulator for open sold tokens
uint public openSoldTokens;
/// Due to an emergency, set this to true to halt the contribution
bool public halted;
/// ERC20 compilant wanchain token contact instance
WanToken public wanToken;
/// Quota for early adopters sale, Quota
mapping (address => uint256) public earlyUserQuotas;
/// tags show address can join in open sale
mapping (address => uint256) public fullWhiteList;
uint256 public normalBuyLimit = 65 ether;
/*
* EVENTS
*/
event NewSale(address indexed destAddress, uint ethCost, uint gotTokens);
//event PartnerAddressQuota(address indexed partnerAddress, uint quota);
/*
* MODIFIERS
*/
modifier onlyWallet {
require(msg.sender == wanport);
_;
}
modifier notHalted() {
require(!halted);
_;
}
modifier initialized() {
require(address(wanport) != 0x0);
_;
}
modifier notEarlierThan(uint x) {
require(now >= x);
_;
}
modifier earlierThan(uint x) {
require(now < x);
_;
}
modifier ceilingNotReached() {
require(openSoldTokens < MAX_OPEN_SOLD);
_;
}
modifier isSaleEnded() {
require(now > endTime || openSoldTokens >= MAX_OPEN_SOLD);
_;
}
/**
* CONSTRUCTOR
*
* @dev Initialize the Wanchain contribution contract
* @param _wanport The escrow account address, all ethers will be sent to this address.
* @param _bootTime ICO boot time
*/
function WanchainContribution(address _wanport, uint _bootTime){
require(_wanport != 0x0);
halted = false;
wanport = _wanport;
earlyReserveBeginTime = _bootTime;
startTime = earlyReserveBeginTime + EARLY_CONTRIBUTION_DURATION;
endTime = startTime + MAX_CONTRIBUTION_DURATION;
openSoldTokens = 0;
/// Create wanchain token contract instance
wanToken = new WanToken(this,startTime, endTime);
/// Reserve tokens according wanchain ICO rules
uint stakeMultiplier = WAN_TOTAL_SUPPLY / DIVISOR_STAKE;
wanToken.mintToken(DEV_TEAM_HOLDER, DEV_TEAM_STAKE * stakeMultiplier);
wanToken.mintToken(FOUNDATION_HOLDER, FOUNDATION_STAKE * stakeMultiplier);
wanToken.mintToken(MINERS_HOLDER, MINERS_STAKE * stakeMultiplier);
wanToken.mintToken(PRESALE_HOLDER, PRESALE_RESERVERED_AMOUNT);
}
/**
* Fallback function
*
* @dev If anybody sends Ether directly to this contract, consider he is getting wan token
*/
function () public payable {
buyWanCoin(msg.sender);
}
/*
* PUBLIC FUNCTIONS
*/
/// @dev Exchange msg.value ether to WAN for account recepient
/// @param receipient WAN tokens receiver
function buyWanCoin(address receipient)
public
payable
notHalted
initialized
ceilingNotReached
notEarlierThan(earlyReserveBeginTime)
earlierThan(endTime)
returns (bool)
{
require(receipient != 0x0);
require(msg.value >= 0.1 ether);
// Do not allow contracts to game the system
require(!isContract(msg.sender));
if( now < startTime && now >= earlyReserveBeginTime)
buyEarlyAdopters(receipient);
else {
require( tx.gasprice <= 50000000000 wei );
require(msg.value <= normalBuyLimit);
buyNormal(receipient);
}
return true;
}
function setNormalBuyLimit(uint256 limit)
public
initialized
onlyOwner
earlierThan(endTime)
{
normalBuyLimit = limit;
}
/// @dev batch set quota for early user quota
function setEarlyWhitelistQuotas(address[] users, uint earlyCap, uint openTag)
public
onlyOwner
earlierThan(earlyReserveBeginTime)
{
for( uint i = 0; i < users.length; i++) {
earlyUserQuotas[users[i]] = earlyCap;
fullWhiteList[users[i]] = openTag;
}
}
/// @dev batch set quota for early user quota
function setLaterWhiteList(address[] users, uint openTag)
public
onlyOwner
earlierThan(endTime)
{
require(saleNotEnd());
for( uint i = 0; i < users.length; i++) {
fullWhiteList[users[i]] = openTag;
}
}
/// @dev Emergency situation that requires contribution period to stop.
/// Contributing not possible anymore.
function halt() public onlyWallet{
halted = true;
}
/// @dev Emergency situation resolved.
/// Contributing becomes possible again withing the outlined restrictions.
function unHalt() public onlyWallet{
halted = false;
}
/// @dev Emergency situation
function changeWalletAddress(address newAddress) onlyWallet {
wanport = newAddress;
}
/// @return true if sale not ended, false otherwise.
function saleNotEnd() constant returns (bool) {
return now < endTime && openSoldTokens < MAX_OPEN_SOLD;
}
/// CONSTANT METHODS
/// @dev Get current exchange rate
function priceRate() public constant returns (uint) {
// Three price tiers
if (earlyReserveBeginTime <= now && now < startTime + 1 weeks)
return PRICE_RATE_FIRST;
if (startTime + 1 weeks <= now && now < startTime + 2 weeks)
return PRICE_RATE_SECOND;
if (startTime + 2 weeks <= now && now < endTime)
return PRICE_RATE_LAST;
// Should not be called before or after contribution period
assert(false);
}
function claimTokens(address receipent)
public
isSaleEnded
{
wanToken.claimTokens(receipent);
}
/*
* INTERNAL FUNCTIONS
*/
/// @dev Buy wanchain tokens for early adopters
function buyEarlyAdopters(address receipient) internal {
uint quotaAvailable = earlyUserQuotas[receipient];
require(quotaAvailable > 0);
uint toFund = quotaAvailable.min256(msg.value);
uint tokenAvailable4Adopter = toFund.mul(PRICE_RATE_FIRST);
earlyUserQuotas[receipient] = earlyUserQuotas[receipient].sub(toFund);
buyCommon(receipient, toFund, tokenAvailable4Adopter);
}
/// @dev Buy wanchain token normally
function buyNormal(address receipient) internal {
uint inWhiteListTag = fullWhiteList[receipient];
require(inWhiteListTag > 0);
// protect partner quota in stage one
uint tokenAvailable = MAX_OPEN_SOLD.sub(openSoldTokens);
require(tokenAvailable > 0);
uint toFund;
uint toCollect;
(toFund, toCollect) = costAndBuyTokens(tokenAvailable);
buyCommon(receipient, toFund, toCollect);
}
/// @dev Utility function for bug wanchain token
function buyCommon(address receipient, uint toFund, uint wanTokenCollect) internal {
require(msg.value >= toFund); // double check
if(toFund > 0) {
require(wanToken.mintToken(receipient, wanTokenCollect));
wanport.transfer(toFund);
openSoldTokens = openSoldTokens.add(wanTokenCollect);
NewSale(receipient, toFund, wanTokenCollect);
}
uint toReturn = msg.value.sub(toFund);
if(toReturn > 0) {
msg.sender.transfer(toReturn);
}
}
/// @dev Utility function for calculate available tokens and cost ethers
function costAndBuyTokens(uint availableToken) constant internal returns (uint costValue, uint getTokens){
// all conditions has checked in the caller functions
uint exchangeRate = priceRate();
getTokens = exchangeRate * msg.value;
if(availableToken >= getTokens){
costValue = msg.value;
} else {
costValue = availableToken / exchangeRate;
getTokens = availableToken;
}
}
/// @dev Internal function to determine if an address is a contract
/// @param _addr The address being queried
/// @return True if `_addr` is a contract
function isContract(address _addr) constant internal returns(bool) {
uint size;
if (_addr == 0) return false;
assembly {
size := extcodesize(_addr)
}
return size > 0;
}
} | /// @title Wanchain Contribution Contract
/// ICO Rules according: https://www.wanchain.org/crowdsale
/// For more information about this token sale, please visit https://wanchain.org
/// @author Zane Liang - <[email protected]> | NatSpecSingleLine | changeWalletAddress | function changeWalletAddress(address newAddress) onlyWallet {
wanport = newAddress;
}
| /// @dev Emergency situation | NatSpecSingleLine | v0.4.13+commit.fb4cb1a | bzzr://cf354415565dbcba55ca7d803241ed623e9875b86e7d49619e734c70d0b4d0bf | {
"func_code_index": [
7765,
7871
]
} | 5,036 |
|
WanchainContribution | WanchainContribution.sol | 0xaac3090257be280087d8bdc530265203d105b120 | Solidity | WanchainContribution | contract WanchainContribution is Owned {
using SafeMath for uint;
/// Constant fields
/// Wanchain total tokens supply
uint public constant WAN_TOTAL_SUPPLY = 210000000 ether;
uint public constant EARLY_CONTRIBUTION_DURATION = 24 hours;
uint public constant MAX_CONTRIBUTION_DURATION = 3 weeks;
/// Exchange rates for first phase
uint public constant PRICE_RATE_FIRST = 880;
/// Exchange rates for second phase
uint public constant PRICE_RATE_SECOND = 790;
/// Exchange rates for last phase
uint public constant PRICE_RATE_LAST = 750;
/// ----------------------------------------------------------------------------------------------------
/// | | | | |
/// | PUBLIC SALE (PRESALE + OPEN SALE) | DEV TEAM | FOUNDATION | MINER |
/// | 51% | 20% | 19% | 10% |
/// ----------------------------------------------------------------------------------------------------
/// OPEN_SALE_STAKE + PRESALE_STAKE = 51; 51% sale for public
uint public constant OPEN_SALE_STAKE = 510; // 51% for open sale
// Reserved stakes
uint public constant DEV_TEAM_STAKE = 200; // 20%
uint public constant FOUNDATION_STAKE = 190; // 19%
uint public constant MINERS_STAKE = 100; // 10%
uint public constant DIVISOR_STAKE = 1000;
uint public constant PRESALE_RESERVERED_AMOUNT = 41506655 ether; //presale prize amount(40000*880)
/// Holder address for presale and reserved tokens
/// TODO: change addressed before deployed to main net
// Addresses of Patrons
address public constant DEV_TEAM_HOLDER = 0x0001cdC69b1eb8bCCE29311C01092Bdcc92f8f8F;
address public constant FOUNDATION_HOLDER = 0x00dB4023b32008C45E62Add57De256a9399752D4;
address public constant MINERS_HOLDER = 0x00f870D11eA43AA1c4C715c61dC045E32d232787;
address public constant PRESALE_HOLDER = 0x00577c25A81fA2401C5246F4a7D5ebaFfA4b00Aa;
uint public MAX_OPEN_SOLD = WAN_TOTAL_SUPPLY * OPEN_SALE_STAKE / DIVISOR_STAKE - PRESALE_RESERVERED_AMOUNT;
/// Fields that are only changed in constructor
/// All deposited ETH will be instantly forwarded to this address.
address public wanport;
/// Early Adopters reserved start time
uint public earlyReserveBeginTime;
/// Contribution start time
uint public startTime;
/// Contribution end time
uint public endTime;
/// Fields that can be changed by functions
/// Accumulator for open sold tokens
uint public openSoldTokens;
/// Due to an emergency, set this to true to halt the contribution
bool public halted;
/// ERC20 compilant wanchain token contact instance
WanToken public wanToken;
/// Quota for early adopters sale, Quota
mapping (address => uint256) public earlyUserQuotas;
/// tags show address can join in open sale
mapping (address => uint256) public fullWhiteList;
uint256 public normalBuyLimit = 65 ether;
/*
* EVENTS
*/
event NewSale(address indexed destAddress, uint ethCost, uint gotTokens);
//event PartnerAddressQuota(address indexed partnerAddress, uint quota);
/*
* MODIFIERS
*/
modifier onlyWallet {
require(msg.sender == wanport);
_;
}
modifier notHalted() {
require(!halted);
_;
}
modifier initialized() {
require(address(wanport) != 0x0);
_;
}
modifier notEarlierThan(uint x) {
require(now >= x);
_;
}
modifier earlierThan(uint x) {
require(now < x);
_;
}
modifier ceilingNotReached() {
require(openSoldTokens < MAX_OPEN_SOLD);
_;
}
modifier isSaleEnded() {
require(now > endTime || openSoldTokens >= MAX_OPEN_SOLD);
_;
}
/**
* CONSTRUCTOR
*
* @dev Initialize the Wanchain contribution contract
* @param _wanport The escrow account address, all ethers will be sent to this address.
* @param _bootTime ICO boot time
*/
function WanchainContribution(address _wanport, uint _bootTime){
require(_wanport != 0x0);
halted = false;
wanport = _wanport;
earlyReserveBeginTime = _bootTime;
startTime = earlyReserveBeginTime + EARLY_CONTRIBUTION_DURATION;
endTime = startTime + MAX_CONTRIBUTION_DURATION;
openSoldTokens = 0;
/// Create wanchain token contract instance
wanToken = new WanToken(this,startTime, endTime);
/// Reserve tokens according wanchain ICO rules
uint stakeMultiplier = WAN_TOTAL_SUPPLY / DIVISOR_STAKE;
wanToken.mintToken(DEV_TEAM_HOLDER, DEV_TEAM_STAKE * stakeMultiplier);
wanToken.mintToken(FOUNDATION_HOLDER, FOUNDATION_STAKE * stakeMultiplier);
wanToken.mintToken(MINERS_HOLDER, MINERS_STAKE * stakeMultiplier);
wanToken.mintToken(PRESALE_HOLDER, PRESALE_RESERVERED_AMOUNT);
}
/**
* Fallback function
*
* @dev If anybody sends Ether directly to this contract, consider he is getting wan token
*/
function () public payable {
buyWanCoin(msg.sender);
}
/*
* PUBLIC FUNCTIONS
*/
/// @dev Exchange msg.value ether to WAN for account recepient
/// @param receipient WAN tokens receiver
function buyWanCoin(address receipient)
public
payable
notHalted
initialized
ceilingNotReached
notEarlierThan(earlyReserveBeginTime)
earlierThan(endTime)
returns (bool)
{
require(receipient != 0x0);
require(msg.value >= 0.1 ether);
// Do not allow contracts to game the system
require(!isContract(msg.sender));
if( now < startTime && now >= earlyReserveBeginTime)
buyEarlyAdopters(receipient);
else {
require( tx.gasprice <= 50000000000 wei );
require(msg.value <= normalBuyLimit);
buyNormal(receipient);
}
return true;
}
function setNormalBuyLimit(uint256 limit)
public
initialized
onlyOwner
earlierThan(endTime)
{
normalBuyLimit = limit;
}
/// @dev batch set quota for early user quota
function setEarlyWhitelistQuotas(address[] users, uint earlyCap, uint openTag)
public
onlyOwner
earlierThan(earlyReserveBeginTime)
{
for( uint i = 0; i < users.length; i++) {
earlyUserQuotas[users[i]] = earlyCap;
fullWhiteList[users[i]] = openTag;
}
}
/// @dev batch set quota for early user quota
function setLaterWhiteList(address[] users, uint openTag)
public
onlyOwner
earlierThan(endTime)
{
require(saleNotEnd());
for( uint i = 0; i < users.length; i++) {
fullWhiteList[users[i]] = openTag;
}
}
/// @dev Emergency situation that requires contribution period to stop.
/// Contributing not possible anymore.
function halt() public onlyWallet{
halted = true;
}
/// @dev Emergency situation resolved.
/// Contributing becomes possible again withing the outlined restrictions.
function unHalt() public onlyWallet{
halted = false;
}
/// @dev Emergency situation
function changeWalletAddress(address newAddress) onlyWallet {
wanport = newAddress;
}
/// @return true if sale not ended, false otherwise.
function saleNotEnd() constant returns (bool) {
return now < endTime && openSoldTokens < MAX_OPEN_SOLD;
}
/// CONSTANT METHODS
/// @dev Get current exchange rate
function priceRate() public constant returns (uint) {
// Three price tiers
if (earlyReserveBeginTime <= now && now < startTime + 1 weeks)
return PRICE_RATE_FIRST;
if (startTime + 1 weeks <= now && now < startTime + 2 weeks)
return PRICE_RATE_SECOND;
if (startTime + 2 weeks <= now && now < endTime)
return PRICE_RATE_LAST;
// Should not be called before or after contribution period
assert(false);
}
function claimTokens(address receipent)
public
isSaleEnded
{
wanToken.claimTokens(receipent);
}
/*
* INTERNAL FUNCTIONS
*/
/// @dev Buy wanchain tokens for early adopters
function buyEarlyAdopters(address receipient) internal {
uint quotaAvailable = earlyUserQuotas[receipient];
require(quotaAvailable > 0);
uint toFund = quotaAvailable.min256(msg.value);
uint tokenAvailable4Adopter = toFund.mul(PRICE_RATE_FIRST);
earlyUserQuotas[receipient] = earlyUserQuotas[receipient].sub(toFund);
buyCommon(receipient, toFund, tokenAvailable4Adopter);
}
/// @dev Buy wanchain token normally
function buyNormal(address receipient) internal {
uint inWhiteListTag = fullWhiteList[receipient];
require(inWhiteListTag > 0);
// protect partner quota in stage one
uint tokenAvailable = MAX_OPEN_SOLD.sub(openSoldTokens);
require(tokenAvailable > 0);
uint toFund;
uint toCollect;
(toFund, toCollect) = costAndBuyTokens(tokenAvailable);
buyCommon(receipient, toFund, toCollect);
}
/// @dev Utility function for bug wanchain token
function buyCommon(address receipient, uint toFund, uint wanTokenCollect) internal {
require(msg.value >= toFund); // double check
if(toFund > 0) {
require(wanToken.mintToken(receipient, wanTokenCollect));
wanport.transfer(toFund);
openSoldTokens = openSoldTokens.add(wanTokenCollect);
NewSale(receipient, toFund, wanTokenCollect);
}
uint toReturn = msg.value.sub(toFund);
if(toReturn > 0) {
msg.sender.transfer(toReturn);
}
}
/// @dev Utility function for calculate available tokens and cost ethers
function costAndBuyTokens(uint availableToken) constant internal returns (uint costValue, uint getTokens){
// all conditions has checked in the caller functions
uint exchangeRate = priceRate();
getTokens = exchangeRate * msg.value;
if(availableToken >= getTokens){
costValue = msg.value;
} else {
costValue = availableToken / exchangeRate;
getTokens = availableToken;
}
}
/// @dev Internal function to determine if an address is a contract
/// @param _addr The address being queried
/// @return True if `_addr` is a contract
function isContract(address _addr) constant internal returns(bool) {
uint size;
if (_addr == 0) return false;
assembly {
size := extcodesize(_addr)
}
return size > 0;
}
} | /// @title Wanchain Contribution Contract
/// ICO Rules according: https://www.wanchain.org/crowdsale
/// For more information about this token sale, please visit https://wanchain.org
/// @author Zane Liang - <[email protected]> | NatSpecSingleLine | saleNotEnd | function saleNotEnd() constant returns (bool) {
return now < endTime && openSoldTokens < MAX_OPEN_SOLD;
}
| /// @return true if sale not ended, false otherwise. | NatSpecSingleLine | v0.4.13+commit.fb4cb1a | bzzr://cf354415565dbcba55ca7d803241ed623e9875b86e7d49619e734c70d0b4d0bf | {
"func_code_index": [
7932,
8056
]
} | 5,037 |
|
WanchainContribution | WanchainContribution.sol | 0xaac3090257be280087d8bdc530265203d105b120 | Solidity | WanchainContribution | contract WanchainContribution is Owned {
using SafeMath for uint;
/// Constant fields
/// Wanchain total tokens supply
uint public constant WAN_TOTAL_SUPPLY = 210000000 ether;
uint public constant EARLY_CONTRIBUTION_DURATION = 24 hours;
uint public constant MAX_CONTRIBUTION_DURATION = 3 weeks;
/// Exchange rates for first phase
uint public constant PRICE_RATE_FIRST = 880;
/// Exchange rates for second phase
uint public constant PRICE_RATE_SECOND = 790;
/// Exchange rates for last phase
uint public constant PRICE_RATE_LAST = 750;
/// ----------------------------------------------------------------------------------------------------
/// | | | | |
/// | PUBLIC SALE (PRESALE + OPEN SALE) | DEV TEAM | FOUNDATION | MINER |
/// | 51% | 20% | 19% | 10% |
/// ----------------------------------------------------------------------------------------------------
/// OPEN_SALE_STAKE + PRESALE_STAKE = 51; 51% sale for public
uint public constant OPEN_SALE_STAKE = 510; // 51% for open sale
// Reserved stakes
uint public constant DEV_TEAM_STAKE = 200; // 20%
uint public constant FOUNDATION_STAKE = 190; // 19%
uint public constant MINERS_STAKE = 100; // 10%
uint public constant DIVISOR_STAKE = 1000;
uint public constant PRESALE_RESERVERED_AMOUNT = 41506655 ether; //presale prize amount(40000*880)
/// Holder address for presale and reserved tokens
/// TODO: change addressed before deployed to main net
// Addresses of Patrons
address public constant DEV_TEAM_HOLDER = 0x0001cdC69b1eb8bCCE29311C01092Bdcc92f8f8F;
address public constant FOUNDATION_HOLDER = 0x00dB4023b32008C45E62Add57De256a9399752D4;
address public constant MINERS_HOLDER = 0x00f870D11eA43AA1c4C715c61dC045E32d232787;
address public constant PRESALE_HOLDER = 0x00577c25A81fA2401C5246F4a7D5ebaFfA4b00Aa;
uint public MAX_OPEN_SOLD = WAN_TOTAL_SUPPLY * OPEN_SALE_STAKE / DIVISOR_STAKE - PRESALE_RESERVERED_AMOUNT;
/// Fields that are only changed in constructor
/// All deposited ETH will be instantly forwarded to this address.
address public wanport;
/// Early Adopters reserved start time
uint public earlyReserveBeginTime;
/// Contribution start time
uint public startTime;
/// Contribution end time
uint public endTime;
/// Fields that can be changed by functions
/// Accumulator for open sold tokens
uint public openSoldTokens;
/// Due to an emergency, set this to true to halt the contribution
bool public halted;
/// ERC20 compilant wanchain token contact instance
WanToken public wanToken;
/// Quota for early adopters sale, Quota
mapping (address => uint256) public earlyUserQuotas;
/// tags show address can join in open sale
mapping (address => uint256) public fullWhiteList;
uint256 public normalBuyLimit = 65 ether;
/*
* EVENTS
*/
event NewSale(address indexed destAddress, uint ethCost, uint gotTokens);
//event PartnerAddressQuota(address indexed partnerAddress, uint quota);
/*
* MODIFIERS
*/
modifier onlyWallet {
require(msg.sender == wanport);
_;
}
modifier notHalted() {
require(!halted);
_;
}
modifier initialized() {
require(address(wanport) != 0x0);
_;
}
modifier notEarlierThan(uint x) {
require(now >= x);
_;
}
modifier earlierThan(uint x) {
require(now < x);
_;
}
modifier ceilingNotReached() {
require(openSoldTokens < MAX_OPEN_SOLD);
_;
}
modifier isSaleEnded() {
require(now > endTime || openSoldTokens >= MAX_OPEN_SOLD);
_;
}
/**
* CONSTRUCTOR
*
* @dev Initialize the Wanchain contribution contract
* @param _wanport The escrow account address, all ethers will be sent to this address.
* @param _bootTime ICO boot time
*/
function WanchainContribution(address _wanport, uint _bootTime){
require(_wanport != 0x0);
halted = false;
wanport = _wanport;
earlyReserveBeginTime = _bootTime;
startTime = earlyReserveBeginTime + EARLY_CONTRIBUTION_DURATION;
endTime = startTime + MAX_CONTRIBUTION_DURATION;
openSoldTokens = 0;
/// Create wanchain token contract instance
wanToken = new WanToken(this,startTime, endTime);
/// Reserve tokens according wanchain ICO rules
uint stakeMultiplier = WAN_TOTAL_SUPPLY / DIVISOR_STAKE;
wanToken.mintToken(DEV_TEAM_HOLDER, DEV_TEAM_STAKE * stakeMultiplier);
wanToken.mintToken(FOUNDATION_HOLDER, FOUNDATION_STAKE * stakeMultiplier);
wanToken.mintToken(MINERS_HOLDER, MINERS_STAKE * stakeMultiplier);
wanToken.mintToken(PRESALE_HOLDER, PRESALE_RESERVERED_AMOUNT);
}
/**
* Fallback function
*
* @dev If anybody sends Ether directly to this contract, consider he is getting wan token
*/
function () public payable {
buyWanCoin(msg.sender);
}
/*
* PUBLIC FUNCTIONS
*/
/// @dev Exchange msg.value ether to WAN for account recepient
/// @param receipient WAN tokens receiver
function buyWanCoin(address receipient)
public
payable
notHalted
initialized
ceilingNotReached
notEarlierThan(earlyReserveBeginTime)
earlierThan(endTime)
returns (bool)
{
require(receipient != 0x0);
require(msg.value >= 0.1 ether);
// Do not allow contracts to game the system
require(!isContract(msg.sender));
if( now < startTime && now >= earlyReserveBeginTime)
buyEarlyAdopters(receipient);
else {
require( tx.gasprice <= 50000000000 wei );
require(msg.value <= normalBuyLimit);
buyNormal(receipient);
}
return true;
}
function setNormalBuyLimit(uint256 limit)
public
initialized
onlyOwner
earlierThan(endTime)
{
normalBuyLimit = limit;
}
/// @dev batch set quota for early user quota
function setEarlyWhitelistQuotas(address[] users, uint earlyCap, uint openTag)
public
onlyOwner
earlierThan(earlyReserveBeginTime)
{
for( uint i = 0; i < users.length; i++) {
earlyUserQuotas[users[i]] = earlyCap;
fullWhiteList[users[i]] = openTag;
}
}
/// @dev batch set quota for early user quota
function setLaterWhiteList(address[] users, uint openTag)
public
onlyOwner
earlierThan(endTime)
{
require(saleNotEnd());
for( uint i = 0; i < users.length; i++) {
fullWhiteList[users[i]] = openTag;
}
}
/// @dev Emergency situation that requires contribution period to stop.
/// Contributing not possible anymore.
function halt() public onlyWallet{
halted = true;
}
/// @dev Emergency situation resolved.
/// Contributing becomes possible again withing the outlined restrictions.
function unHalt() public onlyWallet{
halted = false;
}
/// @dev Emergency situation
function changeWalletAddress(address newAddress) onlyWallet {
wanport = newAddress;
}
/// @return true if sale not ended, false otherwise.
function saleNotEnd() constant returns (bool) {
return now < endTime && openSoldTokens < MAX_OPEN_SOLD;
}
/// CONSTANT METHODS
/// @dev Get current exchange rate
function priceRate() public constant returns (uint) {
// Three price tiers
if (earlyReserveBeginTime <= now && now < startTime + 1 weeks)
return PRICE_RATE_FIRST;
if (startTime + 1 weeks <= now && now < startTime + 2 weeks)
return PRICE_RATE_SECOND;
if (startTime + 2 weeks <= now && now < endTime)
return PRICE_RATE_LAST;
// Should not be called before or after contribution period
assert(false);
}
function claimTokens(address receipent)
public
isSaleEnded
{
wanToken.claimTokens(receipent);
}
/*
* INTERNAL FUNCTIONS
*/
/// @dev Buy wanchain tokens for early adopters
function buyEarlyAdopters(address receipient) internal {
uint quotaAvailable = earlyUserQuotas[receipient];
require(quotaAvailable > 0);
uint toFund = quotaAvailable.min256(msg.value);
uint tokenAvailable4Adopter = toFund.mul(PRICE_RATE_FIRST);
earlyUserQuotas[receipient] = earlyUserQuotas[receipient].sub(toFund);
buyCommon(receipient, toFund, tokenAvailable4Adopter);
}
/// @dev Buy wanchain token normally
function buyNormal(address receipient) internal {
uint inWhiteListTag = fullWhiteList[receipient];
require(inWhiteListTag > 0);
// protect partner quota in stage one
uint tokenAvailable = MAX_OPEN_SOLD.sub(openSoldTokens);
require(tokenAvailable > 0);
uint toFund;
uint toCollect;
(toFund, toCollect) = costAndBuyTokens(tokenAvailable);
buyCommon(receipient, toFund, toCollect);
}
/// @dev Utility function for bug wanchain token
function buyCommon(address receipient, uint toFund, uint wanTokenCollect) internal {
require(msg.value >= toFund); // double check
if(toFund > 0) {
require(wanToken.mintToken(receipient, wanTokenCollect));
wanport.transfer(toFund);
openSoldTokens = openSoldTokens.add(wanTokenCollect);
NewSale(receipient, toFund, wanTokenCollect);
}
uint toReturn = msg.value.sub(toFund);
if(toReturn > 0) {
msg.sender.transfer(toReturn);
}
}
/// @dev Utility function for calculate available tokens and cost ethers
function costAndBuyTokens(uint availableToken) constant internal returns (uint costValue, uint getTokens){
// all conditions has checked in the caller functions
uint exchangeRate = priceRate();
getTokens = exchangeRate * msg.value;
if(availableToken >= getTokens){
costValue = msg.value;
} else {
costValue = availableToken / exchangeRate;
getTokens = availableToken;
}
}
/// @dev Internal function to determine if an address is a contract
/// @param _addr The address being queried
/// @return True if `_addr` is a contract
function isContract(address _addr) constant internal returns(bool) {
uint size;
if (_addr == 0) return false;
assembly {
size := extcodesize(_addr)
}
return size > 0;
}
} | /// @title Wanchain Contribution Contract
/// ICO Rules according: https://www.wanchain.org/crowdsale
/// For more information about this token sale, please visit https://wanchain.org
/// @author Zane Liang - <[email protected]> | NatSpecSingleLine | priceRate | function priceRate() public constant returns (uint) {
// Three price tiers
if (earlyReserveBeginTime <= now && now < startTime + 1 weeks)
return PRICE_RATE_FIRST;
if (startTime + 1 weeks <= now && now < startTime + 2 weeks)
return PRICE_RATE_SECOND;
if (startTime + 2 weeks <= now && now < endTime)
return PRICE_RATE_LAST;
// Should not be called before or after contribution period
assert(false);
}
| /// CONSTANT METHODS
/// @dev Get current exchange rate | NatSpecSingleLine | v0.4.13+commit.fb4cb1a | bzzr://cf354415565dbcba55ca7d803241ed623e9875b86e7d49619e734c70d0b4d0bf | {
"func_code_index": [
8125,
8627
]
} | 5,038 |
|
WanchainContribution | WanchainContribution.sol | 0xaac3090257be280087d8bdc530265203d105b120 | Solidity | WanchainContribution | contract WanchainContribution is Owned {
using SafeMath for uint;
/// Constant fields
/// Wanchain total tokens supply
uint public constant WAN_TOTAL_SUPPLY = 210000000 ether;
uint public constant EARLY_CONTRIBUTION_DURATION = 24 hours;
uint public constant MAX_CONTRIBUTION_DURATION = 3 weeks;
/// Exchange rates for first phase
uint public constant PRICE_RATE_FIRST = 880;
/// Exchange rates for second phase
uint public constant PRICE_RATE_SECOND = 790;
/// Exchange rates for last phase
uint public constant PRICE_RATE_LAST = 750;
/// ----------------------------------------------------------------------------------------------------
/// | | | | |
/// | PUBLIC SALE (PRESALE + OPEN SALE) | DEV TEAM | FOUNDATION | MINER |
/// | 51% | 20% | 19% | 10% |
/// ----------------------------------------------------------------------------------------------------
/// OPEN_SALE_STAKE + PRESALE_STAKE = 51; 51% sale for public
uint public constant OPEN_SALE_STAKE = 510; // 51% for open sale
// Reserved stakes
uint public constant DEV_TEAM_STAKE = 200; // 20%
uint public constant FOUNDATION_STAKE = 190; // 19%
uint public constant MINERS_STAKE = 100; // 10%
uint public constant DIVISOR_STAKE = 1000;
uint public constant PRESALE_RESERVERED_AMOUNT = 41506655 ether; //presale prize amount(40000*880)
/// Holder address for presale and reserved tokens
/// TODO: change addressed before deployed to main net
// Addresses of Patrons
address public constant DEV_TEAM_HOLDER = 0x0001cdC69b1eb8bCCE29311C01092Bdcc92f8f8F;
address public constant FOUNDATION_HOLDER = 0x00dB4023b32008C45E62Add57De256a9399752D4;
address public constant MINERS_HOLDER = 0x00f870D11eA43AA1c4C715c61dC045E32d232787;
address public constant PRESALE_HOLDER = 0x00577c25A81fA2401C5246F4a7D5ebaFfA4b00Aa;
uint public MAX_OPEN_SOLD = WAN_TOTAL_SUPPLY * OPEN_SALE_STAKE / DIVISOR_STAKE - PRESALE_RESERVERED_AMOUNT;
/// Fields that are only changed in constructor
/// All deposited ETH will be instantly forwarded to this address.
address public wanport;
/// Early Adopters reserved start time
uint public earlyReserveBeginTime;
/// Contribution start time
uint public startTime;
/// Contribution end time
uint public endTime;
/// Fields that can be changed by functions
/// Accumulator for open sold tokens
uint public openSoldTokens;
/// Due to an emergency, set this to true to halt the contribution
bool public halted;
/// ERC20 compilant wanchain token contact instance
WanToken public wanToken;
/// Quota for early adopters sale, Quota
mapping (address => uint256) public earlyUserQuotas;
/// tags show address can join in open sale
mapping (address => uint256) public fullWhiteList;
uint256 public normalBuyLimit = 65 ether;
/*
* EVENTS
*/
event NewSale(address indexed destAddress, uint ethCost, uint gotTokens);
//event PartnerAddressQuota(address indexed partnerAddress, uint quota);
/*
* MODIFIERS
*/
modifier onlyWallet {
require(msg.sender == wanport);
_;
}
modifier notHalted() {
require(!halted);
_;
}
modifier initialized() {
require(address(wanport) != 0x0);
_;
}
modifier notEarlierThan(uint x) {
require(now >= x);
_;
}
modifier earlierThan(uint x) {
require(now < x);
_;
}
modifier ceilingNotReached() {
require(openSoldTokens < MAX_OPEN_SOLD);
_;
}
modifier isSaleEnded() {
require(now > endTime || openSoldTokens >= MAX_OPEN_SOLD);
_;
}
/**
* CONSTRUCTOR
*
* @dev Initialize the Wanchain contribution contract
* @param _wanport The escrow account address, all ethers will be sent to this address.
* @param _bootTime ICO boot time
*/
function WanchainContribution(address _wanport, uint _bootTime){
require(_wanport != 0x0);
halted = false;
wanport = _wanport;
earlyReserveBeginTime = _bootTime;
startTime = earlyReserveBeginTime + EARLY_CONTRIBUTION_DURATION;
endTime = startTime + MAX_CONTRIBUTION_DURATION;
openSoldTokens = 0;
/// Create wanchain token contract instance
wanToken = new WanToken(this,startTime, endTime);
/// Reserve tokens according wanchain ICO rules
uint stakeMultiplier = WAN_TOTAL_SUPPLY / DIVISOR_STAKE;
wanToken.mintToken(DEV_TEAM_HOLDER, DEV_TEAM_STAKE * stakeMultiplier);
wanToken.mintToken(FOUNDATION_HOLDER, FOUNDATION_STAKE * stakeMultiplier);
wanToken.mintToken(MINERS_HOLDER, MINERS_STAKE * stakeMultiplier);
wanToken.mintToken(PRESALE_HOLDER, PRESALE_RESERVERED_AMOUNT);
}
/**
* Fallback function
*
* @dev If anybody sends Ether directly to this contract, consider he is getting wan token
*/
function () public payable {
buyWanCoin(msg.sender);
}
/*
* PUBLIC FUNCTIONS
*/
/// @dev Exchange msg.value ether to WAN for account recepient
/// @param receipient WAN tokens receiver
function buyWanCoin(address receipient)
public
payable
notHalted
initialized
ceilingNotReached
notEarlierThan(earlyReserveBeginTime)
earlierThan(endTime)
returns (bool)
{
require(receipient != 0x0);
require(msg.value >= 0.1 ether);
// Do not allow contracts to game the system
require(!isContract(msg.sender));
if( now < startTime && now >= earlyReserveBeginTime)
buyEarlyAdopters(receipient);
else {
require( tx.gasprice <= 50000000000 wei );
require(msg.value <= normalBuyLimit);
buyNormal(receipient);
}
return true;
}
function setNormalBuyLimit(uint256 limit)
public
initialized
onlyOwner
earlierThan(endTime)
{
normalBuyLimit = limit;
}
/// @dev batch set quota for early user quota
function setEarlyWhitelistQuotas(address[] users, uint earlyCap, uint openTag)
public
onlyOwner
earlierThan(earlyReserveBeginTime)
{
for( uint i = 0; i < users.length; i++) {
earlyUserQuotas[users[i]] = earlyCap;
fullWhiteList[users[i]] = openTag;
}
}
/// @dev batch set quota for early user quota
function setLaterWhiteList(address[] users, uint openTag)
public
onlyOwner
earlierThan(endTime)
{
require(saleNotEnd());
for( uint i = 0; i < users.length; i++) {
fullWhiteList[users[i]] = openTag;
}
}
/// @dev Emergency situation that requires contribution period to stop.
/// Contributing not possible anymore.
function halt() public onlyWallet{
halted = true;
}
/// @dev Emergency situation resolved.
/// Contributing becomes possible again withing the outlined restrictions.
function unHalt() public onlyWallet{
halted = false;
}
/// @dev Emergency situation
function changeWalletAddress(address newAddress) onlyWallet {
wanport = newAddress;
}
/// @return true if sale not ended, false otherwise.
function saleNotEnd() constant returns (bool) {
return now < endTime && openSoldTokens < MAX_OPEN_SOLD;
}
/// CONSTANT METHODS
/// @dev Get current exchange rate
function priceRate() public constant returns (uint) {
// Three price tiers
if (earlyReserveBeginTime <= now && now < startTime + 1 weeks)
return PRICE_RATE_FIRST;
if (startTime + 1 weeks <= now && now < startTime + 2 weeks)
return PRICE_RATE_SECOND;
if (startTime + 2 weeks <= now && now < endTime)
return PRICE_RATE_LAST;
// Should not be called before or after contribution period
assert(false);
}
function claimTokens(address receipent)
public
isSaleEnded
{
wanToken.claimTokens(receipent);
}
/*
* INTERNAL FUNCTIONS
*/
/// @dev Buy wanchain tokens for early adopters
function buyEarlyAdopters(address receipient) internal {
uint quotaAvailable = earlyUserQuotas[receipient];
require(quotaAvailable > 0);
uint toFund = quotaAvailable.min256(msg.value);
uint tokenAvailable4Adopter = toFund.mul(PRICE_RATE_FIRST);
earlyUserQuotas[receipient] = earlyUserQuotas[receipient].sub(toFund);
buyCommon(receipient, toFund, tokenAvailable4Adopter);
}
/// @dev Buy wanchain token normally
function buyNormal(address receipient) internal {
uint inWhiteListTag = fullWhiteList[receipient];
require(inWhiteListTag > 0);
// protect partner quota in stage one
uint tokenAvailable = MAX_OPEN_SOLD.sub(openSoldTokens);
require(tokenAvailable > 0);
uint toFund;
uint toCollect;
(toFund, toCollect) = costAndBuyTokens(tokenAvailable);
buyCommon(receipient, toFund, toCollect);
}
/// @dev Utility function for bug wanchain token
function buyCommon(address receipient, uint toFund, uint wanTokenCollect) internal {
require(msg.value >= toFund); // double check
if(toFund > 0) {
require(wanToken.mintToken(receipient, wanTokenCollect));
wanport.transfer(toFund);
openSoldTokens = openSoldTokens.add(wanTokenCollect);
NewSale(receipient, toFund, wanTokenCollect);
}
uint toReturn = msg.value.sub(toFund);
if(toReturn > 0) {
msg.sender.transfer(toReturn);
}
}
/// @dev Utility function for calculate available tokens and cost ethers
function costAndBuyTokens(uint availableToken) constant internal returns (uint costValue, uint getTokens){
// all conditions has checked in the caller functions
uint exchangeRate = priceRate();
getTokens = exchangeRate * msg.value;
if(availableToken >= getTokens){
costValue = msg.value;
} else {
costValue = availableToken / exchangeRate;
getTokens = availableToken;
}
}
/// @dev Internal function to determine if an address is a contract
/// @param _addr The address being queried
/// @return True if `_addr` is a contract
function isContract(address _addr) constant internal returns(bool) {
uint size;
if (_addr == 0) return false;
assembly {
size := extcodesize(_addr)
}
return size > 0;
}
} | /// @title Wanchain Contribution Contract
/// ICO Rules according: https://www.wanchain.org/crowdsale
/// For more information about this token sale, please visit https://wanchain.org
/// @author Zane Liang - <[email protected]> | NatSpecSingleLine | buyEarlyAdopters | function buyEarlyAdopters(address receipient) internal {
uint quotaAvailable = earlyUserQuotas[receipient];
require(quotaAvailable > 0);
uint toFund = quotaAvailable.min256(msg.value);
uint tokenAvailable4Adopter = toFund.mul(PRICE_RATE_FIRST);
earlyUserQuotas[receipient] = earlyUserQuotas[receipient].sub(toFund);
buyCommon(receipient, toFund, tokenAvailable4Adopter);
}
| /// @dev Buy wanchain tokens for early adopters | NatSpecSingleLine | v0.4.13+commit.fb4cb1a | bzzr://cf354415565dbcba55ca7d803241ed623e9875b86e7d49619e734c70d0b4d0bf | {
"func_code_index": [
8869,
9301
]
} | 5,039 |
|
WanchainContribution | WanchainContribution.sol | 0xaac3090257be280087d8bdc530265203d105b120 | Solidity | WanchainContribution | contract WanchainContribution is Owned {
using SafeMath for uint;
/// Constant fields
/// Wanchain total tokens supply
uint public constant WAN_TOTAL_SUPPLY = 210000000 ether;
uint public constant EARLY_CONTRIBUTION_DURATION = 24 hours;
uint public constant MAX_CONTRIBUTION_DURATION = 3 weeks;
/// Exchange rates for first phase
uint public constant PRICE_RATE_FIRST = 880;
/// Exchange rates for second phase
uint public constant PRICE_RATE_SECOND = 790;
/// Exchange rates for last phase
uint public constant PRICE_RATE_LAST = 750;
/// ----------------------------------------------------------------------------------------------------
/// | | | | |
/// | PUBLIC SALE (PRESALE + OPEN SALE) | DEV TEAM | FOUNDATION | MINER |
/// | 51% | 20% | 19% | 10% |
/// ----------------------------------------------------------------------------------------------------
/// OPEN_SALE_STAKE + PRESALE_STAKE = 51; 51% sale for public
uint public constant OPEN_SALE_STAKE = 510; // 51% for open sale
// Reserved stakes
uint public constant DEV_TEAM_STAKE = 200; // 20%
uint public constant FOUNDATION_STAKE = 190; // 19%
uint public constant MINERS_STAKE = 100; // 10%
uint public constant DIVISOR_STAKE = 1000;
uint public constant PRESALE_RESERVERED_AMOUNT = 41506655 ether; //presale prize amount(40000*880)
/// Holder address for presale and reserved tokens
/// TODO: change addressed before deployed to main net
// Addresses of Patrons
address public constant DEV_TEAM_HOLDER = 0x0001cdC69b1eb8bCCE29311C01092Bdcc92f8f8F;
address public constant FOUNDATION_HOLDER = 0x00dB4023b32008C45E62Add57De256a9399752D4;
address public constant MINERS_HOLDER = 0x00f870D11eA43AA1c4C715c61dC045E32d232787;
address public constant PRESALE_HOLDER = 0x00577c25A81fA2401C5246F4a7D5ebaFfA4b00Aa;
uint public MAX_OPEN_SOLD = WAN_TOTAL_SUPPLY * OPEN_SALE_STAKE / DIVISOR_STAKE - PRESALE_RESERVERED_AMOUNT;
/// Fields that are only changed in constructor
/// All deposited ETH will be instantly forwarded to this address.
address public wanport;
/// Early Adopters reserved start time
uint public earlyReserveBeginTime;
/// Contribution start time
uint public startTime;
/// Contribution end time
uint public endTime;
/// Fields that can be changed by functions
/// Accumulator for open sold tokens
uint public openSoldTokens;
/// Due to an emergency, set this to true to halt the contribution
bool public halted;
/// ERC20 compilant wanchain token contact instance
WanToken public wanToken;
/// Quota for early adopters sale, Quota
mapping (address => uint256) public earlyUserQuotas;
/// tags show address can join in open sale
mapping (address => uint256) public fullWhiteList;
uint256 public normalBuyLimit = 65 ether;
/*
* EVENTS
*/
event NewSale(address indexed destAddress, uint ethCost, uint gotTokens);
//event PartnerAddressQuota(address indexed partnerAddress, uint quota);
/*
* MODIFIERS
*/
modifier onlyWallet {
require(msg.sender == wanport);
_;
}
modifier notHalted() {
require(!halted);
_;
}
modifier initialized() {
require(address(wanport) != 0x0);
_;
}
modifier notEarlierThan(uint x) {
require(now >= x);
_;
}
modifier earlierThan(uint x) {
require(now < x);
_;
}
modifier ceilingNotReached() {
require(openSoldTokens < MAX_OPEN_SOLD);
_;
}
modifier isSaleEnded() {
require(now > endTime || openSoldTokens >= MAX_OPEN_SOLD);
_;
}
/**
* CONSTRUCTOR
*
* @dev Initialize the Wanchain contribution contract
* @param _wanport The escrow account address, all ethers will be sent to this address.
* @param _bootTime ICO boot time
*/
function WanchainContribution(address _wanport, uint _bootTime){
require(_wanport != 0x0);
halted = false;
wanport = _wanport;
earlyReserveBeginTime = _bootTime;
startTime = earlyReserveBeginTime + EARLY_CONTRIBUTION_DURATION;
endTime = startTime + MAX_CONTRIBUTION_DURATION;
openSoldTokens = 0;
/// Create wanchain token contract instance
wanToken = new WanToken(this,startTime, endTime);
/// Reserve tokens according wanchain ICO rules
uint stakeMultiplier = WAN_TOTAL_SUPPLY / DIVISOR_STAKE;
wanToken.mintToken(DEV_TEAM_HOLDER, DEV_TEAM_STAKE * stakeMultiplier);
wanToken.mintToken(FOUNDATION_HOLDER, FOUNDATION_STAKE * stakeMultiplier);
wanToken.mintToken(MINERS_HOLDER, MINERS_STAKE * stakeMultiplier);
wanToken.mintToken(PRESALE_HOLDER, PRESALE_RESERVERED_AMOUNT);
}
/**
* Fallback function
*
* @dev If anybody sends Ether directly to this contract, consider he is getting wan token
*/
function () public payable {
buyWanCoin(msg.sender);
}
/*
* PUBLIC FUNCTIONS
*/
/// @dev Exchange msg.value ether to WAN for account recepient
/// @param receipient WAN tokens receiver
function buyWanCoin(address receipient)
public
payable
notHalted
initialized
ceilingNotReached
notEarlierThan(earlyReserveBeginTime)
earlierThan(endTime)
returns (bool)
{
require(receipient != 0x0);
require(msg.value >= 0.1 ether);
// Do not allow contracts to game the system
require(!isContract(msg.sender));
if( now < startTime && now >= earlyReserveBeginTime)
buyEarlyAdopters(receipient);
else {
require( tx.gasprice <= 50000000000 wei );
require(msg.value <= normalBuyLimit);
buyNormal(receipient);
}
return true;
}
function setNormalBuyLimit(uint256 limit)
public
initialized
onlyOwner
earlierThan(endTime)
{
normalBuyLimit = limit;
}
/// @dev batch set quota for early user quota
function setEarlyWhitelistQuotas(address[] users, uint earlyCap, uint openTag)
public
onlyOwner
earlierThan(earlyReserveBeginTime)
{
for( uint i = 0; i < users.length; i++) {
earlyUserQuotas[users[i]] = earlyCap;
fullWhiteList[users[i]] = openTag;
}
}
/// @dev batch set quota for early user quota
function setLaterWhiteList(address[] users, uint openTag)
public
onlyOwner
earlierThan(endTime)
{
require(saleNotEnd());
for( uint i = 0; i < users.length; i++) {
fullWhiteList[users[i]] = openTag;
}
}
/// @dev Emergency situation that requires contribution period to stop.
/// Contributing not possible anymore.
function halt() public onlyWallet{
halted = true;
}
/// @dev Emergency situation resolved.
/// Contributing becomes possible again withing the outlined restrictions.
function unHalt() public onlyWallet{
halted = false;
}
/// @dev Emergency situation
function changeWalletAddress(address newAddress) onlyWallet {
wanport = newAddress;
}
/// @return true if sale not ended, false otherwise.
function saleNotEnd() constant returns (bool) {
return now < endTime && openSoldTokens < MAX_OPEN_SOLD;
}
/// CONSTANT METHODS
/// @dev Get current exchange rate
function priceRate() public constant returns (uint) {
// Three price tiers
if (earlyReserveBeginTime <= now && now < startTime + 1 weeks)
return PRICE_RATE_FIRST;
if (startTime + 1 weeks <= now && now < startTime + 2 weeks)
return PRICE_RATE_SECOND;
if (startTime + 2 weeks <= now && now < endTime)
return PRICE_RATE_LAST;
// Should not be called before or after contribution period
assert(false);
}
function claimTokens(address receipent)
public
isSaleEnded
{
wanToken.claimTokens(receipent);
}
/*
* INTERNAL FUNCTIONS
*/
/// @dev Buy wanchain tokens for early adopters
function buyEarlyAdopters(address receipient) internal {
uint quotaAvailable = earlyUserQuotas[receipient];
require(quotaAvailable > 0);
uint toFund = quotaAvailable.min256(msg.value);
uint tokenAvailable4Adopter = toFund.mul(PRICE_RATE_FIRST);
earlyUserQuotas[receipient] = earlyUserQuotas[receipient].sub(toFund);
buyCommon(receipient, toFund, tokenAvailable4Adopter);
}
/// @dev Buy wanchain token normally
function buyNormal(address receipient) internal {
uint inWhiteListTag = fullWhiteList[receipient];
require(inWhiteListTag > 0);
// protect partner quota in stage one
uint tokenAvailable = MAX_OPEN_SOLD.sub(openSoldTokens);
require(tokenAvailable > 0);
uint toFund;
uint toCollect;
(toFund, toCollect) = costAndBuyTokens(tokenAvailable);
buyCommon(receipient, toFund, toCollect);
}
/// @dev Utility function for bug wanchain token
function buyCommon(address receipient, uint toFund, uint wanTokenCollect) internal {
require(msg.value >= toFund); // double check
if(toFund > 0) {
require(wanToken.mintToken(receipient, wanTokenCollect));
wanport.transfer(toFund);
openSoldTokens = openSoldTokens.add(wanTokenCollect);
NewSale(receipient, toFund, wanTokenCollect);
}
uint toReturn = msg.value.sub(toFund);
if(toReturn > 0) {
msg.sender.transfer(toReturn);
}
}
/// @dev Utility function for calculate available tokens and cost ethers
function costAndBuyTokens(uint availableToken) constant internal returns (uint costValue, uint getTokens){
// all conditions has checked in the caller functions
uint exchangeRate = priceRate();
getTokens = exchangeRate * msg.value;
if(availableToken >= getTokens){
costValue = msg.value;
} else {
costValue = availableToken / exchangeRate;
getTokens = availableToken;
}
}
/// @dev Internal function to determine if an address is a contract
/// @param _addr The address being queried
/// @return True if `_addr` is a contract
function isContract(address _addr) constant internal returns(bool) {
uint size;
if (_addr == 0) return false;
assembly {
size := extcodesize(_addr)
}
return size > 0;
}
} | /// @title Wanchain Contribution Contract
/// ICO Rules according: https://www.wanchain.org/crowdsale
/// For more information about this token sale, please visit https://wanchain.org
/// @author Zane Liang - <[email protected]> | NatSpecSingleLine | buyNormal | function buyNormal(address receipient) internal {
uint inWhiteListTag = fullWhiteList[receipient];
require(inWhiteListTag > 0);
// protect partner quota in stage one
uint tokenAvailable = MAX_OPEN_SOLD.sub(openSoldTokens);
require(tokenAvailable > 0);
uint toFund;
uint toCollect;
(toFund, toCollect) = costAndBuyTokens(tokenAvailable);
buyCommon(receipient, toFund, toCollect);
}
| /// @dev Buy wanchain token normally | NatSpecSingleLine | v0.4.13+commit.fb4cb1a | bzzr://cf354415565dbcba55ca7d803241ed623e9875b86e7d49619e734c70d0b4d0bf | {
"func_code_index": [
9346,
9815
]
} | 5,040 |
|
WanchainContribution | WanchainContribution.sol | 0xaac3090257be280087d8bdc530265203d105b120 | Solidity | WanchainContribution | contract WanchainContribution is Owned {
using SafeMath for uint;
/// Constant fields
/// Wanchain total tokens supply
uint public constant WAN_TOTAL_SUPPLY = 210000000 ether;
uint public constant EARLY_CONTRIBUTION_DURATION = 24 hours;
uint public constant MAX_CONTRIBUTION_DURATION = 3 weeks;
/// Exchange rates for first phase
uint public constant PRICE_RATE_FIRST = 880;
/// Exchange rates for second phase
uint public constant PRICE_RATE_SECOND = 790;
/// Exchange rates for last phase
uint public constant PRICE_RATE_LAST = 750;
/// ----------------------------------------------------------------------------------------------------
/// | | | | |
/// | PUBLIC SALE (PRESALE + OPEN SALE) | DEV TEAM | FOUNDATION | MINER |
/// | 51% | 20% | 19% | 10% |
/// ----------------------------------------------------------------------------------------------------
/// OPEN_SALE_STAKE + PRESALE_STAKE = 51; 51% sale for public
uint public constant OPEN_SALE_STAKE = 510; // 51% for open sale
// Reserved stakes
uint public constant DEV_TEAM_STAKE = 200; // 20%
uint public constant FOUNDATION_STAKE = 190; // 19%
uint public constant MINERS_STAKE = 100; // 10%
uint public constant DIVISOR_STAKE = 1000;
uint public constant PRESALE_RESERVERED_AMOUNT = 41506655 ether; //presale prize amount(40000*880)
/// Holder address for presale and reserved tokens
/// TODO: change addressed before deployed to main net
// Addresses of Patrons
address public constant DEV_TEAM_HOLDER = 0x0001cdC69b1eb8bCCE29311C01092Bdcc92f8f8F;
address public constant FOUNDATION_HOLDER = 0x00dB4023b32008C45E62Add57De256a9399752D4;
address public constant MINERS_HOLDER = 0x00f870D11eA43AA1c4C715c61dC045E32d232787;
address public constant PRESALE_HOLDER = 0x00577c25A81fA2401C5246F4a7D5ebaFfA4b00Aa;
uint public MAX_OPEN_SOLD = WAN_TOTAL_SUPPLY * OPEN_SALE_STAKE / DIVISOR_STAKE - PRESALE_RESERVERED_AMOUNT;
/// Fields that are only changed in constructor
/// All deposited ETH will be instantly forwarded to this address.
address public wanport;
/// Early Adopters reserved start time
uint public earlyReserveBeginTime;
/// Contribution start time
uint public startTime;
/// Contribution end time
uint public endTime;
/// Fields that can be changed by functions
/// Accumulator for open sold tokens
uint public openSoldTokens;
/// Due to an emergency, set this to true to halt the contribution
bool public halted;
/// ERC20 compilant wanchain token contact instance
WanToken public wanToken;
/// Quota for early adopters sale, Quota
mapping (address => uint256) public earlyUserQuotas;
/// tags show address can join in open sale
mapping (address => uint256) public fullWhiteList;
uint256 public normalBuyLimit = 65 ether;
/*
* EVENTS
*/
event NewSale(address indexed destAddress, uint ethCost, uint gotTokens);
//event PartnerAddressQuota(address indexed partnerAddress, uint quota);
/*
* MODIFIERS
*/
modifier onlyWallet {
require(msg.sender == wanport);
_;
}
modifier notHalted() {
require(!halted);
_;
}
modifier initialized() {
require(address(wanport) != 0x0);
_;
}
modifier notEarlierThan(uint x) {
require(now >= x);
_;
}
modifier earlierThan(uint x) {
require(now < x);
_;
}
modifier ceilingNotReached() {
require(openSoldTokens < MAX_OPEN_SOLD);
_;
}
modifier isSaleEnded() {
require(now > endTime || openSoldTokens >= MAX_OPEN_SOLD);
_;
}
/**
* CONSTRUCTOR
*
* @dev Initialize the Wanchain contribution contract
* @param _wanport The escrow account address, all ethers will be sent to this address.
* @param _bootTime ICO boot time
*/
function WanchainContribution(address _wanport, uint _bootTime){
require(_wanport != 0x0);
halted = false;
wanport = _wanport;
earlyReserveBeginTime = _bootTime;
startTime = earlyReserveBeginTime + EARLY_CONTRIBUTION_DURATION;
endTime = startTime + MAX_CONTRIBUTION_DURATION;
openSoldTokens = 0;
/// Create wanchain token contract instance
wanToken = new WanToken(this,startTime, endTime);
/// Reserve tokens according wanchain ICO rules
uint stakeMultiplier = WAN_TOTAL_SUPPLY / DIVISOR_STAKE;
wanToken.mintToken(DEV_TEAM_HOLDER, DEV_TEAM_STAKE * stakeMultiplier);
wanToken.mintToken(FOUNDATION_HOLDER, FOUNDATION_STAKE * stakeMultiplier);
wanToken.mintToken(MINERS_HOLDER, MINERS_STAKE * stakeMultiplier);
wanToken.mintToken(PRESALE_HOLDER, PRESALE_RESERVERED_AMOUNT);
}
/**
* Fallback function
*
* @dev If anybody sends Ether directly to this contract, consider he is getting wan token
*/
function () public payable {
buyWanCoin(msg.sender);
}
/*
* PUBLIC FUNCTIONS
*/
/// @dev Exchange msg.value ether to WAN for account recepient
/// @param receipient WAN tokens receiver
function buyWanCoin(address receipient)
public
payable
notHalted
initialized
ceilingNotReached
notEarlierThan(earlyReserveBeginTime)
earlierThan(endTime)
returns (bool)
{
require(receipient != 0x0);
require(msg.value >= 0.1 ether);
// Do not allow contracts to game the system
require(!isContract(msg.sender));
if( now < startTime && now >= earlyReserveBeginTime)
buyEarlyAdopters(receipient);
else {
require( tx.gasprice <= 50000000000 wei );
require(msg.value <= normalBuyLimit);
buyNormal(receipient);
}
return true;
}
function setNormalBuyLimit(uint256 limit)
public
initialized
onlyOwner
earlierThan(endTime)
{
normalBuyLimit = limit;
}
/// @dev batch set quota for early user quota
function setEarlyWhitelistQuotas(address[] users, uint earlyCap, uint openTag)
public
onlyOwner
earlierThan(earlyReserveBeginTime)
{
for( uint i = 0; i < users.length; i++) {
earlyUserQuotas[users[i]] = earlyCap;
fullWhiteList[users[i]] = openTag;
}
}
/// @dev batch set quota for early user quota
function setLaterWhiteList(address[] users, uint openTag)
public
onlyOwner
earlierThan(endTime)
{
require(saleNotEnd());
for( uint i = 0; i < users.length; i++) {
fullWhiteList[users[i]] = openTag;
}
}
/// @dev Emergency situation that requires contribution period to stop.
/// Contributing not possible anymore.
function halt() public onlyWallet{
halted = true;
}
/// @dev Emergency situation resolved.
/// Contributing becomes possible again withing the outlined restrictions.
function unHalt() public onlyWallet{
halted = false;
}
/// @dev Emergency situation
function changeWalletAddress(address newAddress) onlyWallet {
wanport = newAddress;
}
/// @return true if sale not ended, false otherwise.
function saleNotEnd() constant returns (bool) {
return now < endTime && openSoldTokens < MAX_OPEN_SOLD;
}
/// CONSTANT METHODS
/// @dev Get current exchange rate
function priceRate() public constant returns (uint) {
// Three price tiers
if (earlyReserveBeginTime <= now && now < startTime + 1 weeks)
return PRICE_RATE_FIRST;
if (startTime + 1 weeks <= now && now < startTime + 2 weeks)
return PRICE_RATE_SECOND;
if (startTime + 2 weeks <= now && now < endTime)
return PRICE_RATE_LAST;
// Should not be called before or after contribution period
assert(false);
}
function claimTokens(address receipent)
public
isSaleEnded
{
wanToken.claimTokens(receipent);
}
/*
* INTERNAL FUNCTIONS
*/
/// @dev Buy wanchain tokens for early adopters
function buyEarlyAdopters(address receipient) internal {
uint quotaAvailable = earlyUserQuotas[receipient];
require(quotaAvailable > 0);
uint toFund = quotaAvailable.min256(msg.value);
uint tokenAvailable4Adopter = toFund.mul(PRICE_RATE_FIRST);
earlyUserQuotas[receipient] = earlyUserQuotas[receipient].sub(toFund);
buyCommon(receipient, toFund, tokenAvailable4Adopter);
}
/// @dev Buy wanchain token normally
function buyNormal(address receipient) internal {
uint inWhiteListTag = fullWhiteList[receipient];
require(inWhiteListTag > 0);
// protect partner quota in stage one
uint tokenAvailable = MAX_OPEN_SOLD.sub(openSoldTokens);
require(tokenAvailable > 0);
uint toFund;
uint toCollect;
(toFund, toCollect) = costAndBuyTokens(tokenAvailable);
buyCommon(receipient, toFund, toCollect);
}
/// @dev Utility function for bug wanchain token
function buyCommon(address receipient, uint toFund, uint wanTokenCollect) internal {
require(msg.value >= toFund); // double check
if(toFund > 0) {
require(wanToken.mintToken(receipient, wanTokenCollect));
wanport.transfer(toFund);
openSoldTokens = openSoldTokens.add(wanTokenCollect);
NewSale(receipient, toFund, wanTokenCollect);
}
uint toReturn = msg.value.sub(toFund);
if(toReturn > 0) {
msg.sender.transfer(toReturn);
}
}
/// @dev Utility function for calculate available tokens and cost ethers
function costAndBuyTokens(uint availableToken) constant internal returns (uint costValue, uint getTokens){
// all conditions has checked in the caller functions
uint exchangeRate = priceRate();
getTokens = exchangeRate * msg.value;
if(availableToken >= getTokens){
costValue = msg.value;
} else {
costValue = availableToken / exchangeRate;
getTokens = availableToken;
}
}
/// @dev Internal function to determine if an address is a contract
/// @param _addr The address being queried
/// @return True if `_addr` is a contract
function isContract(address _addr) constant internal returns(bool) {
uint size;
if (_addr == 0) return false;
assembly {
size := extcodesize(_addr)
}
return size > 0;
}
} | /// @title Wanchain Contribution Contract
/// ICO Rules according: https://www.wanchain.org/crowdsale
/// For more information about this token sale, please visit https://wanchain.org
/// @author Zane Liang - <[email protected]> | NatSpecSingleLine | buyCommon | function buyCommon(address receipient, uint toFund, uint wanTokenCollect) internal {
require(msg.value >= toFund); // double check
if(toFund > 0) {
require(wanToken.mintToken(receipient, wanTokenCollect));
wanport.transfer(toFund);
openSoldTokens = openSoldTokens.add(wanTokenCollect);
NewSale(receipient, toFund, wanTokenCollect);
}
uint toReturn = msg.value.sub(toFund);
if(toReturn > 0) {
msg.sender.transfer(toReturn);
}
}
| /// @dev Utility function for bug wanchain token | NatSpecSingleLine | v0.4.13+commit.fb4cb1a | bzzr://cf354415565dbcba55ca7d803241ed623e9875b86e7d49619e734c70d0b4d0bf | {
"func_code_index": [
9872,
10452
]
} | 5,041 |
|
WanchainContribution | WanchainContribution.sol | 0xaac3090257be280087d8bdc530265203d105b120 | Solidity | WanchainContribution | contract WanchainContribution is Owned {
using SafeMath for uint;
/// Constant fields
/// Wanchain total tokens supply
uint public constant WAN_TOTAL_SUPPLY = 210000000 ether;
uint public constant EARLY_CONTRIBUTION_DURATION = 24 hours;
uint public constant MAX_CONTRIBUTION_DURATION = 3 weeks;
/// Exchange rates for first phase
uint public constant PRICE_RATE_FIRST = 880;
/// Exchange rates for second phase
uint public constant PRICE_RATE_SECOND = 790;
/// Exchange rates for last phase
uint public constant PRICE_RATE_LAST = 750;
/// ----------------------------------------------------------------------------------------------------
/// | | | | |
/// | PUBLIC SALE (PRESALE + OPEN SALE) | DEV TEAM | FOUNDATION | MINER |
/// | 51% | 20% | 19% | 10% |
/// ----------------------------------------------------------------------------------------------------
/// OPEN_SALE_STAKE + PRESALE_STAKE = 51; 51% sale for public
uint public constant OPEN_SALE_STAKE = 510; // 51% for open sale
// Reserved stakes
uint public constant DEV_TEAM_STAKE = 200; // 20%
uint public constant FOUNDATION_STAKE = 190; // 19%
uint public constant MINERS_STAKE = 100; // 10%
uint public constant DIVISOR_STAKE = 1000;
uint public constant PRESALE_RESERVERED_AMOUNT = 41506655 ether; //presale prize amount(40000*880)
/// Holder address for presale and reserved tokens
/// TODO: change addressed before deployed to main net
// Addresses of Patrons
address public constant DEV_TEAM_HOLDER = 0x0001cdC69b1eb8bCCE29311C01092Bdcc92f8f8F;
address public constant FOUNDATION_HOLDER = 0x00dB4023b32008C45E62Add57De256a9399752D4;
address public constant MINERS_HOLDER = 0x00f870D11eA43AA1c4C715c61dC045E32d232787;
address public constant PRESALE_HOLDER = 0x00577c25A81fA2401C5246F4a7D5ebaFfA4b00Aa;
uint public MAX_OPEN_SOLD = WAN_TOTAL_SUPPLY * OPEN_SALE_STAKE / DIVISOR_STAKE - PRESALE_RESERVERED_AMOUNT;
/// Fields that are only changed in constructor
/// All deposited ETH will be instantly forwarded to this address.
address public wanport;
/// Early Adopters reserved start time
uint public earlyReserveBeginTime;
/// Contribution start time
uint public startTime;
/// Contribution end time
uint public endTime;
/// Fields that can be changed by functions
/// Accumulator for open sold tokens
uint public openSoldTokens;
/// Due to an emergency, set this to true to halt the contribution
bool public halted;
/// ERC20 compilant wanchain token contact instance
WanToken public wanToken;
/// Quota for early adopters sale, Quota
mapping (address => uint256) public earlyUserQuotas;
/// tags show address can join in open sale
mapping (address => uint256) public fullWhiteList;
uint256 public normalBuyLimit = 65 ether;
/*
* EVENTS
*/
event NewSale(address indexed destAddress, uint ethCost, uint gotTokens);
//event PartnerAddressQuota(address indexed partnerAddress, uint quota);
/*
* MODIFIERS
*/
modifier onlyWallet {
require(msg.sender == wanport);
_;
}
modifier notHalted() {
require(!halted);
_;
}
modifier initialized() {
require(address(wanport) != 0x0);
_;
}
modifier notEarlierThan(uint x) {
require(now >= x);
_;
}
modifier earlierThan(uint x) {
require(now < x);
_;
}
modifier ceilingNotReached() {
require(openSoldTokens < MAX_OPEN_SOLD);
_;
}
modifier isSaleEnded() {
require(now > endTime || openSoldTokens >= MAX_OPEN_SOLD);
_;
}
/**
* CONSTRUCTOR
*
* @dev Initialize the Wanchain contribution contract
* @param _wanport The escrow account address, all ethers will be sent to this address.
* @param _bootTime ICO boot time
*/
function WanchainContribution(address _wanport, uint _bootTime){
require(_wanport != 0x0);
halted = false;
wanport = _wanport;
earlyReserveBeginTime = _bootTime;
startTime = earlyReserveBeginTime + EARLY_CONTRIBUTION_DURATION;
endTime = startTime + MAX_CONTRIBUTION_DURATION;
openSoldTokens = 0;
/// Create wanchain token contract instance
wanToken = new WanToken(this,startTime, endTime);
/// Reserve tokens according wanchain ICO rules
uint stakeMultiplier = WAN_TOTAL_SUPPLY / DIVISOR_STAKE;
wanToken.mintToken(DEV_TEAM_HOLDER, DEV_TEAM_STAKE * stakeMultiplier);
wanToken.mintToken(FOUNDATION_HOLDER, FOUNDATION_STAKE * stakeMultiplier);
wanToken.mintToken(MINERS_HOLDER, MINERS_STAKE * stakeMultiplier);
wanToken.mintToken(PRESALE_HOLDER, PRESALE_RESERVERED_AMOUNT);
}
/**
* Fallback function
*
* @dev If anybody sends Ether directly to this contract, consider he is getting wan token
*/
function () public payable {
buyWanCoin(msg.sender);
}
/*
* PUBLIC FUNCTIONS
*/
/// @dev Exchange msg.value ether to WAN for account recepient
/// @param receipient WAN tokens receiver
function buyWanCoin(address receipient)
public
payable
notHalted
initialized
ceilingNotReached
notEarlierThan(earlyReserveBeginTime)
earlierThan(endTime)
returns (bool)
{
require(receipient != 0x0);
require(msg.value >= 0.1 ether);
// Do not allow contracts to game the system
require(!isContract(msg.sender));
if( now < startTime && now >= earlyReserveBeginTime)
buyEarlyAdopters(receipient);
else {
require( tx.gasprice <= 50000000000 wei );
require(msg.value <= normalBuyLimit);
buyNormal(receipient);
}
return true;
}
function setNormalBuyLimit(uint256 limit)
public
initialized
onlyOwner
earlierThan(endTime)
{
normalBuyLimit = limit;
}
/// @dev batch set quota for early user quota
function setEarlyWhitelistQuotas(address[] users, uint earlyCap, uint openTag)
public
onlyOwner
earlierThan(earlyReserveBeginTime)
{
for( uint i = 0; i < users.length; i++) {
earlyUserQuotas[users[i]] = earlyCap;
fullWhiteList[users[i]] = openTag;
}
}
/// @dev batch set quota for early user quota
function setLaterWhiteList(address[] users, uint openTag)
public
onlyOwner
earlierThan(endTime)
{
require(saleNotEnd());
for( uint i = 0; i < users.length; i++) {
fullWhiteList[users[i]] = openTag;
}
}
/// @dev Emergency situation that requires contribution period to stop.
/// Contributing not possible anymore.
function halt() public onlyWallet{
halted = true;
}
/// @dev Emergency situation resolved.
/// Contributing becomes possible again withing the outlined restrictions.
function unHalt() public onlyWallet{
halted = false;
}
/// @dev Emergency situation
function changeWalletAddress(address newAddress) onlyWallet {
wanport = newAddress;
}
/// @return true if sale not ended, false otherwise.
function saleNotEnd() constant returns (bool) {
return now < endTime && openSoldTokens < MAX_OPEN_SOLD;
}
/// CONSTANT METHODS
/// @dev Get current exchange rate
function priceRate() public constant returns (uint) {
// Three price tiers
if (earlyReserveBeginTime <= now && now < startTime + 1 weeks)
return PRICE_RATE_FIRST;
if (startTime + 1 weeks <= now && now < startTime + 2 weeks)
return PRICE_RATE_SECOND;
if (startTime + 2 weeks <= now && now < endTime)
return PRICE_RATE_LAST;
// Should not be called before or after contribution period
assert(false);
}
function claimTokens(address receipent)
public
isSaleEnded
{
wanToken.claimTokens(receipent);
}
/*
* INTERNAL FUNCTIONS
*/
/// @dev Buy wanchain tokens for early adopters
function buyEarlyAdopters(address receipient) internal {
uint quotaAvailable = earlyUserQuotas[receipient];
require(quotaAvailable > 0);
uint toFund = quotaAvailable.min256(msg.value);
uint tokenAvailable4Adopter = toFund.mul(PRICE_RATE_FIRST);
earlyUserQuotas[receipient] = earlyUserQuotas[receipient].sub(toFund);
buyCommon(receipient, toFund, tokenAvailable4Adopter);
}
/// @dev Buy wanchain token normally
function buyNormal(address receipient) internal {
uint inWhiteListTag = fullWhiteList[receipient];
require(inWhiteListTag > 0);
// protect partner quota in stage one
uint tokenAvailable = MAX_OPEN_SOLD.sub(openSoldTokens);
require(tokenAvailable > 0);
uint toFund;
uint toCollect;
(toFund, toCollect) = costAndBuyTokens(tokenAvailable);
buyCommon(receipient, toFund, toCollect);
}
/// @dev Utility function for bug wanchain token
function buyCommon(address receipient, uint toFund, uint wanTokenCollect) internal {
require(msg.value >= toFund); // double check
if(toFund > 0) {
require(wanToken.mintToken(receipient, wanTokenCollect));
wanport.transfer(toFund);
openSoldTokens = openSoldTokens.add(wanTokenCollect);
NewSale(receipient, toFund, wanTokenCollect);
}
uint toReturn = msg.value.sub(toFund);
if(toReturn > 0) {
msg.sender.transfer(toReturn);
}
}
/// @dev Utility function for calculate available tokens and cost ethers
function costAndBuyTokens(uint availableToken) constant internal returns (uint costValue, uint getTokens){
// all conditions has checked in the caller functions
uint exchangeRate = priceRate();
getTokens = exchangeRate * msg.value;
if(availableToken >= getTokens){
costValue = msg.value;
} else {
costValue = availableToken / exchangeRate;
getTokens = availableToken;
}
}
/// @dev Internal function to determine if an address is a contract
/// @param _addr The address being queried
/// @return True if `_addr` is a contract
function isContract(address _addr) constant internal returns(bool) {
uint size;
if (_addr == 0) return false;
assembly {
size := extcodesize(_addr)
}
return size > 0;
}
} | /// @title Wanchain Contribution Contract
/// ICO Rules according: https://www.wanchain.org/crowdsale
/// For more information about this token sale, please visit https://wanchain.org
/// @author Zane Liang - <[email protected]> | NatSpecSingleLine | costAndBuyTokens | function costAndBuyTokens(uint availableToken) constant internal returns (uint costValue, uint getTokens){
// all conditions has checked in the caller functions
uint exchangeRate = priceRate();
getTokens = exchangeRate * msg.value;
if(availableToken >= getTokens){
costValue = msg.value;
} else {
costValue = availableToken / exchangeRate;
getTokens = availableToken;
}
}
| /// @dev Utility function for calculate available tokens and cost ethers | NatSpecSingleLine | v0.4.13+commit.fb4cb1a | bzzr://cf354415565dbcba55ca7d803241ed623e9875b86e7d49619e734c70d0b4d0bf | {
"func_code_index": [
10533,
10985
]
} | 5,042 |
|
WanchainContribution | WanchainContribution.sol | 0xaac3090257be280087d8bdc530265203d105b120 | Solidity | WanchainContribution | contract WanchainContribution is Owned {
using SafeMath for uint;
/// Constant fields
/// Wanchain total tokens supply
uint public constant WAN_TOTAL_SUPPLY = 210000000 ether;
uint public constant EARLY_CONTRIBUTION_DURATION = 24 hours;
uint public constant MAX_CONTRIBUTION_DURATION = 3 weeks;
/// Exchange rates for first phase
uint public constant PRICE_RATE_FIRST = 880;
/// Exchange rates for second phase
uint public constant PRICE_RATE_SECOND = 790;
/// Exchange rates for last phase
uint public constant PRICE_RATE_LAST = 750;
/// ----------------------------------------------------------------------------------------------------
/// | | | | |
/// | PUBLIC SALE (PRESALE + OPEN SALE) | DEV TEAM | FOUNDATION | MINER |
/// | 51% | 20% | 19% | 10% |
/// ----------------------------------------------------------------------------------------------------
/// OPEN_SALE_STAKE + PRESALE_STAKE = 51; 51% sale for public
uint public constant OPEN_SALE_STAKE = 510; // 51% for open sale
// Reserved stakes
uint public constant DEV_TEAM_STAKE = 200; // 20%
uint public constant FOUNDATION_STAKE = 190; // 19%
uint public constant MINERS_STAKE = 100; // 10%
uint public constant DIVISOR_STAKE = 1000;
uint public constant PRESALE_RESERVERED_AMOUNT = 41506655 ether; //presale prize amount(40000*880)
/// Holder address for presale and reserved tokens
/// TODO: change addressed before deployed to main net
// Addresses of Patrons
address public constant DEV_TEAM_HOLDER = 0x0001cdC69b1eb8bCCE29311C01092Bdcc92f8f8F;
address public constant FOUNDATION_HOLDER = 0x00dB4023b32008C45E62Add57De256a9399752D4;
address public constant MINERS_HOLDER = 0x00f870D11eA43AA1c4C715c61dC045E32d232787;
address public constant PRESALE_HOLDER = 0x00577c25A81fA2401C5246F4a7D5ebaFfA4b00Aa;
uint public MAX_OPEN_SOLD = WAN_TOTAL_SUPPLY * OPEN_SALE_STAKE / DIVISOR_STAKE - PRESALE_RESERVERED_AMOUNT;
/// Fields that are only changed in constructor
/// All deposited ETH will be instantly forwarded to this address.
address public wanport;
/// Early Adopters reserved start time
uint public earlyReserveBeginTime;
/// Contribution start time
uint public startTime;
/// Contribution end time
uint public endTime;
/// Fields that can be changed by functions
/// Accumulator for open sold tokens
uint public openSoldTokens;
/// Due to an emergency, set this to true to halt the contribution
bool public halted;
/// ERC20 compilant wanchain token contact instance
WanToken public wanToken;
/// Quota for early adopters sale, Quota
mapping (address => uint256) public earlyUserQuotas;
/// tags show address can join in open sale
mapping (address => uint256) public fullWhiteList;
uint256 public normalBuyLimit = 65 ether;
/*
* EVENTS
*/
event NewSale(address indexed destAddress, uint ethCost, uint gotTokens);
//event PartnerAddressQuota(address indexed partnerAddress, uint quota);
/*
* MODIFIERS
*/
modifier onlyWallet {
require(msg.sender == wanport);
_;
}
modifier notHalted() {
require(!halted);
_;
}
modifier initialized() {
require(address(wanport) != 0x0);
_;
}
modifier notEarlierThan(uint x) {
require(now >= x);
_;
}
modifier earlierThan(uint x) {
require(now < x);
_;
}
modifier ceilingNotReached() {
require(openSoldTokens < MAX_OPEN_SOLD);
_;
}
modifier isSaleEnded() {
require(now > endTime || openSoldTokens >= MAX_OPEN_SOLD);
_;
}
/**
* CONSTRUCTOR
*
* @dev Initialize the Wanchain contribution contract
* @param _wanport The escrow account address, all ethers will be sent to this address.
* @param _bootTime ICO boot time
*/
function WanchainContribution(address _wanport, uint _bootTime){
require(_wanport != 0x0);
halted = false;
wanport = _wanport;
earlyReserveBeginTime = _bootTime;
startTime = earlyReserveBeginTime + EARLY_CONTRIBUTION_DURATION;
endTime = startTime + MAX_CONTRIBUTION_DURATION;
openSoldTokens = 0;
/// Create wanchain token contract instance
wanToken = new WanToken(this,startTime, endTime);
/// Reserve tokens according wanchain ICO rules
uint stakeMultiplier = WAN_TOTAL_SUPPLY / DIVISOR_STAKE;
wanToken.mintToken(DEV_TEAM_HOLDER, DEV_TEAM_STAKE * stakeMultiplier);
wanToken.mintToken(FOUNDATION_HOLDER, FOUNDATION_STAKE * stakeMultiplier);
wanToken.mintToken(MINERS_HOLDER, MINERS_STAKE * stakeMultiplier);
wanToken.mintToken(PRESALE_HOLDER, PRESALE_RESERVERED_AMOUNT);
}
/**
* Fallback function
*
* @dev If anybody sends Ether directly to this contract, consider he is getting wan token
*/
function () public payable {
buyWanCoin(msg.sender);
}
/*
* PUBLIC FUNCTIONS
*/
/// @dev Exchange msg.value ether to WAN for account recepient
/// @param receipient WAN tokens receiver
function buyWanCoin(address receipient)
public
payable
notHalted
initialized
ceilingNotReached
notEarlierThan(earlyReserveBeginTime)
earlierThan(endTime)
returns (bool)
{
require(receipient != 0x0);
require(msg.value >= 0.1 ether);
// Do not allow contracts to game the system
require(!isContract(msg.sender));
if( now < startTime && now >= earlyReserveBeginTime)
buyEarlyAdopters(receipient);
else {
require( tx.gasprice <= 50000000000 wei );
require(msg.value <= normalBuyLimit);
buyNormal(receipient);
}
return true;
}
function setNormalBuyLimit(uint256 limit)
public
initialized
onlyOwner
earlierThan(endTime)
{
normalBuyLimit = limit;
}
/// @dev batch set quota for early user quota
function setEarlyWhitelistQuotas(address[] users, uint earlyCap, uint openTag)
public
onlyOwner
earlierThan(earlyReserveBeginTime)
{
for( uint i = 0; i < users.length; i++) {
earlyUserQuotas[users[i]] = earlyCap;
fullWhiteList[users[i]] = openTag;
}
}
/// @dev batch set quota for early user quota
function setLaterWhiteList(address[] users, uint openTag)
public
onlyOwner
earlierThan(endTime)
{
require(saleNotEnd());
for( uint i = 0; i < users.length; i++) {
fullWhiteList[users[i]] = openTag;
}
}
/// @dev Emergency situation that requires contribution period to stop.
/// Contributing not possible anymore.
function halt() public onlyWallet{
halted = true;
}
/// @dev Emergency situation resolved.
/// Contributing becomes possible again withing the outlined restrictions.
function unHalt() public onlyWallet{
halted = false;
}
/// @dev Emergency situation
function changeWalletAddress(address newAddress) onlyWallet {
wanport = newAddress;
}
/// @return true if sale not ended, false otherwise.
function saleNotEnd() constant returns (bool) {
return now < endTime && openSoldTokens < MAX_OPEN_SOLD;
}
/// CONSTANT METHODS
/// @dev Get current exchange rate
function priceRate() public constant returns (uint) {
// Three price tiers
if (earlyReserveBeginTime <= now && now < startTime + 1 weeks)
return PRICE_RATE_FIRST;
if (startTime + 1 weeks <= now && now < startTime + 2 weeks)
return PRICE_RATE_SECOND;
if (startTime + 2 weeks <= now && now < endTime)
return PRICE_RATE_LAST;
// Should not be called before or after contribution period
assert(false);
}
function claimTokens(address receipent)
public
isSaleEnded
{
wanToken.claimTokens(receipent);
}
/*
* INTERNAL FUNCTIONS
*/
/// @dev Buy wanchain tokens for early adopters
function buyEarlyAdopters(address receipient) internal {
uint quotaAvailable = earlyUserQuotas[receipient];
require(quotaAvailable > 0);
uint toFund = quotaAvailable.min256(msg.value);
uint tokenAvailable4Adopter = toFund.mul(PRICE_RATE_FIRST);
earlyUserQuotas[receipient] = earlyUserQuotas[receipient].sub(toFund);
buyCommon(receipient, toFund, tokenAvailable4Adopter);
}
/// @dev Buy wanchain token normally
function buyNormal(address receipient) internal {
uint inWhiteListTag = fullWhiteList[receipient];
require(inWhiteListTag > 0);
// protect partner quota in stage one
uint tokenAvailable = MAX_OPEN_SOLD.sub(openSoldTokens);
require(tokenAvailable > 0);
uint toFund;
uint toCollect;
(toFund, toCollect) = costAndBuyTokens(tokenAvailable);
buyCommon(receipient, toFund, toCollect);
}
/// @dev Utility function for bug wanchain token
function buyCommon(address receipient, uint toFund, uint wanTokenCollect) internal {
require(msg.value >= toFund); // double check
if(toFund > 0) {
require(wanToken.mintToken(receipient, wanTokenCollect));
wanport.transfer(toFund);
openSoldTokens = openSoldTokens.add(wanTokenCollect);
NewSale(receipient, toFund, wanTokenCollect);
}
uint toReturn = msg.value.sub(toFund);
if(toReturn > 0) {
msg.sender.transfer(toReturn);
}
}
/// @dev Utility function for calculate available tokens and cost ethers
function costAndBuyTokens(uint availableToken) constant internal returns (uint costValue, uint getTokens){
// all conditions has checked in the caller functions
uint exchangeRate = priceRate();
getTokens = exchangeRate * msg.value;
if(availableToken >= getTokens){
costValue = msg.value;
} else {
costValue = availableToken / exchangeRate;
getTokens = availableToken;
}
}
/// @dev Internal function to determine if an address is a contract
/// @param _addr The address being queried
/// @return True if `_addr` is a contract
function isContract(address _addr) constant internal returns(bool) {
uint size;
if (_addr == 0) return false;
assembly {
size := extcodesize(_addr)
}
return size > 0;
}
} | /// @title Wanchain Contribution Contract
/// ICO Rules according: https://www.wanchain.org/crowdsale
/// For more information about this token sale, please visit https://wanchain.org
/// @author Zane Liang - <[email protected]> | NatSpecSingleLine | isContract | function isContract(address _addr) constant internal returns(bool) {
uint size;
if (_addr == 0) return false;
assembly {
size := extcodesize(_addr)
}
return size > 0;
}
| /// @dev Internal function to determine if an address is a contract
/// @param _addr The address being queried
/// @return True if `_addr` is a contract | NatSpecSingleLine | v0.4.13+commit.fb4cb1a | bzzr://cf354415565dbcba55ca7d803241ed623e9875b86e7d49619e734c70d0b4d0bf | {
"func_code_index": [
11156,
11392
]
} | 5,043 |
|
BabyStarl | BabyStarl.sol | 0xebc7dac5edf07bfa97b3728dd71985b48d45f418 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | totalSupply | function totalSupply() external view returns (uint256);
| /**
* @dev Returns the amount of tokens in existence.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://bb886ce1f95a2a607e37c279c7a40bb205af2d9cf6893e706726934a70edd0d5 | {
"func_code_index": [
94,
154
]
} | 5,044 |
||
BabyStarl | BabyStarl.sol | 0xebc7dac5edf07bfa97b3728dd71985b48d45f418 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | balanceOf | function balanceOf(address account) external view returns (uint256);
| /**
* @dev Returns the amount of tokens owned by `account`.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://bb886ce1f95a2a607e37c279c7a40bb205af2d9cf6893e706726934a70edd0d5 | {
"func_code_index": [
237,
310
]
} | 5,045 |
||
BabyStarl | BabyStarl.sol | 0xebc7dac5edf07bfa97b3728dd71985b48d45f418 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | transfer | function transfer(address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://bb886ce1f95a2a607e37c279c7a40bb205af2d9cf6893e706726934a70edd0d5 | {
"func_code_index": [
534,
616
]
} | 5,046 |
||
BabyStarl | BabyStarl.sol | 0xebc7dac5edf07bfa97b3728dd71985b48d45f418 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | allowance | function allowance(address owner, address spender) external view returns (uint256);
| /**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://bb886ce1f95a2a607e37c279c7a40bb205af2d9cf6893e706726934a70edd0d5 | {
"func_code_index": [
895,
983
]
} | 5,047 |
||
BabyStarl | BabyStarl.sol | 0xebc7dac5edf07bfa97b3728dd71985b48d45f418 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | approve | function approve(address spender, uint256 amount) external returns (bool);
| /**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://bb886ce1f95a2a607e37c279c7a40bb205af2d9cf6893e706726934a70edd0d5 | {
"func_code_index": [
1647,
1726
]
} | 5,048 |
||
BabyStarl | BabyStarl.sol | 0xebc7dac5edf07bfa97b3728dd71985b48d45f418 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | transferFrom | function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://bb886ce1f95a2a607e37c279c7a40bb205af2d9cf6893e706726934a70edd0d5 | {
"func_code_index": [
2039,
2141
]
} | 5,049 |
||
BabyStarl | BabyStarl.sol | 0xebc7dac5edf07bfa97b3728dd71985b48d45f418 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | add | function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
| /**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://bb886ce1f95a2a607e37c279c7a40bb205af2d9cf6893e706726934a70edd0d5 | {
"func_code_index": [
259,
445
]
} | 5,050 |
||
BabyStarl | BabyStarl.sol | 0xebc7dac5edf07bfa97b3728dd71985b48d45f418 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | sub | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://bb886ce1f95a2a607e37c279c7a40bb205af2d9cf6893e706726934a70edd0d5 | {
"func_code_index": [
723,
864
]
} | 5,051 |
||
BabyStarl | BabyStarl.sol | 0xebc7dac5edf07bfa97b3728dd71985b48d45f418 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | sub | function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://bb886ce1f95a2a607e37c279c7a40bb205af2d9cf6893e706726934a70edd0d5 | {
"func_code_index": [
1162,
1359
]
} | 5,052 |
||
BabyStarl | BabyStarl.sol | 0xebc7dac5edf07bfa97b3728dd71985b48d45f418 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
| /**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://bb886ce1f95a2a607e37c279c7a40bb205af2d9cf6893e706726934a70edd0d5 | {
"func_code_index": [
1613,
2089
]
} | 5,053 |
||
BabyStarl | BabyStarl.sol | 0xebc7dac5edf07bfa97b3728dd71985b48d45f418 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | div | function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
| /**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://bb886ce1f95a2a607e37c279c7a40bb205af2d9cf6893e706726934a70edd0d5 | {
"func_code_index": [
2560,
2697
]
} | 5,054 |
||
BabyStarl | BabyStarl.sol | 0xebc7dac5edf07bfa97b3728dd71985b48d45f418 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | div | function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
| /**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://bb886ce1f95a2a607e37c279c7a40bb205af2d9cf6893e706726934a70edd0d5 | {
"func_code_index": [
3188,
3471
]
} | 5,055 |
||
BabyStarl | BabyStarl.sol | 0xebc7dac5edf07bfa97b3728dd71985b48d45f418 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | mod | function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
| /**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://bb886ce1f95a2a607e37c279c7a40bb205af2d9cf6893e706726934a70edd0d5 | {
"func_code_index": [
3931,
4066
]
} | 5,056 |
||
BabyStarl | BabyStarl.sol | 0xebc7dac5edf07bfa97b3728dd71985b48d45f418 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | mod | function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
| /**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://bb886ce1f95a2a607e37c279c7a40bb205af2d9cf6893e706726934a70edd0d5 | {
"func_code_index": [
4546,
4717
]
} | 5,057 |
||
BabyStarl | BabyStarl.sol | 0xebc7dac5edf07bfa97b3728dd71985b48d45f418 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | isContract | function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
| /**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://bb886ce1f95a2a607e37c279c7a40bb205af2d9cf6893e706726934a70edd0d5 | {
"func_code_index": [
606,
1230
]
} | 5,058 |
||
BabyStarl | BabyStarl.sol | 0xebc7dac5edf07bfa97b3728dd71985b48d45f418 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | sendValue | function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
| /**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://bb886ce1f95a2a607e37c279c7a40bb205af2d9cf6893e706726934a70edd0d5 | {
"func_code_index": [
2160,
2562
]
} | 5,059 |
||
BabyStarl | BabyStarl.sol | 0xebc7dac5edf07bfa97b3728dd71985b48d45f418 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | functionCall | function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
| /**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://bb886ce1f95a2a607e37c279c7a40bb205af2d9cf6893e706726934a70edd0d5 | {
"func_code_index": [
3318,
3496
]
} | 5,060 |
||
BabyStarl | BabyStarl.sol | 0xebc7dac5edf07bfa97b3728dd71985b48d45f418 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | functionCall | function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://bb886ce1f95a2a607e37c279c7a40bb205af2d9cf6893e706726934a70edd0d5 | {
"func_code_index": [
3721,
3922
]
} | 5,061 |
||
BabyStarl | BabyStarl.sol | 0xebc7dac5edf07bfa97b3728dd71985b48d45f418 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | functionCallWithValue | function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://bb886ce1f95a2a607e37c279c7a40bb205af2d9cf6893e706726934a70edd0d5 | {
"func_code_index": [
4292,
4523
]
} | 5,062 |
||
BabyStarl | BabyStarl.sol | 0xebc7dac5edf07bfa97b3728dd71985b48d45f418 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | functionCallWithValue | function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
| /**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://bb886ce1f95a2a607e37c279c7a40bb205af2d9cf6893e706726934a70edd0d5 | {
"func_code_index": [
4774,
5095
]
} | 5,063 |
||
BabyStarl | BabyStarl.sol | 0xebc7dac5edf07bfa97b3728dd71985b48d45f418 | Solidity | Ownable | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
} | owner | function owner() public view returns (address) {
return _owner;
}
| /**
* @dev Returns the address of the current owner.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://bb886ce1f95a2a607e37c279c7a40bb205af2d9cf6893e706726934a70edd0d5 | {
"func_code_index": [
497,
581
]
} | 5,064 |
||
BabyStarl | BabyStarl.sol | 0xebc7dac5edf07bfa97b3728dd71985b48d45f418 | Solidity | Ownable | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
} | renounceOwnership | function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
| /**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://bb886ce1f95a2a607e37c279c7a40bb205af2d9cf6893e706726934a70edd0d5 | {
"func_code_index": [
1139,
1292
]
} | 5,065 |
||
BabyStarl | BabyStarl.sol | 0xebc7dac5edf07bfa97b3728dd71985b48d45f418 | Solidity | Ownable | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
} | transferOwnership | function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
| /**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://bb886ce1f95a2a607e37c279c7a40bb205af2d9cf6893e706726934a70edd0d5 | {
"func_code_index": [
1442,
1691
]
} | 5,066 |
||
iETHRewards | contracts/iETHRewards.sol | 0x0333bd82e1f5ff89c19ec44ab5302a0041b33139 | Solidity | iETHRewards | contract iETHRewards is LPTokenWrapper, IRewardDistributionRecipient {
IERC20 public snx = IERC20(0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F);
uint256 public constant DURATION = 7 days;
uint256 public periodFinish = 0;
uint256 public rewardRate = 0;
uint256 public lastUpdateTime;
uint256 public rewardPerTokenStored;
mapping(address => uint256) public userRewardPerTokenPaid;
mapping(address => uint256) public rewards;
event RewardAdded(uint256 reward);
event Staked(address indexed user, uint256 amount);
event Withdrawn(address indexed user, uint256 amount);
event RewardPaid(address indexed user, uint256 reward);
modifier updateReward(address account) {
rewardPerTokenStored = rewardPerToken();
lastUpdateTime = lastTimeRewardApplicable();
if (account != address(0)) {
rewards[account] = earned(account);
userRewardPerTokenPaid[account] = rewardPerTokenStored;
}
_;
}
function lastTimeRewardApplicable() public view returns (uint256) {
return Math.min(block.timestamp, periodFinish);
}
function rewardPerToken() public view returns (uint256) {
if (totalSupply() == 0) {
return rewardPerTokenStored;
}
return
rewardPerTokenStored.add(
lastTimeRewardApplicable()
.sub(lastUpdateTime)
.mul(rewardRate)
.mul(1e18)
.div(totalSupply())
);
}
function earned(address account) public view returns (uint256) {
return
balanceOf(account)
.mul(rewardPerToken().sub(userRewardPerTokenPaid[account]))
.div(1e18)
.add(rewards[account]);
}
// stake visibility is public as overriding LPTokenWrapper's stake() function
function stake(uint256 amount) public updateReward(msg.sender) {
require(amount > 0, "Cannot stake 0");
super.stake(amount);
emit Staked(msg.sender, amount);
}
function withdraw(uint256 amount) public updateReward(msg.sender) {
require(amount > 0, "Cannot withdraw 0");
super.withdraw(amount);
emit Withdrawn(msg.sender, amount);
}
function exit() external {
withdraw(balanceOf(msg.sender));
getReward();
}
function getReward() public updateReward(msg.sender) {
uint256 reward = earned(msg.sender);
if (reward > 0) {
rewards[msg.sender] = 0;
snx.safeTransfer(msg.sender, reward);
emit RewardPaid(msg.sender, reward);
}
}
function notifyRewardAmount(uint256 reward)
external
onlyRewardDistribution
updateReward(address(0))
{
if (block.timestamp >= periodFinish) {
rewardRate = reward.div(DURATION);
} else {
uint256 remaining = periodFinish.sub(block.timestamp);
uint256 leftover = remaining.mul(rewardRate);
rewardRate = reward.add(leftover).div(DURATION);
}
lastUpdateTime = block.timestamp;
periodFinish = block.timestamp.add(DURATION);
emit RewardAdded(reward);
}
} | stake | function stake(uint256 amount) public updateReward(msg.sender) {
require(amount > 0, "Cannot stake 0");
super.stake(amount);
emit Staked(msg.sender, amount);
}
| // stake visibility is public as overriding LPTokenWrapper's stake() function | LineComment | v0.5.5+commit.47a71e8f | MIT | bzzr://dae748db0658f524ef80ddcdcc1ba07e7fa6bcd7604de1cf2768ac59feea0a9a | {
"func_code_index": [
1947,
2143
]
} | 5,067 |
||
OriginalInu | OriginalInu.sol | 0x579bc1aca7f398dfa3b31e0eca30c12ce3ef80ff | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | totalSupply | function totalSupply() external view returns (uint256);
| /**
* @dev Returns the amount of tokens in existence.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://0d0ad5fe53ae667bfb4d7878ce5bd100b73b00e832cf86b5c1fa34e7a78897aa | {
"func_code_index": [
94,
154
]
} | 5,068 |
||
OriginalInu | OriginalInu.sol | 0x579bc1aca7f398dfa3b31e0eca30c12ce3ef80ff | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | balanceOf | function balanceOf(address account) external view returns (uint256);
| /**
* @dev Returns the amount of tokens owned by `account`.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://0d0ad5fe53ae667bfb4d7878ce5bd100b73b00e832cf86b5c1fa34e7a78897aa | {
"func_code_index": [
237,
310
]
} | 5,069 |
||
OriginalInu | OriginalInu.sol | 0x579bc1aca7f398dfa3b31e0eca30c12ce3ef80ff | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | transfer | function transfer(address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://0d0ad5fe53ae667bfb4d7878ce5bd100b73b00e832cf86b5c1fa34e7a78897aa | {
"func_code_index": [
534,
616
]
} | 5,070 |
||
OriginalInu | OriginalInu.sol | 0x579bc1aca7f398dfa3b31e0eca30c12ce3ef80ff | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | allowance | function allowance(address owner, address spender) external view returns (uint256);
| /**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://0d0ad5fe53ae667bfb4d7878ce5bd100b73b00e832cf86b5c1fa34e7a78897aa | {
"func_code_index": [
895,
983
]
} | 5,071 |
||
OriginalInu | OriginalInu.sol | 0x579bc1aca7f398dfa3b31e0eca30c12ce3ef80ff | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | approve | function approve(address spender, uint256 amount) external returns (bool);
| /**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://0d0ad5fe53ae667bfb4d7878ce5bd100b73b00e832cf86b5c1fa34e7a78897aa | {
"func_code_index": [
1647,
1726
]
} | 5,072 |
||
OriginalInu | OriginalInu.sol | 0x579bc1aca7f398dfa3b31e0eca30c12ce3ef80ff | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | transferFrom | function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://0d0ad5fe53ae667bfb4d7878ce5bd100b73b00e832cf86b5c1fa34e7a78897aa | {
"func_code_index": [
2039,
2141
]
} | 5,073 |
||
OriginalInu | OriginalInu.sol | 0x579bc1aca7f398dfa3b31e0eca30c12ce3ef80ff | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | add | function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
| /**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://0d0ad5fe53ae667bfb4d7878ce5bd100b73b00e832cf86b5c1fa34e7a78897aa | {
"func_code_index": [
259,
445
]
} | 5,074 |
||
OriginalInu | OriginalInu.sol | 0x579bc1aca7f398dfa3b31e0eca30c12ce3ef80ff | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | sub | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://0d0ad5fe53ae667bfb4d7878ce5bd100b73b00e832cf86b5c1fa34e7a78897aa | {
"func_code_index": [
723,
864
]
} | 5,075 |
||
OriginalInu | OriginalInu.sol | 0x579bc1aca7f398dfa3b31e0eca30c12ce3ef80ff | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | sub | function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://0d0ad5fe53ae667bfb4d7878ce5bd100b73b00e832cf86b5c1fa34e7a78897aa | {
"func_code_index": [
1162,
1359
]
} | 5,076 |
||
OriginalInu | OriginalInu.sol | 0x579bc1aca7f398dfa3b31e0eca30c12ce3ef80ff | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
| /**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://0d0ad5fe53ae667bfb4d7878ce5bd100b73b00e832cf86b5c1fa34e7a78897aa | {
"func_code_index": [
1613,
2089
]
} | 5,077 |
||
OriginalInu | OriginalInu.sol | 0x579bc1aca7f398dfa3b31e0eca30c12ce3ef80ff | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | div | function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
| /**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://0d0ad5fe53ae667bfb4d7878ce5bd100b73b00e832cf86b5c1fa34e7a78897aa | {
"func_code_index": [
2560,
2697
]
} | 5,078 |
||
OriginalInu | OriginalInu.sol | 0x579bc1aca7f398dfa3b31e0eca30c12ce3ef80ff | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | div | function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
| /**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://0d0ad5fe53ae667bfb4d7878ce5bd100b73b00e832cf86b5c1fa34e7a78897aa | {
"func_code_index": [
3188,
3471
]
} | 5,079 |
||
OriginalInu | OriginalInu.sol | 0x579bc1aca7f398dfa3b31e0eca30c12ce3ef80ff | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | mod | function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
| /**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://0d0ad5fe53ae667bfb4d7878ce5bd100b73b00e832cf86b5c1fa34e7a78897aa | {
"func_code_index": [
3931,
4066
]
} | 5,080 |
||
OriginalInu | OriginalInu.sol | 0x579bc1aca7f398dfa3b31e0eca30c12ce3ef80ff | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | mod | function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
| /**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://0d0ad5fe53ae667bfb4d7878ce5bd100b73b00e832cf86b5c1fa34e7a78897aa | {
"func_code_index": [
4546,
4717
]
} | 5,081 |
||
OriginalInu | OriginalInu.sol | 0x579bc1aca7f398dfa3b31e0eca30c12ce3ef80ff | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | isContract | function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
| /**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://0d0ad5fe53ae667bfb4d7878ce5bd100b73b00e832cf86b5c1fa34e7a78897aa | {
"func_code_index": [
606,
1230
]
} | 5,082 |
||
OriginalInu | OriginalInu.sol | 0x579bc1aca7f398dfa3b31e0eca30c12ce3ef80ff | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | sendValue | function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
| /**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://0d0ad5fe53ae667bfb4d7878ce5bd100b73b00e832cf86b5c1fa34e7a78897aa | {
"func_code_index": [
2160,
2562
]
} | 5,083 |
||
OriginalInu | OriginalInu.sol | 0x579bc1aca7f398dfa3b31e0eca30c12ce3ef80ff | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | functionCall | function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
| /**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://0d0ad5fe53ae667bfb4d7878ce5bd100b73b00e832cf86b5c1fa34e7a78897aa | {
"func_code_index": [
3318,
3496
]
} | 5,084 |
||
OriginalInu | OriginalInu.sol | 0x579bc1aca7f398dfa3b31e0eca30c12ce3ef80ff | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | functionCall | function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://0d0ad5fe53ae667bfb4d7878ce5bd100b73b00e832cf86b5c1fa34e7a78897aa | {
"func_code_index": [
3721,
3922
]
} | 5,085 |
||
OriginalInu | OriginalInu.sol | 0x579bc1aca7f398dfa3b31e0eca30c12ce3ef80ff | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | functionCallWithValue | function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://0d0ad5fe53ae667bfb4d7878ce5bd100b73b00e832cf86b5c1fa34e7a78897aa | {
"func_code_index": [
4292,
4523
]
} | 5,086 |
||
OriginalInu | OriginalInu.sol | 0x579bc1aca7f398dfa3b31e0eca30c12ce3ef80ff | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | functionCallWithValue | function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
| /**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://0d0ad5fe53ae667bfb4d7878ce5bd100b73b00e832cf86b5c1fa34e7a78897aa | {
"func_code_index": [
4774,
5095
]
} | 5,087 |
||
OriginalInu | OriginalInu.sol | 0x579bc1aca7f398dfa3b31e0eca30c12ce3ef80ff | Solidity | Ownable | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
} | owner | function owner() public view returns (address) {
return _owner;
}
| /**
* @dev Returns the address of the current owner.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://0d0ad5fe53ae667bfb4d7878ce5bd100b73b00e832cf86b5c1fa34e7a78897aa | {
"func_code_index": [
497,
581
]
} | 5,088 |
||
OriginalInu | OriginalInu.sol | 0x579bc1aca7f398dfa3b31e0eca30c12ce3ef80ff | Solidity | Ownable | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
} | renounceOwnership | function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
| /**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://0d0ad5fe53ae667bfb4d7878ce5bd100b73b00e832cf86b5c1fa34e7a78897aa | {
"func_code_index": [
1139,
1292
]
} | 5,089 |
||
OriginalInu | OriginalInu.sol | 0x579bc1aca7f398dfa3b31e0eca30c12ce3ef80ff | Solidity | Ownable | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
} | transferOwnership | function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
| /**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://0d0ad5fe53ae667bfb4d7878ce5bd100b73b00e832cf86b5c1fa34e7a78897aa | {
"func_code_index": [
1442,
1691
]
} | 5,090 |
||
StrikersChecklist | StrikersChecklist.sol | 0xdbc260a05f81629ffa062df3d1668a43133abba4 | Solidity | Ownable | contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
} | /**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/ | NatSpecMultiLine | 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.24+commit.e67f0147 | bzzr://f87c20fe7eb593456a65c383f65f6ca3a578031b9800b338b3629208d23ef268 | {
"func_code_index": [
261,
321
]
} | 5,091 |
|
StrikersChecklist | StrikersChecklist.sol | 0xdbc260a05f81629ffa062df3d1668a43133abba4 | Solidity | Ownable | contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
} | /**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/ | NatSpecMultiLine | transferOwnership | function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
| /**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://f87c20fe7eb593456a65c383f65f6ca3a578031b9800b338b3629208d23ef268 | {
"func_code_index": [
640,
821
]
} | 5,092 |
|
StrikersChecklist | StrikersChecklist.sol | 0xdbc260a05f81629ffa062df3d1668a43133abba4 | Solidity | StrikersPlayerList | contract StrikersPlayerList is Ownable {
// We only use playerIds in StrikersChecklist.sol (to
// indicate which player features on instances of a
// given ChecklistItem), and nowhere else in the app.
// While it's not explictly necessary for any of our
// contracts to know that playerId 0 corresponds to
// Lionel Messi, we think that it's nice to have
// a canonical source of truth for who the playerIds
// actually refer to. Storing strings (player names)
// is expensive, so we just use Events to prove that,
// at some point, we said a playerId represents a given person.
/// @dev The event we fire when we add a player.
event PlayerAdded(uint8 indexed id, string name);
/// @dev How many players we've added so far
/// (max 255, though we don't plan on getting close)
uint8 public playerCount;
/// @dev Here we add the players we are launching with on Day 1.
/// Players are loosely ranked by things like FIFA ratings,
/// number of Instagram followers, and opinions of CryptoStrikers
/// team members. Feel free to yell at us on Twitter.
constructor() public {
addPlayer("Lionel Messi"); // 0
addPlayer("Cristiano Ronaldo"); // 1
addPlayer("Neymar"); // 2
addPlayer("Mohamed Salah"); // 3
addPlayer("Robert Lewandowski"); // 4
addPlayer("Kevin De Bruyne"); // 5
addPlayer("Luka Modrić"); // 6
addPlayer("Eden Hazard"); // 7
addPlayer("Sergio Ramos"); // 8
addPlayer("Toni Kroos"); // 9
addPlayer("Luis Suárez"); // 10
addPlayer("Harry Kane"); // 11
addPlayer("Sergio Agüero"); // 12
addPlayer("Kylian Mbappé"); // 13
addPlayer("Gonzalo Higuaín"); // 14
addPlayer("David de Gea"); // 15
addPlayer("Antoine Griezmann"); // 16
addPlayer("N'Golo Kanté"); // 17
addPlayer("Edinson Cavani"); // 18
addPlayer("Paul Pogba"); // 19
addPlayer("Isco"); // 20
addPlayer("Marcelo"); // 21
addPlayer("Manuel Neuer"); // 22
addPlayer("Dries Mertens"); // 23
addPlayer("James Rodríguez"); // 24
addPlayer("Paulo Dybala"); // 25
addPlayer("Christian Eriksen"); // 26
addPlayer("David Silva"); // 27
addPlayer("Gabriel Jesus"); // 28
addPlayer("Thiago"); // 29
addPlayer("Thibaut Courtois"); // 30
addPlayer("Philippe Coutinho"); // 31
addPlayer("Andrés Iniesta"); // 32
addPlayer("Casemiro"); // 33
addPlayer("Romelu Lukaku"); // 34
addPlayer("Gerard Piqué"); // 35
addPlayer("Mats Hummels"); // 36
addPlayer("Diego Godín"); // 37
addPlayer("Mesut Özil"); // 38
addPlayer("Son Heung-min"); // 39
addPlayer("Raheem Sterling"); // 40
addPlayer("Hugo Lloris"); // 41
addPlayer("Radamel Falcao"); // 42
addPlayer("Ivan Rakitić"); // 43
addPlayer("Leroy Sané"); // 44
addPlayer("Roberto Firmino"); // 45
addPlayer("Sadio Mané"); // 46
addPlayer("Thomas Müller"); // 47
addPlayer("Dele Alli"); // 48
addPlayer("Keylor Navas"); // 49
addPlayer("Thiago Silva"); // 50
addPlayer("Raphaël Varane"); // 51
addPlayer("Ángel Di María"); // 52
addPlayer("Jordi Alba"); // 53
addPlayer("Medhi Benatia"); // 54
addPlayer("Timo Werner"); // 55
addPlayer("Gylfi Sigurðsson"); // 56
addPlayer("Nemanja Matić"); // 57
addPlayer("Kalidou Koulibaly"); // 58
addPlayer("Bernardo Silva"); // 59
addPlayer("Vincent Kompany"); // 60
addPlayer("João Moutinho"); // 61
addPlayer("Toby Alderweireld"); // 62
addPlayer("Emil Forsberg"); // 63
addPlayer("Mario Mandžukić"); // 64
addPlayer("Sergej Milinković-Savić"); // 65
addPlayer("Shinji Kagawa"); // 66
addPlayer("Granit Xhaka"); // 67
addPlayer("Andreas Christensen"); // 68
addPlayer("Piotr Zieliński"); // 69
addPlayer("Fyodor Smolov"); // 70
addPlayer("Xherdan Shaqiri"); // 71
addPlayer("Marcus Rashford"); // 72
addPlayer("Javier Hernández"); // 73
addPlayer("Hirving Lozano"); // 74
addPlayer("Hakim Ziyech"); // 75
addPlayer("Victor Moses"); // 76
addPlayer("Jefferson Farfán"); // 77
addPlayer("Mohamed Elneny"); // 78
addPlayer("Marcus Berg"); // 79
addPlayer("Guillermo Ochoa"); // 80
addPlayer("Igor Akinfeev"); // 81
addPlayer("Sardar Azmoun"); // 82
addPlayer("Christian Cueva"); // 83
addPlayer("Wahbi Khazri"); // 84
addPlayer("Keisuke Honda"); // 85
addPlayer("Tim Cahill"); // 86
addPlayer("John Obi Mikel"); // 87
addPlayer("Ki Sung-yueng"); // 88
addPlayer("Bryan Ruiz"); // 89
addPlayer("Maya Yoshida"); // 90
addPlayer("Nawaf Al Abed"); // 91
addPlayer("Lee Chung-yong"); // 92
addPlayer("Gabriel Gómez"); // 93
addPlayer("Naïm Sliti"); // 94
addPlayer("Reza Ghoochannejhad"); // 95
addPlayer("Mile Jedinak"); // 96
addPlayer("Mohammad Al-Sahlawi"); // 97
addPlayer("Aron Gunnarsson"); // 98
addPlayer("Blas Pérez"); // 99
addPlayer("Dani Alves"); // 100
addPlayer("Zlatan Ibrahimović"); // 101
}
/// @dev Fires an event, proving that we said a player corresponds to a given ID.
/// @param _name The name of the player we are adding.
function addPlayer(string _name) public onlyOwner {
require(playerCount < 255, "You've already added the maximum amount of players.");
emit PlayerAdded(playerCount, _name);
playerCount++;
}
} | /// @title The contract that manages all the players that appear in our game.
/// @author The CryptoStrikers Team | NatSpecSingleLine | addPlayer | function addPlayer(string _name) public onlyOwner {
require(playerCount < 255, "You've already added the maximum amount of players.");
emit PlayerAdded(playerCount, _name);
playerCount++;
}
| /// @dev Fires an event, proving that we said a player corresponds to a given ID.
/// @param _name The name of the player we are adding. | NatSpecSingleLine | v0.4.24+commit.e67f0147 | bzzr://f87c20fe7eb593456a65c383f65f6ca3a578031b9800b338b3629208d23ef268 | {
"func_code_index": [
5268,
5478
]
} | 5,093 |
|
StrikersChecklist | StrikersChecklist.sol | 0xdbc260a05f81629ffa062df3d1668a43133abba4 | Solidity | StrikersChecklist | contract StrikersChecklist is StrikersPlayerList {
// High level overview of everything going on in this contract:
//
// ChecklistItem is the parent class to Card and has 3 properties:
// - uint8 checklistId (000 to 255)
// - uint8 playerId (see StrikersPlayerList.sol)
// - RarityTier tier (more info below)
//
// Two things to note: the checklistId is not explicitly stored
// on the checklistItem struct, and it's composed of two parts.
// (For the following, assume it is left padded with zeros to reach
// three digits, such that checklistId 0 becomes 000)
// - the first digit represents the setId
// * 0 = Originals Set
// * 1 = Iconics Set
// * 2 = Unreleased Set
// - the last two digits represent its index in the appropriate set arary
//
// For example, checklist ID 100 would represent fhe first checklist item
// in the iconicChecklistItems array (first digit = 1 = Iconics Set, last two
// digits = 00 = first index of array)
//
// Because checklistId is represented as a uint8 throughout the app, the highest
// value it can take is 255, which means we can't add more than 56 items to our
// Unreleased Set's unreleasedChecklistItems array (setId 2). Also, once we've initialized
// this contract, it's impossible for us to add more checklist items to the Originals
// and Iconics set -- what you see here is what you get.
//
// Simple enough right?
/// @dev We initialize this contract with so much data that we have
/// to stage it in 4 different steps, ~33 checklist items at a time.
enum DeployStep {
WaitingForStepOne,
WaitingForStepTwo,
WaitingForStepThree,
WaitingForStepFour,
DoneInitialDeploy
}
/// @dev Enum containing all our rarity tiers, just because
/// it's cleaner dealing with these values than with uint8s.
enum RarityTier {
IconicReferral,
IconicInsert,
Diamond,
Gold,
Silver,
Bronze
}
/// @dev A lookup table indicating how limited the cards
/// in each tier are. If this value is 0, it means
/// that cards of this rarity tier are unlimited,
/// which is only the case for the 8 Iconics cards
/// we give away as part of our referral program.
uint16[] public tierLimits = [
0, // Iconic - Referral Bonus (uncapped)
100, // Iconic Inserts ("Card of the Day")
1000, // Diamond
1664, // Gold
3328, // Silver
4352 // Bronze
];
/// @dev ChecklistItem is essentially the parent class to Card.
/// It represents a given superclass of cards (eg Originals Messi),
/// and then each Card is an instance of this ChecklistItem, with
/// its own serial number, mint date, etc.
struct ChecklistItem {
uint8 playerId;
RarityTier tier;
}
/// @dev The deploy step we're at. Defaults to WaitingForStepOne.
DeployStep public deployStep;
/// @dev Array containing all the Originals checklist items (000 - 099)
ChecklistItem[] public originalChecklistItems;
/// @dev Array containing all the Iconics checklist items (100 - 131)
ChecklistItem[] public iconicChecklistItems;
/// @dev Array containing all the unreleased checklist items (200 - 255 max)
ChecklistItem[] public unreleasedChecklistItems;
/// @dev Internal function to add a checklist item to the Originals set.
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function _addOriginalChecklistItem(uint8 _playerId, RarityTier _tier) internal {
originalChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev Internal function to add a checklist item to the Iconics set.
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function _addIconicChecklistItem(uint8 _playerId, RarityTier _tier) internal {
iconicChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev External function to add a checklist item to our mystery set.
/// Must have completed initial deploy, and can't add more than 56 items (because checklistId is a uint8).
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function addUnreleasedChecklistItem(uint8 _playerId, RarityTier _tier) external onlyOwner {
require(deployStep == DeployStep.DoneInitialDeploy, "Finish deploying the Originals and Iconics sets first.");
require(unreleasedCount() < 56, "You can't add any more checklist items.");
require(_playerId < playerCount, "This player doesn't exist in our player list.");
unreleasedChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev Returns how many Original checklist items we've added.
function originalsCount() external view returns (uint256) {
return originalChecklistItems.length;
}
/// @dev Returns how many Iconic checklist items we've added.
function iconicsCount() public view returns (uint256) {
return iconicChecklistItems.length;
}
/// @dev Returns how many Unreleased checklist items we've added.
function unreleasedCount() public view returns (uint256) {
return unreleasedChecklistItems.length;
}
// In the next four functions, we initialize this contract with our
// 132 initial checklist items (100 Originals, 32 Iconics). Because
// of how much data we need to store, it has to be broken up into
// four different function calls, which need to be called in sequence.
// The ordering of the checklist items we add determines their
// checklist ID, which is left-padded in our frontend to be a
// 3-digit identifier where the first digit is the setId and the last
// 2 digits represents the checklist items index in the appropriate ___ChecklistItems array.
// For example, Originals Messi is the first item for set ID 0, and this
// is displayed as #000 throughout the app. Our Card struct declare its
// checklistId property as uint8, so we have
// to be mindful that we can only have 256 total checklist items.
/// @dev Deploys Originals #000 through #032.
function deployStepOne() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepOne, "You're not following the steps in order...");
/* ORIGINALS - DIAMOND */
_addOriginalChecklistItem(0, RarityTier.Diamond); // 000 Messi
_addOriginalChecklistItem(1, RarityTier.Diamond); // 001 Ronaldo
_addOriginalChecklistItem(2, RarityTier.Diamond); // 002 Neymar
_addOriginalChecklistItem(3, RarityTier.Diamond); // 003 Salah
/* ORIGINALS - GOLD */
_addOriginalChecklistItem(4, RarityTier.Gold); // 004 Lewandowski
_addOriginalChecklistItem(5, RarityTier.Gold); // 005 De Bruyne
_addOriginalChecklistItem(6, RarityTier.Gold); // 006 Modrić
_addOriginalChecklistItem(7, RarityTier.Gold); // 007 Hazard
_addOriginalChecklistItem(8, RarityTier.Gold); // 008 Ramos
_addOriginalChecklistItem(9, RarityTier.Gold); // 009 Kroos
_addOriginalChecklistItem(10, RarityTier.Gold); // 010 Suárez
_addOriginalChecklistItem(11, RarityTier.Gold); // 011 Kane
_addOriginalChecklistItem(12, RarityTier.Gold); // 012 Agüero
_addOriginalChecklistItem(13, RarityTier.Gold); // 013 Mbappé
_addOriginalChecklistItem(14, RarityTier.Gold); // 014 Higuaín
_addOriginalChecklistItem(15, RarityTier.Gold); // 015 de Gea
_addOriginalChecklistItem(16, RarityTier.Gold); // 016 Griezmann
_addOriginalChecklistItem(17, RarityTier.Gold); // 017 Kanté
_addOriginalChecklistItem(18, RarityTier.Gold); // 018 Cavani
_addOriginalChecklistItem(19, RarityTier.Gold); // 019 Pogba
/* ORIGINALS - SILVER (020 to 032) */
_addOriginalChecklistItem(20, RarityTier.Silver); // 020 Isco
_addOriginalChecklistItem(21, RarityTier.Silver); // 021 Marcelo
_addOriginalChecklistItem(22, RarityTier.Silver); // 022 Neuer
_addOriginalChecklistItem(23, RarityTier.Silver); // 023 Mertens
_addOriginalChecklistItem(24, RarityTier.Silver); // 024 James
_addOriginalChecklistItem(25, RarityTier.Silver); // 025 Dybala
_addOriginalChecklistItem(26, RarityTier.Silver); // 026 Eriksen
_addOriginalChecklistItem(27, RarityTier.Silver); // 027 David Silva
_addOriginalChecklistItem(28, RarityTier.Silver); // 028 Gabriel Jesus
_addOriginalChecklistItem(29, RarityTier.Silver); // 029 Thiago
_addOriginalChecklistItem(30, RarityTier.Silver); // 030 Courtois
_addOriginalChecklistItem(31, RarityTier.Silver); // 031 Coutinho
_addOriginalChecklistItem(32, RarityTier.Silver); // 032 Iniesta
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepTwo;
}
/// @dev Deploys Originals #033 through #065.
function deployStepTwo() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepTwo, "You're not following the steps in order...");
/* ORIGINALS - SILVER (033 to 049) */
_addOriginalChecklistItem(33, RarityTier.Silver); // 033 Casemiro
_addOriginalChecklistItem(34, RarityTier.Silver); // 034 Lukaku
_addOriginalChecklistItem(35, RarityTier.Silver); // 035 Piqué
_addOriginalChecklistItem(36, RarityTier.Silver); // 036 Hummels
_addOriginalChecklistItem(37, RarityTier.Silver); // 037 Godín
_addOriginalChecklistItem(38, RarityTier.Silver); // 038 Özil
_addOriginalChecklistItem(39, RarityTier.Silver); // 039 Son
_addOriginalChecklistItem(40, RarityTier.Silver); // 040 Sterling
_addOriginalChecklistItem(41, RarityTier.Silver); // 041 Lloris
_addOriginalChecklistItem(42, RarityTier.Silver); // 042 Falcao
_addOriginalChecklistItem(43, RarityTier.Silver); // 043 Rakitić
_addOriginalChecklistItem(44, RarityTier.Silver); // 044 Sané
_addOriginalChecklistItem(45, RarityTier.Silver); // 045 Firmino
_addOriginalChecklistItem(46, RarityTier.Silver); // 046 Mané
_addOriginalChecklistItem(47, RarityTier.Silver); // 047 Müller
_addOriginalChecklistItem(48, RarityTier.Silver); // 048 Alli
_addOriginalChecklistItem(49, RarityTier.Silver); // 049 Navas
/* ORIGINALS - BRONZE (050 to 065) */
_addOriginalChecklistItem(50, RarityTier.Bronze); // 050 Thiago Silva
_addOriginalChecklistItem(51, RarityTier.Bronze); // 051 Varane
_addOriginalChecklistItem(52, RarityTier.Bronze); // 052 Di María
_addOriginalChecklistItem(53, RarityTier.Bronze); // 053 Alba
_addOriginalChecklistItem(54, RarityTier.Bronze); // 054 Benatia
_addOriginalChecklistItem(55, RarityTier.Bronze); // 055 Werner
_addOriginalChecklistItem(56, RarityTier.Bronze); // 056 Sigurðsson
_addOriginalChecklistItem(57, RarityTier.Bronze); // 057 Matić
_addOriginalChecklistItem(58, RarityTier.Bronze); // 058 Koulibaly
_addOriginalChecklistItem(59, RarityTier.Bronze); // 059 Bernardo Silva
_addOriginalChecklistItem(60, RarityTier.Bronze); // 060 Kompany
_addOriginalChecklistItem(61, RarityTier.Bronze); // 061 Moutinho
_addOriginalChecklistItem(62, RarityTier.Bronze); // 062 Alderweireld
_addOriginalChecklistItem(63, RarityTier.Bronze); // 063 Forsberg
_addOriginalChecklistItem(64, RarityTier.Bronze); // 064 Mandžukić
_addOriginalChecklistItem(65, RarityTier.Bronze); // 065 Milinković-Savić
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepThree;
}
/// @dev Deploys Originals #066 through #099.
function deployStepThree() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepThree, "You're not following the steps in order...");
/* ORIGINALS - BRONZE (066 to 099) */
_addOriginalChecklistItem(66, RarityTier.Bronze); // 066 Kagawa
_addOriginalChecklistItem(67, RarityTier.Bronze); // 067 Xhaka
_addOriginalChecklistItem(68, RarityTier.Bronze); // 068 Christensen
_addOriginalChecklistItem(69, RarityTier.Bronze); // 069 Zieliński
_addOriginalChecklistItem(70, RarityTier.Bronze); // 070 Smolov
_addOriginalChecklistItem(71, RarityTier.Bronze); // 071 Shaqiri
_addOriginalChecklistItem(72, RarityTier.Bronze); // 072 Rashford
_addOriginalChecklistItem(73, RarityTier.Bronze); // 073 Hernández
_addOriginalChecklistItem(74, RarityTier.Bronze); // 074 Lozano
_addOriginalChecklistItem(75, RarityTier.Bronze); // 075 Ziyech
_addOriginalChecklistItem(76, RarityTier.Bronze); // 076 Moses
_addOriginalChecklistItem(77, RarityTier.Bronze); // 077 Farfán
_addOriginalChecklistItem(78, RarityTier.Bronze); // 078 Elneny
_addOriginalChecklistItem(79, RarityTier.Bronze); // 079 Berg
_addOriginalChecklistItem(80, RarityTier.Bronze); // 080 Ochoa
_addOriginalChecklistItem(81, RarityTier.Bronze); // 081 Akinfeev
_addOriginalChecklistItem(82, RarityTier.Bronze); // 082 Azmoun
_addOriginalChecklistItem(83, RarityTier.Bronze); // 083 Cueva
_addOriginalChecklistItem(84, RarityTier.Bronze); // 084 Khazri
_addOriginalChecklistItem(85, RarityTier.Bronze); // 085 Honda
_addOriginalChecklistItem(86, RarityTier.Bronze); // 086 Cahill
_addOriginalChecklistItem(87, RarityTier.Bronze); // 087 Mikel
_addOriginalChecklistItem(88, RarityTier.Bronze); // 088 Sung-yueng
_addOriginalChecklistItem(89, RarityTier.Bronze); // 089 Ruiz
_addOriginalChecklistItem(90, RarityTier.Bronze); // 090 Yoshida
_addOriginalChecklistItem(91, RarityTier.Bronze); // 091 Al Abed
_addOriginalChecklistItem(92, RarityTier.Bronze); // 092 Chung-yong
_addOriginalChecklistItem(93, RarityTier.Bronze); // 093 Gómez
_addOriginalChecklistItem(94, RarityTier.Bronze); // 094 Sliti
_addOriginalChecklistItem(95, RarityTier.Bronze); // 095 Ghoochannejhad
_addOriginalChecklistItem(96, RarityTier.Bronze); // 096 Jedinak
_addOriginalChecklistItem(97, RarityTier.Bronze); // 097 Al-Sahlawi
_addOriginalChecklistItem(98, RarityTier.Bronze); // 098 Gunnarsson
_addOriginalChecklistItem(99, RarityTier.Bronze); // 099 Pérez
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepFour;
}
/// @dev Deploys all Iconics and marks the deploy as complete!
function deployStepFour() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepFour, "You're not following the steps in order...");
/* ICONICS */
_addIconicChecklistItem(0, RarityTier.IconicInsert); // 100 Messi
_addIconicChecklistItem(1, RarityTier.IconicInsert); // 101 Ronaldo
_addIconicChecklistItem(2, RarityTier.IconicInsert); // 102 Neymar
_addIconicChecklistItem(3, RarityTier.IconicInsert); // 103 Salah
_addIconicChecklistItem(4, RarityTier.IconicInsert); // 104 Lewandowski
_addIconicChecklistItem(5, RarityTier.IconicInsert); // 105 De Bruyne
_addIconicChecklistItem(6, RarityTier.IconicInsert); // 106 Modrić
_addIconicChecklistItem(7, RarityTier.IconicInsert); // 107 Hazard
_addIconicChecklistItem(8, RarityTier.IconicInsert); // 108 Ramos
_addIconicChecklistItem(9, RarityTier.IconicInsert); // 109 Kroos
_addIconicChecklistItem(10, RarityTier.IconicInsert); // 110 Suárez
_addIconicChecklistItem(11, RarityTier.IconicInsert); // 111 Kane
_addIconicChecklistItem(12, RarityTier.IconicInsert); // 112 Agüero
_addIconicChecklistItem(15, RarityTier.IconicInsert); // 113 de Gea
_addIconicChecklistItem(16, RarityTier.IconicInsert); // 114 Griezmann
_addIconicChecklistItem(17, RarityTier.IconicReferral); // 115 Kanté
_addIconicChecklistItem(18, RarityTier.IconicReferral); // 116 Cavani
_addIconicChecklistItem(19, RarityTier.IconicInsert); // 117 Pogba
_addIconicChecklistItem(21, RarityTier.IconicInsert); // 118 Marcelo
_addIconicChecklistItem(24, RarityTier.IconicInsert); // 119 James
_addIconicChecklistItem(26, RarityTier.IconicInsert); // 120 Eriksen
_addIconicChecklistItem(29, RarityTier.IconicReferral); // 121 Thiago
_addIconicChecklistItem(36, RarityTier.IconicReferral); // 122 Hummels
_addIconicChecklistItem(38, RarityTier.IconicReferral); // 123 Özil
_addIconicChecklistItem(39, RarityTier.IconicInsert); // 124 Son
_addIconicChecklistItem(46, RarityTier.IconicInsert); // 125 Mané
_addIconicChecklistItem(48, RarityTier.IconicInsert); // 126 Alli
_addIconicChecklistItem(49, RarityTier.IconicReferral); // 127 Navas
_addIconicChecklistItem(73, RarityTier.IconicInsert); // 128 Hernández
_addIconicChecklistItem(85, RarityTier.IconicInsert); // 129 Honda
_addIconicChecklistItem(100, RarityTier.IconicReferral); // 130 Alves
_addIconicChecklistItem(101, RarityTier.IconicReferral); // 131 Zlatan
// Mark the initial deploy as complete.
deployStep = DeployStep.DoneInitialDeploy;
}
/// @dev Returns the mint limit for a given checklist item, based on its tier.
/// @param _checklistId Which checklist item we need to get the limit for.
/// @return How much of this checklist item we are allowed to mint.
function limitForChecklistId(uint8 _checklistId) external view returns (uint16) {
RarityTier rarityTier;
uint8 index;
if (_checklistId < 100) { // Originals = #000 to #099
rarityTier = originalChecklistItems[_checklistId].tier;
} else if (_checklistId < 200) { // Iconics = #100 to #131
index = _checklistId - 100;
require(index < iconicsCount(), "This Iconics checklist item doesn't exist.");
rarityTier = iconicChecklistItems[index].tier;
} else { // Unreleased = #200 to max #255
index = _checklistId - 200;
require(index < unreleasedCount(), "This Unreleased checklist item doesn't exist.");
rarityTier = unreleasedChecklistItems[index].tier;
}
return tierLimits[uint8(rarityTier)];
}
} | /// @title The contract that manages checklist items, sets, and rarity tiers.
/// @author The CryptoStrikers Team | NatSpecSingleLine | _addOriginalChecklistItem | function _addOriginalChecklistItem(uint8 _playerId, RarityTier _tier) internal {
originalChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
| /// @dev Internal function to add a checklist item to the Originals set.
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits) | NatSpecSingleLine | v0.4.24+commit.e67f0147 | bzzr://f87c20fe7eb593456a65c383f65f6ca3a578031b9800b338b3629208d23ef268 | {
"func_code_index": [
3628,
3822
]
} | 5,094 |
|
StrikersChecklist | StrikersChecklist.sol | 0xdbc260a05f81629ffa062df3d1668a43133abba4 | Solidity | StrikersChecklist | contract StrikersChecklist is StrikersPlayerList {
// High level overview of everything going on in this contract:
//
// ChecklistItem is the parent class to Card and has 3 properties:
// - uint8 checklistId (000 to 255)
// - uint8 playerId (see StrikersPlayerList.sol)
// - RarityTier tier (more info below)
//
// Two things to note: the checklistId is not explicitly stored
// on the checklistItem struct, and it's composed of two parts.
// (For the following, assume it is left padded with zeros to reach
// three digits, such that checklistId 0 becomes 000)
// - the first digit represents the setId
// * 0 = Originals Set
// * 1 = Iconics Set
// * 2 = Unreleased Set
// - the last two digits represent its index in the appropriate set arary
//
// For example, checklist ID 100 would represent fhe first checklist item
// in the iconicChecklistItems array (first digit = 1 = Iconics Set, last two
// digits = 00 = first index of array)
//
// Because checklistId is represented as a uint8 throughout the app, the highest
// value it can take is 255, which means we can't add more than 56 items to our
// Unreleased Set's unreleasedChecklistItems array (setId 2). Also, once we've initialized
// this contract, it's impossible for us to add more checklist items to the Originals
// and Iconics set -- what you see here is what you get.
//
// Simple enough right?
/// @dev We initialize this contract with so much data that we have
/// to stage it in 4 different steps, ~33 checklist items at a time.
enum DeployStep {
WaitingForStepOne,
WaitingForStepTwo,
WaitingForStepThree,
WaitingForStepFour,
DoneInitialDeploy
}
/// @dev Enum containing all our rarity tiers, just because
/// it's cleaner dealing with these values than with uint8s.
enum RarityTier {
IconicReferral,
IconicInsert,
Diamond,
Gold,
Silver,
Bronze
}
/// @dev A lookup table indicating how limited the cards
/// in each tier are. If this value is 0, it means
/// that cards of this rarity tier are unlimited,
/// which is only the case for the 8 Iconics cards
/// we give away as part of our referral program.
uint16[] public tierLimits = [
0, // Iconic - Referral Bonus (uncapped)
100, // Iconic Inserts ("Card of the Day")
1000, // Diamond
1664, // Gold
3328, // Silver
4352 // Bronze
];
/// @dev ChecklistItem is essentially the parent class to Card.
/// It represents a given superclass of cards (eg Originals Messi),
/// and then each Card is an instance of this ChecklistItem, with
/// its own serial number, mint date, etc.
struct ChecklistItem {
uint8 playerId;
RarityTier tier;
}
/// @dev The deploy step we're at. Defaults to WaitingForStepOne.
DeployStep public deployStep;
/// @dev Array containing all the Originals checklist items (000 - 099)
ChecklistItem[] public originalChecklistItems;
/// @dev Array containing all the Iconics checklist items (100 - 131)
ChecklistItem[] public iconicChecklistItems;
/// @dev Array containing all the unreleased checklist items (200 - 255 max)
ChecklistItem[] public unreleasedChecklistItems;
/// @dev Internal function to add a checklist item to the Originals set.
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function _addOriginalChecklistItem(uint8 _playerId, RarityTier _tier) internal {
originalChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev Internal function to add a checklist item to the Iconics set.
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function _addIconicChecklistItem(uint8 _playerId, RarityTier _tier) internal {
iconicChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev External function to add a checklist item to our mystery set.
/// Must have completed initial deploy, and can't add more than 56 items (because checklistId is a uint8).
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function addUnreleasedChecklistItem(uint8 _playerId, RarityTier _tier) external onlyOwner {
require(deployStep == DeployStep.DoneInitialDeploy, "Finish deploying the Originals and Iconics sets first.");
require(unreleasedCount() < 56, "You can't add any more checklist items.");
require(_playerId < playerCount, "This player doesn't exist in our player list.");
unreleasedChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev Returns how many Original checklist items we've added.
function originalsCount() external view returns (uint256) {
return originalChecklistItems.length;
}
/// @dev Returns how many Iconic checklist items we've added.
function iconicsCount() public view returns (uint256) {
return iconicChecklistItems.length;
}
/// @dev Returns how many Unreleased checklist items we've added.
function unreleasedCount() public view returns (uint256) {
return unreleasedChecklistItems.length;
}
// In the next four functions, we initialize this contract with our
// 132 initial checklist items (100 Originals, 32 Iconics). Because
// of how much data we need to store, it has to be broken up into
// four different function calls, which need to be called in sequence.
// The ordering of the checklist items we add determines their
// checklist ID, which is left-padded in our frontend to be a
// 3-digit identifier where the first digit is the setId and the last
// 2 digits represents the checklist items index in the appropriate ___ChecklistItems array.
// For example, Originals Messi is the first item for set ID 0, and this
// is displayed as #000 throughout the app. Our Card struct declare its
// checklistId property as uint8, so we have
// to be mindful that we can only have 256 total checklist items.
/// @dev Deploys Originals #000 through #032.
function deployStepOne() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepOne, "You're not following the steps in order...");
/* ORIGINALS - DIAMOND */
_addOriginalChecklistItem(0, RarityTier.Diamond); // 000 Messi
_addOriginalChecklistItem(1, RarityTier.Diamond); // 001 Ronaldo
_addOriginalChecklistItem(2, RarityTier.Diamond); // 002 Neymar
_addOriginalChecklistItem(3, RarityTier.Diamond); // 003 Salah
/* ORIGINALS - GOLD */
_addOriginalChecklistItem(4, RarityTier.Gold); // 004 Lewandowski
_addOriginalChecklistItem(5, RarityTier.Gold); // 005 De Bruyne
_addOriginalChecklistItem(6, RarityTier.Gold); // 006 Modrić
_addOriginalChecklistItem(7, RarityTier.Gold); // 007 Hazard
_addOriginalChecklistItem(8, RarityTier.Gold); // 008 Ramos
_addOriginalChecklistItem(9, RarityTier.Gold); // 009 Kroos
_addOriginalChecklistItem(10, RarityTier.Gold); // 010 Suárez
_addOriginalChecklistItem(11, RarityTier.Gold); // 011 Kane
_addOriginalChecklistItem(12, RarityTier.Gold); // 012 Agüero
_addOriginalChecklistItem(13, RarityTier.Gold); // 013 Mbappé
_addOriginalChecklistItem(14, RarityTier.Gold); // 014 Higuaín
_addOriginalChecklistItem(15, RarityTier.Gold); // 015 de Gea
_addOriginalChecklistItem(16, RarityTier.Gold); // 016 Griezmann
_addOriginalChecklistItem(17, RarityTier.Gold); // 017 Kanté
_addOriginalChecklistItem(18, RarityTier.Gold); // 018 Cavani
_addOriginalChecklistItem(19, RarityTier.Gold); // 019 Pogba
/* ORIGINALS - SILVER (020 to 032) */
_addOriginalChecklistItem(20, RarityTier.Silver); // 020 Isco
_addOriginalChecklistItem(21, RarityTier.Silver); // 021 Marcelo
_addOriginalChecklistItem(22, RarityTier.Silver); // 022 Neuer
_addOriginalChecklistItem(23, RarityTier.Silver); // 023 Mertens
_addOriginalChecklistItem(24, RarityTier.Silver); // 024 James
_addOriginalChecklistItem(25, RarityTier.Silver); // 025 Dybala
_addOriginalChecklistItem(26, RarityTier.Silver); // 026 Eriksen
_addOriginalChecklistItem(27, RarityTier.Silver); // 027 David Silva
_addOriginalChecklistItem(28, RarityTier.Silver); // 028 Gabriel Jesus
_addOriginalChecklistItem(29, RarityTier.Silver); // 029 Thiago
_addOriginalChecklistItem(30, RarityTier.Silver); // 030 Courtois
_addOriginalChecklistItem(31, RarityTier.Silver); // 031 Coutinho
_addOriginalChecklistItem(32, RarityTier.Silver); // 032 Iniesta
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepTwo;
}
/// @dev Deploys Originals #033 through #065.
function deployStepTwo() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepTwo, "You're not following the steps in order...");
/* ORIGINALS - SILVER (033 to 049) */
_addOriginalChecklistItem(33, RarityTier.Silver); // 033 Casemiro
_addOriginalChecklistItem(34, RarityTier.Silver); // 034 Lukaku
_addOriginalChecklistItem(35, RarityTier.Silver); // 035 Piqué
_addOriginalChecklistItem(36, RarityTier.Silver); // 036 Hummels
_addOriginalChecklistItem(37, RarityTier.Silver); // 037 Godín
_addOriginalChecklistItem(38, RarityTier.Silver); // 038 Özil
_addOriginalChecklistItem(39, RarityTier.Silver); // 039 Son
_addOriginalChecklistItem(40, RarityTier.Silver); // 040 Sterling
_addOriginalChecklistItem(41, RarityTier.Silver); // 041 Lloris
_addOriginalChecklistItem(42, RarityTier.Silver); // 042 Falcao
_addOriginalChecklistItem(43, RarityTier.Silver); // 043 Rakitić
_addOriginalChecklistItem(44, RarityTier.Silver); // 044 Sané
_addOriginalChecklistItem(45, RarityTier.Silver); // 045 Firmino
_addOriginalChecklistItem(46, RarityTier.Silver); // 046 Mané
_addOriginalChecklistItem(47, RarityTier.Silver); // 047 Müller
_addOriginalChecklistItem(48, RarityTier.Silver); // 048 Alli
_addOriginalChecklistItem(49, RarityTier.Silver); // 049 Navas
/* ORIGINALS - BRONZE (050 to 065) */
_addOriginalChecklistItem(50, RarityTier.Bronze); // 050 Thiago Silva
_addOriginalChecklistItem(51, RarityTier.Bronze); // 051 Varane
_addOriginalChecklistItem(52, RarityTier.Bronze); // 052 Di María
_addOriginalChecklistItem(53, RarityTier.Bronze); // 053 Alba
_addOriginalChecklistItem(54, RarityTier.Bronze); // 054 Benatia
_addOriginalChecklistItem(55, RarityTier.Bronze); // 055 Werner
_addOriginalChecklistItem(56, RarityTier.Bronze); // 056 Sigurðsson
_addOriginalChecklistItem(57, RarityTier.Bronze); // 057 Matić
_addOriginalChecklistItem(58, RarityTier.Bronze); // 058 Koulibaly
_addOriginalChecklistItem(59, RarityTier.Bronze); // 059 Bernardo Silva
_addOriginalChecklistItem(60, RarityTier.Bronze); // 060 Kompany
_addOriginalChecklistItem(61, RarityTier.Bronze); // 061 Moutinho
_addOriginalChecklistItem(62, RarityTier.Bronze); // 062 Alderweireld
_addOriginalChecklistItem(63, RarityTier.Bronze); // 063 Forsberg
_addOriginalChecklistItem(64, RarityTier.Bronze); // 064 Mandžukić
_addOriginalChecklistItem(65, RarityTier.Bronze); // 065 Milinković-Savić
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepThree;
}
/// @dev Deploys Originals #066 through #099.
function deployStepThree() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepThree, "You're not following the steps in order...");
/* ORIGINALS - BRONZE (066 to 099) */
_addOriginalChecklistItem(66, RarityTier.Bronze); // 066 Kagawa
_addOriginalChecklistItem(67, RarityTier.Bronze); // 067 Xhaka
_addOriginalChecklistItem(68, RarityTier.Bronze); // 068 Christensen
_addOriginalChecklistItem(69, RarityTier.Bronze); // 069 Zieliński
_addOriginalChecklistItem(70, RarityTier.Bronze); // 070 Smolov
_addOriginalChecklistItem(71, RarityTier.Bronze); // 071 Shaqiri
_addOriginalChecklistItem(72, RarityTier.Bronze); // 072 Rashford
_addOriginalChecklistItem(73, RarityTier.Bronze); // 073 Hernández
_addOriginalChecklistItem(74, RarityTier.Bronze); // 074 Lozano
_addOriginalChecklistItem(75, RarityTier.Bronze); // 075 Ziyech
_addOriginalChecklistItem(76, RarityTier.Bronze); // 076 Moses
_addOriginalChecklistItem(77, RarityTier.Bronze); // 077 Farfán
_addOriginalChecklistItem(78, RarityTier.Bronze); // 078 Elneny
_addOriginalChecklistItem(79, RarityTier.Bronze); // 079 Berg
_addOriginalChecklistItem(80, RarityTier.Bronze); // 080 Ochoa
_addOriginalChecklistItem(81, RarityTier.Bronze); // 081 Akinfeev
_addOriginalChecklistItem(82, RarityTier.Bronze); // 082 Azmoun
_addOriginalChecklistItem(83, RarityTier.Bronze); // 083 Cueva
_addOriginalChecklistItem(84, RarityTier.Bronze); // 084 Khazri
_addOriginalChecklistItem(85, RarityTier.Bronze); // 085 Honda
_addOriginalChecklistItem(86, RarityTier.Bronze); // 086 Cahill
_addOriginalChecklistItem(87, RarityTier.Bronze); // 087 Mikel
_addOriginalChecklistItem(88, RarityTier.Bronze); // 088 Sung-yueng
_addOriginalChecklistItem(89, RarityTier.Bronze); // 089 Ruiz
_addOriginalChecklistItem(90, RarityTier.Bronze); // 090 Yoshida
_addOriginalChecklistItem(91, RarityTier.Bronze); // 091 Al Abed
_addOriginalChecklistItem(92, RarityTier.Bronze); // 092 Chung-yong
_addOriginalChecklistItem(93, RarityTier.Bronze); // 093 Gómez
_addOriginalChecklistItem(94, RarityTier.Bronze); // 094 Sliti
_addOriginalChecklistItem(95, RarityTier.Bronze); // 095 Ghoochannejhad
_addOriginalChecklistItem(96, RarityTier.Bronze); // 096 Jedinak
_addOriginalChecklistItem(97, RarityTier.Bronze); // 097 Al-Sahlawi
_addOriginalChecklistItem(98, RarityTier.Bronze); // 098 Gunnarsson
_addOriginalChecklistItem(99, RarityTier.Bronze); // 099 Pérez
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepFour;
}
/// @dev Deploys all Iconics and marks the deploy as complete!
function deployStepFour() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepFour, "You're not following the steps in order...");
/* ICONICS */
_addIconicChecklistItem(0, RarityTier.IconicInsert); // 100 Messi
_addIconicChecklistItem(1, RarityTier.IconicInsert); // 101 Ronaldo
_addIconicChecklistItem(2, RarityTier.IconicInsert); // 102 Neymar
_addIconicChecklistItem(3, RarityTier.IconicInsert); // 103 Salah
_addIconicChecklistItem(4, RarityTier.IconicInsert); // 104 Lewandowski
_addIconicChecklistItem(5, RarityTier.IconicInsert); // 105 De Bruyne
_addIconicChecklistItem(6, RarityTier.IconicInsert); // 106 Modrić
_addIconicChecklistItem(7, RarityTier.IconicInsert); // 107 Hazard
_addIconicChecklistItem(8, RarityTier.IconicInsert); // 108 Ramos
_addIconicChecklistItem(9, RarityTier.IconicInsert); // 109 Kroos
_addIconicChecklistItem(10, RarityTier.IconicInsert); // 110 Suárez
_addIconicChecklistItem(11, RarityTier.IconicInsert); // 111 Kane
_addIconicChecklistItem(12, RarityTier.IconicInsert); // 112 Agüero
_addIconicChecklistItem(15, RarityTier.IconicInsert); // 113 de Gea
_addIconicChecklistItem(16, RarityTier.IconicInsert); // 114 Griezmann
_addIconicChecklistItem(17, RarityTier.IconicReferral); // 115 Kanté
_addIconicChecklistItem(18, RarityTier.IconicReferral); // 116 Cavani
_addIconicChecklistItem(19, RarityTier.IconicInsert); // 117 Pogba
_addIconicChecklistItem(21, RarityTier.IconicInsert); // 118 Marcelo
_addIconicChecklistItem(24, RarityTier.IconicInsert); // 119 James
_addIconicChecklistItem(26, RarityTier.IconicInsert); // 120 Eriksen
_addIconicChecklistItem(29, RarityTier.IconicReferral); // 121 Thiago
_addIconicChecklistItem(36, RarityTier.IconicReferral); // 122 Hummels
_addIconicChecklistItem(38, RarityTier.IconicReferral); // 123 Özil
_addIconicChecklistItem(39, RarityTier.IconicInsert); // 124 Son
_addIconicChecklistItem(46, RarityTier.IconicInsert); // 125 Mané
_addIconicChecklistItem(48, RarityTier.IconicInsert); // 126 Alli
_addIconicChecklistItem(49, RarityTier.IconicReferral); // 127 Navas
_addIconicChecklistItem(73, RarityTier.IconicInsert); // 128 Hernández
_addIconicChecklistItem(85, RarityTier.IconicInsert); // 129 Honda
_addIconicChecklistItem(100, RarityTier.IconicReferral); // 130 Alves
_addIconicChecklistItem(101, RarityTier.IconicReferral); // 131 Zlatan
// Mark the initial deploy as complete.
deployStep = DeployStep.DoneInitialDeploy;
}
/// @dev Returns the mint limit for a given checklist item, based on its tier.
/// @param _checklistId Which checklist item we need to get the limit for.
/// @return How much of this checklist item we are allowed to mint.
function limitForChecklistId(uint8 _checklistId) external view returns (uint16) {
RarityTier rarityTier;
uint8 index;
if (_checklistId < 100) { // Originals = #000 to #099
rarityTier = originalChecklistItems[_checklistId].tier;
} else if (_checklistId < 200) { // Iconics = #100 to #131
index = _checklistId - 100;
require(index < iconicsCount(), "This Iconics checklist item doesn't exist.");
rarityTier = iconicChecklistItems[index].tier;
} else { // Unreleased = #200 to max #255
index = _checklistId - 200;
require(index < unreleasedCount(), "This Unreleased checklist item doesn't exist.");
rarityTier = unreleasedChecklistItems[index].tier;
}
return tierLimits[uint8(rarityTier)];
}
} | /// @title The contract that manages checklist items, sets, and rarity tiers.
/// @author The CryptoStrikers Team | NatSpecSingleLine | _addIconicChecklistItem | function _addIconicChecklistItem(uint8 _playerId, RarityTier _tier) internal {
iconicChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
| /// @dev Internal function to add a checklist item to the Iconics set.
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits) | NatSpecSingleLine | v0.4.24+commit.e67f0147 | bzzr://f87c20fe7eb593456a65c383f65f6ca3a578031b9800b338b3629208d23ef268 | {
"func_code_index": [
4106,
4296
]
} | 5,095 |
|
StrikersChecklist | StrikersChecklist.sol | 0xdbc260a05f81629ffa062df3d1668a43133abba4 | Solidity | StrikersChecklist | contract StrikersChecklist is StrikersPlayerList {
// High level overview of everything going on in this contract:
//
// ChecklistItem is the parent class to Card and has 3 properties:
// - uint8 checklistId (000 to 255)
// - uint8 playerId (see StrikersPlayerList.sol)
// - RarityTier tier (more info below)
//
// Two things to note: the checklistId is not explicitly stored
// on the checklistItem struct, and it's composed of two parts.
// (For the following, assume it is left padded with zeros to reach
// three digits, such that checklistId 0 becomes 000)
// - the first digit represents the setId
// * 0 = Originals Set
// * 1 = Iconics Set
// * 2 = Unreleased Set
// - the last two digits represent its index in the appropriate set arary
//
// For example, checklist ID 100 would represent fhe first checklist item
// in the iconicChecklistItems array (first digit = 1 = Iconics Set, last two
// digits = 00 = first index of array)
//
// Because checklistId is represented as a uint8 throughout the app, the highest
// value it can take is 255, which means we can't add more than 56 items to our
// Unreleased Set's unreleasedChecklistItems array (setId 2). Also, once we've initialized
// this contract, it's impossible for us to add more checklist items to the Originals
// and Iconics set -- what you see here is what you get.
//
// Simple enough right?
/// @dev We initialize this contract with so much data that we have
/// to stage it in 4 different steps, ~33 checklist items at a time.
enum DeployStep {
WaitingForStepOne,
WaitingForStepTwo,
WaitingForStepThree,
WaitingForStepFour,
DoneInitialDeploy
}
/// @dev Enum containing all our rarity tiers, just because
/// it's cleaner dealing with these values than with uint8s.
enum RarityTier {
IconicReferral,
IconicInsert,
Diamond,
Gold,
Silver,
Bronze
}
/// @dev A lookup table indicating how limited the cards
/// in each tier are. If this value is 0, it means
/// that cards of this rarity tier are unlimited,
/// which is only the case for the 8 Iconics cards
/// we give away as part of our referral program.
uint16[] public tierLimits = [
0, // Iconic - Referral Bonus (uncapped)
100, // Iconic Inserts ("Card of the Day")
1000, // Diamond
1664, // Gold
3328, // Silver
4352 // Bronze
];
/// @dev ChecklistItem is essentially the parent class to Card.
/// It represents a given superclass of cards (eg Originals Messi),
/// and then each Card is an instance of this ChecklistItem, with
/// its own serial number, mint date, etc.
struct ChecklistItem {
uint8 playerId;
RarityTier tier;
}
/// @dev The deploy step we're at. Defaults to WaitingForStepOne.
DeployStep public deployStep;
/// @dev Array containing all the Originals checklist items (000 - 099)
ChecklistItem[] public originalChecklistItems;
/// @dev Array containing all the Iconics checklist items (100 - 131)
ChecklistItem[] public iconicChecklistItems;
/// @dev Array containing all the unreleased checklist items (200 - 255 max)
ChecklistItem[] public unreleasedChecklistItems;
/// @dev Internal function to add a checklist item to the Originals set.
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function _addOriginalChecklistItem(uint8 _playerId, RarityTier _tier) internal {
originalChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev Internal function to add a checklist item to the Iconics set.
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function _addIconicChecklistItem(uint8 _playerId, RarityTier _tier) internal {
iconicChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev External function to add a checklist item to our mystery set.
/// Must have completed initial deploy, and can't add more than 56 items (because checklistId is a uint8).
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function addUnreleasedChecklistItem(uint8 _playerId, RarityTier _tier) external onlyOwner {
require(deployStep == DeployStep.DoneInitialDeploy, "Finish deploying the Originals and Iconics sets first.");
require(unreleasedCount() < 56, "You can't add any more checklist items.");
require(_playerId < playerCount, "This player doesn't exist in our player list.");
unreleasedChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev Returns how many Original checklist items we've added.
function originalsCount() external view returns (uint256) {
return originalChecklistItems.length;
}
/// @dev Returns how many Iconic checklist items we've added.
function iconicsCount() public view returns (uint256) {
return iconicChecklistItems.length;
}
/// @dev Returns how many Unreleased checklist items we've added.
function unreleasedCount() public view returns (uint256) {
return unreleasedChecklistItems.length;
}
// In the next four functions, we initialize this contract with our
// 132 initial checklist items (100 Originals, 32 Iconics). Because
// of how much data we need to store, it has to be broken up into
// four different function calls, which need to be called in sequence.
// The ordering of the checklist items we add determines their
// checklist ID, which is left-padded in our frontend to be a
// 3-digit identifier where the first digit is the setId and the last
// 2 digits represents the checklist items index in the appropriate ___ChecklistItems array.
// For example, Originals Messi is the first item for set ID 0, and this
// is displayed as #000 throughout the app. Our Card struct declare its
// checklistId property as uint8, so we have
// to be mindful that we can only have 256 total checklist items.
/// @dev Deploys Originals #000 through #032.
function deployStepOne() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepOne, "You're not following the steps in order...");
/* ORIGINALS - DIAMOND */
_addOriginalChecklistItem(0, RarityTier.Diamond); // 000 Messi
_addOriginalChecklistItem(1, RarityTier.Diamond); // 001 Ronaldo
_addOriginalChecklistItem(2, RarityTier.Diamond); // 002 Neymar
_addOriginalChecklistItem(3, RarityTier.Diamond); // 003 Salah
/* ORIGINALS - GOLD */
_addOriginalChecklistItem(4, RarityTier.Gold); // 004 Lewandowski
_addOriginalChecklistItem(5, RarityTier.Gold); // 005 De Bruyne
_addOriginalChecklistItem(6, RarityTier.Gold); // 006 Modrić
_addOriginalChecklistItem(7, RarityTier.Gold); // 007 Hazard
_addOriginalChecklistItem(8, RarityTier.Gold); // 008 Ramos
_addOriginalChecklistItem(9, RarityTier.Gold); // 009 Kroos
_addOriginalChecklistItem(10, RarityTier.Gold); // 010 Suárez
_addOriginalChecklistItem(11, RarityTier.Gold); // 011 Kane
_addOriginalChecklistItem(12, RarityTier.Gold); // 012 Agüero
_addOriginalChecklistItem(13, RarityTier.Gold); // 013 Mbappé
_addOriginalChecklistItem(14, RarityTier.Gold); // 014 Higuaín
_addOriginalChecklistItem(15, RarityTier.Gold); // 015 de Gea
_addOriginalChecklistItem(16, RarityTier.Gold); // 016 Griezmann
_addOriginalChecklistItem(17, RarityTier.Gold); // 017 Kanté
_addOriginalChecklistItem(18, RarityTier.Gold); // 018 Cavani
_addOriginalChecklistItem(19, RarityTier.Gold); // 019 Pogba
/* ORIGINALS - SILVER (020 to 032) */
_addOriginalChecklistItem(20, RarityTier.Silver); // 020 Isco
_addOriginalChecklistItem(21, RarityTier.Silver); // 021 Marcelo
_addOriginalChecklistItem(22, RarityTier.Silver); // 022 Neuer
_addOriginalChecklistItem(23, RarityTier.Silver); // 023 Mertens
_addOriginalChecklistItem(24, RarityTier.Silver); // 024 James
_addOriginalChecklistItem(25, RarityTier.Silver); // 025 Dybala
_addOriginalChecklistItem(26, RarityTier.Silver); // 026 Eriksen
_addOriginalChecklistItem(27, RarityTier.Silver); // 027 David Silva
_addOriginalChecklistItem(28, RarityTier.Silver); // 028 Gabriel Jesus
_addOriginalChecklistItem(29, RarityTier.Silver); // 029 Thiago
_addOriginalChecklistItem(30, RarityTier.Silver); // 030 Courtois
_addOriginalChecklistItem(31, RarityTier.Silver); // 031 Coutinho
_addOriginalChecklistItem(32, RarityTier.Silver); // 032 Iniesta
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepTwo;
}
/// @dev Deploys Originals #033 through #065.
function deployStepTwo() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepTwo, "You're not following the steps in order...");
/* ORIGINALS - SILVER (033 to 049) */
_addOriginalChecklistItem(33, RarityTier.Silver); // 033 Casemiro
_addOriginalChecklistItem(34, RarityTier.Silver); // 034 Lukaku
_addOriginalChecklistItem(35, RarityTier.Silver); // 035 Piqué
_addOriginalChecklistItem(36, RarityTier.Silver); // 036 Hummels
_addOriginalChecklistItem(37, RarityTier.Silver); // 037 Godín
_addOriginalChecklistItem(38, RarityTier.Silver); // 038 Özil
_addOriginalChecklistItem(39, RarityTier.Silver); // 039 Son
_addOriginalChecklistItem(40, RarityTier.Silver); // 040 Sterling
_addOriginalChecklistItem(41, RarityTier.Silver); // 041 Lloris
_addOriginalChecklistItem(42, RarityTier.Silver); // 042 Falcao
_addOriginalChecklistItem(43, RarityTier.Silver); // 043 Rakitić
_addOriginalChecklistItem(44, RarityTier.Silver); // 044 Sané
_addOriginalChecklistItem(45, RarityTier.Silver); // 045 Firmino
_addOriginalChecklistItem(46, RarityTier.Silver); // 046 Mané
_addOriginalChecklistItem(47, RarityTier.Silver); // 047 Müller
_addOriginalChecklistItem(48, RarityTier.Silver); // 048 Alli
_addOriginalChecklistItem(49, RarityTier.Silver); // 049 Navas
/* ORIGINALS - BRONZE (050 to 065) */
_addOriginalChecklistItem(50, RarityTier.Bronze); // 050 Thiago Silva
_addOriginalChecklistItem(51, RarityTier.Bronze); // 051 Varane
_addOriginalChecklistItem(52, RarityTier.Bronze); // 052 Di María
_addOriginalChecklistItem(53, RarityTier.Bronze); // 053 Alba
_addOriginalChecklistItem(54, RarityTier.Bronze); // 054 Benatia
_addOriginalChecklistItem(55, RarityTier.Bronze); // 055 Werner
_addOriginalChecklistItem(56, RarityTier.Bronze); // 056 Sigurðsson
_addOriginalChecklistItem(57, RarityTier.Bronze); // 057 Matić
_addOriginalChecklistItem(58, RarityTier.Bronze); // 058 Koulibaly
_addOriginalChecklistItem(59, RarityTier.Bronze); // 059 Bernardo Silva
_addOriginalChecklistItem(60, RarityTier.Bronze); // 060 Kompany
_addOriginalChecklistItem(61, RarityTier.Bronze); // 061 Moutinho
_addOriginalChecklistItem(62, RarityTier.Bronze); // 062 Alderweireld
_addOriginalChecklistItem(63, RarityTier.Bronze); // 063 Forsberg
_addOriginalChecklistItem(64, RarityTier.Bronze); // 064 Mandžukić
_addOriginalChecklistItem(65, RarityTier.Bronze); // 065 Milinković-Savić
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepThree;
}
/// @dev Deploys Originals #066 through #099.
function deployStepThree() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepThree, "You're not following the steps in order...");
/* ORIGINALS - BRONZE (066 to 099) */
_addOriginalChecklistItem(66, RarityTier.Bronze); // 066 Kagawa
_addOriginalChecklistItem(67, RarityTier.Bronze); // 067 Xhaka
_addOriginalChecklistItem(68, RarityTier.Bronze); // 068 Christensen
_addOriginalChecklistItem(69, RarityTier.Bronze); // 069 Zieliński
_addOriginalChecklistItem(70, RarityTier.Bronze); // 070 Smolov
_addOriginalChecklistItem(71, RarityTier.Bronze); // 071 Shaqiri
_addOriginalChecklistItem(72, RarityTier.Bronze); // 072 Rashford
_addOriginalChecklistItem(73, RarityTier.Bronze); // 073 Hernández
_addOriginalChecklistItem(74, RarityTier.Bronze); // 074 Lozano
_addOriginalChecklistItem(75, RarityTier.Bronze); // 075 Ziyech
_addOriginalChecklistItem(76, RarityTier.Bronze); // 076 Moses
_addOriginalChecklistItem(77, RarityTier.Bronze); // 077 Farfán
_addOriginalChecklistItem(78, RarityTier.Bronze); // 078 Elneny
_addOriginalChecklistItem(79, RarityTier.Bronze); // 079 Berg
_addOriginalChecklistItem(80, RarityTier.Bronze); // 080 Ochoa
_addOriginalChecklistItem(81, RarityTier.Bronze); // 081 Akinfeev
_addOriginalChecklistItem(82, RarityTier.Bronze); // 082 Azmoun
_addOriginalChecklistItem(83, RarityTier.Bronze); // 083 Cueva
_addOriginalChecklistItem(84, RarityTier.Bronze); // 084 Khazri
_addOriginalChecklistItem(85, RarityTier.Bronze); // 085 Honda
_addOriginalChecklistItem(86, RarityTier.Bronze); // 086 Cahill
_addOriginalChecklistItem(87, RarityTier.Bronze); // 087 Mikel
_addOriginalChecklistItem(88, RarityTier.Bronze); // 088 Sung-yueng
_addOriginalChecklistItem(89, RarityTier.Bronze); // 089 Ruiz
_addOriginalChecklistItem(90, RarityTier.Bronze); // 090 Yoshida
_addOriginalChecklistItem(91, RarityTier.Bronze); // 091 Al Abed
_addOriginalChecklistItem(92, RarityTier.Bronze); // 092 Chung-yong
_addOriginalChecklistItem(93, RarityTier.Bronze); // 093 Gómez
_addOriginalChecklistItem(94, RarityTier.Bronze); // 094 Sliti
_addOriginalChecklistItem(95, RarityTier.Bronze); // 095 Ghoochannejhad
_addOriginalChecklistItem(96, RarityTier.Bronze); // 096 Jedinak
_addOriginalChecklistItem(97, RarityTier.Bronze); // 097 Al-Sahlawi
_addOriginalChecklistItem(98, RarityTier.Bronze); // 098 Gunnarsson
_addOriginalChecklistItem(99, RarityTier.Bronze); // 099 Pérez
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepFour;
}
/// @dev Deploys all Iconics and marks the deploy as complete!
function deployStepFour() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepFour, "You're not following the steps in order...");
/* ICONICS */
_addIconicChecklistItem(0, RarityTier.IconicInsert); // 100 Messi
_addIconicChecklistItem(1, RarityTier.IconicInsert); // 101 Ronaldo
_addIconicChecklistItem(2, RarityTier.IconicInsert); // 102 Neymar
_addIconicChecklistItem(3, RarityTier.IconicInsert); // 103 Salah
_addIconicChecklistItem(4, RarityTier.IconicInsert); // 104 Lewandowski
_addIconicChecklistItem(5, RarityTier.IconicInsert); // 105 De Bruyne
_addIconicChecklistItem(6, RarityTier.IconicInsert); // 106 Modrić
_addIconicChecklistItem(7, RarityTier.IconicInsert); // 107 Hazard
_addIconicChecklistItem(8, RarityTier.IconicInsert); // 108 Ramos
_addIconicChecklistItem(9, RarityTier.IconicInsert); // 109 Kroos
_addIconicChecklistItem(10, RarityTier.IconicInsert); // 110 Suárez
_addIconicChecklistItem(11, RarityTier.IconicInsert); // 111 Kane
_addIconicChecklistItem(12, RarityTier.IconicInsert); // 112 Agüero
_addIconicChecklistItem(15, RarityTier.IconicInsert); // 113 de Gea
_addIconicChecklistItem(16, RarityTier.IconicInsert); // 114 Griezmann
_addIconicChecklistItem(17, RarityTier.IconicReferral); // 115 Kanté
_addIconicChecklistItem(18, RarityTier.IconicReferral); // 116 Cavani
_addIconicChecklistItem(19, RarityTier.IconicInsert); // 117 Pogba
_addIconicChecklistItem(21, RarityTier.IconicInsert); // 118 Marcelo
_addIconicChecklistItem(24, RarityTier.IconicInsert); // 119 James
_addIconicChecklistItem(26, RarityTier.IconicInsert); // 120 Eriksen
_addIconicChecklistItem(29, RarityTier.IconicReferral); // 121 Thiago
_addIconicChecklistItem(36, RarityTier.IconicReferral); // 122 Hummels
_addIconicChecklistItem(38, RarityTier.IconicReferral); // 123 Özil
_addIconicChecklistItem(39, RarityTier.IconicInsert); // 124 Son
_addIconicChecklistItem(46, RarityTier.IconicInsert); // 125 Mané
_addIconicChecklistItem(48, RarityTier.IconicInsert); // 126 Alli
_addIconicChecklistItem(49, RarityTier.IconicReferral); // 127 Navas
_addIconicChecklistItem(73, RarityTier.IconicInsert); // 128 Hernández
_addIconicChecklistItem(85, RarityTier.IconicInsert); // 129 Honda
_addIconicChecklistItem(100, RarityTier.IconicReferral); // 130 Alves
_addIconicChecklistItem(101, RarityTier.IconicReferral); // 131 Zlatan
// Mark the initial deploy as complete.
deployStep = DeployStep.DoneInitialDeploy;
}
/// @dev Returns the mint limit for a given checklist item, based on its tier.
/// @param _checklistId Which checklist item we need to get the limit for.
/// @return How much of this checklist item we are allowed to mint.
function limitForChecklistId(uint8 _checklistId) external view returns (uint16) {
RarityTier rarityTier;
uint8 index;
if (_checklistId < 100) { // Originals = #000 to #099
rarityTier = originalChecklistItems[_checklistId].tier;
} else if (_checklistId < 200) { // Iconics = #100 to #131
index = _checklistId - 100;
require(index < iconicsCount(), "This Iconics checklist item doesn't exist.");
rarityTier = iconicChecklistItems[index].tier;
} else { // Unreleased = #200 to max #255
index = _checklistId - 200;
require(index < unreleasedCount(), "This Unreleased checklist item doesn't exist.");
rarityTier = unreleasedChecklistItems[index].tier;
}
return tierLimits[uint8(rarityTier)];
}
} | /// @title The contract that manages checklist items, sets, and rarity tiers.
/// @author The CryptoStrikers Team | NatSpecSingleLine | addUnreleasedChecklistItem | function addUnreleasedChecklistItem(uint8 _playerId, RarityTier _tier) external onlyOwner {
require(deployStep == DeployStep.DoneInitialDeploy, "Finish deploying the Originals and Iconics sets first.");
require(unreleasedCount() < 56, "You can't add any more checklist items.");
require(_playerId < playerCount, "This player doesn't exist in our player list.");
unreleasedChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
| /// @dev External function to add a checklist item to our mystery set.
/// Must have completed initial deploy, and can't add more than 56 items (because checklistId is a uint8).
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits) | NatSpecSingleLine | v0.4.24+commit.e67f0147 | bzzr://f87c20fe7eb593456a65c383f65f6ca3a578031b9800b338b3629208d23ef268 | {
"func_code_index": [
4692,
5184
]
} | 5,096 |
|
StrikersChecklist | StrikersChecklist.sol | 0xdbc260a05f81629ffa062df3d1668a43133abba4 | Solidity | StrikersChecklist | contract StrikersChecklist is StrikersPlayerList {
// High level overview of everything going on in this contract:
//
// ChecklistItem is the parent class to Card and has 3 properties:
// - uint8 checklistId (000 to 255)
// - uint8 playerId (see StrikersPlayerList.sol)
// - RarityTier tier (more info below)
//
// Two things to note: the checklistId is not explicitly stored
// on the checklistItem struct, and it's composed of two parts.
// (For the following, assume it is left padded with zeros to reach
// three digits, such that checklistId 0 becomes 000)
// - the first digit represents the setId
// * 0 = Originals Set
// * 1 = Iconics Set
// * 2 = Unreleased Set
// - the last two digits represent its index in the appropriate set arary
//
// For example, checklist ID 100 would represent fhe first checklist item
// in the iconicChecklistItems array (first digit = 1 = Iconics Set, last two
// digits = 00 = first index of array)
//
// Because checklistId is represented as a uint8 throughout the app, the highest
// value it can take is 255, which means we can't add more than 56 items to our
// Unreleased Set's unreleasedChecklistItems array (setId 2). Also, once we've initialized
// this contract, it's impossible for us to add more checklist items to the Originals
// and Iconics set -- what you see here is what you get.
//
// Simple enough right?
/// @dev We initialize this contract with so much data that we have
/// to stage it in 4 different steps, ~33 checklist items at a time.
enum DeployStep {
WaitingForStepOne,
WaitingForStepTwo,
WaitingForStepThree,
WaitingForStepFour,
DoneInitialDeploy
}
/// @dev Enum containing all our rarity tiers, just because
/// it's cleaner dealing with these values than with uint8s.
enum RarityTier {
IconicReferral,
IconicInsert,
Diamond,
Gold,
Silver,
Bronze
}
/// @dev A lookup table indicating how limited the cards
/// in each tier are. If this value is 0, it means
/// that cards of this rarity tier are unlimited,
/// which is only the case for the 8 Iconics cards
/// we give away as part of our referral program.
uint16[] public tierLimits = [
0, // Iconic - Referral Bonus (uncapped)
100, // Iconic Inserts ("Card of the Day")
1000, // Diamond
1664, // Gold
3328, // Silver
4352 // Bronze
];
/// @dev ChecklistItem is essentially the parent class to Card.
/// It represents a given superclass of cards (eg Originals Messi),
/// and then each Card is an instance of this ChecklistItem, with
/// its own serial number, mint date, etc.
struct ChecklistItem {
uint8 playerId;
RarityTier tier;
}
/// @dev The deploy step we're at. Defaults to WaitingForStepOne.
DeployStep public deployStep;
/// @dev Array containing all the Originals checklist items (000 - 099)
ChecklistItem[] public originalChecklistItems;
/// @dev Array containing all the Iconics checklist items (100 - 131)
ChecklistItem[] public iconicChecklistItems;
/// @dev Array containing all the unreleased checklist items (200 - 255 max)
ChecklistItem[] public unreleasedChecklistItems;
/// @dev Internal function to add a checklist item to the Originals set.
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function _addOriginalChecklistItem(uint8 _playerId, RarityTier _tier) internal {
originalChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev Internal function to add a checklist item to the Iconics set.
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function _addIconicChecklistItem(uint8 _playerId, RarityTier _tier) internal {
iconicChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev External function to add a checklist item to our mystery set.
/// Must have completed initial deploy, and can't add more than 56 items (because checklistId is a uint8).
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function addUnreleasedChecklistItem(uint8 _playerId, RarityTier _tier) external onlyOwner {
require(deployStep == DeployStep.DoneInitialDeploy, "Finish deploying the Originals and Iconics sets first.");
require(unreleasedCount() < 56, "You can't add any more checklist items.");
require(_playerId < playerCount, "This player doesn't exist in our player list.");
unreleasedChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev Returns how many Original checklist items we've added.
function originalsCount() external view returns (uint256) {
return originalChecklistItems.length;
}
/// @dev Returns how many Iconic checklist items we've added.
function iconicsCount() public view returns (uint256) {
return iconicChecklistItems.length;
}
/// @dev Returns how many Unreleased checklist items we've added.
function unreleasedCount() public view returns (uint256) {
return unreleasedChecklistItems.length;
}
// In the next four functions, we initialize this contract with our
// 132 initial checklist items (100 Originals, 32 Iconics). Because
// of how much data we need to store, it has to be broken up into
// four different function calls, which need to be called in sequence.
// The ordering of the checklist items we add determines their
// checklist ID, which is left-padded in our frontend to be a
// 3-digit identifier where the first digit is the setId and the last
// 2 digits represents the checklist items index in the appropriate ___ChecklistItems array.
// For example, Originals Messi is the first item for set ID 0, and this
// is displayed as #000 throughout the app. Our Card struct declare its
// checklistId property as uint8, so we have
// to be mindful that we can only have 256 total checklist items.
/// @dev Deploys Originals #000 through #032.
function deployStepOne() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepOne, "You're not following the steps in order...");
/* ORIGINALS - DIAMOND */
_addOriginalChecklistItem(0, RarityTier.Diamond); // 000 Messi
_addOriginalChecklistItem(1, RarityTier.Diamond); // 001 Ronaldo
_addOriginalChecklistItem(2, RarityTier.Diamond); // 002 Neymar
_addOriginalChecklistItem(3, RarityTier.Diamond); // 003 Salah
/* ORIGINALS - GOLD */
_addOriginalChecklistItem(4, RarityTier.Gold); // 004 Lewandowski
_addOriginalChecklistItem(5, RarityTier.Gold); // 005 De Bruyne
_addOriginalChecklistItem(6, RarityTier.Gold); // 006 Modrić
_addOriginalChecklistItem(7, RarityTier.Gold); // 007 Hazard
_addOriginalChecklistItem(8, RarityTier.Gold); // 008 Ramos
_addOriginalChecklistItem(9, RarityTier.Gold); // 009 Kroos
_addOriginalChecklistItem(10, RarityTier.Gold); // 010 Suárez
_addOriginalChecklistItem(11, RarityTier.Gold); // 011 Kane
_addOriginalChecklistItem(12, RarityTier.Gold); // 012 Agüero
_addOriginalChecklistItem(13, RarityTier.Gold); // 013 Mbappé
_addOriginalChecklistItem(14, RarityTier.Gold); // 014 Higuaín
_addOriginalChecklistItem(15, RarityTier.Gold); // 015 de Gea
_addOriginalChecklistItem(16, RarityTier.Gold); // 016 Griezmann
_addOriginalChecklistItem(17, RarityTier.Gold); // 017 Kanté
_addOriginalChecklistItem(18, RarityTier.Gold); // 018 Cavani
_addOriginalChecklistItem(19, RarityTier.Gold); // 019 Pogba
/* ORIGINALS - SILVER (020 to 032) */
_addOriginalChecklistItem(20, RarityTier.Silver); // 020 Isco
_addOriginalChecklistItem(21, RarityTier.Silver); // 021 Marcelo
_addOriginalChecklistItem(22, RarityTier.Silver); // 022 Neuer
_addOriginalChecklistItem(23, RarityTier.Silver); // 023 Mertens
_addOriginalChecklistItem(24, RarityTier.Silver); // 024 James
_addOriginalChecklistItem(25, RarityTier.Silver); // 025 Dybala
_addOriginalChecklistItem(26, RarityTier.Silver); // 026 Eriksen
_addOriginalChecklistItem(27, RarityTier.Silver); // 027 David Silva
_addOriginalChecklistItem(28, RarityTier.Silver); // 028 Gabriel Jesus
_addOriginalChecklistItem(29, RarityTier.Silver); // 029 Thiago
_addOriginalChecklistItem(30, RarityTier.Silver); // 030 Courtois
_addOriginalChecklistItem(31, RarityTier.Silver); // 031 Coutinho
_addOriginalChecklistItem(32, RarityTier.Silver); // 032 Iniesta
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepTwo;
}
/// @dev Deploys Originals #033 through #065.
function deployStepTwo() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepTwo, "You're not following the steps in order...");
/* ORIGINALS - SILVER (033 to 049) */
_addOriginalChecklistItem(33, RarityTier.Silver); // 033 Casemiro
_addOriginalChecklistItem(34, RarityTier.Silver); // 034 Lukaku
_addOriginalChecklistItem(35, RarityTier.Silver); // 035 Piqué
_addOriginalChecklistItem(36, RarityTier.Silver); // 036 Hummels
_addOriginalChecklistItem(37, RarityTier.Silver); // 037 Godín
_addOriginalChecklistItem(38, RarityTier.Silver); // 038 Özil
_addOriginalChecklistItem(39, RarityTier.Silver); // 039 Son
_addOriginalChecklistItem(40, RarityTier.Silver); // 040 Sterling
_addOriginalChecklistItem(41, RarityTier.Silver); // 041 Lloris
_addOriginalChecklistItem(42, RarityTier.Silver); // 042 Falcao
_addOriginalChecklistItem(43, RarityTier.Silver); // 043 Rakitić
_addOriginalChecklistItem(44, RarityTier.Silver); // 044 Sané
_addOriginalChecklistItem(45, RarityTier.Silver); // 045 Firmino
_addOriginalChecklistItem(46, RarityTier.Silver); // 046 Mané
_addOriginalChecklistItem(47, RarityTier.Silver); // 047 Müller
_addOriginalChecklistItem(48, RarityTier.Silver); // 048 Alli
_addOriginalChecklistItem(49, RarityTier.Silver); // 049 Navas
/* ORIGINALS - BRONZE (050 to 065) */
_addOriginalChecklistItem(50, RarityTier.Bronze); // 050 Thiago Silva
_addOriginalChecklistItem(51, RarityTier.Bronze); // 051 Varane
_addOriginalChecklistItem(52, RarityTier.Bronze); // 052 Di María
_addOriginalChecklistItem(53, RarityTier.Bronze); // 053 Alba
_addOriginalChecklistItem(54, RarityTier.Bronze); // 054 Benatia
_addOriginalChecklistItem(55, RarityTier.Bronze); // 055 Werner
_addOriginalChecklistItem(56, RarityTier.Bronze); // 056 Sigurðsson
_addOriginalChecklistItem(57, RarityTier.Bronze); // 057 Matić
_addOriginalChecklistItem(58, RarityTier.Bronze); // 058 Koulibaly
_addOriginalChecklistItem(59, RarityTier.Bronze); // 059 Bernardo Silva
_addOriginalChecklistItem(60, RarityTier.Bronze); // 060 Kompany
_addOriginalChecklistItem(61, RarityTier.Bronze); // 061 Moutinho
_addOriginalChecklistItem(62, RarityTier.Bronze); // 062 Alderweireld
_addOriginalChecklistItem(63, RarityTier.Bronze); // 063 Forsberg
_addOriginalChecklistItem(64, RarityTier.Bronze); // 064 Mandžukić
_addOriginalChecklistItem(65, RarityTier.Bronze); // 065 Milinković-Savić
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepThree;
}
/// @dev Deploys Originals #066 through #099.
function deployStepThree() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepThree, "You're not following the steps in order...");
/* ORIGINALS - BRONZE (066 to 099) */
_addOriginalChecklistItem(66, RarityTier.Bronze); // 066 Kagawa
_addOriginalChecklistItem(67, RarityTier.Bronze); // 067 Xhaka
_addOriginalChecklistItem(68, RarityTier.Bronze); // 068 Christensen
_addOriginalChecklistItem(69, RarityTier.Bronze); // 069 Zieliński
_addOriginalChecklistItem(70, RarityTier.Bronze); // 070 Smolov
_addOriginalChecklistItem(71, RarityTier.Bronze); // 071 Shaqiri
_addOriginalChecklistItem(72, RarityTier.Bronze); // 072 Rashford
_addOriginalChecklistItem(73, RarityTier.Bronze); // 073 Hernández
_addOriginalChecklistItem(74, RarityTier.Bronze); // 074 Lozano
_addOriginalChecklistItem(75, RarityTier.Bronze); // 075 Ziyech
_addOriginalChecklistItem(76, RarityTier.Bronze); // 076 Moses
_addOriginalChecklistItem(77, RarityTier.Bronze); // 077 Farfán
_addOriginalChecklistItem(78, RarityTier.Bronze); // 078 Elneny
_addOriginalChecklistItem(79, RarityTier.Bronze); // 079 Berg
_addOriginalChecklistItem(80, RarityTier.Bronze); // 080 Ochoa
_addOriginalChecklistItem(81, RarityTier.Bronze); // 081 Akinfeev
_addOriginalChecklistItem(82, RarityTier.Bronze); // 082 Azmoun
_addOriginalChecklistItem(83, RarityTier.Bronze); // 083 Cueva
_addOriginalChecklistItem(84, RarityTier.Bronze); // 084 Khazri
_addOriginalChecklistItem(85, RarityTier.Bronze); // 085 Honda
_addOriginalChecklistItem(86, RarityTier.Bronze); // 086 Cahill
_addOriginalChecklistItem(87, RarityTier.Bronze); // 087 Mikel
_addOriginalChecklistItem(88, RarityTier.Bronze); // 088 Sung-yueng
_addOriginalChecklistItem(89, RarityTier.Bronze); // 089 Ruiz
_addOriginalChecklistItem(90, RarityTier.Bronze); // 090 Yoshida
_addOriginalChecklistItem(91, RarityTier.Bronze); // 091 Al Abed
_addOriginalChecklistItem(92, RarityTier.Bronze); // 092 Chung-yong
_addOriginalChecklistItem(93, RarityTier.Bronze); // 093 Gómez
_addOriginalChecklistItem(94, RarityTier.Bronze); // 094 Sliti
_addOriginalChecklistItem(95, RarityTier.Bronze); // 095 Ghoochannejhad
_addOriginalChecklistItem(96, RarityTier.Bronze); // 096 Jedinak
_addOriginalChecklistItem(97, RarityTier.Bronze); // 097 Al-Sahlawi
_addOriginalChecklistItem(98, RarityTier.Bronze); // 098 Gunnarsson
_addOriginalChecklistItem(99, RarityTier.Bronze); // 099 Pérez
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepFour;
}
/// @dev Deploys all Iconics and marks the deploy as complete!
function deployStepFour() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepFour, "You're not following the steps in order...");
/* ICONICS */
_addIconicChecklistItem(0, RarityTier.IconicInsert); // 100 Messi
_addIconicChecklistItem(1, RarityTier.IconicInsert); // 101 Ronaldo
_addIconicChecklistItem(2, RarityTier.IconicInsert); // 102 Neymar
_addIconicChecklistItem(3, RarityTier.IconicInsert); // 103 Salah
_addIconicChecklistItem(4, RarityTier.IconicInsert); // 104 Lewandowski
_addIconicChecklistItem(5, RarityTier.IconicInsert); // 105 De Bruyne
_addIconicChecklistItem(6, RarityTier.IconicInsert); // 106 Modrić
_addIconicChecklistItem(7, RarityTier.IconicInsert); // 107 Hazard
_addIconicChecklistItem(8, RarityTier.IconicInsert); // 108 Ramos
_addIconicChecklistItem(9, RarityTier.IconicInsert); // 109 Kroos
_addIconicChecklistItem(10, RarityTier.IconicInsert); // 110 Suárez
_addIconicChecklistItem(11, RarityTier.IconicInsert); // 111 Kane
_addIconicChecklistItem(12, RarityTier.IconicInsert); // 112 Agüero
_addIconicChecklistItem(15, RarityTier.IconicInsert); // 113 de Gea
_addIconicChecklistItem(16, RarityTier.IconicInsert); // 114 Griezmann
_addIconicChecklistItem(17, RarityTier.IconicReferral); // 115 Kanté
_addIconicChecklistItem(18, RarityTier.IconicReferral); // 116 Cavani
_addIconicChecklistItem(19, RarityTier.IconicInsert); // 117 Pogba
_addIconicChecklistItem(21, RarityTier.IconicInsert); // 118 Marcelo
_addIconicChecklistItem(24, RarityTier.IconicInsert); // 119 James
_addIconicChecklistItem(26, RarityTier.IconicInsert); // 120 Eriksen
_addIconicChecklistItem(29, RarityTier.IconicReferral); // 121 Thiago
_addIconicChecklistItem(36, RarityTier.IconicReferral); // 122 Hummels
_addIconicChecklistItem(38, RarityTier.IconicReferral); // 123 Özil
_addIconicChecklistItem(39, RarityTier.IconicInsert); // 124 Son
_addIconicChecklistItem(46, RarityTier.IconicInsert); // 125 Mané
_addIconicChecklistItem(48, RarityTier.IconicInsert); // 126 Alli
_addIconicChecklistItem(49, RarityTier.IconicReferral); // 127 Navas
_addIconicChecklistItem(73, RarityTier.IconicInsert); // 128 Hernández
_addIconicChecklistItem(85, RarityTier.IconicInsert); // 129 Honda
_addIconicChecklistItem(100, RarityTier.IconicReferral); // 130 Alves
_addIconicChecklistItem(101, RarityTier.IconicReferral); // 131 Zlatan
// Mark the initial deploy as complete.
deployStep = DeployStep.DoneInitialDeploy;
}
/// @dev Returns the mint limit for a given checklist item, based on its tier.
/// @param _checklistId Which checklist item we need to get the limit for.
/// @return How much of this checklist item we are allowed to mint.
function limitForChecklistId(uint8 _checklistId) external view returns (uint16) {
RarityTier rarityTier;
uint8 index;
if (_checklistId < 100) { // Originals = #000 to #099
rarityTier = originalChecklistItems[_checklistId].tier;
} else if (_checklistId < 200) { // Iconics = #100 to #131
index = _checklistId - 100;
require(index < iconicsCount(), "This Iconics checklist item doesn't exist.");
rarityTier = iconicChecklistItems[index].tier;
} else { // Unreleased = #200 to max #255
index = _checklistId - 200;
require(index < unreleasedCount(), "This Unreleased checklist item doesn't exist.");
rarityTier = unreleasedChecklistItems[index].tier;
}
return tierLimits[uint8(rarityTier)];
}
} | /// @title The contract that manages checklist items, sets, and rarity tiers.
/// @author The CryptoStrikers Team | NatSpecSingleLine | originalsCount | function originalsCount() external view returns (uint256) {
return originalChecklistItems.length;
}
| /// @dev Returns how many Original checklist items we've added. | NatSpecSingleLine | v0.4.24+commit.e67f0147 | bzzr://f87c20fe7eb593456a65c383f65f6ca3a578031b9800b338b3629208d23ef268 | {
"func_code_index": [
5254,
5364
]
} | 5,097 |
|
StrikersChecklist | StrikersChecklist.sol | 0xdbc260a05f81629ffa062df3d1668a43133abba4 | Solidity | StrikersChecklist | contract StrikersChecklist is StrikersPlayerList {
// High level overview of everything going on in this contract:
//
// ChecklistItem is the parent class to Card and has 3 properties:
// - uint8 checklistId (000 to 255)
// - uint8 playerId (see StrikersPlayerList.sol)
// - RarityTier tier (more info below)
//
// Two things to note: the checklistId is not explicitly stored
// on the checklistItem struct, and it's composed of two parts.
// (For the following, assume it is left padded with zeros to reach
// three digits, such that checklistId 0 becomes 000)
// - the first digit represents the setId
// * 0 = Originals Set
// * 1 = Iconics Set
// * 2 = Unreleased Set
// - the last two digits represent its index in the appropriate set arary
//
// For example, checklist ID 100 would represent fhe first checklist item
// in the iconicChecklistItems array (first digit = 1 = Iconics Set, last two
// digits = 00 = first index of array)
//
// Because checklistId is represented as a uint8 throughout the app, the highest
// value it can take is 255, which means we can't add more than 56 items to our
// Unreleased Set's unreleasedChecklistItems array (setId 2). Also, once we've initialized
// this contract, it's impossible for us to add more checklist items to the Originals
// and Iconics set -- what you see here is what you get.
//
// Simple enough right?
/// @dev We initialize this contract with so much data that we have
/// to stage it in 4 different steps, ~33 checklist items at a time.
enum DeployStep {
WaitingForStepOne,
WaitingForStepTwo,
WaitingForStepThree,
WaitingForStepFour,
DoneInitialDeploy
}
/// @dev Enum containing all our rarity tiers, just because
/// it's cleaner dealing with these values than with uint8s.
enum RarityTier {
IconicReferral,
IconicInsert,
Diamond,
Gold,
Silver,
Bronze
}
/// @dev A lookup table indicating how limited the cards
/// in each tier are. If this value is 0, it means
/// that cards of this rarity tier are unlimited,
/// which is only the case for the 8 Iconics cards
/// we give away as part of our referral program.
uint16[] public tierLimits = [
0, // Iconic - Referral Bonus (uncapped)
100, // Iconic Inserts ("Card of the Day")
1000, // Diamond
1664, // Gold
3328, // Silver
4352 // Bronze
];
/// @dev ChecklistItem is essentially the parent class to Card.
/// It represents a given superclass of cards (eg Originals Messi),
/// and then each Card is an instance of this ChecklistItem, with
/// its own serial number, mint date, etc.
struct ChecklistItem {
uint8 playerId;
RarityTier tier;
}
/// @dev The deploy step we're at. Defaults to WaitingForStepOne.
DeployStep public deployStep;
/// @dev Array containing all the Originals checklist items (000 - 099)
ChecklistItem[] public originalChecklistItems;
/// @dev Array containing all the Iconics checklist items (100 - 131)
ChecklistItem[] public iconicChecklistItems;
/// @dev Array containing all the unreleased checklist items (200 - 255 max)
ChecklistItem[] public unreleasedChecklistItems;
/// @dev Internal function to add a checklist item to the Originals set.
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function _addOriginalChecklistItem(uint8 _playerId, RarityTier _tier) internal {
originalChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev Internal function to add a checklist item to the Iconics set.
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function _addIconicChecklistItem(uint8 _playerId, RarityTier _tier) internal {
iconicChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev External function to add a checklist item to our mystery set.
/// Must have completed initial deploy, and can't add more than 56 items (because checklistId is a uint8).
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function addUnreleasedChecklistItem(uint8 _playerId, RarityTier _tier) external onlyOwner {
require(deployStep == DeployStep.DoneInitialDeploy, "Finish deploying the Originals and Iconics sets first.");
require(unreleasedCount() < 56, "You can't add any more checklist items.");
require(_playerId < playerCount, "This player doesn't exist in our player list.");
unreleasedChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev Returns how many Original checklist items we've added.
function originalsCount() external view returns (uint256) {
return originalChecklistItems.length;
}
/// @dev Returns how many Iconic checklist items we've added.
function iconicsCount() public view returns (uint256) {
return iconicChecklistItems.length;
}
/// @dev Returns how many Unreleased checklist items we've added.
function unreleasedCount() public view returns (uint256) {
return unreleasedChecklistItems.length;
}
// In the next four functions, we initialize this contract with our
// 132 initial checklist items (100 Originals, 32 Iconics). Because
// of how much data we need to store, it has to be broken up into
// four different function calls, which need to be called in sequence.
// The ordering of the checklist items we add determines their
// checklist ID, which is left-padded in our frontend to be a
// 3-digit identifier where the first digit is the setId and the last
// 2 digits represents the checklist items index in the appropriate ___ChecklistItems array.
// For example, Originals Messi is the first item for set ID 0, and this
// is displayed as #000 throughout the app. Our Card struct declare its
// checklistId property as uint8, so we have
// to be mindful that we can only have 256 total checklist items.
/// @dev Deploys Originals #000 through #032.
function deployStepOne() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepOne, "You're not following the steps in order...");
/* ORIGINALS - DIAMOND */
_addOriginalChecklistItem(0, RarityTier.Diamond); // 000 Messi
_addOriginalChecklistItem(1, RarityTier.Diamond); // 001 Ronaldo
_addOriginalChecklistItem(2, RarityTier.Diamond); // 002 Neymar
_addOriginalChecklistItem(3, RarityTier.Diamond); // 003 Salah
/* ORIGINALS - GOLD */
_addOriginalChecklistItem(4, RarityTier.Gold); // 004 Lewandowski
_addOriginalChecklistItem(5, RarityTier.Gold); // 005 De Bruyne
_addOriginalChecklistItem(6, RarityTier.Gold); // 006 Modrić
_addOriginalChecklistItem(7, RarityTier.Gold); // 007 Hazard
_addOriginalChecklistItem(8, RarityTier.Gold); // 008 Ramos
_addOriginalChecklistItem(9, RarityTier.Gold); // 009 Kroos
_addOriginalChecklistItem(10, RarityTier.Gold); // 010 Suárez
_addOriginalChecklistItem(11, RarityTier.Gold); // 011 Kane
_addOriginalChecklistItem(12, RarityTier.Gold); // 012 Agüero
_addOriginalChecklistItem(13, RarityTier.Gold); // 013 Mbappé
_addOriginalChecklistItem(14, RarityTier.Gold); // 014 Higuaín
_addOriginalChecklistItem(15, RarityTier.Gold); // 015 de Gea
_addOriginalChecklistItem(16, RarityTier.Gold); // 016 Griezmann
_addOriginalChecklistItem(17, RarityTier.Gold); // 017 Kanté
_addOriginalChecklistItem(18, RarityTier.Gold); // 018 Cavani
_addOriginalChecklistItem(19, RarityTier.Gold); // 019 Pogba
/* ORIGINALS - SILVER (020 to 032) */
_addOriginalChecklistItem(20, RarityTier.Silver); // 020 Isco
_addOriginalChecklistItem(21, RarityTier.Silver); // 021 Marcelo
_addOriginalChecklistItem(22, RarityTier.Silver); // 022 Neuer
_addOriginalChecklistItem(23, RarityTier.Silver); // 023 Mertens
_addOriginalChecklistItem(24, RarityTier.Silver); // 024 James
_addOriginalChecklistItem(25, RarityTier.Silver); // 025 Dybala
_addOriginalChecklistItem(26, RarityTier.Silver); // 026 Eriksen
_addOriginalChecklistItem(27, RarityTier.Silver); // 027 David Silva
_addOriginalChecklistItem(28, RarityTier.Silver); // 028 Gabriel Jesus
_addOriginalChecklistItem(29, RarityTier.Silver); // 029 Thiago
_addOriginalChecklistItem(30, RarityTier.Silver); // 030 Courtois
_addOriginalChecklistItem(31, RarityTier.Silver); // 031 Coutinho
_addOriginalChecklistItem(32, RarityTier.Silver); // 032 Iniesta
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepTwo;
}
/// @dev Deploys Originals #033 through #065.
function deployStepTwo() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepTwo, "You're not following the steps in order...");
/* ORIGINALS - SILVER (033 to 049) */
_addOriginalChecklistItem(33, RarityTier.Silver); // 033 Casemiro
_addOriginalChecklistItem(34, RarityTier.Silver); // 034 Lukaku
_addOriginalChecklistItem(35, RarityTier.Silver); // 035 Piqué
_addOriginalChecklistItem(36, RarityTier.Silver); // 036 Hummels
_addOriginalChecklistItem(37, RarityTier.Silver); // 037 Godín
_addOriginalChecklistItem(38, RarityTier.Silver); // 038 Özil
_addOriginalChecklistItem(39, RarityTier.Silver); // 039 Son
_addOriginalChecklistItem(40, RarityTier.Silver); // 040 Sterling
_addOriginalChecklistItem(41, RarityTier.Silver); // 041 Lloris
_addOriginalChecklistItem(42, RarityTier.Silver); // 042 Falcao
_addOriginalChecklistItem(43, RarityTier.Silver); // 043 Rakitić
_addOriginalChecklistItem(44, RarityTier.Silver); // 044 Sané
_addOriginalChecklistItem(45, RarityTier.Silver); // 045 Firmino
_addOriginalChecklistItem(46, RarityTier.Silver); // 046 Mané
_addOriginalChecklistItem(47, RarityTier.Silver); // 047 Müller
_addOriginalChecklistItem(48, RarityTier.Silver); // 048 Alli
_addOriginalChecklistItem(49, RarityTier.Silver); // 049 Navas
/* ORIGINALS - BRONZE (050 to 065) */
_addOriginalChecklistItem(50, RarityTier.Bronze); // 050 Thiago Silva
_addOriginalChecklistItem(51, RarityTier.Bronze); // 051 Varane
_addOriginalChecklistItem(52, RarityTier.Bronze); // 052 Di María
_addOriginalChecklistItem(53, RarityTier.Bronze); // 053 Alba
_addOriginalChecklistItem(54, RarityTier.Bronze); // 054 Benatia
_addOriginalChecklistItem(55, RarityTier.Bronze); // 055 Werner
_addOriginalChecklistItem(56, RarityTier.Bronze); // 056 Sigurðsson
_addOriginalChecklistItem(57, RarityTier.Bronze); // 057 Matić
_addOriginalChecklistItem(58, RarityTier.Bronze); // 058 Koulibaly
_addOriginalChecklistItem(59, RarityTier.Bronze); // 059 Bernardo Silva
_addOriginalChecklistItem(60, RarityTier.Bronze); // 060 Kompany
_addOriginalChecklistItem(61, RarityTier.Bronze); // 061 Moutinho
_addOriginalChecklistItem(62, RarityTier.Bronze); // 062 Alderweireld
_addOriginalChecklistItem(63, RarityTier.Bronze); // 063 Forsberg
_addOriginalChecklistItem(64, RarityTier.Bronze); // 064 Mandžukić
_addOriginalChecklistItem(65, RarityTier.Bronze); // 065 Milinković-Savić
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepThree;
}
/// @dev Deploys Originals #066 through #099.
function deployStepThree() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepThree, "You're not following the steps in order...");
/* ORIGINALS - BRONZE (066 to 099) */
_addOriginalChecklistItem(66, RarityTier.Bronze); // 066 Kagawa
_addOriginalChecklistItem(67, RarityTier.Bronze); // 067 Xhaka
_addOriginalChecklistItem(68, RarityTier.Bronze); // 068 Christensen
_addOriginalChecklistItem(69, RarityTier.Bronze); // 069 Zieliński
_addOriginalChecklistItem(70, RarityTier.Bronze); // 070 Smolov
_addOriginalChecklistItem(71, RarityTier.Bronze); // 071 Shaqiri
_addOriginalChecklistItem(72, RarityTier.Bronze); // 072 Rashford
_addOriginalChecklistItem(73, RarityTier.Bronze); // 073 Hernández
_addOriginalChecklistItem(74, RarityTier.Bronze); // 074 Lozano
_addOriginalChecklistItem(75, RarityTier.Bronze); // 075 Ziyech
_addOriginalChecklistItem(76, RarityTier.Bronze); // 076 Moses
_addOriginalChecklistItem(77, RarityTier.Bronze); // 077 Farfán
_addOriginalChecklistItem(78, RarityTier.Bronze); // 078 Elneny
_addOriginalChecklistItem(79, RarityTier.Bronze); // 079 Berg
_addOriginalChecklistItem(80, RarityTier.Bronze); // 080 Ochoa
_addOriginalChecklistItem(81, RarityTier.Bronze); // 081 Akinfeev
_addOriginalChecklistItem(82, RarityTier.Bronze); // 082 Azmoun
_addOriginalChecklistItem(83, RarityTier.Bronze); // 083 Cueva
_addOriginalChecklistItem(84, RarityTier.Bronze); // 084 Khazri
_addOriginalChecklistItem(85, RarityTier.Bronze); // 085 Honda
_addOriginalChecklistItem(86, RarityTier.Bronze); // 086 Cahill
_addOriginalChecklistItem(87, RarityTier.Bronze); // 087 Mikel
_addOriginalChecklistItem(88, RarityTier.Bronze); // 088 Sung-yueng
_addOriginalChecklistItem(89, RarityTier.Bronze); // 089 Ruiz
_addOriginalChecklistItem(90, RarityTier.Bronze); // 090 Yoshida
_addOriginalChecklistItem(91, RarityTier.Bronze); // 091 Al Abed
_addOriginalChecklistItem(92, RarityTier.Bronze); // 092 Chung-yong
_addOriginalChecklistItem(93, RarityTier.Bronze); // 093 Gómez
_addOriginalChecklistItem(94, RarityTier.Bronze); // 094 Sliti
_addOriginalChecklistItem(95, RarityTier.Bronze); // 095 Ghoochannejhad
_addOriginalChecklistItem(96, RarityTier.Bronze); // 096 Jedinak
_addOriginalChecklistItem(97, RarityTier.Bronze); // 097 Al-Sahlawi
_addOriginalChecklistItem(98, RarityTier.Bronze); // 098 Gunnarsson
_addOriginalChecklistItem(99, RarityTier.Bronze); // 099 Pérez
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepFour;
}
/// @dev Deploys all Iconics and marks the deploy as complete!
function deployStepFour() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepFour, "You're not following the steps in order...");
/* ICONICS */
_addIconicChecklistItem(0, RarityTier.IconicInsert); // 100 Messi
_addIconicChecklistItem(1, RarityTier.IconicInsert); // 101 Ronaldo
_addIconicChecklistItem(2, RarityTier.IconicInsert); // 102 Neymar
_addIconicChecklistItem(3, RarityTier.IconicInsert); // 103 Salah
_addIconicChecklistItem(4, RarityTier.IconicInsert); // 104 Lewandowski
_addIconicChecklistItem(5, RarityTier.IconicInsert); // 105 De Bruyne
_addIconicChecklistItem(6, RarityTier.IconicInsert); // 106 Modrić
_addIconicChecklistItem(7, RarityTier.IconicInsert); // 107 Hazard
_addIconicChecklistItem(8, RarityTier.IconicInsert); // 108 Ramos
_addIconicChecklistItem(9, RarityTier.IconicInsert); // 109 Kroos
_addIconicChecklistItem(10, RarityTier.IconicInsert); // 110 Suárez
_addIconicChecklistItem(11, RarityTier.IconicInsert); // 111 Kane
_addIconicChecklistItem(12, RarityTier.IconicInsert); // 112 Agüero
_addIconicChecklistItem(15, RarityTier.IconicInsert); // 113 de Gea
_addIconicChecklistItem(16, RarityTier.IconicInsert); // 114 Griezmann
_addIconicChecklistItem(17, RarityTier.IconicReferral); // 115 Kanté
_addIconicChecklistItem(18, RarityTier.IconicReferral); // 116 Cavani
_addIconicChecklistItem(19, RarityTier.IconicInsert); // 117 Pogba
_addIconicChecklistItem(21, RarityTier.IconicInsert); // 118 Marcelo
_addIconicChecklistItem(24, RarityTier.IconicInsert); // 119 James
_addIconicChecklistItem(26, RarityTier.IconicInsert); // 120 Eriksen
_addIconicChecklistItem(29, RarityTier.IconicReferral); // 121 Thiago
_addIconicChecklistItem(36, RarityTier.IconicReferral); // 122 Hummels
_addIconicChecklistItem(38, RarityTier.IconicReferral); // 123 Özil
_addIconicChecklistItem(39, RarityTier.IconicInsert); // 124 Son
_addIconicChecklistItem(46, RarityTier.IconicInsert); // 125 Mané
_addIconicChecklistItem(48, RarityTier.IconicInsert); // 126 Alli
_addIconicChecklistItem(49, RarityTier.IconicReferral); // 127 Navas
_addIconicChecklistItem(73, RarityTier.IconicInsert); // 128 Hernández
_addIconicChecklistItem(85, RarityTier.IconicInsert); // 129 Honda
_addIconicChecklistItem(100, RarityTier.IconicReferral); // 130 Alves
_addIconicChecklistItem(101, RarityTier.IconicReferral); // 131 Zlatan
// Mark the initial deploy as complete.
deployStep = DeployStep.DoneInitialDeploy;
}
/// @dev Returns the mint limit for a given checklist item, based on its tier.
/// @param _checklistId Which checklist item we need to get the limit for.
/// @return How much of this checklist item we are allowed to mint.
function limitForChecklistId(uint8 _checklistId) external view returns (uint16) {
RarityTier rarityTier;
uint8 index;
if (_checklistId < 100) { // Originals = #000 to #099
rarityTier = originalChecklistItems[_checklistId].tier;
} else if (_checklistId < 200) { // Iconics = #100 to #131
index = _checklistId - 100;
require(index < iconicsCount(), "This Iconics checklist item doesn't exist.");
rarityTier = iconicChecklistItems[index].tier;
} else { // Unreleased = #200 to max #255
index = _checklistId - 200;
require(index < unreleasedCount(), "This Unreleased checklist item doesn't exist.");
rarityTier = unreleasedChecklistItems[index].tier;
}
return tierLimits[uint8(rarityTier)];
}
} | /// @title The contract that manages checklist items, sets, and rarity tiers.
/// @author The CryptoStrikers Team | NatSpecSingleLine | iconicsCount | function iconicsCount() public view returns (uint256) {
return iconicChecklistItems.length;
}
| /// @dev Returns how many Iconic checklist items we've added. | NatSpecSingleLine | v0.4.24+commit.e67f0147 | bzzr://f87c20fe7eb593456a65c383f65f6ca3a578031b9800b338b3629208d23ef268 | {
"func_code_index": [
5432,
5536
]
} | 5,098 |
|
StrikersChecklist | StrikersChecklist.sol | 0xdbc260a05f81629ffa062df3d1668a43133abba4 | Solidity | StrikersChecklist | contract StrikersChecklist is StrikersPlayerList {
// High level overview of everything going on in this contract:
//
// ChecklistItem is the parent class to Card and has 3 properties:
// - uint8 checklistId (000 to 255)
// - uint8 playerId (see StrikersPlayerList.sol)
// - RarityTier tier (more info below)
//
// Two things to note: the checklistId is not explicitly stored
// on the checklistItem struct, and it's composed of two parts.
// (For the following, assume it is left padded with zeros to reach
// three digits, such that checklistId 0 becomes 000)
// - the first digit represents the setId
// * 0 = Originals Set
// * 1 = Iconics Set
// * 2 = Unreleased Set
// - the last two digits represent its index in the appropriate set arary
//
// For example, checklist ID 100 would represent fhe first checklist item
// in the iconicChecklistItems array (first digit = 1 = Iconics Set, last two
// digits = 00 = first index of array)
//
// Because checklistId is represented as a uint8 throughout the app, the highest
// value it can take is 255, which means we can't add more than 56 items to our
// Unreleased Set's unreleasedChecklistItems array (setId 2). Also, once we've initialized
// this contract, it's impossible for us to add more checklist items to the Originals
// and Iconics set -- what you see here is what you get.
//
// Simple enough right?
/// @dev We initialize this contract with so much data that we have
/// to stage it in 4 different steps, ~33 checklist items at a time.
enum DeployStep {
WaitingForStepOne,
WaitingForStepTwo,
WaitingForStepThree,
WaitingForStepFour,
DoneInitialDeploy
}
/// @dev Enum containing all our rarity tiers, just because
/// it's cleaner dealing with these values than with uint8s.
enum RarityTier {
IconicReferral,
IconicInsert,
Diamond,
Gold,
Silver,
Bronze
}
/// @dev A lookup table indicating how limited the cards
/// in each tier are. If this value is 0, it means
/// that cards of this rarity tier are unlimited,
/// which is only the case for the 8 Iconics cards
/// we give away as part of our referral program.
uint16[] public tierLimits = [
0, // Iconic - Referral Bonus (uncapped)
100, // Iconic Inserts ("Card of the Day")
1000, // Diamond
1664, // Gold
3328, // Silver
4352 // Bronze
];
/// @dev ChecklistItem is essentially the parent class to Card.
/// It represents a given superclass of cards (eg Originals Messi),
/// and then each Card is an instance of this ChecklistItem, with
/// its own serial number, mint date, etc.
struct ChecklistItem {
uint8 playerId;
RarityTier tier;
}
/// @dev The deploy step we're at. Defaults to WaitingForStepOne.
DeployStep public deployStep;
/// @dev Array containing all the Originals checklist items (000 - 099)
ChecklistItem[] public originalChecklistItems;
/// @dev Array containing all the Iconics checklist items (100 - 131)
ChecklistItem[] public iconicChecklistItems;
/// @dev Array containing all the unreleased checklist items (200 - 255 max)
ChecklistItem[] public unreleasedChecklistItems;
/// @dev Internal function to add a checklist item to the Originals set.
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function _addOriginalChecklistItem(uint8 _playerId, RarityTier _tier) internal {
originalChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev Internal function to add a checklist item to the Iconics set.
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function _addIconicChecklistItem(uint8 _playerId, RarityTier _tier) internal {
iconicChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev External function to add a checklist item to our mystery set.
/// Must have completed initial deploy, and can't add more than 56 items (because checklistId is a uint8).
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function addUnreleasedChecklistItem(uint8 _playerId, RarityTier _tier) external onlyOwner {
require(deployStep == DeployStep.DoneInitialDeploy, "Finish deploying the Originals and Iconics sets first.");
require(unreleasedCount() < 56, "You can't add any more checklist items.");
require(_playerId < playerCount, "This player doesn't exist in our player list.");
unreleasedChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev Returns how many Original checklist items we've added.
function originalsCount() external view returns (uint256) {
return originalChecklistItems.length;
}
/// @dev Returns how many Iconic checklist items we've added.
function iconicsCount() public view returns (uint256) {
return iconicChecklistItems.length;
}
/// @dev Returns how many Unreleased checklist items we've added.
function unreleasedCount() public view returns (uint256) {
return unreleasedChecklistItems.length;
}
// In the next four functions, we initialize this contract with our
// 132 initial checklist items (100 Originals, 32 Iconics). Because
// of how much data we need to store, it has to be broken up into
// four different function calls, which need to be called in sequence.
// The ordering of the checklist items we add determines their
// checklist ID, which is left-padded in our frontend to be a
// 3-digit identifier where the first digit is the setId and the last
// 2 digits represents the checklist items index in the appropriate ___ChecklistItems array.
// For example, Originals Messi is the first item for set ID 0, and this
// is displayed as #000 throughout the app. Our Card struct declare its
// checklistId property as uint8, so we have
// to be mindful that we can only have 256 total checklist items.
/// @dev Deploys Originals #000 through #032.
function deployStepOne() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepOne, "You're not following the steps in order...");
/* ORIGINALS - DIAMOND */
_addOriginalChecklistItem(0, RarityTier.Diamond); // 000 Messi
_addOriginalChecklistItem(1, RarityTier.Diamond); // 001 Ronaldo
_addOriginalChecklistItem(2, RarityTier.Diamond); // 002 Neymar
_addOriginalChecklistItem(3, RarityTier.Diamond); // 003 Salah
/* ORIGINALS - GOLD */
_addOriginalChecklistItem(4, RarityTier.Gold); // 004 Lewandowski
_addOriginalChecklistItem(5, RarityTier.Gold); // 005 De Bruyne
_addOriginalChecklistItem(6, RarityTier.Gold); // 006 Modrić
_addOriginalChecklistItem(7, RarityTier.Gold); // 007 Hazard
_addOriginalChecklistItem(8, RarityTier.Gold); // 008 Ramos
_addOriginalChecklistItem(9, RarityTier.Gold); // 009 Kroos
_addOriginalChecklistItem(10, RarityTier.Gold); // 010 Suárez
_addOriginalChecklistItem(11, RarityTier.Gold); // 011 Kane
_addOriginalChecklistItem(12, RarityTier.Gold); // 012 Agüero
_addOriginalChecklistItem(13, RarityTier.Gold); // 013 Mbappé
_addOriginalChecklistItem(14, RarityTier.Gold); // 014 Higuaín
_addOriginalChecklistItem(15, RarityTier.Gold); // 015 de Gea
_addOriginalChecklistItem(16, RarityTier.Gold); // 016 Griezmann
_addOriginalChecklistItem(17, RarityTier.Gold); // 017 Kanté
_addOriginalChecklistItem(18, RarityTier.Gold); // 018 Cavani
_addOriginalChecklistItem(19, RarityTier.Gold); // 019 Pogba
/* ORIGINALS - SILVER (020 to 032) */
_addOriginalChecklistItem(20, RarityTier.Silver); // 020 Isco
_addOriginalChecklistItem(21, RarityTier.Silver); // 021 Marcelo
_addOriginalChecklistItem(22, RarityTier.Silver); // 022 Neuer
_addOriginalChecklistItem(23, RarityTier.Silver); // 023 Mertens
_addOriginalChecklistItem(24, RarityTier.Silver); // 024 James
_addOriginalChecklistItem(25, RarityTier.Silver); // 025 Dybala
_addOriginalChecklistItem(26, RarityTier.Silver); // 026 Eriksen
_addOriginalChecklistItem(27, RarityTier.Silver); // 027 David Silva
_addOriginalChecklistItem(28, RarityTier.Silver); // 028 Gabriel Jesus
_addOriginalChecklistItem(29, RarityTier.Silver); // 029 Thiago
_addOriginalChecklistItem(30, RarityTier.Silver); // 030 Courtois
_addOriginalChecklistItem(31, RarityTier.Silver); // 031 Coutinho
_addOriginalChecklistItem(32, RarityTier.Silver); // 032 Iniesta
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepTwo;
}
/// @dev Deploys Originals #033 through #065.
function deployStepTwo() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepTwo, "You're not following the steps in order...");
/* ORIGINALS - SILVER (033 to 049) */
_addOriginalChecklistItem(33, RarityTier.Silver); // 033 Casemiro
_addOriginalChecklistItem(34, RarityTier.Silver); // 034 Lukaku
_addOriginalChecklistItem(35, RarityTier.Silver); // 035 Piqué
_addOriginalChecklistItem(36, RarityTier.Silver); // 036 Hummels
_addOriginalChecklistItem(37, RarityTier.Silver); // 037 Godín
_addOriginalChecklistItem(38, RarityTier.Silver); // 038 Özil
_addOriginalChecklistItem(39, RarityTier.Silver); // 039 Son
_addOriginalChecklistItem(40, RarityTier.Silver); // 040 Sterling
_addOriginalChecklistItem(41, RarityTier.Silver); // 041 Lloris
_addOriginalChecklistItem(42, RarityTier.Silver); // 042 Falcao
_addOriginalChecklistItem(43, RarityTier.Silver); // 043 Rakitić
_addOriginalChecklistItem(44, RarityTier.Silver); // 044 Sané
_addOriginalChecklistItem(45, RarityTier.Silver); // 045 Firmino
_addOriginalChecklistItem(46, RarityTier.Silver); // 046 Mané
_addOriginalChecklistItem(47, RarityTier.Silver); // 047 Müller
_addOriginalChecklistItem(48, RarityTier.Silver); // 048 Alli
_addOriginalChecklistItem(49, RarityTier.Silver); // 049 Navas
/* ORIGINALS - BRONZE (050 to 065) */
_addOriginalChecklistItem(50, RarityTier.Bronze); // 050 Thiago Silva
_addOriginalChecklistItem(51, RarityTier.Bronze); // 051 Varane
_addOriginalChecklistItem(52, RarityTier.Bronze); // 052 Di María
_addOriginalChecklistItem(53, RarityTier.Bronze); // 053 Alba
_addOriginalChecklistItem(54, RarityTier.Bronze); // 054 Benatia
_addOriginalChecklistItem(55, RarityTier.Bronze); // 055 Werner
_addOriginalChecklistItem(56, RarityTier.Bronze); // 056 Sigurðsson
_addOriginalChecklistItem(57, RarityTier.Bronze); // 057 Matić
_addOriginalChecklistItem(58, RarityTier.Bronze); // 058 Koulibaly
_addOriginalChecklistItem(59, RarityTier.Bronze); // 059 Bernardo Silva
_addOriginalChecklistItem(60, RarityTier.Bronze); // 060 Kompany
_addOriginalChecklistItem(61, RarityTier.Bronze); // 061 Moutinho
_addOriginalChecklistItem(62, RarityTier.Bronze); // 062 Alderweireld
_addOriginalChecklistItem(63, RarityTier.Bronze); // 063 Forsberg
_addOriginalChecklistItem(64, RarityTier.Bronze); // 064 Mandžukić
_addOriginalChecklistItem(65, RarityTier.Bronze); // 065 Milinković-Savić
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepThree;
}
/// @dev Deploys Originals #066 through #099.
function deployStepThree() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepThree, "You're not following the steps in order...");
/* ORIGINALS - BRONZE (066 to 099) */
_addOriginalChecklistItem(66, RarityTier.Bronze); // 066 Kagawa
_addOriginalChecklistItem(67, RarityTier.Bronze); // 067 Xhaka
_addOriginalChecklistItem(68, RarityTier.Bronze); // 068 Christensen
_addOriginalChecklistItem(69, RarityTier.Bronze); // 069 Zieliński
_addOriginalChecklistItem(70, RarityTier.Bronze); // 070 Smolov
_addOriginalChecklistItem(71, RarityTier.Bronze); // 071 Shaqiri
_addOriginalChecklistItem(72, RarityTier.Bronze); // 072 Rashford
_addOriginalChecklistItem(73, RarityTier.Bronze); // 073 Hernández
_addOriginalChecklistItem(74, RarityTier.Bronze); // 074 Lozano
_addOriginalChecklistItem(75, RarityTier.Bronze); // 075 Ziyech
_addOriginalChecklistItem(76, RarityTier.Bronze); // 076 Moses
_addOriginalChecklistItem(77, RarityTier.Bronze); // 077 Farfán
_addOriginalChecklistItem(78, RarityTier.Bronze); // 078 Elneny
_addOriginalChecklistItem(79, RarityTier.Bronze); // 079 Berg
_addOriginalChecklistItem(80, RarityTier.Bronze); // 080 Ochoa
_addOriginalChecklistItem(81, RarityTier.Bronze); // 081 Akinfeev
_addOriginalChecklistItem(82, RarityTier.Bronze); // 082 Azmoun
_addOriginalChecklistItem(83, RarityTier.Bronze); // 083 Cueva
_addOriginalChecklistItem(84, RarityTier.Bronze); // 084 Khazri
_addOriginalChecklistItem(85, RarityTier.Bronze); // 085 Honda
_addOriginalChecklistItem(86, RarityTier.Bronze); // 086 Cahill
_addOriginalChecklistItem(87, RarityTier.Bronze); // 087 Mikel
_addOriginalChecklistItem(88, RarityTier.Bronze); // 088 Sung-yueng
_addOriginalChecklistItem(89, RarityTier.Bronze); // 089 Ruiz
_addOriginalChecklistItem(90, RarityTier.Bronze); // 090 Yoshida
_addOriginalChecklistItem(91, RarityTier.Bronze); // 091 Al Abed
_addOriginalChecklistItem(92, RarityTier.Bronze); // 092 Chung-yong
_addOriginalChecklistItem(93, RarityTier.Bronze); // 093 Gómez
_addOriginalChecklistItem(94, RarityTier.Bronze); // 094 Sliti
_addOriginalChecklistItem(95, RarityTier.Bronze); // 095 Ghoochannejhad
_addOriginalChecklistItem(96, RarityTier.Bronze); // 096 Jedinak
_addOriginalChecklistItem(97, RarityTier.Bronze); // 097 Al-Sahlawi
_addOriginalChecklistItem(98, RarityTier.Bronze); // 098 Gunnarsson
_addOriginalChecklistItem(99, RarityTier.Bronze); // 099 Pérez
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepFour;
}
/// @dev Deploys all Iconics and marks the deploy as complete!
function deployStepFour() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepFour, "You're not following the steps in order...");
/* ICONICS */
_addIconicChecklistItem(0, RarityTier.IconicInsert); // 100 Messi
_addIconicChecklistItem(1, RarityTier.IconicInsert); // 101 Ronaldo
_addIconicChecklistItem(2, RarityTier.IconicInsert); // 102 Neymar
_addIconicChecklistItem(3, RarityTier.IconicInsert); // 103 Salah
_addIconicChecklistItem(4, RarityTier.IconicInsert); // 104 Lewandowski
_addIconicChecklistItem(5, RarityTier.IconicInsert); // 105 De Bruyne
_addIconicChecklistItem(6, RarityTier.IconicInsert); // 106 Modrić
_addIconicChecklistItem(7, RarityTier.IconicInsert); // 107 Hazard
_addIconicChecklistItem(8, RarityTier.IconicInsert); // 108 Ramos
_addIconicChecklistItem(9, RarityTier.IconicInsert); // 109 Kroos
_addIconicChecklistItem(10, RarityTier.IconicInsert); // 110 Suárez
_addIconicChecklistItem(11, RarityTier.IconicInsert); // 111 Kane
_addIconicChecklistItem(12, RarityTier.IconicInsert); // 112 Agüero
_addIconicChecklistItem(15, RarityTier.IconicInsert); // 113 de Gea
_addIconicChecklistItem(16, RarityTier.IconicInsert); // 114 Griezmann
_addIconicChecklistItem(17, RarityTier.IconicReferral); // 115 Kanté
_addIconicChecklistItem(18, RarityTier.IconicReferral); // 116 Cavani
_addIconicChecklistItem(19, RarityTier.IconicInsert); // 117 Pogba
_addIconicChecklistItem(21, RarityTier.IconicInsert); // 118 Marcelo
_addIconicChecklistItem(24, RarityTier.IconicInsert); // 119 James
_addIconicChecklistItem(26, RarityTier.IconicInsert); // 120 Eriksen
_addIconicChecklistItem(29, RarityTier.IconicReferral); // 121 Thiago
_addIconicChecklistItem(36, RarityTier.IconicReferral); // 122 Hummels
_addIconicChecklistItem(38, RarityTier.IconicReferral); // 123 Özil
_addIconicChecklistItem(39, RarityTier.IconicInsert); // 124 Son
_addIconicChecklistItem(46, RarityTier.IconicInsert); // 125 Mané
_addIconicChecklistItem(48, RarityTier.IconicInsert); // 126 Alli
_addIconicChecklistItem(49, RarityTier.IconicReferral); // 127 Navas
_addIconicChecklistItem(73, RarityTier.IconicInsert); // 128 Hernández
_addIconicChecklistItem(85, RarityTier.IconicInsert); // 129 Honda
_addIconicChecklistItem(100, RarityTier.IconicReferral); // 130 Alves
_addIconicChecklistItem(101, RarityTier.IconicReferral); // 131 Zlatan
// Mark the initial deploy as complete.
deployStep = DeployStep.DoneInitialDeploy;
}
/// @dev Returns the mint limit for a given checklist item, based on its tier.
/// @param _checklistId Which checklist item we need to get the limit for.
/// @return How much of this checklist item we are allowed to mint.
function limitForChecklistId(uint8 _checklistId) external view returns (uint16) {
RarityTier rarityTier;
uint8 index;
if (_checklistId < 100) { // Originals = #000 to #099
rarityTier = originalChecklistItems[_checklistId].tier;
} else if (_checklistId < 200) { // Iconics = #100 to #131
index = _checklistId - 100;
require(index < iconicsCount(), "This Iconics checklist item doesn't exist.");
rarityTier = iconicChecklistItems[index].tier;
} else { // Unreleased = #200 to max #255
index = _checklistId - 200;
require(index < unreleasedCount(), "This Unreleased checklist item doesn't exist.");
rarityTier = unreleasedChecklistItems[index].tier;
}
return tierLimits[uint8(rarityTier)];
}
} | /// @title The contract that manages checklist items, sets, and rarity tiers.
/// @author The CryptoStrikers Team | NatSpecSingleLine | unreleasedCount | function unreleasedCount() public view returns (uint256) {
return unreleasedChecklistItems.length;
}
| /// @dev Returns how many Unreleased checklist items we've added. | NatSpecSingleLine | v0.4.24+commit.e67f0147 | bzzr://f87c20fe7eb593456a65c383f65f6ca3a578031b9800b338b3629208d23ef268 | {
"func_code_index": [
5608,
5719
]
} | 5,099 |
|
StrikersChecklist | StrikersChecklist.sol | 0xdbc260a05f81629ffa062df3d1668a43133abba4 | Solidity | StrikersChecklist | contract StrikersChecklist is StrikersPlayerList {
// High level overview of everything going on in this contract:
//
// ChecklistItem is the parent class to Card and has 3 properties:
// - uint8 checklistId (000 to 255)
// - uint8 playerId (see StrikersPlayerList.sol)
// - RarityTier tier (more info below)
//
// Two things to note: the checklistId is not explicitly stored
// on the checklistItem struct, and it's composed of two parts.
// (For the following, assume it is left padded with zeros to reach
// three digits, such that checklistId 0 becomes 000)
// - the first digit represents the setId
// * 0 = Originals Set
// * 1 = Iconics Set
// * 2 = Unreleased Set
// - the last two digits represent its index in the appropriate set arary
//
// For example, checklist ID 100 would represent fhe first checklist item
// in the iconicChecklistItems array (first digit = 1 = Iconics Set, last two
// digits = 00 = first index of array)
//
// Because checklistId is represented as a uint8 throughout the app, the highest
// value it can take is 255, which means we can't add more than 56 items to our
// Unreleased Set's unreleasedChecklistItems array (setId 2). Also, once we've initialized
// this contract, it's impossible for us to add more checklist items to the Originals
// and Iconics set -- what you see here is what you get.
//
// Simple enough right?
/// @dev We initialize this contract with so much data that we have
/// to stage it in 4 different steps, ~33 checklist items at a time.
enum DeployStep {
WaitingForStepOne,
WaitingForStepTwo,
WaitingForStepThree,
WaitingForStepFour,
DoneInitialDeploy
}
/// @dev Enum containing all our rarity tiers, just because
/// it's cleaner dealing with these values than with uint8s.
enum RarityTier {
IconicReferral,
IconicInsert,
Diamond,
Gold,
Silver,
Bronze
}
/// @dev A lookup table indicating how limited the cards
/// in each tier are. If this value is 0, it means
/// that cards of this rarity tier are unlimited,
/// which is only the case for the 8 Iconics cards
/// we give away as part of our referral program.
uint16[] public tierLimits = [
0, // Iconic - Referral Bonus (uncapped)
100, // Iconic Inserts ("Card of the Day")
1000, // Diamond
1664, // Gold
3328, // Silver
4352 // Bronze
];
/// @dev ChecklistItem is essentially the parent class to Card.
/// It represents a given superclass of cards (eg Originals Messi),
/// and then each Card is an instance of this ChecklistItem, with
/// its own serial number, mint date, etc.
struct ChecklistItem {
uint8 playerId;
RarityTier tier;
}
/// @dev The deploy step we're at. Defaults to WaitingForStepOne.
DeployStep public deployStep;
/// @dev Array containing all the Originals checklist items (000 - 099)
ChecklistItem[] public originalChecklistItems;
/// @dev Array containing all the Iconics checklist items (100 - 131)
ChecklistItem[] public iconicChecklistItems;
/// @dev Array containing all the unreleased checklist items (200 - 255 max)
ChecklistItem[] public unreleasedChecklistItems;
/// @dev Internal function to add a checklist item to the Originals set.
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function _addOriginalChecklistItem(uint8 _playerId, RarityTier _tier) internal {
originalChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev Internal function to add a checklist item to the Iconics set.
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function _addIconicChecklistItem(uint8 _playerId, RarityTier _tier) internal {
iconicChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev External function to add a checklist item to our mystery set.
/// Must have completed initial deploy, and can't add more than 56 items (because checklistId is a uint8).
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function addUnreleasedChecklistItem(uint8 _playerId, RarityTier _tier) external onlyOwner {
require(deployStep == DeployStep.DoneInitialDeploy, "Finish deploying the Originals and Iconics sets first.");
require(unreleasedCount() < 56, "You can't add any more checklist items.");
require(_playerId < playerCount, "This player doesn't exist in our player list.");
unreleasedChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev Returns how many Original checklist items we've added.
function originalsCount() external view returns (uint256) {
return originalChecklistItems.length;
}
/// @dev Returns how many Iconic checklist items we've added.
function iconicsCount() public view returns (uint256) {
return iconicChecklistItems.length;
}
/// @dev Returns how many Unreleased checklist items we've added.
function unreleasedCount() public view returns (uint256) {
return unreleasedChecklistItems.length;
}
// In the next four functions, we initialize this contract with our
// 132 initial checklist items (100 Originals, 32 Iconics). Because
// of how much data we need to store, it has to be broken up into
// four different function calls, which need to be called in sequence.
// The ordering of the checklist items we add determines their
// checklist ID, which is left-padded in our frontend to be a
// 3-digit identifier where the first digit is the setId and the last
// 2 digits represents the checklist items index in the appropriate ___ChecklistItems array.
// For example, Originals Messi is the first item for set ID 0, and this
// is displayed as #000 throughout the app. Our Card struct declare its
// checklistId property as uint8, so we have
// to be mindful that we can only have 256 total checklist items.
/// @dev Deploys Originals #000 through #032.
function deployStepOne() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepOne, "You're not following the steps in order...");
/* ORIGINALS - DIAMOND */
_addOriginalChecklistItem(0, RarityTier.Diamond); // 000 Messi
_addOriginalChecklistItem(1, RarityTier.Diamond); // 001 Ronaldo
_addOriginalChecklistItem(2, RarityTier.Diamond); // 002 Neymar
_addOriginalChecklistItem(3, RarityTier.Diamond); // 003 Salah
/* ORIGINALS - GOLD */
_addOriginalChecklistItem(4, RarityTier.Gold); // 004 Lewandowski
_addOriginalChecklistItem(5, RarityTier.Gold); // 005 De Bruyne
_addOriginalChecklistItem(6, RarityTier.Gold); // 006 Modrić
_addOriginalChecklistItem(7, RarityTier.Gold); // 007 Hazard
_addOriginalChecklistItem(8, RarityTier.Gold); // 008 Ramos
_addOriginalChecklistItem(9, RarityTier.Gold); // 009 Kroos
_addOriginalChecklistItem(10, RarityTier.Gold); // 010 Suárez
_addOriginalChecklistItem(11, RarityTier.Gold); // 011 Kane
_addOriginalChecklistItem(12, RarityTier.Gold); // 012 Agüero
_addOriginalChecklistItem(13, RarityTier.Gold); // 013 Mbappé
_addOriginalChecklistItem(14, RarityTier.Gold); // 014 Higuaín
_addOriginalChecklistItem(15, RarityTier.Gold); // 015 de Gea
_addOriginalChecklistItem(16, RarityTier.Gold); // 016 Griezmann
_addOriginalChecklistItem(17, RarityTier.Gold); // 017 Kanté
_addOriginalChecklistItem(18, RarityTier.Gold); // 018 Cavani
_addOriginalChecklistItem(19, RarityTier.Gold); // 019 Pogba
/* ORIGINALS - SILVER (020 to 032) */
_addOriginalChecklistItem(20, RarityTier.Silver); // 020 Isco
_addOriginalChecklistItem(21, RarityTier.Silver); // 021 Marcelo
_addOriginalChecklistItem(22, RarityTier.Silver); // 022 Neuer
_addOriginalChecklistItem(23, RarityTier.Silver); // 023 Mertens
_addOriginalChecklistItem(24, RarityTier.Silver); // 024 James
_addOriginalChecklistItem(25, RarityTier.Silver); // 025 Dybala
_addOriginalChecklistItem(26, RarityTier.Silver); // 026 Eriksen
_addOriginalChecklistItem(27, RarityTier.Silver); // 027 David Silva
_addOriginalChecklistItem(28, RarityTier.Silver); // 028 Gabriel Jesus
_addOriginalChecklistItem(29, RarityTier.Silver); // 029 Thiago
_addOriginalChecklistItem(30, RarityTier.Silver); // 030 Courtois
_addOriginalChecklistItem(31, RarityTier.Silver); // 031 Coutinho
_addOriginalChecklistItem(32, RarityTier.Silver); // 032 Iniesta
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepTwo;
}
/// @dev Deploys Originals #033 through #065.
function deployStepTwo() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepTwo, "You're not following the steps in order...");
/* ORIGINALS - SILVER (033 to 049) */
_addOriginalChecklistItem(33, RarityTier.Silver); // 033 Casemiro
_addOriginalChecklistItem(34, RarityTier.Silver); // 034 Lukaku
_addOriginalChecklistItem(35, RarityTier.Silver); // 035 Piqué
_addOriginalChecklistItem(36, RarityTier.Silver); // 036 Hummels
_addOriginalChecklistItem(37, RarityTier.Silver); // 037 Godín
_addOriginalChecklistItem(38, RarityTier.Silver); // 038 Özil
_addOriginalChecklistItem(39, RarityTier.Silver); // 039 Son
_addOriginalChecklistItem(40, RarityTier.Silver); // 040 Sterling
_addOriginalChecklistItem(41, RarityTier.Silver); // 041 Lloris
_addOriginalChecklistItem(42, RarityTier.Silver); // 042 Falcao
_addOriginalChecklistItem(43, RarityTier.Silver); // 043 Rakitić
_addOriginalChecklistItem(44, RarityTier.Silver); // 044 Sané
_addOriginalChecklistItem(45, RarityTier.Silver); // 045 Firmino
_addOriginalChecklistItem(46, RarityTier.Silver); // 046 Mané
_addOriginalChecklistItem(47, RarityTier.Silver); // 047 Müller
_addOriginalChecklistItem(48, RarityTier.Silver); // 048 Alli
_addOriginalChecklistItem(49, RarityTier.Silver); // 049 Navas
/* ORIGINALS - BRONZE (050 to 065) */
_addOriginalChecklistItem(50, RarityTier.Bronze); // 050 Thiago Silva
_addOriginalChecklistItem(51, RarityTier.Bronze); // 051 Varane
_addOriginalChecklistItem(52, RarityTier.Bronze); // 052 Di María
_addOriginalChecklistItem(53, RarityTier.Bronze); // 053 Alba
_addOriginalChecklistItem(54, RarityTier.Bronze); // 054 Benatia
_addOriginalChecklistItem(55, RarityTier.Bronze); // 055 Werner
_addOriginalChecklistItem(56, RarityTier.Bronze); // 056 Sigurðsson
_addOriginalChecklistItem(57, RarityTier.Bronze); // 057 Matić
_addOriginalChecklistItem(58, RarityTier.Bronze); // 058 Koulibaly
_addOriginalChecklistItem(59, RarityTier.Bronze); // 059 Bernardo Silva
_addOriginalChecklistItem(60, RarityTier.Bronze); // 060 Kompany
_addOriginalChecklistItem(61, RarityTier.Bronze); // 061 Moutinho
_addOriginalChecklistItem(62, RarityTier.Bronze); // 062 Alderweireld
_addOriginalChecklistItem(63, RarityTier.Bronze); // 063 Forsberg
_addOriginalChecklistItem(64, RarityTier.Bronze); // 064 Mandžukić
_addOriginalChecklistItem(65, RarityTier.Bronze); // 065 Milinković-Savić
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepThree;
}
/// @dev Deploys Originals #066 through #099.
function deployStepThree() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepThree, "You're not following the steps in order...");
/* ORIGINALS - BRONZE (066 to 099) */
_addOriginalChecklistItem(66, RarityTier.Bronze); // 066 Kagawa
_addOriginalChecklistItem(67, RarityTier.Bronze); // 067 Xhaka
_addOriginalChecklistItem(68, RarityTier.Bronze); // 068 Christensen
_addOriginalChecklistItem(69, RarityTier.Bronze); // 069 Zieliński
_addOriginalChecklistItem(70, RarityTier.Bronze); // 070 Smolov
_addOriginalChecklistItem(71, RarityTier.Bronze); // 071 Shaqiri
_addOriginalChecklistItem(72, RarityTier.Bronze); // 072 Rashford
_addOriginalChecklistItem(73, RarityTier.Bronze); // 073 Hernández
_addOriginalChecklistItem(74, RarityTier.Bronze); // 074 Lozano
_addOriginalChecklistItem(75, RarityTier.Bronze); // 075 Ziyech
_addOriginalChecklistItem(76, RarityTier.Bronze); // 076 Moses
_addOriginalChecklistItem(77, RarityTier.Bronze); // 077 Farfán
_addOriginalChecklistItem(78, RarityTier.Bronze); // 078 Elneny
_addOriginalChecklistItem(79, RarityTier.Bronze); // 079 Berg
_addOriginalChecklistItem(80, RarityTier.Bronze); // 080 Ochoa
_addOriginalChecklistItem(81, RarityTier.Bronze); // 081 Akinfeev
_addOriginalChecklistItem(82, RarityTier.Bronze); // 082 Azmoun
_addOriginalChecklistItem(83, RarityTier.Bronze); // 083 Cueva
_addOriginalChecklistItem(84, RarityTier.Bronze); // 084 Khazri
_addOriginalChecklistItem(85, RarityTier.Bronze); // 085 Honda
_addOriginalChecklistItem(86, RarityTier.Bronze); // 086 Cahill
_addOriginalChecklistItem(87, RarityTier.Bronze); // 087 Mikel
_addOriginalChecklistItem(88, RarityTier.Bronze); // 088 Sung-yueng
_addOriginalChecklistItem(89, RarityTier.Bronze); // 089 Ruiz
_addOriginalChecklistItem(90, RarityTier.Bronze); // 090 Yoshida
_addOriginalChecklistItem(91, RarityTier.Bronze); // 091 Al Abed
_addOriginalChecklistItem(92, RarityTier.Bronze); // 092 Chung-yong
_addOriginalChecklistItem(93, RarityTier.Bronze); // 093 Gómez
_addOriginalChecklistItem(94, RarityTier.Bronze); // 094 Sliti
_addOriginalChecklistItem(95, RarityTier.Bronze); // 095 Ghoochannejhad
_addOriginalChecklistItem(96, RarityTier.Bronze); // 096 Jedinak
_addOriginalChecklistItem(97, RarityTier.Bronze); // 097 Al-Sahlawi
_addOriginalChecklistItem(98, RarityTier.Bronze); // 098 Gunnarsson
_addOriginalChecklistItem(99, RarityTier.Bronze); // 099 Pérez
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepFour;
}
/// @dev Deploys all Iconics and marks the deploy as complete!
function deployStepFour() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepFour, "You're not following the steps in order...");
/* ICONICS */
_addIconicChecklistItem(0, RarityTier.IconicInsert); // 100 Messi
_addIconicChecklistItem(1, RarityTier.IconicInsert); // 101 Ronaldo
_addIconicChecklistItem(2, RarityTier.IconicInsert); // 102 Neymar
_addIconicChecklistItem(3, RarityTier.IconicInsert); // 103 Salah
_addIconicChecklistItem(4, RarityTier.IconicInsert); // 104 Lewandowski
_addIconicChecklistItem(5, RarityTier.IconicInsert); // 105 De Bruyne
_addIconicChecklistItem(6, RarityTier.IconicInsert); // 106 Modrić
_addIconicChecklistItem(7, RarityTier.IconicInsert); // 107 Hazard
_addIconicChecklistItem(8, RarityTier.IconicInsert); // 108 Ramos
_addIconicChecklistItem(9, RarityTier.IconicInsert); // 109 Kroos
_addIconicChecklistItem(10, RarityTier.IconicInsert); // 110 Suárez
_addIconicChecklistItem(11, RarityTier.IconicInsert); // 111 Kane
_addIconicChecklistItem(12, RarityTier.IconicInsert); // 112 Agüero
_addIconicChecklistItem(15, RarityTier.IconicInsert); // 113 de Gea
_addIconicChecklistItem(16, RarityTier.IconicInsert); // 114 Griezmann
_addIconicChecklistItem(17, RarityTier.IconicReferral); // 115 Kanté
_addIconicChecklistItem(18, RarityTier.IconicReferral); // 116 Cavani
_addIconicChecklistItem(19, RarityTier.IconicInsert); // 117 Pogba
_addIconicChecklistItem(21, RarityTier.IconicInsert); // 118 Marcelo
_addIconicChecklistItem(24, RarityTier.IconicInsert); // 119 James
_addIconicChecklistItem(26, RarityTier.IconicInsert); // 120 Eriksen
_addIconicChecklistItem(29, RarityTier.IconicReferral); // 121 Thiago
_addIconicChecklistItem(36, RarityTier.IconicReferral); // 122 Hummels
_addIconicChecklistItem(38, RarityTier.IconicReferral); // 123 Özil
_addIconicChecklistItem(39, RarityTier.IconicInsert); // 124 Son
_addIconicChecklistItem(46, RarityTier.IconicInsert); // 125 Mané
_addIconicChecklistItem(48, RarityTier.IconicInsert); // 126 Alli
_addIconicChecklistItem(49, RarityTier.IconicReferral); // 127 Navas
_addIconicChecklistItem(73, RarityTier.IconicInsert); // 128 Hernández
_addIconicChecklistItem(85, RarityTier.IconicInsert); // 129 Honda
_addIconicChecklistItem(100, RarityTier.IconicReferral); // 130 Alves
_addIconicChecklistItem(101, RarityTier.IconicReferral); // 131 Zlatan
// Mark the initial deploy as complete.
deployStep = DeployStep.DoneInitialDeploy;
}
/// @dev Returns the mint limit for a given checklist item, based on its tier.
/// @param _checklistId Which checklist item we need to get the limit for.
/// @return How much of this checklist item we are allowed to mint.
function limitForChecklistId(uint8 _checklistId) external view returns (uint16) {
RarityTier rarityTier;
uint8 index;
if (_checklistId < 100) { // Originals = #000 to #099
rarityTier = originalChecklistItems[_checklistId].tier;
} else if (_checklistId < 200) { // Iconics = #100 to #131
index = _checklistId - 100;
require(index < iconicsCount(), "This Iconics checklist item doesn't exist.");
rarityTier = iconicChecklistItems[index].tier;
} else { // Unreleased = #200 to max #255
index = _checklistId - 200;
require(index < unreleasedCount(), "This Unreleased checklist item doesn't exist.");
rarityTier = unreleasedChecklistItems[index].tier;
}
return tierLimits[uint8(rarityTier)];
}
} | /// @title The contract that manages checklist items, sets, and rarity tiers.
/// @author The CryptoStrikers Team | NatSpecSingleLine | deployStepOne | function deployStepOne() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepOne, "You're not following the steps in order...");
/* ORIGINALS - DIAMOND */
_addOriginalChecklistItem(0, RarityTier.Diamond); // 000 Messi
_addOriginalChecklistItem(1, RarityTier.Diamond); // 001 Ronaldo
_addOriginalChecklistItem(2, RarityTier.Diamond); // 002 Neymar
_addOriginalChecklistItem(3, RarityTier.Diamond); // 003 Salah
/* ORIGINALS - GOLD */
_addOriginalChecklistItem(4, RarityTier.Gold); // 004 Lewandowski
_addOriginalChecklistItem(5, RarityTier.Gold); // 005 De Bruyne
_addOriginalChecklistItem(6, RarityTier.Gold); // 006 Modrić
_addOriginalChecklistItem(7, RarityTier.Gold); // 007 Hazard
_addOriginalChecklistItem(8, RarityTier.Gold); // 008 Ramos
_addOriginalChecklistItem(9, RarityTier.Gold); // 009 Kroos
_addOriginalChecklistItem(10, RarityTier.Gold); // 010 Suárez
_addOriginalChecklistItem(11, RarityTier.Gold); // 011 Kane
_addOriginalChecklistItem(12, RarityTier.Gold); // 012 Agüero
_addOriginalChecklistItem(13, RarityTier.Gold); // 013 Mbappé
_addOriginalChecklistItem(14, RarityTier.Gold); // 014 Higuaín
_addOriginalChecklistItem(15, RarityTier.Gold); // 015 de Gea
_addOriginalChecklistItem(16, RarityTier.Gold); // 016 Griezmann
_addOriginalChecklistItem(17, RarityTier.Gold); // 017 Kanté
_addOriginalChecklistItem(18, RarityTier.Gold); // 018 Cavani
_addOriginalChecklistItem(19, RarityTier.Gold); // 019 Pogba
/* ORIGINALS - SILVER (020 to 032) */
_addOriginalChecklistItem(20, RarityTier.Silver); // 020 Isco
_addOriginalChecklistItem(21, RarityTier.Silver); // 021 Marcelo
_addOriginalChecklistItem(22, RarityTier.Silver); // 022 Neuer
_addOriginalChecklistItem(23, RarityTier.Silver); // 023 Mertens
_addOriginalChecklistItem(24, RarityTier.Silver); // 024 James
_addOriginalChecklistItem(25, RarityTier.Silver); // 025 Dybala
_addOriginalChecklistItem(26, RarityTier.Silver); // 026 Eriksen
_addOriginalChecklistItem(27, RarityTier.Silver); // 027 David Silva
_addOriginalChecklistItem(28, RarityTier.Silver); // 028 Gabriel Jesus
_addOriginalChecklistItem(29, RarityTier.Silver); // 029 Thiago
_addOriginalChecklistItem(30, RarityTier.Silver); // 030 Courtois
_addOriginalChecklistItem(31, RarityTier.Silver); // 031 Coutinho
_addOriginalChecklistItem(32, RarityTier.Silver); // 032 Iniesta
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepTwo;
}
| /// @dev Deploys Originals #000 through #032. | NatSpecSingleLine | v0.4.24+commit.e67f0147 | bzzr://f87c20fe7eb593456a65c383f65f6ca3a578031b9800b338b3629208d23ef268 | {
"func_code_index": [
6626,
9239
]
} | 5,100 |
|
StrikersChecklist | StrikersChecklist.sol | 0xdbc260a05f81629ffa062df3d1668a43133abba4 | Solidity | StrikersChecklist | contract StrikersChecklist is StrikersPlayerList {
// High level overview of everything going on in this contract:
//
// ChecklistItem is the parent class to Card and has 3 properties:
// - uint8 checklistId (000 to 255)
// - uint8 playerId (see StrikersPlayerList.sol)
// - RarityTier tier (more info below)
//
// Two things to note: the checklistId is not explicitly stored
// on the checklistItem struct, and it's composed of two parts.
// (For the following, assume it is left padded with zeros to reach
// three digits, such that checklistId 0 becomes 000)
// - the first digit represents the setId
// * 0 = Originals Set
// * 1 = Iconics Set
// * 2 = Unreleased Set
// - the last two digits represent its index in the appropriate set arary
//
// For example, checklist ID 100 would represent fhe first checklist item
// in the iconicChecklistItems array (first digit = 1 = Iconics Set, last two
// digits = 00 = first index of array)
//
// Because checklistId is represented as a uint8 throughout the app, the highest
// value it can take is 255, which means we can't add more than 56 items to our
// Unreleased Set's unreleasedChecklistItems array (setId 2). Also, once we've initialized
// this contract, it's impossible for us to add more checklist items to the Originals
// and Iconics set -- what you see here is what you get.
//
// Simple enough right?
/// @dev We initialize this contract with so much data that we have
/// to stage it in 4 different steps, ~33 checklist items at a time.
enum DeployStep {
WaitingForStepOne,
WaitingForStepTwo,
WaitingForStepThree,
WaitingForStepFour,
DoneInitialDeploy
}
/// @dev Enum containing all our rarity tiers, just because
/// it's cleaner dealing with these values than with uint8s.
enum RarityTier {
IconicReferral,
IconicInsert,
Diamond,
Gold,
Silver,
Bronze
}
/// @dev A lookup table indicating how limited the cards
/// in each tier are. If this value is 0, it means
/// that cards of this rarity tier are unlimited,
/// which is only the case for the 8 Iconics cards
/// we give away as part of our referral program.
uint16[] public tierLimits = [
0, // Iconic - Referral Bonus (uncapped)
100, // Iconic Inserts ("Card of the Day")
1000, // Diamond
1664, // Gold
3328, // Silver
4352 // Bronze
];
/// @dev ChecklistItem is essentially the parent class to Card.
/// It represents a given superclass of cards (eg Originals Messi),
/// and then each Card is an instance of this ChecklistItem, with
/// its own serial number, mint date, etc.
struct ChecklistItem {
uint8 playerId;
RarityTier tier;
}
/// @dev The deploy step we're at. Defaults to WaitingForStepOne.
DeployStep public deployStep;
/// @dev Array containing all the Originals checklist items (000 - 099)
ChecklistItem[] public originalChecklistItems;
/// @dev Array containing all the Iconics checklist items (100 - 131)
ChecklistItem[] public iconicChecklistItems;
/// @dev Array containing all the unreleased checklist items (200 - 255 max)
ChecklistItem[] public unreleasedChecklistItems;
/// @dev Internal function to add a checklist item to the Originals set.
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function _addOriginalChecklistItem(uint8 _playerId, RarityTier _tier) internal {
originalChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev Internal function to add a checklist item to the Iconics set.
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function _addIconicChecklistItem(uint8 _playerId, RarityTier _tier) internal {
iconicChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev External function to add a checklist item to our mystery set.
/// Must have completed initial deploy, and can't add more than 56 items (because checklistId is a uint8).
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function addUnreleasedChecklistItem(uint8 _playerId, RarityTier _tier) external onlyOwner {
require(deployStep == DeployStep.DoneInitialDeploy, "Finish deploying the Originals and Iconics sets first.");
require(unreleasedCount() < 56, "You can't add any more checklist items.");
require(_playerId < playerCount, "This player doesn't exist in our player list.");
unreleasedChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev Returns how many Original checklist items we've added.
function originalsCount() external view returns (uint256) {
return originalChecklistItems.length;
}
/// @dev Returns how many Iconic checklist items we've added.
function iconicsCount() public view returns (uint256) {
return iconicChecklistItems.length;
}
/// @dev Returns how many Unreleased checklist items we've added.
function unreleasedCount() public view returns (uint256) {
return unreleasedChecklistItems.length;
}
// In the next four functions, we initialize this contract with our
// 132 initial checklist items (100 Originals, 32 Iconics). Because
// of how much data we need to store, it has to be broken up into
// four different function calls, which need to be called in sequence.
// The ordering of the checklist items we add determines their
// checklist ID, which is left-padded in our frontend to be a
// 3-digit identifier where the first digit is the setId and the last
// 2 digits represents the checklist items index in the appropriate ___ChecklistItems array.
// For example, Originals Messi is the first item for set ID 0, and this
// is displayed as #000 throughout the app. Our Card struct declare its
// checklistId property as uint8, so we have
// to be mindful that we can only have 256 total checklist items.
/// @dev Deploys Originals #000 through #032.
function deployStepOne() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepOne, "You're not following the steps in order...");
/* ORIGINALS - DIAMOND */
_addOriginalChecklistItem(0, RarityTier.Diamond); // 000 Messi
_addOriginalChecklistItem(1, RarityTier.Diamond); // 001 Ronaldo
_addOriginalChecklistItem(2, RarityTier.Diamond); // 002 Neymar
_addOriginalChecklistItem(3, RarityTier.Diamond); // 003 Salah
/* ORIGINALS - GOLD */
_addOriginalChecklistItem(4, RarityTier.Gold); // 004 Lewandowski
_addOriginalChecklistItem(5, RarityTier.Gold); // 005 De Bruyne
_addOriginalChecklistItem(6, RarityTier.Gold); // 006 Modrić
_addOriginalChecklistItem(7, RarityTier.Gold); // 007 Hazard
_addOriginalChecklistItem(8, RarityTier.Gold); // 008 Ramos
_addOriginalChecklistItem(9, RarityTier.Gold); // 009 Kroos
_addOriginalChecklistItem(10, RarityTier.Gold); // 010 Suárez
_addOriginalChecklistItem(11, RarityTier.Gold); // 011 Kane
_addOriginalChecklistItem(12, RarityTier.Gold); // 012 Agüero
_addOriginalChecklistItem(13, RarityTier.Gold); // 013 Mbappé
_addOriginalChecklistItem(14, RarityTier.Gold); // 014 Higuaín
_addOriginalChecklistItem(15, RarityTier.Gold); // 015 de Gea
_addOriginalChecklistItem(16, RarityTier.Gold); // 016 Griezmann
_addOriginalChecklistItem(17, RarityTier.Gold); // 017 Kanté
_addOriginalChecklistItem(18, RarityTier.Gold); // 018 Cavani
_addOriginalChecklistItem(19, RarityTier.Gold); // 019 Pogba
/* ORIGINALS - SILVER (020 to 032) */
_addOriginalChecklistItem(20, RarityTier.Silver); // 020 Isco
_addOriginalChecklistItem(21, RarityTier.Silver); // 021 Marcelo
_addOriginalChecklistItem(22, RarityTier.Silver); // 022 Neuer
_addOriginalChecklistItem(23, RarityTier.Silver); // 023 Mertens
_addOriginalChecklistItem(24, RarityTier.Silver); // 024 James
_addOriginalChecklistItem(25, RarityTier.Silver); // 025 Dybala
_addOriginalChecklistItem(26, RarityTier.Silver); // 026 Eriksen
_addOriginalChecklistItem(27, RarityTier.Silver); // 027 David Silva
_addOriginalChecklistItem(28, RarityTier.Silver); // 028 Gabriel Jesus
_addOriginalChecklistItem(29, RarityTier.Silver); // 029 Thiago
_addOriginalChecklistItem(30, RarityTier.Silver); // 030 Courtois
_addOriginalChecklistItem(31, RarityTier.Silver); // 031 Coutinho
_addOriginalChecklistItem(32, RarityTier.Silver); // 032 Iniesta
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepTwo;
}
/// @dev Deploys Originals #033 through #065.
function deployStepTwo() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepTwo, "You're not following the steps in order...");
/* ORIGINALS - SILVER (033 to 049) */
_addOriginalChecklistItem(33, RarityTier.Silver); // 033 Casemiro
_addOriginalChecklistItem(34, RarityTier.Silver); // 034 Lukaku
_addOriginalChecklistItem(35, RarityTier.Silver); // 035 Piqué
_addOriginalChecklistItem(36, RarityTier.Silver); // 036 Hummels
_addOriginalChecklistItem(37, RarityTier.Silver); // 037 Godín
_addOriginalChecklistItem(38, RarityTier.Silver); // 038 Özil
_addOriginalChecklistItem(39, RarityTier.Silver); // 039 Son
_addOriginalChecklistItem(40, RarityTier.Silver); // 040 Sterling
_addOriginalChecklistItem(41, RarityTier.Silver); // 041 Lloris
_addOriginalChecklistItem(42, RarityTier.Silver); // 042 Falcao
_addOriginalChecklistItem(43, RarityTier.Silver); // 043 Rakitić
_addOriginalChecklistItem(44, RarityTier.Silver); // 044 Sané
_addOriginalChecklistItem(45, RarityTier.Silver); // 045 Firmino
_addOriginalChecklistItem(46, RarityTier.Silver); // 046 Mané
_addOriginalChecklistItem(47, RarityTier.Silver); // 047 Müller
_addOriginalChecklistItem(48, RarityTier.Silver); // 048 Alli
_addOriginalChecklistItem(49, RarityTier.Silver); // 049 Navas
/* ORIGINALS - BRONZE (050 to 065) */
_addOriginalChecklistItem(50, RarityTier.Bronze); // 050 Thiago Silva
_addOriginalChecklistItem(51, RarityTier.Bronze); // 051 Varane
_addOriginalChecklistItem(52, RarityTier.Bronze); // 052 Di María
_addOriginalChecklistItem(53, RarityTier.Bronze); // 053 Alba
_addOriginalChecklistItem(54, RarityTier.Bronze); // 054 Benatia
_addOriginalChecklistItem(55, RarityTier.Bronze); // 055 Werner
_addOriginalChecklistItem(56, RarityTier.Bronze); // 056 Sigurðsson
_addOriginalChecklistItem(57, RarityTier.Bronze); // 057 Matić
_addOriginalChecklistItem(58, RarityTier.Bronze); // 058 Koulibaly
_addOriginalChecklistItem(59, RarityTier.Bronze); // 059 Bernardo Silva
_addOriginalChecklistItem(60, RarityTier.Bronze); // 060 Kompany
_addOriginalChecklistItem(61, RarityTier.Bronze); // 061 Moutinho
_addOriginalChecklistItem(62, RarityTier.Bronze); // 062 Alderweireld
_addOriginalChecklistItem(63, RarityTier.Bronze); // 063 Forsberg
_addOriginalChecklistItem(64, RarityTier.Bronze); // 064 Mandžukić
_addOriginalChecklistItem(65, RarityTier.Bronze); // 065 Milinković-Savić
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepThree;
}
/// @dev Deploys Originals #066 through #099.
function deployStepThree() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepThree, "You're not following the steps in order...");
/* ORIGINALS - BRONZE (066 to 099) */
_addOriginalChecklistItem(66, RarityTier.Bronze); // 066 Kagawa
_addOriginalChecklistItem(67, RarityTier.Bronze); // 067 Xhaka
_addOriginalChecklistItem(68, RarityTier.Bronze); // 068 Christensen
_addOriginalChecklistItem(69, RarityTier.Bronze); // 069 Zieliński
_addOriginalChecklistItem(70, RarityTier.Bronze); // 070 Smolov
_addOriginalChecklistItem(71, RarityTier.Bronze); // 071 Shaqiri
_addOriginalChecklistItem(72, RarityTier.Bronze); // 072 Rashford
_addOriginalChecklistItem(73, RarityTier.Bronze); // 073 Hernández
_addOriginalChecklistItem(74, RarityTier.Bronze); // 074 Lozano
_addOriginalChecklistItem(75, RarityTier.Bronze); // 075 Ziyech
_addOriginalChecklistItem(76, RarityTier.Bronze); // 076 Moses
_addOriginalChecklistItem(77, RarityTier.Bronze); // 077 Farfán
_addOriginalChecklistItem(78, RarityTier.Bronze); // 078 Elneny
_addOriginalChecklistItem(79, RarityTier.Bronze); // 079 Berg
_addOriginalChecklistItem(80, RarityTier.Bronze); // 080 Ochoa
_addOriginalChecklistItem(81, RarityTier.Bronze); // 081 Akinfeev
_addOriginalChecklistItem(82, RarityTier.Bronze); // 082 Azmoun
_addOriginalChecklistItem(83, RarityTier.Bronze); // 083 Cueva
_addOriginalChecklistItem(84, RarityTier.Bronze); // 084 Khazri
_addOriginalChecklistItem(85, RarityTier.Bronze); // 085 Honda
_addOriginalChecklistItem(86, RarityTier.Bronze); // 086 Cahill
_addOriginalChecklistItem(87, RarityTier.Bronze); // 087 Mikel
_addOriginalChecklistItem(88, RarityTier.Bronze); // 088 Sung-yueng
_addOriginalChecklistItem(89, RarityTier.Bronze); // 089 Ruiz
_addOriginalChecklistItem(90, RarityTier.Bronze); // 090 Yoshida
_addOriginalChecklistItem(91, RarityTier.Bronze); // 091 Al Abed
_addOriginalChecklistItem(92, RarityTier.Bronze); // 092 Chung-yong
_addOriginalChecklistItem(93, RarityTier.Bronze); // 093 Gómez
_addOriginalChecklistItem(94, RarityTier.Bronze); // 094 Sliti
_addOriginalChecklistItem(95, RarityTier.Bronze); // 095 Ghoochannejhad
_addOriginalChecklistItem(96, RarityTier.Bronze); // 096 Jedinak
_addOriginalChecklistItem(97, RarityTier.Bronze); // 097 Al-Sahlawi
_addOriginalChecklistItem(98, RarityTier.Bronze); // 098 Gunnarsson
_addOriginalChecklistItem(99, RarityTier.Bronze); // 099 Pérez
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepFour;
}
/// @dev Deploys all Iconics and marks the deploy as complete!
function deployStepFour() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepFour, "You're not following the steps in order...");
/* ICONICS */
_addIconicChecklistItem(0, RarityTier.IconicInsert); // 100 Messi
_addIconicChecklistItem(1, RarityTier.IconicInsert); // 101 Ronaldo
_addIconicChecklistItem(2, RarityTier.IconicInsert); // 102 Neymar
_addIconicChecklistItem(3, RarityTier.IconicInsert); // 103 Salah
_addIconicChecklistItem(4, RarityTier.IconicInsert); // 104 Lewandowski
_addIconicChecklistItem(5, RarityTier.IconicInsert); // 105 De Bruyne
_addIconicChecklistItem(6, RarityTier.IconicInsert); // 106 Modrić
_addIconicChecklistItem(7, RarityTier.IconicInsert); // 107 Hazard
_addIconicChecklistItem(8, RarityTier.IconicInsert); // 108 Ramos
_addIconicChecklistItem(9, RarityTier.IconicInsert); // 109 Kroos
_addIconicChecklistItem(10, RarityTier.IconicInsert); // 110 Suárez
_addIconicChecklistItem(11, RarityTier.IconicInsert); // 111 Kane
_addIconicChecklistItem(12, RarityTier.IconicInsert); // 112 Agüero
_addIconicChecklistItem(15, RarityTier.IconicInsert); // 113 de Gea
_addIconicChecklistItem(16, RarityTier.IconicInsert); // 114 Griezmann
_addIconicChecklistItem(17, RarityTier.IconicReferral); // 115 Kanté
_addIconicChecklistItem(18, RarityTier.IconicReferral); // 116 Cavani
_addIconicChecklistItem(19, RarityTier.IconicInsert); // 117 Pogba
_addIconicChecklistItem(21, RarityTier.IconicInsert); // 118 Marcelo
_addIconicChecklistItem(24, RarityTier.IconicInsert); // 119 James
_addIconicChecklistItem(26, RarityTier.IconicInsert); // 120 Eriksen
_addIconicChecklistItem(29, RarityTier.IconicReferral); // 121 Thiago
_addIconicChecklistItem(36, RarityTier.IconicReferral); // 122 Hummels
_addIconicChecklistItem(38, RarityTier.IconicReferral); // 123 Özil
_addIconicChecklistItem(39, RarityTier.IconicInsert); // 124 Son
_addIconicChecklistItem(46, RarityTier.IconicInsert); // 125 Mané
_addIconicChecklistItem(48, RarityTier.IconicInsert); // 126 Alli
_addIconicChecklistItem(49, RarityTier.IconicReferral); // 127 Navas
_addIconicChecklistItem(73, RarityTier.IconicInsert); // 128 Hernández
_addIconicChecklistItem(85, RarityTier.IconicInsert); // 129 Honda
_addIconicChecklistItem(100, RarityTier.IconicReferral); // 130 Alves
_addIconicChecklistItem(101, RarityTier.IconicReferral); // 131 Zlatan
// Mark the initial deploy as complete.
deployStep = DeployStep.DoneInitialDeploy;
}
/// @dev Returns the mint limit for a given checklist item, based on its tier.
/// @param _checklistId Which checklist item we need to get the limit for.
/// @return How much of this checklist item we are allowed to mint.
function limitForChecklistId(uint8 _checklistId) external view returns (uint16) {
RarityTier rarityTier;
uint8 index;
if (_checklistId < 100) { // Originals = #000 to #099
rarityTier = originalChecklistItems[_checklistId].tier;
} else if (_checklistId < 200) { // Iconics = #100 to #131
index = _checklistId - 100;
require(index < iconicsCount(), "This Iconics checklist item doesn't exist.");
rarityTier = iconicChecklistItems[index].tier;
} else { // Unreleased = #200 to max #255
index = _checklistId - 200;
require(index < unreleasedCount(), "This Unreleased checklist item doesn't exist.");
rarityTier = unreleasedChecklistItems[index].tier;
}
return tierLimits[uint8(rarityTier)];
}
} | /// @title The contract that manages checklist items, sets, and rarity tiers.
/// @author The CryptoStrikers Team | NatSpecSingleLine | deployStepTwo | function deployStepTwo() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepTwo, "You're not following the steps in order...");
/* ORIGINALS - SILVER (033 to 049) */
_addOriginalChecklistItem(33, RarityTier.Silver); // 033 Casemiro
_addOriginalChecklistItem(34, RarityTier.Silver); // 034 Lukaku
_addOriginalChecklistItem(35, RarityTier.Silver); // 035 Piqué
_addOriginalChecklistItem(36, RarityTier.Silver); // 036 Hummels
_addOriginalChecklistItem(37, RarityTier.Silver); // 037 Godín
_addOriginalChecklistItem(38, RarityTier.Silver); // 038 Özil
_addOriginalChecklistItem(39, RarityTier.Silver); // 039 Son
_addOriginalChecklistItem(40, RarityTier.Silver); // 040 Sterling
_addOriginalChecklistItem(41, RarityTier.Silver); // 041 Lloris
_addOriginalChecklistItem(42, RarityTier.Silver); // 042 Falcao
_addOriginalChecklistItem(43, RarityTier.Silver); // 043 Rakitić
_addOriginalChecklistItem(44, RarityTier.Silver); // 044 Sané
_addOriginalChecklistItem(45, RarityTier.Silver); // 045 Firmino
_addOriginalChecklistItem(46, RarityTier.Silver); // 046 Mané
_addOriginalChecklistItem(47, RarityTier.Silver); // 047 Müller
_addOriginalChecklistItem(48, RarityTier.Silver); // 048 Alli
_addOriginalChecklistItem(49, RarityTier.Silver); // 049 Navas
/* ORIGINALS - BRONZE (050 to 065) */
_addOriginalChecklistItem(50, RarityTier.Bronze); // 050 Thiago Silva
_addOriginalChecklistItem(51, RarityTier.Bronze); // 051 Varane
_addOriginalChecklistItem(52, RarityTier.Bronze); // 052 Di María
_addOriginalChecklistItem(53, RarityTier.Bronze); // 053 Alba
_addOriginalChecklistItem(54, RarityTier.Bronze); // 054 Benatia
_addOriginalChecklistItem(55, RarityTier.Bronze); // 055 Werner
_addOriginalChecklistItem(56, RarityTier.Bronze); // 056 Sigurðsson
_addOriginalChecklistItem(57, RarityTier.Bronze); // 057 Matić
_addOriginalChecklistItem(58, RarityTier.Bronze); // 058 Koulibaly
_addOriginalChecklistItem(59, RarityTier.Bronze); // 059 Bernardo Silva
_addOriginalChecklistItem(60, RarityTier.Bronze); // 060 Kompany
_addOriginalChecklistItem(61, RarityTier.Bronze); // 061 Moutinho
_addOriginalChecklistItem(62, RarityTier.Bronze); // 062 Alderweireld
_addOriginalChecklistItem(63, RarityTier.Bronze); // 063 Forsberg
_addOriginalChecklistItem(64, RarityTier.Bronze); // 064 Mandžukić
_addOriginalChecklistItem(65, RarityTier.Bronze); // 065 Milinković-Savić
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepThree;
}
| /// @dev Deploys Originals #033 through #065. | NatSpecSingleLine | v0.4.24+commit.e67f0147 | bzzr://f87c20fe7eb593456a65c383f65f6ca3a578031b9800b338b3629208d23ef268 | {
"func_code_index": [
9291,
11943
]
} | 5,101 |
|
StrikersChecklist | StrikersChecklist.sol | 0xdbc260a05f81629ffa062df3d1668a43133abba4 | Solidity | StrikersChecklist | contract StrikersChecklist is StrikersPlayerList {
// High level overview of everything going on in this contract:
//
// ChecklistItem is the parent class to Card and has 3 properties:
// - uint8 checklistId (000 to 255)
// - uint8 playerId (see StrikersPlayerList.sol)
// - RarityTier tier (more info below)
//
// Two things to note: the checklistId is not explicitly stored
// on the checklistItem struct, and it's composed of two parts.
// (For the following, assume it is left padded with zeros to reach
// three digits, such that checklistId 0 becomes 000)
// - the first digit represents the setId
// * 0 = Originals Set
// * 1 = Iconics Set
// * 2 = Unreleased Set
// - the last two digits represent its index in the appropriate set arary
//
// For example, checklist ID 100 would represent fhe first checklist item
// in the iconicChecklistItems array (first digit = 1 = Iconics Set, last two
// digits = 00 = first index of array)
//
// Because checklistId is represented as a uint8 throughout the app, the highest
// value it can take is 255, which means we can't add more than 56 items to our
// Unreleased Set's unreleasedChecklistItems array (setId 2). Also, once we've initialized
// this contract, it's impossible for us to add more checklist items to the Originals
// and Iconics set -- what you see here is what you get.
//
// Simple enough right?
/// @dev We initialize this contract with so much data that we have
/// to stage it in 4 different steps, ~33 checklist items at a time.
enum DeployStep {
WaitingForStepOne,
WaitingForStepTwo,
WaitingForStepThree,
WaitingForStepFour,
DoneInitialDeploy
}
/// @dev Enum containing all our rarity tiers, just because
/// it's cleaner dealing with these values than with uint8s.
enum RarityTier {
IconicReferral,
IconicInsert,
Diamond,
Gold,
Silver,
Bronze
}
/// @dev A lookup table indicating how limited the cards
/// in each tier are. If this value is 0, it means
/// that cards of this rarity tier are unlimited,
/// which is only the case for the 8 Iconics cards
/// we give away as part of our referral program.
uint16[] public tierLimits = [
0, // Iconic - Referral Bonus (uncapped)
100, // Iconic Inserts ("Card of the Day")
1000, // Diamond
1664, // Gold
3328, // Silver
4352 // Bronze
];
/// @dev ChecklistItem is essentially the parent class to Card.
/// It represents a given superclass of cards (eg Originals Messi),
/// and then each Card is an instance of this ChecklistItem, with
/// its own serial number, mint date, etc.
struct ChecklistItem {
uint8 playerId;
RarityTier tier;
}
/// @dev The deploy step we're at. Defaults to WaitingForStepOne.
DeployStep public deployStep;
/// @dev Array containing all the Originals checklist items (000 - 099)
ChecklistItem[] public originalChecklistItems;
/// @dev Array containing all the Iconics checklist items (100 - 131)
ChecklistItem[] public iconicChecklistItems;
/// @dev Array containing all the unreleased checklist items (200 - 255 max)
ChecklistItem[] public unreleasedChecklistItems;
/// @dev Internal function to add a checklist item to the Originals set.
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function _addOriginalChecklistItem(uint8 _playerId, RarityTier _tier) internal {
originalChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev Internal function to add a checklist item to the Iconics set.
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function _addIconicChecklistItem(uint8 _playerId, RarityTier _tier) internal {
iconicChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev External function to add a checklist item to our mystery set.
/// Must have completed initial deploy, and can't add more than 56 items (because checklistId is a uint8).
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function addUnreleasedChecklistItem(uint8 _playerId, RarityTier _tier) external onlyOwner {
require(deployStep == DeployStep.DoneInitialDeploy, "Finish deploying the Originals and Iconics sets first.");
require(unreleasedCount() < 56, "You can't add any more checklist items.");
require(_playerId < playerCount, "This player doesn't exist in our player list.");
unreleasedChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev Returns how many Original checklist items we've added.
function originalsCount() external view returns (uint256) {
return originalChecklistItems.length;
}
/// @dev Returns how many Iconic checklist items we've added.
function iconicsCount() public view returns (uint256) {
return iconicChecklistItems.length;
}
/// @dev Returns how many Unreleased checklist items we've added.
function unreleasedCount() public view returns (uint256) {
return unreleasedChecklistItems.length;
}
// In the next four functions, we initialize this contract with our
// 132 initial checklist items (100 Originals, 32 Iconics). Because
// of how much data we need to store, it has to be broken up into
// four different function calls, which need to be called in sequence.
// The ordering of the checklist items we add determines their
// checklist ID, which is left-padded in our frontend to be a
// 3-digit identifier where the first digit is the setId and the last
// 2 digits represents the checklist items index in the appropriate ___ChecklistItems array.
// For example, Originals Messi is the first item for set ID 0, and this
// is displayed as #000 throughout the app. Our Card struct declare its
// checklistId property as uint8, so we have
// to be mindful that we can only have 256 total checklist items.
/// @dev Deploys Originals #000 through #032.
function deployStepOne() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepOne, "You're not following the steps in order...");
/* ORIGINALS - DIAMOND */
_addOriginalChecklistItem(0, RarityTier.Diamond); // 000 Messi
_addOriginalChecklistItem(1, RarityTier.Diamond); // 001 Ronaldo
_addOriginalChecklistItem(2, RarityTier.Diamond); // 002 Neymar
_addOriginalChecklistItem(3, RarityTier.Diamond); // 003 Salah
/* ORIGINALS - GOLD */
_addOriginalChecklistItem(4, RarityTier.Gold); // 004 Lewandowski
_addOriginalChecklistItem(5, RarityTier.Gold); // 005 De Bruyne
_addOriginalChecklistItem(6, RarityTier.Gold); // 006 Modrić
_addOriginalChecklistItem(7, RarityTier.Gold); // 007 Hazard
_addOriginalChecklistItem(8, RarityTier.Gold); // 008 Ramos
_addOriginalChecklistItem(9, RarityTier.Gold); // 009 Kroos
_addOriginalChecklistItem(10, RarityTier.Gold); // 010 Suárez
_addOriginalChecklistItem(11, RarityTier.Gold); // 011 Kane
_addOriginalChecklistItem(12, RarityTier.Gold); // 012 Agüero
_addOriginalChecklistItem(13, RarityTier.Gold); // 013 Mbappé
_addOriginalChecklistItem(14, RarityTier.Gold); // 014 Higuaín
_addOriginalChecklistItem(15, RarityTier.Gold); // 015 de Gea
_addOriginalChecklistItem(16, RarityTier.Gold); // 016 Griezmann
_addOriginalChecklistItem(17, RarityTier.Gold); // 017 Kanté
_addOriginalChecklistItem(18, RarityTier.Gold); // 018 Cavani
_addOriginalChecklistItem(19, RarityTier.Gold); // 019 Pogba
/* ORIGINALS - SILVER (020 to 032) */
_addOriginalChecklistItem(20, RarityTier.Silver); // 020 Isco
_addOriginalChecklistItem(21, RarityTier.Silver); // 021 Marcelo
_addOriginalChecklistItem(22, RarityTier.Silver); // 022 Neuer
_addOriginalChecklistItem(23, RarityTier.Silver); // 023 Mertens
_addOriginalChecklistItem(24, RarityTier.Silver); // 024 James
_addOriginalChecklistItem(25, RarityTier.Silver); // 025 Dybala
_addOriginalChecklistItem(26, RarityTier.Silver); // 026 Eriksen
_addOriginalChecklistItem(27, RarityTier.Silver); // 027 David Silva
_addOriginalChecklistItem(28, RarityTier.Silver); // 028 Gabriel Jesus
_addOriginalChecklistItem(29, RarityTier.Silver); // 029 Thiago
_addOriginalChecklistItem(30, RarityTier.Silver); // 030 Courtois
_addOriginalChecklistItem(31, RarityTier.Silver); // 031 Coutinho
_addOriginalChecklistItem(32, RarityTier.Silver); // 032 Iniesta
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepTwo;
}
/// @dev Deploys Originals #033 through #065.
function deployStepTwo() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepTwo, "You're not following the steps in order...");
/* ORIGINALS - SILVER (033 to 049) */
_addOriginalChecklistItem(33, RarityTier.Silver); // 033 Casemiro
_addOriginalChecklistItem(34, RarityTier.Silver); // 034 Lukaku
_addOriginalChecklistItem(35, RarityTier.Silver); // 035 Piqué
_addOriginalChecklistItem(36, RarityTier.Silver); // 036 Hummels
_addOriginalChecklistItem(37, RarityTier.Silver); // 037 Godín
_addOriginalChecklistItem(38, RarityTier.Silver); // 038 Özil
_addOriginalChecklistItem(39, RarityTier.Silver); // 039 Son
_addOriginalChecklistItem(40, RarityTier.Silver); // 040 Sterling
_addOriginalChecklistItem(41, RarityTier.Silver); // 041 Lloris
_addOriginalChecklistItem(42, RarityTier.Silver); // 042 Falcao
_addOriginalChecklistItem(43, RarityTier.Silver); // 043 Rakitić
_addOriginalChecklistItem(44, RarityTier.Silver); // 044 Sané
_addOriginalChecklistItem(45, RarityTier.Silver); // 045 Firmino
_addOriginalChecklistItem(46, RarityTier.Silver); // 046 Mané
_addOriginalChecklistItem(47, RarityTier.Silver); // 047 Müller
_addOriginalChecklistItem(48, RarityTier.Silver); // 048 Alli
_addOriginalChecklistItem(49, RarityTier.Silver); // 049 Navas
/* ORIGINALS - BRONZE (050 to 065) */
_addOriginalChecklistItem(50, RarityTier.Bronze); // 050 Thiago Silva
_addOriginalChecklistItem(51, RarityTier.Bronze); // 051 Varane
_addOriginalChecklistItem(52, RarityTier.Bronze); // 052 Di María
_addOriginalChecklistItem(53, RarityTier.Bronze); // 053 Alba
_addOriginalChecklistItem(54, RarityTier.Bronze); // 054 Benatia
_addOriginalChecklistItem(55, RarityTier.Bronze); // 055 Werner
_addOriginalChecklistItem(56, RarityTier.Bronze); // 056 Sigurðsson
_addOriginalChecklistItem(57, RarityTier.Bronze); // 057 Matić
_addOriginalChecklistItem(58, RarityTier.Bronze); // 058 Koulibaly
_addOriginalChecklistItem(59, RarityTier.Bronze); // 059 Bernardo Silva
_addOriginalChecklistItem(60, RarityTier.Bronze); // 060 Kompany
_addOriginalChecklistItem(61, RarityTier.Bronze); // 061 Moutinho
_addOriginalChecklistItem(62, RarityTier.Bronze); // 062 Alderweireld
_addOriginalChecklistItem(63, RarityTier.Bronze); // 063 Forsberg
_addOriginalChecklistItem(64, RarityTier.Bronze); // 064 Mandžukić
_addOriginalChecklistItem(65, RarityTier.Bronze); // 065 Milinković-Savić
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepThree;
}
/// @dev Deploys Originals #066 through #099.
function deployStepThree() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepThree, "You're not following the steps in order...");
/* ORIGINALS - BRONZE (066 to 099) */
_addOriginalChecklistItem(66, RarityTier.Bronze); // 066 Kagawa
_addOriginalChecklistItem(67, RarityTier.Bronze); // 067 Xhaka
_addOriginalChecklistItem(68, RarityTier.Bronze); // 068 Christensen
_addOriginalChecklistItem(69, RarityTier.Bronze); // 069 Zieliński
_addOriginalChecklistItem(70, RarityTier.Bronze); // 070 Smolov
_addOriginalChecklistItem(71, RarityTier.Bronze); // 071 Shaqiri
_addOriginalChecklistItem(72, RarityTier.Bronze); // 072 Rashford
_addOriginalChecklistItem(73, RarityTier.Bronze); // 073 Hernández
_addOriginalChecklistItem(74, RarityTier.Bronze); // 074 Lozano
_addOriginalChecklistItem(75, RarityTier.Bronze); // 075 Ziyech
_addOriginalChecklistItem(76, RarityTier.Bronze); // 076 Moses
_addOriginalChecklistItem(77, RarityTier.Bronze); // 077 Farfán
_addOriginalChecklistItem(78, RarityTier.Bronze); // 078 Elneny
_addOriginalChecklistItem(79, RarityTier.Bronze); // 079 Berg
_addOriginalChecklistItem(80, RarityTier.Bronze); // 080 Ochoa
_addOriginalChecklistItem(81, RarityTier.Bronze); // 081 Akinfeev
_addOriginalChecklistItem(82, RarityTier.Bronze); // 082 Azmoun
_addOriginalChecklistItem(83, RarityTier.Bronze); // 083 Cueva
_addOriginalChecklistItem(84, RarityTier.Bronze); // 084 Khazri
_addOriginalChecklistItem(85, RarityTier.Bronze); // 085 Honda
_addOriginalChecklistItem(86, RarityTier.Bronze); // 086 Cahill
_addOriginalChecklistItem(87, RarityTier.Bronze); // 087 Mikel
_addOriginalChecklistItem(88, RarityTier.Bronze); // 088 Sung-yueng
_addOriginalChecklistItem(89, RarityTier.Bronze); // 089 Ruiz
_addOriginalChecklistItem(90, RarityTier.Bronze); // 090 Yoshida
_addOriginalChecklistItem(91, RarityTier.Bronze); // 091 Al Abed
_addOriginalChecklistItem(92, RarityTier.Bronze); // 092 Chung-yong
_addOriginalChecklistItem(93, RarityTier.Bronze); // 093 Gómez
_addOriginalChecklistItem(94, RarityTier.Bronze); // 094 Sliti
_addOriginalChecklistItem(95, RarityTier.Bronze); // 095 Ghoochannejhad
_addOriginalChecklistItem(96, RarityTier.Bronze); // 096 Jedinak
_addOriginalChecklistItem(97, RarityTier.Bronze); // 097 Al-Sahlawi
_addOriginalChecklistItem(98, RarityTier.Bronze); // 098 Gunnarsson
_addOriginalChecklistItem(99, RarityTier.Bronze); // 099 Pérez
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepFour;
}
/// @dev Deploys all Iconics and marks the deploy as complete!
function deployStepFour() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepFour, "You're not following the steps in order...");
/* ICONICS */
_addIconicChecklistItem(0, RarityTier.IconicInsert); // 100 Messi
_addIconicChecklistItem(1, RarityTier.IconicInsert); // 101 Ronaldo
_addIconicChecklistItem(2, RarityTier.IconicInsert); // 102 Neymar
_addIconicChecklistItem(3, RarityTier.IconicInsert); // 103 Salah
_addIconicChecklistItem(4, RarityTier.IconicInsert); // 104 Lewandowski
_addIconicChecklistItem(5, RarityTier.IconicInsert); // 105 De Bruyne
_addIconicChecklistItem(6, RarityTier.IconicInsert); // 106 Modrić
_addIconicChecklistItem(7, RarityTier.IconicInsert); // 107 Hazard
_addIconicChecklistItem(8, RarityTier.IconicInsert); // 108 Ramos
_addIconicChecklistItem(9, RarityTier.IconicInsert); // 109 Kroos
_addIconicChecklistItem(10, RarityTier.IconicInsert); // 110 Suárez
_addIconicChecklistItem(11, RarityTier.IconicInsert); // 111 Kane
_addIconicChecklistItem(12, RarityTier.IconicInsert); // 112 Agüero
_addIconicChecklistItem(15, RarityTier.IconicInsert); // 113 de Gea
_addIconicChecklistItem(16, RarityTier.IconicInsert); // 114 Griezmann
_addIconicChecklistItem(17, RarityTier.IconicReferral); // 115 Kanté
_addIconicChecklistItem(18, RarityTier.IconicReferral); // 116 Cavani
_addIconicChecklistItem(19, RarityTier.IconicInsert); // 117 Pogba
_addIconicChecklistItem(21, RarityTier.IconicInsert); // 118 Marcelo
_addIconicChecklistItem(24, RarityTier.IconicInsert); // 119 James
_addIconicChecklistItem(26, RarityTier.IconicInsert); // 120 Eriksen
_addIconicChecklistItem(29, RarityTier.IconicReferral); // 121 Thiago
_addIconicChecklistItem(36, RarityTier.IconicReferral); // 122 Hummels
_addIconicChecklistItem(38, RarityTier.IconicReferral); // 123 Özil
_addIconicChecklistItem(39, RarityTier.IconicInsert); // 124 Son
_addIconicChecklistItem(46, RarityTier.IconicInsert); // 125 Mané
_addIconicChecklistItem(48, RarityTier.IconicInsert); // 126 Alli
_addIconicChecklistItem(49, RarityTier.IconicReferral); // 127 Navas
_addIconicChecklistItem(73, RarityTier.IconicInsert); // 128 Hernández
_addIconicChecklistItem(85, RarityTier.IconicInsert); // 129 Honda
_addIconicChecklistItem(100, RarityTier.IconicReferral); // 130 Alves
_addIconicChecklistItem(101, RarityTier.IconicReferral); // 131 Zlatan
// Mark the initial deploy as complete.
deployStep = DeployStep.DoneInitialDeploy;
}
/// @dev Returns the mint limit for a given checklist item, based on its tier.
/// @param _checklistId Which checklist item we need to get the limit for.
/// @return How much of this checklist item we are allowed to mint.
function limitForChecklistId(uint8 _checklistId) external view returns (uint16) {
RarityTier rarityTier;
uint8 index;
if (_checklistId < 100) { // Originals = #000 to #099
rarityTier = originalChecklistItems[_checklistId].tier;
} else if (_checklistId < 200) { // Iconics = #100 to #131
index = _checklistId - 100;
require(index < iconicsCount(), "This Iconics checklist item doesn't exist.");
rarityTier = iconicChecklistItems[index].tier;
} else { // Unreleased = #200 to max #255
index = _checklistId - 200;
require(index < unreleasedCount(), "This Unreleased checklist item doesn't exist.");
rarityTier = unreleasedChecklistItems[index].tier;
}
return tierLimits[uint8(rarityTier)];
}
} | /// @title The contract that manages checklist items, sets, and rarity tiers.
/// @author The CryptoStrikers Team | NatSpecSingleLine | deployStepThree | function deployStepThree() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepThree, "You're not following the steps in order...");
/* ORIGINALS - BRONZE (066 to 099) */
_addOriginalChecklistItem(66, RarityTier.Bronze); // 066 Kagawa
_addOriginalChecklistItem(67, RarityTier.Bronze); // 067 Xhaka
_addOriginalChecklistItem(68, RarityTier.Bronze); // 068 Christensen
_addOriginalChecklistItem(69, RarityTier.Bronze); // 069 Zieliński
_addOriginalChecklistItem(70, RarityTier.Bronze); // 070 Smolov
_addOriginalChecklistItem(71, RarityTier.Bronze); // 071 Shaqiri
_addOriginalChecklistItem(72, RarityTier.Bronze); // 072 Rashford
_addOriginalChecklistItem(73, RarityTier.Bronze); // 073 Hernández
_addOriginalChecklistItem(74, RarityTier.Bronze); // 074 Lozano
_addOriginalChecklistItem(75, RarityTier.Bronze); // 075 Ziyech
_addOriginalChecklistItem(76, RarityTier.Bronze); // 076 Moses
_addOriginalChecklistItem(77, RarityTier.Bronze); // 077 Farfán
_addOriginalChecklistItem(78, RarityTier.Bronze); // 078 Elneny
_addOriginalChecklistItem(79, RarityTier.Bronze); // 079 Berg
_addOriginalChecklistItem(80, RarityTier.Bronze); // 080 Ochoa
_addOriginalChecklistItem(81, RarityTier.Bronze); // 081 Akinfeev
_addOriginalChecklistItem(82, RarityTier.Bronze); // 082 Azmoun
_addOriginalChecklistItem(83, RarityTier.Bronze); // 083 Cueva
_addOriginalChecklistItem(84, RarityTier.Bronze); // 084 Khazri
_addOriginalChecklistItem(85, RarityTier.Bronze); // 085 Honda
_addOriginalChecklistItem(86, RarityTier.Bronze); // 086 Cahill
_addOriginalChecklistItem(87, RarityTier.Bronze); // 087 Mikel
_addOriginalChecklistItem(88, RarityTier.Bronze); // 088 Sung-yueng
_addOriginalChecklistItem(89, RarityTier.Bronze); // 089 Ruiz
_addOriginalChecklistItem(90, RarityTier.Bronze); // 090 Yoshida
_addOriginalChecklistItem(91, RarityTier.Bronze); // 091 Al Abed
_addOriginalChecklistItem(92, RarityTier.Bronze); // 092 Chung-yong
_addOriginalChecklistItem(93, RarityTier.Bronze); // 093 Gómez
_addOriginalChecklistItem(94, RarityTier.Bronze); // 094 Sliti
_addOriginalChecklistItem(95, RarityTier.Bronze); // 095 Ghoochannejhad
_addOriginalChecklistItem(96, RarityTier.Bronze); // 096 Jedinak
_addOriginalChecklistItem(97, RarityTier.Bronze); // 097 Al-Sahlawi
_addOriginalChecklistItem(98, RarityTier.Bronze); // 098 Gunnarsson
_addOriginalChecklistItem(99, RarityTier.Bronze); // 099 Pérez
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepFour;
}
| /// @dev Deploys Originals #066 through #099. | NatSpecSingleLine | v0.4.24+commit.e67f0147 | bzzr://f87c20fe7eb593456a65c383f65f6ca3a578031b9800b338b3629208d23ef268 | {
"func_code_index": [
11995,
14666
]
} | 5,102 |
|
StrikersChecklist | StrikersChecklist.sol | 0xdbc260a05f81629ffa062df3d1668a43133abba4 | Solidity | StrikersChecklist | contract StrikersChecklist is StrikersPlayerList {
// High level overview of everything going on in this contract:
//
// ChecklistItem is the parent class to Card and has 3 properties:
// - uint8 checklistId (000 to 255)
// - uint8 playerId (see StrikersPlayerList.sol)
// - RarityTier tier (more info below)
//
// Two things to note: the checklistId is not explicitly stored
// on the checklistItem struct, and it's composed of two parts.
// (For the following, assume it is left padded with zeros to reach
// three digits, such that checklistId 0 becomes 000)
// - the first digit represents the setId
// * 0 = Originals Set
// * 1 = Iconics Set
// * 2 = Unreleased Set
// - the last two digits represent its index in the appropriate set arary
//
// For example, checklist ID 100 would represent fhe first checklist item
// in the iconicChecklistItems array (first digit = 1 = Iconics Set, last two
// digits = 00 = first index of array)
//
// Because checklistId is represented as a uint8 throughout the app, the highest
// value it can take is 255, which means we can't add more than 56 items to our
// Unreleased Set's unreleasedChecklistItems array (setId 2). Also, once we've initialized
// this contract, it's impossible for us to add more checklist items to the Originals
// and Iconics set -- what you see here is what you get.
//
// Simple enough right?
/// @dev We initialize this contract with so much data that we have
/// to stage it in 4 different steps, ~33 checklist items at a time.
enum DeployStep {
WaitingForStepOne,
WaitingForStepTwo,
WaitingForStepThree,
WaitingForStepFour,
DoneInitialDeploy
}
/// @dev Enum containing all our rarity tiers, just because
/// it's cleaner dealing with these values than with uint8s.
enum RarityTier {
IconicReferral,
IconicInsert,
Diamond,
Gold,
Silver,
Bronze
}
/// @dev A lookup table indicating how limited the cards
/// in each tier are. If this value is 0, it means
/// that cards of this rarity tier are unlimited,
/// which is only the case for the 8 Iconics cards
/// we give away as part of our referral program.
uint16[] public tierLimits = [
0, // Iconic - Referral Bonus (uncapped)
100, // Iconic Inserts ("Card of the Day")
1000, // Diamond
1664, // Gold
3328, // Silver
4352 // Bronze
];
/// @dev ChecklistItem is essentially the parent class to Card.
/// It represents a given superclass of cards (eg Originals Messi),
/// and then each Card is an instance of this ChecklistItem, with
/// its own serial number, mint date, etc.
struct ChecklistItem {
uint8 playerId;
RarityTier tier;
}
/// @dev The deploy step we're at. Defaults to WaitingForStepOne.
DeployStep public deployStep;
/// @dev Array containing all the Originals checklist items (000 - 099)
ChecklistItem[] public originalChecklistItems;
/// @dev Array containing all the Iconics checklist items (100 - 131)
ChecklistItem[] public iconicChecklistItems;
/// @dev Array containing all the unreleased checklist items (200 - 255 max)
ChecklistItem[] public unreleasedChecklistItems;
/// @dev Internal function to add a checklist item to the Originals set.
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function _addOriginalChecklistItem(uint8 _playerId, RarityTier _tier) internal {
originalChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev Internal function to add a checklist item to the Iconics set.
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function _addIconicChecklistItem(uint8 _playerId, RarityTier _tier) internal {
iconicChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev External function to add a checklist item to our mystery set.
/// Must have completed initial deploy, and can't add more than 56 items (because checklistId is a uint8).
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function addUnreleasedChecklistItem(uint8 _playerId, RarityTier _tier) external onlyOwner {
require(deployStep == DeployStep.DoneInitialDeploy, "Finish deploying the Originals and Iconics sets first.");
require(unreleasedCount() < 56, "You can't add any more checklist items.");
require(_playerId < playerCount, "This player doesn't exist in our player list.");
unreleasedChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev Returns how many Original checklist items we've added.
function originalsCount() external view returns (uint256) {
return originalChecklistItems.length;
}
/// @dev Returns how many Iconic checklist items we've added.
function iconicsCount() public view returns (uint256) {
return iconicChecklistItems.length;
}
/// @dev Returns how many Unreleased checklist items we've added.
function unreleasedCount() public view returns (uint256) {
return unreleasedChecklistItems.length;
}
// In the next four functions, we initialize this contract with our
// 132 initial checklist items (100 Originals, 32 Iconics). Because
// of how much data we need to store, it has to be broken up into
// four different function calls, which need to be called in sequence.
// The ordering of the checklist items we add determines their
// checklist ID, which is left-padded in our frontend to be a
// 3-digit identifier where the first digit is the setId and the last
// 2 digits represents the checklist items index in the appropriate ___ChecklistItems array.
// For example, Originals Messi is the first item for set ID 0, and this
// is displayed as #000 throughout the app. Our Card struct declare its
// checklistId property as uint8, so we have
// to be mindful that we can only have 256 total checklist items.
/// @dev Deploys Originals #000 through #032.
function deployStepOne() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepOne, "You're not following the steps in order...");
/* ORIGINALS - DIAMOND */
_addOriginalChecklistItem(0, RarityTier.Diamond); // 000 Messi
_addOriginalChecklistItem(1, RarityTier.Diamond); // 001 Ronaldo
_addOriginalChecklistItem(2, RarityTier.Diamond); // 002 Neymar
_addOriginalChecklistItem(3, RarityTier.Diamond); // 003 Salah
/* ORIGINALS - GOLD */
_addOriginalChecklistItem(4, RarityTier.Gold); // 004 Lewandowski
_addOriginalChecklistItem(5, RarityTier.Gold); // 005 De Bruyne
_addOriginalChecklistItem(6, RarityTier.Gold); // 006 Modrić
_addOriginalChecklistItem(7, RarityTier.Gold); // 007 Hazard
_addOriginalChecklistItem(8, RarityTier.Gold); // 008 Ramos
_addOriginalChecklistItem(9, RarityTier.Gold); // 009 Kroos
_addOriginalChecklistItem(10, RarityTier.Gold); // 010 Suárez
_addOriginalChecklistItem(11, RarityTier.Gold); // 011 Kane
_addOriginalChecklistItem(12, RarityTier.Gold); // 012 Agüero
_addOriginalChecklistItem(13, RarityTier.Gold); // 013 Mbappé
_addOriginalChecklistItem(14, RarityTier.Gold); // 014 Higuaín
_addOriginalChecklistItem(15, RarityTier.Gold); // 015 de Gea
_addOriginalChecklistItem(16, RarityTier.Gold); // 016 Griezmann
_addOriginalChecklistItem(17, RarityTier.Gold); // 017 Kanté
_addOriginalChecklistItem(18, RarityTier.Gold); // 018 Cavani
_addOriginalChecklistItem(19, RarityTier.Gold); // 019 Pogba
/* ORIGINALS - SILVER (020 to 032) */
_addOriginalChecklistItem(20, RarityTier.Silver); // 020 Isco
_addOriginalChecklistItem(21, RarityTier.Silver); // 021 Marcelo
_addOriginalChecklistItem(22, RarityTier.Silver); // 022 Neuer
_addOriginalChecklistItem(23, RarityTier.Silver); // 023 Mertens
_addOriginalChecklistItem(24, RarityTier.Silver); // 024 James
_addOriginalChecklistItem(25, RarityTier.Silver); // 025 Dybala
_addOriginalChecklistItem(26, RarityTier.Silver); // 026 Eriksen
_addOriginalChecklistItem(27, RarityTier.Silver); // 027 David Silva
_addOriginalChecklistItem(28, RarityTier.Silver); // 028 Gabriel Jesus
_addOriginalChecklistItem(29, RarityTier.Silver); // 029 Thiago
_addOriginalChecklistItem(30, RarityTier.Silver); // 030 Courtois
_addOriginalChecklistItem(31, RarityTier.Silver); // 031 Coutinho
_addOriginalChecklistItem(32, RarityTier.Silver); // 032 Iniesta
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepTwo;
}
/// @dev Deploys Originals #033 through #065.
function deployStepTwo() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepTwo, "You're not following the steps in order...");
/* ORIGINALS - SILVER (033 to 049) */
_addOriginalChecklistItem(33, RarityTier.Silver); // 033 Casemiro
_addOriginalChecklistItem(34, RarityTier.Silver); // 034 Lukaku
_addOriginalChecklistItem(35, RarityTier.Silver); // 035 Piqué
_addOriginalChecklistItem(36, RarityTier.Silver); // 036 Hummels
_addOriginalChecklistItem(37, RarityTier.Silver); // 037 Godín
_addOriginalChecklistItem(38, RarityTier.Silver); // 038 Özil
_addOriginalChecklistItem(39, RarityTier.Silver); // 039 Son
_addOriginalChecklistItem(40, RarityTier.Silver); // 040 Sterling
_addOriginalChecklistItem(41, RarityTier.Silver); // 041 Lloris
_addOriginalChecklistItem(42, RarityTier.Silver); // 042 Falcao
_addOriginalChecklistItem(43, RarityTier.Silver); // 043 Rakitić
_addOriginalChecklistItem(44, RarityTier.Silver); // 044 Sané
_addOriginalChecklistItem(45, RarityTier.Silver); // 045 Firmino
_addOriginalChecklistItem(46, RarityTier.Silver); // 046 Mané
_addOriginalChecklistItem(47, RarityTier.Silver); // 047 Müller
_addOriginalChecklistItem(48, RarityTier.Silver); // 048 Alli
_addOriginalChecklistItem(49, RarityTier.Silver); // 049 Navas
/* ORIGINALS - BRONZE (050 to 065) */
_addOriginalChecklistItem(50, RarityTier.Bronze); // 050 Thiago Silva
_addOriginalChecklistItem(51, RarityTier.Bronze); // 051 Varane
_addOriginalChecklistItem(52, RarityTier.Bronze); // 052 Di María
_addOriginalChecklistItem(53, RarityTier.Bronze); // 053 Alba
_addOriginalChecklistItem(54, RarityTier.Bronze); // 054 Benatia
_addOriginalChecklistItem(55, RarityTier.Bronze); // 055 Werner
_addOriginalChecklistItem(56, RarityTier.Bronze); // 056 Sigurðsson
_addOriginalChecklistItem(57, RarityTier.Bronze); // 057 Matić
_addOriginalChecklistItem(58, RarityTier.Bronze); // 058 Koulibaly
_addOriginalChecklistItem(59, RarityTier.Bronze); // 059 Bernardo Silva
_addOriginalChecklistItem(60, RarityTier.Bronze); // 060 Kompany
_addOriginalChecklistItem(61, RarityTier.Bronze); // 061 Moutinho
_addOriginalChecklistItem(62, RarityTier.Bronze); // 062 Alderweireld
_addOriginalChecklistItem(63, RarityTier.Bronze); // 063 Forsberg
_addOriginalChecklistItem(64, RarityTier.Bronze); // 064 Mandžukić
_addOriginalChecklistItem(65, RarityTier.Bronze); // 065 Milinković-Savić
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepThree;
}
/// @dev Deploys Originals #066 through #099.
function deployStepThree() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepThree, "You're not following the steps in order...");
/* ORIGINALS - BRONZE (066 to 099) */
_addOriginalChecklistItem(66, RarityTier.Bronze); // 066 Kagawa
_addOriginalChecklistItem(67, RarityTier.Bronze); // 067 Xhaka
_addOriginalChecklistItem(68, RarityTier.Bronze); // 068 Christensen
_addOriginalChecklistItem(69, RarityTier.Bronze); // 069 Zieliński
_addOriginalChecklistItem(70, RarityTier.Bronze); // 070 Smolov
_addOriginalChecklistItem(71, RarityTier.Bronze); // 071 Shaqiri
_addOriginalChecklistItem(72, RarityTier.Bronze); // 072 Rashford
_addOriginalChecklistItem(73, RarityTier.Bronze); // 073 Hernández
_addOriginalChecklistItem(74, RarityTier.Bronze); // 074 Lozano
_addOriginalChecklistItem(75, RarityTier.Bronze); // 075 Ziyech
_addOriginalChecklistItem(76, RarityTier.Bronze); // 076 Moses
_addOriginalChecklistItem(77, RarityTier.Bronze); // 077 Farfán
_addOriginalChecklistItem(78, RarityTier.Bronze); // 078 Elneny
_addOriginalChecklistItem(79, RarityTier.Bronze); // 079 Berg
_addOriginalChecklistItem(80, RarityTier.Bronze); // 080 Ochoa
_addOriginalChecklistItem(81, RarityTier.Bronze); // 081 Akinfeev
_addOriginalChecklistItem(82, RarityTier.Bronze); // 082 Azmoun
_addOriginalChecklistItem(83, RarityTier.Bronze); // 083 Cueva
_addOriginalChecklistItem(84, RarityTier.Bronze); // 084 Khazri
_addOriginalChecklistItem(85, RarityTier.Bronze); // 085 Honda
_addOriginalChecklistItem(86, RarityTier.Bronze); // 086 Cahill
_addOriginalChecklistItem(87, RarityTier.Bronze); // 087 Mikel
_addOriginalChecklistItem(88, RarityTier.Bronze); // 088 Sung-yueng
_addOriginalChecklistItem(89, RarityTier.Bronze); // 089 Ruiz
_addOriginalChecklistItem(90, RarityTier.Bronze); // 090 Yoshida
_addOriginalChecklistItem(91, RarityTier.Bronze); // 091 Al Abed
_addOriginalChecklistItem(92, RarityTier.Bronze); // 092 Chung-yong
_addOriginalChecklistItem(93, RarityTier.Bronze); // 093 Gómez
_addOriginalChecklistItem(94, RarityTier.Bronze); // 094 Sliti
_addOriginalChecklistItem(95, RarityTier.Bronze); // 095 Ghoochannejhad
_addOriginalChecklistItem(96, RarityTier.Bronze); // 096 Jedinak
_addOriginalChecklistItem(97, RarityTier.Bronze); // 097 Al-Sahlawi
_addOriginalChecklistItem(98, RarityTier.Bronze); // 098 Gunnarsson
_addOriginalChecklistItem(99, RarityTier.Bronze); // 099 Pérez
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepFour;
}
/// @dev Deploys all Iconics and marks the deploy as complete!
function deployStepFour() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepFour, "You're not following the steps in order...");
/* ICONICS */
_addIconicChecklistItem(0, RarityTier.IconicInsert); // 100 Messi
_addIconicChecklistItem(1, RarityTier.IconicInsert); // 101 Ronaldo
_addIconicChecklistItem(2, RarityTier.IconicInsert); // 102 Neymar
_addIconicChecklistItem(3, RarityTier.IconicInsert); // 103 Salah
_addIconicChecklistItem(4, RarityTier.IconicInsert); // 104 Lewandowski
_addIconicChecklistItem(5, RarityTier.IconicInsert); // 105 De Bruyne
_addIconicChecklistItem(6, RarityTier.IconicInsert); // 106 Modrić
_addIconicChecklistItem(7, RarityTier.IconicInsert); // 107 Hazard
_addIconicChecklistItem(8, RarityTier.IconicInsert); // 108 Ramos
_addIconicChecklistItem(9, RarityTier.IconicInsert); // 109 Kroos
_addIconicChecklistItem(10, RarityTier.IconicInsert); // 110 Suárez
_addIconicChecklistItem(11, RarityTier.IconicInsert); // 111 Kane
_addIconicChecklistItem(12, RarityTier.IconicInsert); // 112 Agüero
_addIconicChecklistItem(15, RarityTier.IconicInsert); // 113 de Gea
_addIconicChecklistItem(16, RarityTier.IconicInsert); // 114 Griezmann
_addIconicChecklistItem(17, RarityTier.IconicReferral); // 115 Kanté
_addIconicChecklistItem(18, RarityTier.IconicReferral); // 116 Cavani
_addIconicChecklistItem(19, RarityTier.IconicInsert); // 117 Pogba
_addIconicChecklistItem(21, RarityTier.IconicInsert); // 118 Marcelo
_addIconicChecklistItem(24, RarityTier.IconicInsert); // 119 James
_addIconicChecklistItem(26, RarityTier.IconicInsert); // 120 Eriksen
_addIconicChecklistItem(29, RarityTier.IconicReferral); // 121 Thiago
_addIconicChecklistItem(36, RarityTier.IconicReferral); // 122 Hummels
_addIconicChecklistItem(38, RarityTier.IconicReferral); // 123 Özil
_addIconicChecklistItem(39, RarityTier.IconicInsert); // 124 Son
_addIconicChecklistItem(46, RarityTier.IconicInsert); // 125 Mané
_addIconicChecklistItem(48, RarityTier.IconicInsert); // 126 Alli
_addIconicChecklistItem(49, RarityTier.IconicReferral); // 127 Navas
_addIconicChecklistItem(73, RarityTier.IconicInsert); // 128 Hernández
_addIconicChecklistItem(85, RarityTier.IconicInsert); // 129 Honda
_addIconicChecklistItem(100, RarityTier.IconicReferral); // 130 Alves
_addIconicChecklistItem(101, RarityTier.IconicReferral); // 131 Zlatan
// Mark the initial deploy as complete.
deployStep = DeployStep.DoneInitialDeploy;
}
/// @dev Returns the mint limit for a given checklist item, based on its tier.
/// @param _checklistId Which checklist item we need to get the limit for.
/// @return How much of this checklist item we are allowed to mint.
function limitForChecklistId(uint8 _checklistId) external view returns (uint16) {
RarityTier rarityTier;
uint8 index;
if (_checklistId < 100) { // Originals = #000 to #099
rarityTier = originalChecklistItems[_checklistId].tier;
} else if (_checklistId < 200) { // Iconics = #100 to #131
index = _checklistId - 100;
require(index < iconicsCount(), "This Iconics checklist item doesn't exist.");
rarityTier = iconicChecklistItems[index].tier;
} else { // Unreleased = #200 to max #255
index = _checklistId - 200;
require(index < unreleasedCount(), "This Unreleased checklist item doesn't exist.");
rarityTier = unreleasedChecklistItems[index].tier;
}
return tierLimits[uint8(rarityTier)];
}
} | /// @title The contract that manages checklist items, sets, and rarity tiers.
/// @author The CryptoStrikers Team | NatSpecSingleLine | deployStepFour | function deployStepFour() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepFour, "You're not following the steps in order...");
/* ICONICS */
_addIconicChecklistItem(0, RarityTier.IconicInsert); // 100 Messi
_addIconicChecklistItem(1, RarityTier.IconicInsert); // 101 Ronaldo
_addIconicChecklistItem(2, RarityTier.IconicInsert); // 102 Neymar
_addIconicChecklistItem(3, RarityTier.IconicInsert); // 103 Salah
_addIconicChecklistItem(4, RarityTier.IconicInsert); // 104 Lewandowski
_addIconicChecklistItem(5, RarityTier.IconicInsert); // 105 De Bruyne
_addIconicChecklistItem(6, RarityTier.IconicInsert); // 106 Modrić
_addIconicChecklistItem(7, RarityTier.IconicInsert); // 107 Hazard
_addIconicChecklistItem(8, RarityTier.IconicInsert); // 108 Ramos
_addIconicChecklistItem(9, RarityTier.IconicInsert); // 109 Kroos
_addIconicChecklistItem(10, RarityTier.IconicInsert); // 110 Suárez
_addIconicChecklistItem(11, RarityTier.IconicInsert); // 111 Kane
_addIconicChecklistItem(12, RarityTier.IconicInsert); // 112 Agüero
_addIconicChecklistItem(15, RarityTier.IconicInsert); // 113 de Gea
_addIconicChecklistItem(16, RarityTier.IconicInsert); // 114 Griezmann
_addIconicChecklistItem(17, RarityTier.IconicReferral); // 115 Kanté
_addIconicChecklistItem(18, RarityTier.IconicReferral); // 116 Cavani
_addIconicChecklistItem(19, RarityTier.IconicInsert); // 117 Pogba
_addIconicChecklistItem(21, RarityTier.IconicInsert); // 118 Marcelo
_addIconicChecklistItem(24, RarityTier.IconicInsert); // 119 James
_addIconicChecklistItem(26, RarityTier.IconicInsert); // 120 Eriksen
_addIconicChecklistItem(29, RarityTier.IconicReferral); // 121 Thiago
_addIconicChecklistItem(36, RarityTier.IconicReferral); // 122 Hummels
_addIconicChecklistItem(38, RarityTier.IconicReferral); // 123 Özil
_addIconicChecklistItem(39, RarityTier.IconicInsert); // 124 Son
_addIconicChecklistItem(46, RarityTier.IconicInsert); // 125 Mané
_addIconicChecklistItem(48, RarityTier.IconicInsert); // 126 Alli
_addIconicChecklistItem(49, RarityTier.IconicReferral); // 127 Navas
_addIconicChecklistItem(73, RarityTier.IconicInsert); // 128 Hernández
_addIconicChecklistItem(85, RarityTier.IconicInsert); // 129 Honda
_addIconicChecklistItem(100, RarityTier.IconicReferral); // 130 Alves
_addIconicChecklistItem(101, RarityTier.IconicReferral); // 131 Zlatan
// Mark the initial deploy as complete.
deployStep = DeployStep.DoneInitialDeploy;
}
| /// @dev Deploys all Iconics and marks the deploy as complete! | NatSpecSingleLine | v0.4.24+commit.e67f0147 | bzzr://f87c20fe7eb593456a65c383f65f6ca3a578031b9800b338b3629208d23ef268 | {
"func_code_index": [
14735,
17351
]
} | 5,103 |
|
StrikersChecklist | StrikersChecklist.sol | 0xdbc260a05f81629ffa062df3d1668a43133abba4 | Solidity | StrikersChecklist | contract StrikersChecklist is StrikersPlayerList {
// High level overview of everything going on in this contract:
//
// ChecklistItem is the parent class to Card and has 3 properties:
// - uint8 checklistId (000 to 255)
// - uint8 playerId (see StrikersPlayerList.sol)
// - RarityTier tier (more info below)
//
// Two things to note: the checklistId is not explicitly stored
// on the checklistItem struct, and it's composed of two parts.
// (For the following, assume it is left padded with zeros to reach
// three digits, such that checklistId 0 becomes 000)
// - the first digit represents the setId
// * 0 = Originals Set
// * 1 = Iconics Set
// * 2 = Unreleased Set
// - the last two digits represent its index in the appropriate set arary
//
// For example, checklist ID 100 would represent fhe first checklist item
// in the iconicChecklistItems array (first digit = 1 = Iconics Set, last two
// digits = 00 = first index of array)
//
// Because checklistId is represented as a uint8 throughout the app, the highest
// value it can take is 255, which means we can't add more than 56 items to our
// Unreleased Set's unreleasedChecklistItems array (setId 2). Also, once we've initialized
// this contract, it's impossible for us to add more checklist items to the Originals
// and Iconics set -- what you see here is what you get.
//
// Simple enough right?
/// @dev We initialize this contract with so much data that we have
/// to stage it in 4 different steps, ~33 checklist items at a time.
enum DeployStep {
WaitingForStepOne,
WaitingForStepTwo,
WaitingForStepThree,
WaitingForStepFour,
DoneInitialDeploy
}
/// @dev Enum containing all our rarity tiers, just because
/// it's cleaner dealing with these values than with uint8s.
enum RarityTier {
IconicReferral,
IconicInsert,
Diamond,
Gold,
Silver,
Bronze
}
/// @dev A lookup table indicating how limited the cards
/// in each tier are. If this value is 0, it means
/// that cards of this rarity tier are unlimited,
/// which is only the case for the 8 Iconics cards
/// we give away as part of our referral program.
uint16[] public tierLimits = [
0, // Iconic - Referral Bonus (uncapped)
100, // Iconic Inserts ("Card of the Day")
1000, // Diamond
1664, // Gold
3328, // Silver
4352 // Bronze
];
/// @dev ChecklistItem is essentially the parent class to Card.
/// It represents a given superclass of cards (eg Originals Messi),
/// and then each Card is an instance of this ChecklistItem, with
/// its own serial number, mint date, etc.
struct ChecklistItem {
uint8 playerId;
RarityTier tier;
}
/// @dev The deploy step we're at. Defaults to WaitingForStepOne.
DeployStep public deployStep;
/// @dev Array containing all the Originals checklist items (000 - 099)
ChecklistItem[] public originalChecklistItems;
/// @dev Array containing all the Iconics checklist items (100 - 131)
ChecklistItem[] public iconicChecklistItems;
/// @dev Array containing all the unreleased checklist items (200 - 255 max)
ChecklistItem[] public unreleasedChecklistItems;
/// @dev Internal function to add a checklist item to the Originals set.
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function _addOriginalChecklistItem(uint8 _playerId, RarityTier _tier) internal {
originalChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev Internal function to add a checklist item to the Iconics set.
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function _addIconicChecklistItem(uint8 _playerId, RarityTier _tier) internal {
iconicChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev External function to add a checklist item to our mystery set.
/// Must have completed initial deploy, and can't add more than 56 items (because checklistId is a uint8).
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rarity tier. (see Rarity Tier enum and corresponding tierLimits)
function addUnreleasedChecklistItem(uint8 _playerId, RarityTier _tier) external onlyOwner {
require(deployStep == DeployStep.DoneInitialDeploy, "Finish deploying the Originals and Iconics sets first.");
require(unreleasedCount() < 56, "You can't add any more checklist items.");
require(_playerId < playerCount, "This player doesn't exist in our player list.");
unreleasedChecklistItems.push(ChecklistItem({
playerId: _playerId,
tier: _tier
}));
}
/// @dev Returns how many Original checklist items we've added.
function originalsCount() external view returns (uint256) {
return originalChecklistItems.length;
}
/// @dev Returns how many Iconic checklist items we've added.
function iconicsCount() public view returns (uint256) {
return iconicChecklistItems.length;
}
/// @dev Returns how many Unreleased checklist items we've added.
function unreleasedCount() public view returns (uint256) {
return unreleasedChecklistItems.length;
}
// In the next four functions, we initialize this contract with our
// 132 initial checklist items (100 Originals, 32 Iconics). Because
// of how much data we need to store, it has to be broken up into
// four different function calls, which need to be called in sequence.
// The ordering of the checklist items we add determines their
// checklist ID, which is left-padded in our frontend to be a
// 3-digit identifier where the first digit is the setId and the last
// 2 digits represents the checklist items index in the appropriate ___ChecklistItems array.
// For example, Originals Messi is the first item for set ID 0, and this
// is displayed as #000 throughout the app. Our Card struct declare its
// checklistId property as uint8, so we have
// to be mindful that we can only have 256 total checklist items.
/// @dev Deploys Originals #000 through #032.
function deployStepOne() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepOne, "You're not following the steps in order...");
/* ORIGINALS - DIAMOND */
_addOriginalChecklistItem(0, RarityTier.Diamond); // 000 Messi
_addOriginalChecklistItem(1, RarityTier.Diamond); // 001 Ronaldo
_addOriginalChecklistItem(2, RarityTier.Diamond); // 002 Neymar
_addOriginalChecklistItem(3, RarityTier.Diamond); // 003 Salah
/* ORIGINALS - GOLD */
_addOriginalChecklistItem(4, RarityTier.Gold); // 004 Lewandowski
_addOriginalChecklistItem(5, RarityTier.Gold); // 005 De Bruyne
_addOriginalChecklistItem(6, RarityTier.Gold); // 006 Modrić
_addOriginalChecklistItem(7, RarityTier.Gold); // 007 Hazard
_addOriginalChecklistItem(8, RarityTier.Gold); // 008 Ramos
_addOriginalChecklistItem(9, RarityTier.Gold); // 009 Kroos
_addOriginalChecklistItem(10, RarityTier.Gold); // 010 Suárez
_addOriginalChecklistItem(11, RarityTier.Gold); // 011 Kane
_addOriginalChecklistItem(12, RarityTier.Gold); // 012 Agüero
_addOriginalChecklistItem(13, RarityTier.Gold); // 013 Mbappé
_addOriginalChecklistItem(14, RarityTier.Gold); // 014 Higuaín
_addOriginalChecklistItem(15, RarityTier.Gold); // 015 de Gea
_addOriginalChecklistItem(16, RarityTier.Gold); // 016 Griezmann
_addOriginalChecklistItem(17, RarityTier.Gold); // 017 Kanté
_addOriginalChecklistItem(18, RarityTier.Gold); // 018 Cavani
_addOriginalChecklistItem(19, RarityTier.Gold); // 019 Pogba
/* ORIGINALS - SILVER (020 to 032) */
_addOriginalChecklistItem(20, RarityTier.Silver); // 020 Isco
_addOriginalChecklistItem(21, RarityTier.Silver); // 021 Marcelo
_addOriginalChecklistItem(22, RarityTier.Silver); // 022 Neuer
_addOriginalChecklistItem(23, RarityTier.Silver); // 023 Mertens
_addOriginalChecklistItem(24, RarityTier.Silver); // 024 James
_addOriginalChecklistItem(25, RarityTier.Silver); // 025 Dybala
_addOriginalChecklistItem(26, RarityTier.Silver); // 026 Eriksen
_addOriginalChecklistItem(27, RarityTier.Silver); // 027 David Silva
_addOriginalChecklistItem(28, RarityTier.Silver); // 028 Gabriel Jesus
_addOriginalChecklistItem(29, RarityTier.Silver); // 029 Thiago
_addOriginalChecklistItem(30, RarityTier.Silver); // 030 Courtois
_addOriginalChecklistItem(31, RarityTier.Silver); // 031 Coutinho
_addOriginalChecklistItem(32, RarityTier.Silver); // 032 Iniesta
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepTwo;
}
/// @dev Deploys Originals #033 through #065.
function deployStepTwo() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepTwo, "You're not following the steps in order...");
/* ORIGINALS - SILVER (033 to 049) */
_addOriginalChecklistItem(33, RarityTier.Silver); // 033 Casemiro
_addOriginalChecklistItem(34, RarityTier.Silver); // 034 Lukaku
_addOriginalChecklistItem(35, RarityTier.Silver); // 035 Piqué
_addOriginalChecklistItem(36, RarityTier.Silver); // 036 Hummels
_addOriginalChecklistItem(37, RarityTier.Silver); // 037 Godín
_addOriginalChecklistItem(38, RarityTier.Silver); // 038 Özil
_addOriginalChecklistItem(39, RarityTier.Silver); // 039 Son
_addOriginalChecklistItem(40, RarityTier.Silver); // 040 Sterling
_addOriginalChecklistItem(41, RarityTier.Silver); // 041 Lloris
_addOriginalChecklistItem(42, RarityTier.Silver); // 042 Falcao
_addOriginalChecklistItem(43, RarityTier.Silver); // 043 Rakitić
_addOriginalChecklistItem(44, RarityTier.Silver); // 044 Sané
_addOriginalChecklistItem(45, RarityTier.Silver); // 045 Firmino
_addOriginalChecklistItem(46, RarityTier.Silver); // 046 Mané
_addOriginalChecklistItem(47, RarityTier.Silver); // 047 Müller
_addOriginalChecklistItem(48, RarityTier.Silver); // 048 Alli
_addOriginalChecklistItem(49, RarityTier.Silver); // 049 Navas
/* ORIGINALS - BRONZE (050 to 065) */
_addOriginalChecklistItem(50, RarityTier.Bronze); // 050 Thiago Silva
_addOriginalChecklistItem(51, RarityTier.Bronze); // 051 Varane
_addOriginalChecklistItem(52, RarityTier.Bronze); // 052 Di María
_addOriginalChecklistItem(53, RarityTier.Bronze); // 053 Alba
_addOriginalChecklistItem(54, RarityTier.Bronze); // 054 Benatia
_addOriginalChecklistItem(55, RarityTier.Bronze); // 055 Werner
_addOriginalChecklistItem(56, RarityTier.Bronze); // 056 Sigurðsson
_addOriginalChecklistItem(57, RarityTier.Bronze); // 057 Matić
_addOriginalChecklistItem(58, RarityTier.Bronze); // 058 Koulibaly
_addOriginalChecklistItem(59, RarityTier.Bronze); // 059 Bernardo Silva
_addOriginalChecklistItem(60, RarityTier.Bronze); // 060 Kompany
_addOriginalChecklistItem(61, RarityTier.Bronze); // 061 Moutinho
_addOriginalChecklistItem(62, RarityTier.Bronze); // 062 Alderweireld
_addOriginalChecklistItem(63, RarityTier.Bronze); // 063 Forsberg
_addOriginalChecklistItem(64, RarityTier.Bronze); // 064 Mandžukić
_addOriginalChecklistItem(65, RarityTier.Bronze); // 065 Milinković-Savić
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepThree;
}
/// @dev Deploys Originals #066 through #099.
function deployStepThree() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepThree, "You're not following the steps in order...");
/* ORIGINALS - BRONZE (066 to 099) */
_addOriginalChecklistItem(66, RarityTier.Bronze); // 066 Kagawa
_addOriginalChecklistItem(67, RarityTier.Bronze); // 067 Xhaka
_addOriginalChecklistItem(68, RarityTier.Bronze); // 068 Christensen
_addOriginalChecklistItem(69, RarityTier.Bronze); // 069 Zieliński
_addOriginalChecklistItem(70, RarityTier.Bronze); // 070 Smolov
_addOriginalChecklistItem(71, RarityTier.Bronze); // 071 Shaqiri
_addOriginalChecklistItem(72, RarityTier.Bronze); // 072 Rashford
_addOriginalChecklistItem(73, RarityTier.Bronze); // 073 Hernández
_addOriginalChecklistItem(74, RarityTier.Bronze); // 074 Lozano
_addOriginalChecklistItem(75, RarityTier.Bronze); // 075 Ziyech
_addOriginalChecklistItem(76, RarityTier.Bronze); // 076 Moses
_addOriginalChecklistItem(77, RarityTier.Bronze); // 077 Farfán
_addOriginalChecklistItem(78, RarityTier.Bronze); // 078 Elneny
_addOriginalChecklistItem(79, RarityTier.Bronze); // 079 Berg
_addOriginalChecklistItem(80, RarityTier.Bronze); // 080 Ochoa
_addOriginalChecklistItem(81, RarityTier.Bronze); // 081 Akinfeev
_addOriginalChecklistItem(82, RarityTier.Bronze); // 082 Azmoun
_addOriginalChecklistItem(83, RarityTier.Bronze); // 083 Cueva
_addOriginalChecklistItem(84, RarityTier.Bronze); // 084 Khazri
_addOriginalChecklistItem(85, RarityTier.Bronze); // 085 Honda
_addOriginalChecklistItem(86, RarityTier.Bronze); // 086 Cahill
_addOriginalChecklistItem(87, RarityTier.Bronze); // 087 Mikel
_addOriginalChecklistItem(88, RarityTier.Bronze); // 088 Sung-yueng
_addOriginalChecklistItem(89, RarityTier.Bronze); // 089 Ruiz
_addOriginalChecklistItem(90, RarityTier.Bronze); // 090 Yoshida
_addOriginalChecklistItem(91, RarityTier.Bronze); // 091 Al Abed
_addOriginalChecklistItem(92, RarityTier.Bronze); // 092 Chung-yong
_addOriginalChecklistItem(93, RarityTier.Bronze); // 093 Gómez
_addOriginalChecklistItem(94, RarityTier.Bronze); // 094 Sliti
_addOriginalChecklistItem(95, RarityTier.Bronze); // 095 Ghoochannejhad
_addOriginalChecklistItem(96, RarityTier.Bronze); // 096 Jedinak
_addOriginalChecklistItem(97, RarityTier.Bronze); // 097 Al-Sahlawi
_addOriginalChecklistItem(98, RarityTier.Bronze); // 098 Gunnarsson
_addOriginalChecklistItem(99, RarityTier.Bronze); // 099 Pérez
// Move to the next deploy step.
deployStep = DeployStep.WaitingForStepFour;
}
/// @dev Deploys all Iconics and marks the deploy as complete!
function deployStepFour() external onlyOwner {
require(deployStep == DeployStep.WaitingForStepFour, "You're not following the steps in order...");
/* ICONICS */
_addIconicChecklistItem(0, RarityTier.IconicInsert); // 100 Messi
_addIconicChecklistItem(1, RarityTier.IconicInsert); // 101 Ronaldo
_addIconicChecklistItem(2, RarityTier.IconicInsert); // 102 Neymar
_addIconicChecklistItem(3, RarityTier.IconicInsert); // 103 Salah
_addIconicChecklistItem(4, RarityTier.IconicInsert); // 104 Lewandowski
_addIconicChecklistItem(5, RarityTier.IconicInsert); // 105 De Bruyne
_addIconicChecklistItem(6, RarityTier.IconicInsert); // 106 Modrić
_addIconicChecklistItem(7, RarityTier.IconicInsert); // 107 Hazard
_addIconicChecklistItem(8, RarityTier.IconicInsert); // 108 Ramos
_addIconicChecklistItem(9, RarityTier.IconicInsert); // 109 Kroos
_addIconicChecklistItem(10, RarityTier.IconicInsert); // 110 Suárez
_addIconicChecklistItem(11, RarityTier.IconicInsert); // 111 Kane
_addIconicChecklistItem(12, RarityTier.IconicInsert); // 112 Agüero
_addIconicChecklistItem(15, RarityTier.IconicInsert); // 113 de Gea
_addIconicChecklistItem(16, RarityTier.IconicInsert); // 114 Griezmann
_addIconicChecklistItem(17, RarityTier.IconicReferral); // 115 Kanté
_addIconicChecklistItem(18, RarityTier.IconicReferral); // 116 Cavani
_addIconicChecklistItem(19, RarityTier.IconicInsert); // 117 Pogba
_addIconicChecklistItem(21, RarityTier.IconicInsert); // 118 Marcelo
_addIconicChecklistItem(24, RarityTier.IconicInsert); // 119 James
_addIconicChecklistItem(26, RarityTier.IconicInsert); // 120 Eriksen
_addIconicChecklistItem(29, RarityTier.IconicReferral); // 121 Thiago
_addIconicChecklistItem(36, RarityTier.IconicReferral); // 122 Hummels
_addIconicChecklistItem(38, RarityTier.IconicReferral); // 123 Özil
_addIconicChecklistItem(39, RarityTier.IconicInsert); // 124 Son
_addIconicChecklistItem(46, RarityTier.IconicInsert); // 125 Mané
_addIconicChecklistItem(48, RarityTier.IconicInsert); // 126 Alli
_addIconicChecklistItem(49, RarityTier.IconicReferral); // 127 Navas
_addIconicChecklistItem(73, RarityTier.IconicInsert); // 128 Hernández
_addIconicChecklistItem(85, RarityTier.IconicInsert); // 129 Honda
_addIconicChecklistItem(100, RarityTier.IconicReferral); // 130 Alves
_addIconicChecklistItem(101, RarityTier.IconicReferral); // 131 Zlatan
// Mark the initial deploy as complete.
deployStep = DeployStep.DoneInitialDeploy;
}
/// @dev Returns the mint limit for a given checklist item, based on its tier.
/// @param _checklistId Which checklist item we need to get the limit for.
/// @return How much of this checklist item we are allowed to mint.
function limitForChecklistId(uint8 _checklistId) external view returns (uint16) {
RarityTier rarityTier;
uint8 index;
if (_checklistId < 100) { // Originals = #000 to #099
rarityTier = originalChecklistItems[_checklistId].tier;
} else if (_checklistId < 200) { // Iconics = #100 to #131
index = _checklistId - 100;
require(index < iconicsCount(), "This Iconics checklist item doesn't exist.");
rarityTier = iconicChecklistItems[index].tier;
} else { // Unreleased = #200 to max #255
index = _checklistId - 200;
require(index < unreleasedCount(), "This Unreleased checklist item doesn't exist.");
rarityTier = unreleasedChecklistItems[index].tier;
}
return tierLimits[uint8(rarityTier)];
}
} | /// @title The contract that manages checklist items, sets, and rarity tiers.
/// @author The CryptoStrikers Team | NatSpecSingleLine | limitForChecklistId | function limitForChecklistId(uint8 _checklistId) external view returns (uint16) {
RarityTier rarityTier;
uint8 index;
if (_checklistId < 100) { // Originals = #000 to #099
rarityTier = originalChecklistItems[_checklistId].tier;
} else if (_checklistId < 200) { // Iconics = #100 to #131
index = _checklistId - 100;
require(index < iconicsCount(), "This Iconics checklist item doesn't exist.");
rarityTier = iconicChecklistItems[index].tier;
} else { // Unreleased = #200 to max #255
index = _checklistId - 200;
require(index < unreleasedCount(), "This Unreleased checklist item doesn't exist.");
rarityTier = unreleasedChecklistItems[index].tier;
}
return tierLimits[uint8(rarityTier)];
}
| /// @dev Returns the mint limit for a given checklist item, based on its tier.
/// @param _checklistId Which checklist item we need to get the limit for.
/// @return How much of this checklist item we are allowed to mint. | NatSpecSingleLine | v0.4.24+commit.e67f0147 | bzzr://f87c20fe7eb593456a65c383f65f6ca3a578031b9800b338b3629208d23ef268 | {
"func_code_index": [
17585,
18363
]
} | 5,104 |
|
DiamondDolphins | @openzeppelin/contracts/access/Ownable.sol | 0x881018075d93573d581d129574cbff3c632daaea | Solidity | Ownable | abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
} | /**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/ | NatSpecMultiLine | owner | function owner() public view virtual returns (address) {
return _owner;
}
| /**
* @dev Returns the address of the current owner.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | GNU GPLv3 | ipfs://763a4f36c2c223ff72c53e3c00d7bad788692853f811b911cf0ece4d394dca26 | {
"func_code_index": [
399,
491
]
} | 5,105 |
DiamondDolphins | @openzeppelin/contracts/access/Ownable.sol | 0x881018075d93573d581d129574cbff3c632daaea | Solidity | Ownable | abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
} | /**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/ | NatSpecMultiLine | renounceOwnership | function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
| /**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | GNU GPLv3 | ipfs://763a4f36c2c223ff72c53e3c00d7bad788692853f811b911cf0ece4d394dca26 | {
"func_code_index": [
1050,
1149
]
} | 5,106 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.