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
ICO
ICO.sol
0x72cc9d8e0a8034fecd2159fb2a951efe8b49f5ae
Solidity
ICO
contract ICO { using SafeMath for uint256; //This ico have 5 states enum State { stage1, stage2, stage3, stage4, Successful } DateTimeAPI dateTimeContract = DateTimeAPI(0x1a6184CD4C5Bea62B0116de7962EE7315B7bcBce);//Main //DateTimeAPI dateTimeContract = DateTimeAPI(0x1F0a2ba4B115bd3e4007533C52BBd30C17E8B222);//Ropsten //public variables State public state = State.stage1; //Set initial stage uint256 public startTime; uint256 public rate; uint256 public totalRaised; //eth in wei uint256 public totalDistributed; //tokens uint256 public ICOdeadline; uint256 public completedAt; token public tokenReward; address public creator; address public beneficiary; string public version = '1'; mapping(address => bool) public airdropClaimed; mapping(address => uint) public icoTokensReceived; uint public constant TOKEN_SUPPLY_ICO = 130000000 * 10 ** 18; // 130 Million tokens //events for log event LogFundingReceived(address _addr, uint _amount, uint _currentTotal); event LogBeneficiaryPaid(address _beneficiaryAddress); event LogFundingSuccessful(uint _totalRaised); event LogFunderInitialized(address _creator, uint256 _ICOdeadline); event LogContributorsPayout(address _addr, uint _amount); modifier notFinished() { require(state != State.Successful); _; } /** * @notice ICO constructor * @param _addressOfTokenUsedAsReward is the token totalDistributed */ function ICO (token _addressOfTokenUsedAsReward) public { startTime = dateTimeContract.toTimestamp(2018,3,2,12); //From March 2 12:00 UTC ICOdeadline = dateTimeContract.toTimestamp(2018,3,30,12); //Till March 30 12:00 UTC; rate = 80000; //Tokens per ether unit creator = msg.sender; beneficiary = 0x3a1CE9289EC2826A69A115A6AAfC2fbaCc6F8063; tokenReward = _addressOfTokenUsedAsReward; LogFunderInitialized( creator, ICOdeadline); } /** * @notice contribution handler */ function contribute() public notFinished payable { require(now >= startTime); require(msg.value > 50 finney); uint256 tokenBought = 0; totalRaised = totalRaised.add(msg.value); tokenBought = msg.value.mul(rate); //Rate of exchange depends on stage if (state == State.stage1){ tokenBought = tokenBought.mul(15); tokenBought = tokenBought.div(10);//+50% } else if (state == State.stage2){ tokenBought = tokenBought.mul(125); tokenBought = tokenBought.div(100);//+25% } else if (state == State.stage3){ tokenBought = tokenBought.mul(115); tokenBought = tokenBought.div(100);//+15% } icoTokensReceived[msg.sender] = icoTokensReceived[msg.sender].add(tokenBought); totalDistributed = totalDistributed.add(tokenBought); tokenReward.transfer(msg.sender, tokenBought); LogFundingReceived(msg.sender, msg.value, totalRaised); LogContributorsPayout(msg.sender, tokenBought); checkIfFundingCompleteOrExpired(); } function claimAirdrop() external { doAirdrop(msg.sender); } function doAirdrop(address _participant) internal { uint airdrop = computeAirdrop(_participant); require( airdrop > 0 ); // update balances and token issue volume airdropClaimed[_participant] = true; tokenReward.transfer(_participant,airdrop); // log LogContributorsPayout(_participant, airdrop); } /* Function to estimate airdrop amount. For some accounts, the value of */ /* tokens received by calling claimAirdrop() may be less than gas costs */ /* If an account has tokens from the ico, the amount after the airdrop */ /* will be newBalance = tokens * TOKEN_SUPPLY_ICO / totalDistributed */ function computeAirdrop(address _participant) public constant returns (uint airdrop) { require(state == State.Successful); // return 0 is the airdrop was already claimed if( airdropClaimed[_participant] ) return 0; // return 0 if the account does not hold any crowdsale tokens if( icoTokensReceived[_participant] == 0 ) return 0; // airdrop amount uint tokens = icoTokensReceived[_participant]; uint newBalance = tokens.mul(TOKEN_SUPPLY_ICO) / totalDistributed; airdrop = newBalance - tokens; } /** * @notice check status */ function checkIfFundingCompleteOrExpired() public { if(state == State.stage1 && now > dateTimeContract.toTimestamp(2018,3,9,12)) { //Till March 9 12:00 UTC state = State.stage2; } else if(state == State.stage2 && now > dateTimeContract.toTimestamp(2018,3,16,12)) { //Till March 16 12:00 UTC state = State.stage3; } else if(state == State.stage3 && now > dateTimeContract.toTimestamp(2018,3,23,12)) { //From March 23 12:00 UTC state = State.stage4; } else if(now > ICOdeadline && state!=State.Successful) { //if we reach ico deadline and its not Successful yet state = State.Successful; //ico becomes Successful completedAt = now; //ICO is complete LogFundingSuccessful(totalRaised); //we log the finish finished(); //and execute closure } } /** * @notice closure handler */ function finished() public { //When finished eth are transfered to beneficiary require(state == State.Successful); require(beneficiary.send(this.balance)); LogBeneficiaryPaid(beneficiary); } /* * @dev direct payments */ function () public payable { contribute(); } }
ICO
function ICO (token _addressOfTokenUsedAsReward) public { startTime = dateTimeContract.toTimestamp(2018,3,2,12); //From March 2 12:00 UTC ICOdeadline = dateTimeContract.toTimestamp(2018,3,30,12); //Till March 30 12:00 UTC; rate = 80000; //Tokens per ether unit creator = msg.sender; beneficiary = 0x3a1CE9289EC2826A69A115A6AAfC2fbaCc6F8063; tokenReward = _addressOfTokenUsedAsReward; LogFunderInitialized( creator, ICOdeadline); }
/** * @notice ICO constructor * @param _addressOfTokenUsedAsReward is the token totalDistributed */
NatSpecMultiLine
v0.4.20+commit.3155dd80
bzzr://ece2f4bd86ae366120bdf54d4b2a32b7e2d16fd87a6efbcea35fecb1b2b9193b
{ "func_code_index": [ 1598, 2141 ] }
7
ICO
ICO.sol
0x72cc9d8e0a8034fecd2159fb2a951efe8b49f5ae
Solidity
ICO
contract ICO { using SafeMath for uint256; //This ico have 5 states enum State { stage1, stage2, stage3, stage4, Successful } DateTimeAPI dateTimeContract = DateTimeAPI(0x1a6184CD4C5Bea62B0116de7962EE7315B7bcBce);//Main //DateTimeAPI dateTimeContract = DateTimeAPI(0x1F0a2ba4B115bd3e4007533C52BBd30C17E8B222);//Ropsten //public variables State public state = State.stage1; //Set initial stage uint256 public startTime; uint256 public rate; uint256 public totalRaised; //eth in wei uint256 public totalDistributed; //tokens uint256 public ICOdeadline; uint256 public completedAt; token public tokenReward; address public creator; address public beneficiary; string public version = '1'; mapping(address => bool) public airdropClaimed; mapping(address => uint) public icoTokensReceived; uint public constant TOKEN_SUPPLY_ICO = 130000000 * 10 ** 18; // 130 Million tokens //events for log event LogFundingReceived(address _addr, uint _amount, uint _currentTotal); event LogBeneficiaryPaid(address _beneficiaryAddress); event LogFundingSuccessful(uint _totalRaised); event LogFunderInitialized(address _creator, uint256 _ICOdeadline); event LogContributorsPayout(address _addr, uint _amount); modifier notFinished() { require(state != State.Successful); _; } /** * @notice ICO constructor * @param _addressOfTokenUsedAsReward is the token totalDistributed */ function ICO (token _addressOfTokenUsedAsReward) public { startTime = dateTimeContract.toTimestamp(2018,3,2,12); //From March 2 12:00 UTC ICOdeadline = dateTimeContract.toTimestamp(2018,3,30,12); //Till March 30 12:00 UTC; rate = 80000; //Tokens per ether unit creator = msg.sender; beneficiary = 0x3a1CE9289EC2826A69A115A6AAfC2fbaCc6F8063; tokenReward = _addressOfTokenUsedAsReward; LogFunderInitialized( creator, ICOdeadline); } /** * @notice contribution handler */ function contribute() public notFinished payable { require(now >= startTime); require(msg.value > 50 finney); uint256 tokenBought = 0; totalRaised = totalRaised.add(msg.value); tokenBought = msg.value.mul(rate); //Rate of exchange depends on stage if (state == State.stage1){ tokenBought = tokenBought.mul(15); tokenBought = tokenBought.div(10);//+50% } else if (state == State.stage2){ tokenBought = tokenBought.mul(125); tokenBought = tokenBought.div(100);//+25% } else if (state == State.stage3){ tokenBought = tokenBought.mul(115); tokenBought = tokenBought.div(100);//+15% } icoTokensReceived[msg.sender] = icoTokensReceived[msg.sender].add(tokenBought); totalDistributed = totalDistributed.add(tokenBought); tokenReward.transfer(msg.sender, tokenBought); LogFundingReceived(msg.sender, msg.value, totalRaised); LogContributorsPayout(msg.sender, tokenBought); checkIfFundingCompleteOrExpired(); } function claimAirdrop() external { doAirdrop(msg.sender); } function doAirdrop(address _participant) internal { uint airdrop = computeAirdrop(_participant); require( airdrop > 0 ); // update balances and token issue volume airdropClaimed[_participant] = true; tokenReward.transfer(_participant,airdrop); // log LogContributorsPayout(_participant, airdrop); } /* Function to estimate airdrop amount. For some accounts, the value of */ /* tokens received by calling claimAirdrop() may be less than gas costs */ /* If an account has tokens from the ico, the amount after the airdrop */ /* will be newBalance = tokens * TOKEN_SUPPLY_ICO / totalDistributed */ function computeAirdrop(address _participant) public constant returns (uint airdrop) { require(state == State.Successful); // return 0 is the airdrop was already claimed if( airdropClaimed[_participant] ) return 0; // return 0 if the account does not hold any crowdsale tokens if( icoTokensReceived[_participant] == 0 ) return 0; // airdrop amount uint tokens = icoTokensReceived[_participant]; uint newBalance = tokens.mul(TOKEN_SUPPLY_ICO) / totalDistributed; airdrop = newBalance - tokens; } /** * @notice check status */ function checkIfFundingCompleteOrExpired() public { if(state == State.stage1 && now > dateTimeContract.toTimestamp(2018,3,9,12)) { //Till March 9 12:00 UTC state = State.stage2; } else if(state == State.stage2 && now > dateTimeContract.toTimestamp(2018,3,16,12)) { //Till March 16 12:00 UTC state = State.stage3; } else if(state == State.stage3 && now > dateTimeContract.toTimestamp(2018,3,23,12)) { //From March 23 12:00 UTC state = State.stage4; } else if(now > ICOdeadline && state!=State.Successful) { //if we reach ico deadline and its not Successful yet state = State.Successful; //ico becomes Successful completedAt = now; //ICO is complete LogFundingSuccessful(totalRaised); //we log the finish finished(); //and execute closure } } /** * @notice closure handler */ function finished() public { //When finished eth are transfered to beneficiary require(state == State.Successful); require(beneficiary.send(this.balance)); LogBeneficiaryPaid(beneficiary); } /* * @dev direct payments */ function () public payable { contribute(); } }
contribute
function contribute() public notFinished payable { require(now >= startTime); require(msg.value > 50 finney); uint256 tokenBought = 0; totalRaised = totalRaised.add(msg.value); tokenBought = msg.value.mul(rate); //Rate of exchange depends on stage if (state == State.stage1){ tokenBought = tokenBought.mul(15); tokenBought = tokenBought.div(10);//+50% } else if (state == State.stage2){ tokenBought = tokenBought.mul(125); tokenBought = tokenBought.div(100);//+25% } else if (state == State.stage3){ tokenBought = tokenBought.mul(115); tokenBought = tokenBought.div(100);//+15% } icoTokensReceived[msg.sender] = icoTokensReceived[msg.sender].add(tokenBought); totalDistributed = totalDistributed.add(tokenBought); tokenReward.transfer(msg.sender, tokenBought); LogFundingReceived(msg.sender, msg.value, totalRaised); LogContributorsPayout(msg.sender, tokenBought); checkIfFundingCompleteOrExpired(); }
/** * @notice contribution handler */
NatSpecMultiLine
v0.4.20+commit.3155dd80
bzzr://ece2f4bd86ae366120bdf54d4b2a32b7e2d16fd87a6efbcea35fecb1b2b9193b
{ "func_code_index": [ 2197, 3412 ] }
8
ICO
ICO.sol
0x72cc9d8e0a8034fecd2159fb2a951efe8b49f5ae
Solidity
ICO
contract ICO { using SafeMath for uint256; //This ico have 5 states enum State { stage1, stage2, stage3, stage4, Successful } DateTimeAPI dateTimeContract = DateTimeAPI(0x1a6184CD4C5Bea62B0116de7962EE7315B7bcBce);//Main //DateTimeAPI dateTimeContract = DateTimeAPI(0x1F0a2ba4B115bd3e4007533C52BBd30C17E8B222);//Ropsten //public variables State public state = State.stage1; //Set initial stage uint256 public startTime; uint256 public rate; uint256 public totalRaised; //eth in wei uint256 public totalDistributed; //tokens uint256 public ICOdeadline; uint256 public completedAt; token public tokenReward; address public creator; address public beneficiary; string public version = '1'; mapping(address => bool) public airdropClaimed; mapping(address => uint) public icoTokensReceived; uint public constant TOKEN_SUPPLY_ICO = 130000000 * 10 ** 18; // 130 Million tokens //events for log event LogFundingReceived(address _addr, uint _amount, uint _currentTotal); event LogBeneficiaryPaid(address _beneficiaryAddress); event LogFundingSuccessful(uint _totalRaised); event LogFunderInitialized(address _creator, uint256 _ICOdeadline); event LogContributorsPayout(address _addr, uint _amount); modifier notFinished() { require(state != State.Successful); _; } /** * @notice ICO constructor * @param _addressOfTokenUsedAsReward is the token totalDistributed */ function ICO (token _addressOfTokenUsedAsReward) public { startTime = dateTimeContract.toTimestamp(2018,3,2,12); //From March 2 12:00 UTC ICOdeadline = dateTimeContract.toTimestamp(2018,3,30,12); //Till March 30 12:00 UTC; rate = 80000; //Tokens per ether unit creator = msg.sender; beneficiary = 0x3a1CE9289EC2826A69A115A6AAfC2fbaCc6F8063; tokenReward = _addressOfTokenUsedAsReward; LogFunderInitialized( creator, ICOdeadline); } /** * @notice contribution handler */ function contribute() public notFinished payable { require(now >= startTime); require(msg.value > 50 finney); uint256 tokenBought = 0; totalRaised = totalRaised.add(msg.value); tokenBought = msg.value.mul(rate); //Rate of exchange depends on stage if (state == State.stage1){ tokenBought = tokenBought.mul(15); tokenBought = tokenBought.div(10);//+50% } else if (state == State.stage2){ tokenBought = tokenBought.mul(125); tokenBought = tokenBought.div(100);//+25% } else if (state == State.stage3){ tokenBought = tokenBought.mul(115); tokenBought = tokenBought.div(100);//+15% } icoTokensReceived[msg.sender] = icoTokensReceived[msg.sender].add(tokenBought); totalDistributed = totalDistributed.add(tokenBought); tokenReward.transfer(msg.sender, tokenBought); LogFundingReceived(msg.sender, msg.value, totalRaised); LogContributorsPayout(msg.sender, tokenBought); checkIfFundingCompleteOrExpired(); } function claimAirdrop() external { doAirdrop(msg.sender); } function doAirdrop(address _participant) internal { uint airdrop = computeAirdrop(_participant); require( airdrop > 0 ); // update balances and token issue volume airdropClaimed[_participant] = true; tokenReward.transfer(_participant,airdrop); // log LogContributorsPayout(_participant, airdrop); } /* Function to estimate airdrop amount. For some accounts, the value of */ /* tokens received by calling claimAirdrop() may be less than gas costs */ /* If an account has tokens from the ico, the amount after the airdrop */ /* will be newBalance = tokens * TOKEN_SUPPLY_ICO / totalDistributed */ function computeAirdrop(address _participant) public constant returns (uint airdrop) { require(state == State.Successful); // return 0 is the airdrop was already claimed if( airdropClaimed[_participant] ) return 0; // return 0 if the account does not hold any crowdsale tokens if( icoTokensReceived[_participant] == 0 ) return 0; // airdrop amount uint tokens = icoTokensReceived[_participant]; uint newBalance = tokens.mul(TOKEN_SUPPLY_ICO) / totalDistributed; airdrop = newBalance - tokens; } /** * @notice check status */ function checkIfFundingCompleteOrExpired() public { if(state == State.stage1 && now > dateTimeContract.toTimestamp(2018,3,9,12)) { //Till March 9 12:00 UTC state = State.stage2; } else if(state == State.stage2 && now > dateTimeContract.toTimestamp(2018,3,16,12)) { //Till March 16 12:00 UTC state = State.stage3; } else if(state == State.stage3 && now > dateTimeContract.toTimestamp(2018,3,23,12)) { //From March 23 12:00 UTC state = State.stage4; } else if(now > ICOdeadline && state!=State.Successful) { //if we reach ico deadline and its not Successful yet state = State.Successful; //ico becomes Successful completedAt = now; //ICO is complete LogFundingSuccessful(totalRaised); //we log the finish finished(); //and execute closure } } /** * @notice closure handler */ function finished() public { //When finished eth are transfered to beneficiary require(state == State.Successful); require(beneficiary.send(this.balance)); LogBeneficiaryPaid(beneficiary); } /* * @dev direct payments */ function () public payable { contribute(); } }
computeAirdrop
function computeAirdrop(address _participant) public constant returns (uint airdrop) { require(state == State.Successful); // return 0 is the airdrop was already claimed if( airdropClaimed[_participant] ) return 0; // return 0 if the account does not hold any crowdsale tokens if( icoTokensReceived[_participant] == 0 ) return 0; // airdrop amount uint tokens = icoTokensReceived[_participant]; uint newBalance = tokens.mul(TOKEN_SUPPLY_ICO) / totalDistributed; airdrop = newBalance - tokens; }
/* will be newBalance = tokens * TOKEN_SUPPLY_ICO / totalDistributed */
Comment
v0.4.20+commit.3155dd80
bzzr://ece2f4bd86ae366120bdf54d4b2a32b7e2d16fd87a6efbcea35fecb1b2b9193b
{ "func_code_index": [ 4206, 4798 ] }
9
ICO
ICO.sol
0x72cc9d8e0a8034fecd2159fb2a951efe8b49f5ae
Solidity
ICO
contract ICO { using SafeMath for uint256; //This ico have 5 states enum State { stage1, stage2, stage3, stage4, Successful } DateTimeAPI dateTimeContract = DateTimeAPI(0x1a6184CD4C5Bea62B0116de7962EE7315B7bcBce);//Main //DateTimeAPI dateTimeContract = DateTimeAPI(0x1F0a2ba4B115bd3e4007533C52BBd30C17E8B222);//Ropsten //public variables State public state = State.stage1; //Set initial stage uint256 public startTime; uint256 public rate; uint256 public totalRaised; //eth in wei uint256 public totalDistributed; //tokens uint256 public ICOdeadline; uint256 public completedAt; token public tokenReward; address public creator; address public beneficiary; string public version = '1'; mapping(address => bool) public airdropClaimed; mapping(address => uint) public icoTokensReceived; uint public constant TOKEN_SUPPLY_ICO = 130000000 * 10 ** 18; // 130 Million tokens //events for log event LogFundingReceived(address _addr, uint _amount, uint _currentTotal); event LogBeneficiaryPaid(address _beneficiaryAddress); event LogFundingSuccessful(uint _totalRaised); event LogFunderInitialized(address _creator, uint256 _ICOdeadline); event LogContributorsPayout(address _addr, uint _amount); modifier notFinished() { require(state != State.Successful); _; } /** * @notice ICO constructor * @param _addressOfTokenUsedAsReward is the token totalDistributed */ function ICO (token _addressOfTokenUsedAsReward) public { startTime = dateTimeContract.toTimestamp(2018,3,2,12); //From March 2 12:00 UTC ICOdeadline = dateTimeContract.toTimestamp(2018,3,30,12); //Till March 30 12:00 UTC; rate = 80000; //Tokens per ether unit creator = msg.sender; beneficiary = 0x3a1CE9289EC2826A69A115A6AAfC2fbaCc6F8063; tokenReward = _addressOfTokenUsedAsReward; LogFunderInitialized( creator, ICOdeadline); } /** * @notice contribution handler */ function contribute() public notFinished payable { require(now >= startTime); require(msg.value > 50 finney); uint256 tokenBought = 0; totalRaised = totalRaised.add(msg.value); tokenBought = msg.value.mul(rate); //Rate of exchange depends on stage if (state == State.stage1){ tokenBought = tokenBought.mul(15); tokenBought = tokenBought.div(10);//+50% } else if (state == State.stage2){ tokenBought = tokenBought.mul(125); tokenBought = tokenBought.div(100);//+25% } else if (state == State.stage3){ tokenBought = tokenBought.mul(115); tokenBought = tokenBought.div(100);//+15% } icoTokensReceived[msg.sender] = icoTokensReceived[msg.sender].add(tokenBought); totalDistributed = totalDistributed.add(tokenBought); tokenReward.transfer(msg.sender, tokenBought); LogFundingReceived(msg.sender, msg.value, totalRaised); LogContributorsPayout(msg.sender, tokenBought); checkIfFundingCompleteOrExpired(); } function claimAirdrop() external { doAirdrop(msg.sender); } function doAirdrop(address _participant) internal { uint airdrop = computeAirdrop(_participant); require( airdrop > 0 ); // update balances and token issue volume airdropClaimed[_participant] = true; tokenReward.transfer(_participant,airdrop); // log LogContributorsPayout(_participant, airdrop); } /* Function to estimate airdrop amount. For some accounts, the value of */ /* tokens received by calling claimAirdrop() may be less than gas costs */ /* If an account has tokens from the ico, the amount after the airdrop */ /* will be newBalance = tokens * TOKEN_SUPPLY_ICO / totalDistributed */ function computeAirdrop(address _participant) public constant returns (uint airdrop) { require(state == State.Successful); // return 0 is the airdrop was already claimed if( airdropClaimed[_participant] ) return 0; // return 0 if the account does not hold any crowdsale tokens if( icoTokensReceived[_participant] == 0 ) return 0; // airdrop amount uint tokens = icoTokensReceived[_participant]; uint newBalance = tokens.mul(TOKEN_SUPPLY_ICO) / totalDistributed; airdrop = newBalance - tokens; } /** * @notice check status */ function checkIfFundingCompleteOrExpired() public { if(state == State.stage1 && now > dateTimeContract.toTimestamp(2018,3,9,12)) { //Till March 9 12:00 UTC state = State.stage2; } else if(state == State.stage2 && now > dateTimeContract.toTimestamp(2018,3,16,12)) { //Till March 16 12:00 UTC state = State.stage3; } else if(state == State.stage3 && now > dateTimeContract.toTimestamp(2018,3,23,12)) { //From March 23 12:00 UTC state = State.stage4; } else if(now > ICOdeadline && state!=State.Successful) { //if we reach ico deadline and its not Successful yet state = State.Successful; //ico becomes Successful completedAt = now; //ICO is complete LogFundingSuccessful(totalRaised); //we log the finish finished(); //and execute closure } } /** * @notice closure handler */ function finished() public { //When finished eth are transfered to beneficiary require(state == State.Successful); require(beneficiary.send(this.balance)); LogBeneficiaryPaid(beneficiary); } /* * @dev direct payments */ function () public payable { contribute(); } }
checkIfFundingCompleteOrExpired
function checkIfFundingCompleteOrExpired() public { if(state == State.stage1 && now > dateTimeContract.toTimestamp(2018,3,9,12)) { //Till March 9 12:00 UTC state = State.stage2; } else if(state == State.stage2 && now > dateTimeContract.toTimestamp(2018,3,16,12)) { //Till March 16 12:00 UTC state = State.stage3; } else if(state == State.stage3 && now > dateTimeContract.toTimestamp(2018,3,23,12)) { //From March 23 12:00 UTC state = State.stage4; } else if(now > ICOdeadline && state!=State.Successful) { //if we reach ico deadline and its not Successful yet state = State.Successful; //ico becomes Successful completedAt = now; //ICO is complete LogFundingSuccessful(totalRaised); //we log the finish finished(); //and execute closure }
/** * @notice check status */
NatSpecMultiLine
v0.4.20+commit.3155dd80
bzzr://ece2f4bd86ae366120bdf54d4b2a32b7e2d16fd87a6efbcea35fecb1b2b9193b
{ "func_code_index": [ 4846, 5752 ] }
10
ICO
ICO.sol
0x72cc9d8e0a8034fecd2159fb2a951efe8b49f5ae
Solidity
ICO
contract ICO { using SafeMath for uint256; //This ico have 5 states enum State { stage1, stage2, stage3, stage4, Successful } DateTimeAPI dateTimeContract = DateTimeAPI(0x1a6184CD4C5Bea62B0116de7962EE7315B7bcBce);//Main //DateTimeAPI dateTimeContract = DateTimeAPI(0x1F0a2ba4B115bd3e4007533C52BBd30C17E8B222);//Ropsten //public variables State public state = State.stage1; //Set initial stage uint256 public startTime; uint256 public rate; uint256 public totalRaised; //eth in wei uint256 public totalDistributed; //tokens uint256 public ICOdeadline; uint256 public completedAt; token public tokenReward; address public creator; address public beneficiary; string public version = '1'; mapping(address => bool) public airdropClaimed; mapping(address => uint) public icoTokensReceived; uint public constant TOKEN_SUPPLY_ICO = 130000000 * 10 ** 18; // 130 Million tokens //events for log event LogFundingReceived(address _addr, uint _amount, uint _currentTotal); event LogBeneficiaryPaid(address _beneficiaryAddress); event LogFundingSuccessful(uint _totalRaised); event LogFunderInitialized(address _creator, uint256 _ICOdeadline); event LogContributorsPayout(address _addr, uint _amount); modifier notFinished() { require(state != State.Successful); _; } /** * @notice ICO constructor * @param _addressOfTokenUsedAsReward is the token totalDistributed */ function ICO (token _addressOfTokenUsedAsReward) public { startTime = dateTimeContract.toTimestamp(2018,3,2,12); //From March 2 12:00 UTC ICOdeadline = dateTimeContract.toTimestamp(2018,3,30,12); //Till March 30 12:00 UTC; rate = 80000; //Tokens per ether unit creator = msg.sender; beneficiary = 0x3a1CE9289EC2826A69A115A6AAfC2fbaCc6F8063; tokenReward = _addressOfTokenUsedAsReward; LogFunderInitialized( creator, ICOdeadline); } /** * @notice contribution handler */ function contribute() public notFinished payable { require(now >= startTime); require(msg.value > 50 finney); uint256 tokenBought = 0; totalRaised = totalRaised.add(msg.value); tokenBought = msg.value.mul(rate); //Rate of exchange depends on stage if (state == State.stage1){ tokenBought = tokenBought.mul(15); tokenBought = tokenBought.div(10);//+50% } else if (state == State.stage2){ tokenBought = tokenBought.mul(125); tokenBought = tokenBought.div(100);//+25% } else if (state == State.stage3){ tokenBought = tokenBought.mul(115); tokenBought = tokenBought.div(100);//+15% } icoTokensReceived[msg.sender] = icoTokensReceived[msg.sender].add(tokenBought); totalDistributed = totalDistributed.add(tokenBought); tokenReward.transfer(msg.sender, tokenBought); LogFundingReceived(msg.sender, msg.value, totalRaised); LogContributorsPayout(msg.sender, tokenBought); checkIfFundingCompleteOrExpired(); } function claimAirdrop() external { doAirdrop(msg.sender); } function doAirdrop(address _participant) internal { uint airdrop = computeAirdrop(_participant); require( airdrop > 0 ); // update balances and token issue volume airdropClaimed[_participant] = true; tokenReward.transfer(_participant,airdrop); // log LogContributorsPayout(_participant, airdrop); } /* Function to estimate airdrop amount. For some accounts, the value of */ /* tokens received by calling claimAirdrop() may be less than gas costs */ /* If an account has tokens from the ico, the amount after the airdrop */ /* will be newBalance = tokens * TOKEN_SUPPLY_ICO / totalDistributed */ function computeAirdrop(address _participant) public constant returns (uint airdrop) { require(state == State.Successful); // return 0 is the airdrop was already claimed if( airdropClaimed[_participant] ) return 0; // return 0 if the account does not hold any crowdsale tokens if( icoTokensReceived[_participant] == 0 ) return 0; // airdrop amount uint tokens = icoTokensReceived[_participant]; uint newBalance = tokens.mul(TOKEN_SUPPLY_ICO) / totalDistributed; airdrop = newBalance - tokens; } /** * @notice check status */ function checkIfFundingCompleteOrExpired() public { if(state == State.stage1 && now > dateTimeContract.toTimestamp(2018,3,9,12)) { //Till March 9 12:00 UTC state = State.stage2; } else if(state == State.stage2 && now > dateTimeContract.toTimestamp(2018,3,16,12)) { //Till March 16 12:00 UTC state = State.stage3; } else if(state == State.stage3 && now > dateTimeContract.toTimestamp(2018,3,23,12)) { //From March 23 12:00 UTC state = State.stage4; } else if(now > ICOdeadline && state!=State.Successful) { //if we reach ico deadline and its not Successful yet state = State.Successful; //ico becomes Successful completedAt = now; //ICO is complete LogFundingSuccessful(totalRaised); //we log the finish finished(); //and execute closure } } /** * @notice closure handler */ function finished() public { //When finished eth are transfered to beneficiary require(state == State.Successful); require(beneficiary.send(this.balance)); LogBeneficiaryPaid(beneficiary); } /* * @dev direct payments */ function () public payable { contribute(); } }
finished
function finished() public { //When finished eth are transfered to beneficiary require(state == State.Successful); require(beneficiary.send(this.balance)); LogBeneficiaryPaid(beneficiary); }
/** * @notice closure handler */
NatSpecMultiLine
v0.4.20+commit.3155dd80
bzzr://ece2f4bd86ae366120bdf54d4b2a32b7e2d16fd87a6efbcea35fecb1b2b9193b
{ "func_code_index": [ 5803, 6034 ] }
11
ICO
ICO.sol
0x72cc9d8e0a8034fecd2159fb2a951efe8b49f5ae
Solidity
ICO
contract ICO { using SafeMath for uint256; //This ico have 5 states enum State { stage1, stage2, stage3, stage4, Successful } DateTimeAPI dateTimeContract = DateTimeAPI(0x1a6184CD4C5Bea62B0116de7962EE7315B7bcBce);//Main //DateTimeAPI dateTimeContract = DateTimeAPI(0x1F0a2ba4B115bd3e4007533C52BBd30C17E8B222);//Ropsten //public variables State public state = State.stage1; //Set initial stage uint256 public startTime; uint256 public rate; uint256 public totalRaised; //eth in wei uint256 public totalDistributed; //tokens uint256 public ICOdeadline; uint256 public completedAt; token public tokenReward; address public creator; address public beneficiary; string public version = '1'; mapping(address => bool) public airdropClaimed; mapping(address => uint) public icoTokensReceived; uint public constant TOKEN_SUPPLY_ICO = 130000000 * 10 ** 18; // 130 Million tokens //events for log event LogFundingReceived(address _addr, uint _amount, uint _currentTotal); event LogBeneficiaryPaid(address _beneficiaryAddress); event LogFundingSuccessful(uint _totalRaised); event LogFunderInitialized(address _creator, uint256 _ICOdeadline); event LogContributorsPayout(address _addr, uint _amount); modifier notFinished() { require(state != State.Successful); _; } /** * @notice ICO constructor * @param _addressOfTokenUsedAsReward is the token totalDistributed */ function ICO (token _addressOfTokenUsedAsReward) public { startTime = dateTimeContract.toTimestamp(2018,3,2,12); //From March 2 12:00 UTC ICOdeadline = dateTimeContract.toTimestamp(2018,3,30,12); //Till March 30 12:00 UTC; rate = 80000; //Tokens per ether unit creator = msg.sender; beneficiary = 0x3a1CE9289EC2826A69A115A6AAfC2fbaCc6F8063; tokenReward = _addressOfTokenUsedAsReward; LogFunderInitialized( creator, ICOdeadline); } /** * @notice contribution handler */ function contribute() public notFinished payable { require(now >= startTime); require(msg.value > 50 finney); uint256 tokenBought = 0; totalRaised = totalRaised.add(msg.value); tokenBought = msg.value.mul(rate); //Rate of exchange depends on stage if (state == State.stage1){ tokenBought = tokenBought.mul(15); tokenBought = tokenBought.div(10);//+50% } else if (state == State.stage2){ tokenBought = tokenBought.mul(125); tokenBought = tokenBought.div(100);//+25% } else if (state == State.stage3){ tokenBought = tokenBought.mul(115); tokenBought = tokenBought.div(100);//+15% } icoTokensReceived[msg.sender] = icoTokensReceived[msg.sender].add(tokenBought); totalDistributed = totalDistributed.add(tokenBought); tokenReward.transfer(msg.sender, tokenBought); LogFundingReceived(msg.sender, msg.value, totalRaised); LogContributorsPayout(msg.sender, tokenBought); checkIfFundingCompleteOrExpired(); } function claimAirdrop() external { doAirdrop(msg.sender); } function doAirdrop(address _participant) internal { uint airdrop = computeAirdrop(_participant); require( airdrop > 0 ); // update balances and token issue volume airdropClaimed[_participant] = true; tokenReward.transfer(_participant,airdrop); // log LogContributorsPayout(_participant, airdrop); } /* Function to estimate airdrop amount. For some accounts, the value of */ /* tokens received by calling claimAirdrop() may be less than gas costs */ /* If an account has tokens from the ico, the amount after the airdrop */ /* will be newBalance = tokens * TOKEN_SUPPLY_ICO / totalDistributed */ function computeAirdrop(address _participant) public constant returns (uint airdrop) { require(state == State.Successful); // return 0 is the airdrop was already claimed if( airdropClaimed[_participant] ) return 0; // return 0 if the account does not hold any crowdsale tokens if( icoTokensReceived[_participant] == 0 ) return 0; // airdrop amount uint tokens = icoTokensReceived[_participant]; uint newBalance = tokens.mul(TOKEN_SUPPLY_ICO) / totalDistributed; airdrop = newBalance - tokens; } /** * @notice check status */ function checkIfFundingCompleteOrExpired() public { if(state == State.stage1 && now > dateTimeContract.toTimestamp(2018,3,9,12)) { //Till March 9 12:00 UTC state = State.stage2; } else if(state == State.stage2 && now > dateTimeContract.toTimestamp(2018,3,16,12)) { //Till March 16 12:00 UTC state = State.stage3; } else if(state == State.stage3 && now > dateTimeContract.toTimestamp(2018,3,23,12)) { //From March 23 12:00 UTC state = State.stage4; } else if(now > ICOdeadline && state!=State.Successful) { //if we reach ico deadline and its not Successful yet state = State.Successful; //ico becomes Successful completedAt = now; //ICO is complete LogFundingSuccessful(totalRaised); //we log the finish finished(); //and execute closure } } /** * @notice closure handler */ function finished() public { //When finished eth are transfered to beneficiary require(state == State.Successful); require(beneficiary.send(this.balance)); LogBeneficiaryPaid(beneficiary); } /* * @dev direct payments */ function () public payable { contribute(); } }
function () public payable { contribute(); }
/* * @dev direct payments */
Comment
v0.4.20+commit.3155dd80
bzzr://ece2f4bd86ae366120bdf54d4b2a32b7e2d16fd87a6efbcea35fecb1b2b9193b
{ "func_code_index": [ 6081, 6156 ] }
12
Application
contracts/Application.sol
0x26400bde3ecf7f6ce42815ee435b857b363f514d
Solidity
Application
contract Application is ERC721Tradable { uint256 public hardcap; address payable wallet; bool public locked; string constant public ipfshash = 'QmVX2DQxWNMUiTA5MXTCHUFS6mm55VqiJC1sUvaACs5HLW'; constructor(address payable _wallet, address _proxyRegistryAddress) public ERC721Tradable("THEM Applications", "MAPPLY", _proxyRegistryAddress) { wallet = _wallet; locked = true; hardcap = 69; } /** * Buy a token and mint it in the process. (Only 1 - 69). * @param _to address of the future owner of the token */ function buy(address _to) external payable { uint256 payed = msg.value; uint256 price = currentPrice(); require(!locked, 'Buying is not unlocked yet.'); require(balanceOf(_to) == 0, 'Only one application per address.'); require(totalSupply() < hardcap, 'Sold out!'); require(price <= payed, 'Price must be equal or larger to the sales price.'); _mintToInternal(_to); wallet.transfer(msg.value); } /** * First one costs 0.01 ETH, last one costs ~0.1 ETH. */ function currentPrice() public view returns (uint256 price) { return (0.01 ether) + (totalSupply() * (0.00131 ether)); } function changeWallet(address payable _newWallet) public onlyOwner { wallet = _newWallet; } /** * Irreversably unlock buying. */ function unlock() public onlyOwner { locked = false; } function baseTokenURI() public pure returns (string memory) { return "https://api.them.af/api/application/"; } function contractURI() public pure returns (string memory) { return "https://api.them.af/api/contracts/application"; } }
/** * @title Application * Application - a contract for non-fungible Applications. */
NatSpecMultiLine
buy
function buy(address _to) external payable { uint256 payed = msg.value; uint256 price = currentPrice(); require(!locked, 'Buying is not unlocked yet.'); require(balanceOf(_to) == 0, 'Only one application per address.'); require(totalSupply() < hardcap, 'Sold out!'); require(price <= payed, 'Price must be equal or larger to the sales price.'); _mintToInternal(_to); wallet.transfer(msg.value); }
/** * Buy a token and mint it in the process. (Only 1 - 69). * @param _to address of the future owner of the token */
NatSpecMultiLine
v0.5.17+commit.d19bba13
Unlicense
bzzr://1ed0d0f4f96a74a23aaa98522e1d224b71eeefce9561a9ab97b7190ac4b2439b
{ "func_code_index": [ 614, 1104 ] }
13
Application
contracts/Application.sol
0x26400bde3ecf7f6ce42815ee435b857b363f514d
Solidity
Application
contract Application is ERC721Tradable { uint256 public hardcap; address payable wallet; bool public locked; string constant public ipfshash = 'QmVX2DQxWNMUiTA5MXTCHUFS6mm55VqiJC1sUvaACs5HLW'; constructor(address payable _wallet, address _proxyRegistryAddress) public ERC721Tradable("THEM Applications", "MAPPLY", _proxyRegistryAddress) { wallet = _wallet; locked = true; hardcap = 69; } /** * Buy a token and mint it in the process. (Only 1 - 69). * @param _to address of the future owner of the token */ function buy(address _to) external payable { uint256 payed = msg.value; uint256 price = currentPrice(); require(!locked, 'Buying is not unlocked yet.'); require(balanceOf(_to) == 0, 'Only one application per address.'); require(totalSupply() < hardcap, 'Sold out!'); require(price <= payed, 'Price must be equal or larger to the sales price.'); _mintToInternal(_to); wallet.transfer(msg.value); } /** * First one costs 0.01 ETH, last one costs ~0.1 ETH. */ function currentPrice() public view returns (uint256 price) { return (0.01 ether) + (totalSupply() * (0.00131 ether)); } function changeWallet(address payable _newWallet) public onlyOwner { wallet = _newWallet; } /** * Irreversably unlock buying. */ function unlock() public onlyOwner { locked = false; } function baseTokenURI() public pure returns (string memory) { return "https://api.them.af/api/application/"; } function contractURI() public pure returns (string memory) { return "https://api.them.af/api/contracts/application"; } }
/** * @title Application * Application - a contract for non-fungible Applications. */
NatSpecMultiLine
currentPrice
function currentPrice() public view returns (uint256 price) { return (0.01 ether) + (totalSupply() * (0.00131 ether)); }
/** * First one costs 0.01 ETH, last one costs ~0.1 ETH. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
Unlicense
bzzr://1ed0d0f4f96a74a23aaa98522e1d224b71eeefce9561a9ab97b7190ac4b2439b
{ "func_code_index": [ 1184, 1324 ] }
14
Application
contracts/Application.sol
0x26400bde3ecf7f6ce42815ee435b857b363f514d
Solidity
Application
contract Application is ERC721Tradable { uint256 public hardcap; address payable wallet; bool public locked; string constant public ipfshash = 'QmVX2DQxWNMUiTA5MXTCHUFS6mm55VqiJC1sUvaACs5HLW'; constructor(address payable _wallet, address _proxyRegistryAddress) public ERC721Tradable("THEM Applications", "MAPPLY", _proxyRegistryAddress) { wallet = _wallet; locked = true; hardcap = 69; } /** * Buy a token and mint it in the process. (Only 1 - 69). * @param _to address of the future owner of the token */ function buy(address _to) external payable { uint256 payed = msg.value; uint256 price = currentPrice(); require(!locked, 'Buying is not unlocked yet.'); require(balanceOf(_to) == 0, 'Only one application per address.'); require(totalSupply() < hardcap, 'Sold out!'); require(price <= payed, 'Price must be equal or larger to the sales price.'); _mintToInternal(_to); wallet.transfer(msg.value); } /** * First one costs 0.01 ETH, last one costs ~0.1 ETH. */ function currentPrice() public view returns (uint256 price) { return (0.01 ether) + (totalSupply() * (0.00131 ether)); } function changeWallet(address payable _newWallet) public onlyOwner { wallet = _newWallet; } /** * Irreversably unlock buying. */ function unlock() public onlyOwner { locked = false; } function baseTokenURI() public pure returns (string memory) { return "https://api.them.af/api/application/"; } function contractURI() public pure returns (string memory) { return "https://api.them.af/api/contracts/application"; } }
/** * @title Application * Application - a contract for non-fungible Applications. */
NatSpecMultiLine
unlock
function unlock() public onlyOwner { locked = false; }
/** * Irreversably unlock buying. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
Unlicense
bzzr://1ed0d0f4f96a74a23aaa98522e1d224b71eeefce9561a9ab97b7190ac4b2439b
{ "func_code_index": [ 1494, 1567 ] }
15
CFolioFarm
contracts/src/investment/interfaces/ICFolioFarm.sol
0xb18104e050f1e8e828dd2b0260f7feb1c2178752
Solidity
ICFolioFarm
interface ICFolioFarm { /** * @dev Return invested balance of account */ function balanceOf(address account) external view returns (uint256); /** * @dev Return total, balances[account], rewardDuration, rewardForDuration, earned[account] */ function getUIData(address account) external view returns (uint256[5] memory); /** * @dev Increase amount of non-rewarded asset */ function addAssets(address account, uint256 amount) external; /** * @dev Remove amount of previous added assets */ function removeAssets(address account, uint256 amount) external; /** * @dev Increase amount of shares and earn rewards */ function addShares(address account, uint256 amount) external; /** * @dev Remove amount of previous added shares, rewards will not be claimed */ function removeShares(address account, uint256 amount) external; /** * @dev Claim rewards harvested during reward time */ function getReward(address account, address rewardRecipient) external; /** * @dev Remove all shares and call getRewards() in a single step */ function exit(address account, address rewardRecipient) external; }
/** * @title ICFolioFarm * * @dev ICFolioFarm is the business logic interface to c-folio farms. */
NatSpecMultiLine
balanceOf
function balanceOf(address account) external view returns (uint256);
/** * @dev Return invested balance of account */
NatSpecMultiLine
v0.7.4+commit.3f05b770
Apache-2.0
{ "func_code_index": [ 81, 151 ] }
16
CFolioFarm
contracts/src/investment/interfaces/ICFolioFarm.sol
0xb18104e050f1e8e828dd2b0260f7feb1c2178752
Solidity
ICFolioFarm
interface ICFolioFarm { /** * @dev Return invested balance of account */ function balanceOf(address account) external view returns (uint256); /** * @dev Return total, balances[account], rewardDuration, rewardForDuration, earned[account] */ function getUIData(address account) external view returns (uint256[5] memory); /** * @dev Increase amount of non-rewarded asset */ function addAssets(address account, uint256 amount) external; /** * @dev Remove amount of previous added assets */ function removeAssets(address account, uint256 amount) external; /** * @dev Increase amount of shares and earn rewards */ function addShares(address account, uint256 amount) external; /** * @dev Remove amount of previous added shares, rewards will not be claimed */ function removeShares(address account, uint256 amount) external; /** * @dev Claim rewards harvested during reward time */ function getReward(address account, address rewardRecipient) external; /** * @dev Remove all shares and call getRewards() in a single step */ function exit(address account, address rewardRecipient) external; }
/** * @title ICFolioFarm * * @dev ICFolioFarm is the business logic interface to c-folio farms. */
NatSpecMultiLine
getUIData
function getUIData(address account) external view returns (uint256[5] memory);
/** * @dev Return total, balances[account], rewardDuration, rewardForDuration, earned[account] */
NatSpecMultiLine
v0.7.4+commit.3f05b770
Apache-2.0
{ "func_code_index": [ 259, 339 ] }
17
CFolioFarm
contracts/src/investment/interfaces/ICFolioFarm.sol
0xb18104e050f1e8e828dd2b0260f7feb1c2178752
Solidity
ICFolioFarm
interface ICFolioFarm { /** * @dev Return invested balance of account */ function balanceOf(address account) external view returns (uint256); /** * @dev Return total, balances[account], rewardDuration, rewardForDuration, earned[account] */ function getUIData(address account) external view returns (uint256[5] memory); /** * @dev Increase amount of non-rewarded asset */ function addAssets(address account, uint256 amount) external; /** * @dev Remove amount of previous added assets */ function removeAssets(address account, uint256 amount) external; /** * @dev Increase amount of shares and earn rewards */ function addShares(address account, uint256 amount) external; /** * @dev Remove amount of previous added shares, rewards will not be claimed */ function removeShares(address account, uint256 amount) external; /** * @dev Claim rewards harvested during reward time */ function getReward(address account, address rewardRecipient) external; /** * @dev Remove all shares and call getRewards() in a single step */ function exit(address account, address rewardRecipient) external; }
/** * @title ICFolioFarm * * @dev ICFolioFarm is the business logic interface to c-folio farms. */
NatSpecMultiLine
addAssets
function addAssets(address account, uint256 amount) external;
/** * @dev Increase amount of non-rewarded asset */
NatSpecMultiLine
v0.7.4+commit.3f05b770
Apache-2.0
{ "func_code_index": [ 401, 464 ] }
18
CFolioFarm
contracts/src/investment/interfaces/ICFolioFarm.sol
0xb18104e050f1e8e828dd2b0260f7feb1c2178752
Solidity
ICFolioFarm
interface ICFolioFarm { /** * @dev Return invested balance of account */ function balanceOf(address account) external view returns (uint256); /** * @dev Return total, balances[account], rewardDuration, rewardForDuration, earned[account] */ function getUIData(address account) external view returns (uint256[5] memory); /** * @dev Increase amount of non-rewarded asset */ function addAssets(address account, uint256 amount) external; /** * @dev Remove amount of previous added assets */ function removeAssets(address account, uint256 amount) external; /** * @dev Increase amount of shares and earn rewards */ function addShares(address account, uint256 amount) external; /** * @dev Remove amount of previous added shares, rewards will not be claimed */ function removeShares(address account, uint256 amount) external; /** * @dev Claim rewards harvested during reward time */ function getReward(address account, address rewardRecipient) external; /** * @dev Remove all shares and call getRewards() in a single step */ function exit(address account, address rewardRecipient) external; }
/** * @title ICFolioFarm * * @dev ICFolioFarm is the business logic interface to c-folio farms. */
NatSpecMultiLine
removeAssets
function removeAssets(address account, uint256 amount) external;
/** * @dev Remove amount of previous added assets */
NatSpecMultiLine
v0.7.4+commit.3f05b770
Apache-2.0
{ "func_code_index": [ 527, 593 ] }
19
CFolioFarm
contracts/src/investment/interfaces/ICFolioFarm.sol
0xb18104e050f1e8e828dd2b0260f7feb1c2178752
Solidity
ICFolioFarm
interface ICFolioFarm { /** * @dev Return invested balance of account */ function balanceOf(address account) external view returns (uint256); /** * @dev Return total, balances[account], rewardDuration, rewardForDuration, earned[account] */ function getUIData(address account) external view returns (uint256[5] memory); /** * @dev Increase amount of non-rewarded asset */ function addAssets(address account, uint256 amount) external; /** * @dev Remove amount of previous added assets */ function removeAssets(address account, uint256 amount) external; /** * @dev Increase amount of shares and earn rewards */ function addShares(address account, uint256 amount) external; /** * @dev Remove amount of previous added shares, rewards will not be claimed */ function removeShares(address account, uint256 amount) external; /** * @dev Claim rewards harvested during reward time */ function getReward(address account, address rewardRecipient) external; /** * @dev Remove all shares and call getRewards() in a single step */ function exit(address account, address rewardRecipient) external; }
/** * @title ICFolioFarm * * @dev ICFolioFarm is the business logic interface to c-folio farms. */
NatSpecMultiLine
addShares
function addShares(address account, uint256 amount) external;
/** * @dev Increase amount of shares and earn rewards */
NatSpecMultiLine
v0.7.4+commit.3f05b770
Apache-2.0
{ "func_code_index": [ 660, 723 ] }
20
CFolioFarm
contracts/src/investment/interfaces/ICFolioFarm.sol
0xb18104e050f1e8e828dd2b0260f7feb1c2178752
Solidity
ICFolioFarm
interface ICFolioFarm { /** * @dev Return invested balance of account */ function balanceOf(address account) external view returns (uint256); /** * @dev Return total, balances[account], rewardDuration, rewardForDuration, earned[account] */ function getUIData(address account) external view returns (uint256[5] memory); /** * @dev Increase amount of non-rewarded asset */ function addAssets(address account, uint256 amount) external; /** * @dev Remove amount of previous added assets */ function removeAssets(address account, uint256 amount) external; /** * @dev Increase amount of shares and earn rewards */ function addShares(address account, uint256 amount) external; /** * @dev Remove amount of previous added shares, rewards will not be claimed */ function removeShares(address account, uint256 amount) external; /** * @dev Claim rewards harvested during reward time */ function getReward(address account, address rewardRecipient) external; /** * @dev Remove all shares and call getRewards() in a single step */ function exit(address account, address rewardRecipient) external; }
/** * @title ICFolioFarm * * @dev ICFolioFarm is the business logic interface to c-folio farms. */
NatSpecMultiLine
removeShares
function removeShares(address account, uint256 amount) external;
/** * @dev Remove amount of previous added shares, rewards will not be claimed */
NatSpecMultiLine
v0.7.4+commit.3f05b770
Apache-2.0
{ "func_code_index": [ 815, 881 ] }
21
CFolioFarm
contracts/src/investment/interfaces/ICFolioFarm.sol
0xb18104e050f1e8e828dd2b0260f7feb1c2178752
Solidity
ICFolioFarm
interface ICFolioFarm { /** * @dev Return invested balance of account */ function balanceOf(address account) external view returns (uint256); /** * @dev Return total, balances[account], rewardDuration, rewardForDuration, earned[account] */ function getUIData(address account) external view returns (uint256[5] memory); /** * @dev Increase amount of non-rewarded asset */ function addAssets(address account, uint256 amount) external; /** * @dev Remove amount of previous added assets */ function removeAssets(address account, uint256 amount) external; /** * @dev Increase amount of shares and earn rewards */ function addShares(address account, uint256 amount) external; /** * @dev Remove amount of previous added shares, rewards will not be claimed */ function removeShares(address account, uint256 amount) external; /** * @dev Claim rewards harvested during reward time */ function getReward(address account, address rewardRecipient) external; /** * @dev Remove all shares and call getRewards() in a single step */ function exit(address account, address rewardRecipient) external; }
/** * @title ICFolioFarm * * @dev ICFolioFarm is the business logic interface to c-folio farms. */
NatSpecMultiLine
getReward
function getReward(address account, address rewardRecipient) external;
/** * @dev Claim rewards harvested during reward time */
NatSpecMultiLine
v0.7.4+commit.3f05b770
Apache-2.0
{ "func_code_index": [ 948, 1020 ] }
22
CFolioFarm
contracts/src/investment/interfaces/ICFolioFarm.sol
0xb18104e050f1e8e828dd2b0260f7feb1c2178752
Solidity
ICFolioFarm
interface ICFolioFarm { /** * @dev Return invested balance of account */ function balanceOf(address account) external view returns (uint256); /** * @dev Return total, balances[account], rewardDuration, rewardForDuration, earned[account] */ function getUIData(address account) external view returns (uint256[5] memory); /** * @dev Increase amount of non-rewarded asset */ function addAssets(address account, uint256 amount) external; /** * @dev Remove amount of previous added assets */ function removeAssets(address account, uint256 amount) external; /** * @dev Increase amount of shares and earn rewards */ function addShares(address account, uint256 amount) external; /** * @dev Remove amount of previous added shares, rewards will not be claimed */ function removeShares(address account, uint256 amount) external; /** * @dev Claim rewards harvested during reward time */ function getReward(address account, address rewardRecipient) external; /** * @dev Remove all shares and call getRewards() in a single step */ function exit(address account, address rewardRecipient) external; }
/** * @title ICFolioFarm * * @dev ICFolioFarm is the business logic interface to c-folio farms. */
NatSpecMultiLine
exit
function exit(address account, address rewardRecipient) external;
/** * @dev Remove all shares and call getRewards() in a single step */
NatSpecMultiLine
v0.7.4+commit.3f05b770
Apache-2.0
{ "func_code_index": [ 1101, 1168 ] }
23
CFolioFarm
contracts/src/investment/interfaces/ICFolioFarm.sol
0xb18104e050f1e8e828dd2b0260f7feb1c2178752
Solidity
ICFolioFarmOwnable
interface ICFolioFarmOwnable is ICFolioFarm { /** * @dev Transfer ownership */ function transferOwnership(address newOwner) external; }
/** * @title ICFolioFarmOwnable */
NatSpecMultiLine
transferOwnership
function transferOwnership(address newOwner) external;
/** * @dev Transfer ownership */
NatSpecMultiLine
v0.7.4+commit.3f05b770
Apache-2.0
{ "func_code_index": [ 87, 143 ] }
24
CFolioFarm
contracts/src/investment/interfaces/IFarm.sol
0xb18104e050f1e8e828dd2b0260f7feb1c2178752
Solidity
IFarm
interface IFarm { /** * @dev Return the farm's controller */ function controller() external view returns (IController); /** * @dev Return a unique, case-sensitive farm name */ function farmName() external view returns (string memory); /** * @dev Return when reward period is finished (UTC timestamp) */ function periodFinish() external view returns (uint256); /** * @dev Sets a new controller, can only called by current controller */ function setController(address newController) external; /** * @dev This function must be called initially and close at the time the * reward period ends */ function notifyRewardAmount(uint256 reward) external; /** * @dev Set the duration of farm rewards, to continue rewards, * notifyRewardAmount() has to called for the next period */ function setRewardsDuration(uint256 _rewardsDuration) external; /** * @dev Rebalance strategies (if implemented) */ function rebalance() external; }
controller
function controller() external view returns (IController);
/** * @dev Return the farm's controller */
NatSpecMultiLine
v0.7.4+commit.3f05b770
Apache-2.0
{ "func_code_index": [ 69, 129 ] }
25
CFolioFarm
contracts/src/investment/interfaces/IFarm.sol
0xb18104e050f1e8e828dd2b0260f7feb1c2178752
Solidity
IFarm
interface IFarm { /** * @dev Return the farm's controller */ function controller() external view returns (IController); /** * @dev Return a unique, case-sensitive farm name */ function farmName() external view returns (string memory); /** * @dev Return when reward period is finished (UTC timestamp) */ function periodFinish() external view returns (uint256); /** * @dev Sets a new controller, can only called by current controller */ function setController(address newController) external; /** * @dev This function must be called initially and close at the time the * reward period ends */ function notifyRewardAmount(uint256 reward) external; /** * @dev Set the duration of farm rewards, to continue rewards, * notifyRewardAmount() has to called for the next period */ function setRewardsDuration(uint256 _rewardsDuration) external; /** * @dev Rebalance strategies (if implemented) */ function rebalance() external; }
farmName
function farmName() external view returns (string memory);
/** * @dev Return a unique, case-sensitive farm name */
NatSpecMultiLine
v0.7.4+commit.3f05b770
Apache-2.0
{ "func_code_index": [ 195, 255 ] }
26
CFolioFarm
contracts/src/investment/interfaces/IFarm.sol
0xb18104e050f1e8e828dd2b0260f7feb1c2178752
Solidity
IFarm
interface IFarm { /** * @dev Return the farm's controller */ function controller() external view returns (IController); /** * @dev Return a unique, case-sensitive farm name */ function farmName() external view returns (string memory); /** * @dev Return when reward period is finished (UTC timestamp) */ function periodFinish() external view returns (uint256); /** * @dev Sets a new controller, can only called by current controller */ function setController(address newController) external; /** * @dev This function must be called initially and close at the time the * reward period ends */ function notifyRewardAmount(uint256 reward) external; /** * @dev Set the duration of farm rewards, to continue rewards, * notifyRewardAmount() has to called for the next period */ function setRewardsDuration(uint256 _rewardsDuration) external; /** * @dev Rebalance strategies (if implemented) */ function rebalance() external; }
periodFinish
function periodFinish() external view returns (uint256);
/** * @dev Return when reward period is finished (UTC timestamp) */
NatSpecMultiLine
v0.7.4+commit.3f05b770
Apache-2.0
{ "func_code_index": [ 333, 391 ] }
27
CFolioFarm
contracts/src/investment/interfaces/IFarm.sol
0xb18104e050f1e8e828dd2b0260f7feb1c2178752
Solidity
IFarm
interface IFarm { /** * @dev Return the farm's controller */ function controller() external view returns (IController); /** * @dev Return a unique, case-sensitive farm name */ function farmName() external view returns (string memory); /** * @dev Return when reward period is finished (UTC timestamp) */ function periodFinish() external view returns (uint256); /** * @dev Sets a new controller, can only called by current controller */ function setController(address newController) external; /** * @dev This function must be called initially and close at the time the * reward period ends */ function notifyRewardAmount(uint256 reward) external; /** * @dev Set the duration of farm rewards, to continue rewards, * notifyRewardAmount() has to called for the next period */ function setRewardsDuration(uint256 _rewardsDuration) external; /** * @dev Rebalance strategies (if implemented) */ function rebalance() external; }
setController
function setController(address newController) external;
/** * @dev Sets a new controller, can only called by current controller */
NatSpecMultiLine
v0.7.4+commit.3f05b770
Apache-2.0
{ "func_code_index": [ 476, 533 ] }
28
CFolioFarm
contracts/src/investment/interfaces/IFarm.sol
0xb18104e050f1e8e828dd2b0260f7feb1c2178752
Solidity
IFarm
interface IFarm { /** * @dev Return the farm's controller */ function controller() external view returns (IController); /** * @dev Return a unique, case-sensitive farm name */ function farmName() external view returns (string memory); /** * @dev Return when reward period is finished (UTC timestamp) */ function periodFinish() external view returns (uint256); /** * @dev Sets a new controller, can only called by current controller */ function setController(address newController) external; /** * @dev This function must be called initially and close at the time the * reward period ends */ function notifyRewardAmount(uint256 reward) external; /** * @dev Set the duration of farm rewards, to continue rewards, * notifyRewardAmount() has to called for the next period */ function setRewardsDuration(uint256 _rewardsDuration) external; /** * @dev Rebalance strategies (if implemented) */ function rebalance() external; }
notifyRewardAmount
function notifyRewardAmount(uint256 reward) external;
/** * @dev This function must be called initially and close at the time the * reward period ends */
NatSpecMultiLine
v0.7.4+commit.3f05b770
Apache-2.0
{ "func_code_index": [ 646, 701 ] }
29
CFolioFarm
contracts/src/investment/interfaces/IFarm.sol
0xb18104e050f1e8e828dd2b0260f7feb1c2178752
Solidity
IFarm
interface IFarm { /** * @dev Return the farm's controller */ function controller() external view returns (IController); /** * @dev Return a unique, case-sensitive farm name */ function farmName() external view returns (string memory); /** * @dev Return when reward period is finished (UTC timestamp) */ function periodFinish() external view returns (uint256); /** * @dev Sets a new controller, can only called by current controller */ function setController(address newController) external; /** * @dev This function must be called initially and close at the time the * reward period ends */ function notifyRewardAmount(uint256 reward) external; /** * @dev Set the duration of farm rewards, to continue rewards, * notifyRewardAmount() has to called for the next period */ function setRewardsDuration(uint256 _rewardsDuration) external; /** * @dev Rebalance strategies (if implemented) */ function rebalance() external; }
setRewardsDuration
function setRewardsDuration(uint256 _rewardsDuration) external;
/** * @dev Set the duration of farm rewards, to continue rewards, * notifyRewardAmount() has to called for the next period */
NatSpecMultiLine
v0.7.4+commit.3f05b770
Apache-2.0
{ "func_code_index": [ 840, 905 ] }
30
CFolioFarm
contracts/src/investment/interfaces/IFarm.sol
0xb18104e050f1e8e828dd2b0260f7feb1c2178752
Solidity
IFarm
interface IFarm { /** * @dev Return the farm's controller */ function controller() external view returns (IController); /** * @dev Return a unique, case-sensitive farm name */ function farmName() external view returns (string memory); /** * @dev Return when reward period is finished (UTC timestamp) */ function periodFinish() external view returns (uint256); /** * @dev Sets a new controller, can only called by current controller */ function setController(address newController) external; /** * @dev This function must be called initially and close at the time the * reward period ends */ function notifyRewardAmount(uint256 reward) external; /** * @dev Set the duration of farm rewards, to continue rewards, * notifyRewardAmount() has to called for the next period */ function setRewardsDuration(uint256 _rewardsDuration) external; /** * @dev Rebalance strategies (if implemented) */ function rebalance() external; }
rebalance
function rebalance() external;
/** * @dev Rebalance strategies (if implemented) */
NatSpecMultiLine
v0.7.4+commit.3f05b770
Apache-2.0
{ "func_code_index": [ 967, 999 ] }
31
CFolioFarm
contracts/src/utils/ERC20Recovery.sol
0xb18104e050f1e8e828dd2b0260f7feb1c2178752
Solidity
ERC20Recovery
contract ERC20Recovery { using SafeERC20 for IERC20; ////////////////////////////////////////////////////////////////////////////// // Events ////////////////////////////////////////////////////////////////////////////// /** * @dev Fired when a recipient receives recovered ERC-20 tokens * * @param recipient The target recipient receving the recovered coins * @param tokenAddress The address of the ERC-20 token * @param tokenAmount The amount of the token being recovered */ event Recovered( address indexed recipient, address indexed tokenAddress, uint256 tokenAmount ); ////////////////////////////////////////////////////////////////////////////// // Internal interface ////////////////////////////////////////////////////////////////////////////// /** * @dev Recover ERC20 token from contract which have been transfered * either by accident or via airdrop * * Proper access must be verified. All tokens used by the system must * be blocked from recovery. * * @param recipient The target recipient of the recovered coins * @param tokenAddress The address of the ERC-20 token * @param tokenAmount The amount of the token to recover */ function _recoverERC20( address recipient, address tokenAddress, uint256 tokenAmount ) internal { // Validate parameters require(recipient != address(0), "Can't recover to address 0"); // Update state IERC20(tokenAddress).safeTransfer(recipient, tokenAmount); // Dispatch event emit Recovered(recipient, tokenAddress, tokenAmount); } }
_recoverERC20
function _recoverERC20( address recipient, address tokenAddress, uint256 tokenAmount ) internal { // Validate parameters require(recipient != address(0), "Can't recover to address 0"); // Update state IERC20(tokenAddress).safeTransfer(recipient, tokenAmount); // Dispatch event emit Recovered(recipient, tokenAddress, tokenAmount); }
/** * @dev Recover ERC20 token from contract which have been transfered * either by accident or via airdrop * * Proper access must be verified. All tokens used by the system must * be blocked from recovery. * * @param recipient The target recipient of the recovered coins * @param tokenAddress The address of the ERC-20 token * @param tokenAmount The amount of the token to recover */
NatSpecMultiLine
v0.7.4+commit.3f05b770
Apache-2.0
{ "func_code_index": [ 1225, 1602 ] }
32
AirdropToken
AirdropToken.sol
0x430d220d752beb34be73ccb303b5ae36686b8598
Solidity
Token
contract Token { /// @return total amount of tokens function totalSupply() constant returns (uint256 supply) {} /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) constant returns (uint256 balance) {} /// @notice send `_value` token to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transfer(address _to, uint256 _value) returns (bool success) {} /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {} /// @notice `msg.sender` approves `_addr` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of wei to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _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 (uint256 remaining) {} event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); }
totalSupply
function totalSupply() constant returns (uint256 supply) {}
/// @return total amount of tokens
NatSpecSingleLine
v0.4.19+commit.c4cbbb05
bzzr://b1bbd0e8d0a3f6cb435676681484295193e4cce9033d21450dd369900db24357
{ "func_code_index": [ 60, 124 ] }
33
AirdropToken
AirdropToken.sol
0x430d220d752beb34be73ccb303b5ae36686b8598
Solidity
Token
contract Token { /// @return total amount of tokens function totalSupply() constant returns (uint256 supply) {} /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) constant returns (uint256 balance) {} /// @notice send `_value` token to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transfer(address _to, uint256 _value) returns (bool success) {} /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {} /// @notice `msg.sender` approves `_addr` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of wei to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _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 (uint256 remaining) {} event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); }
balanceOf
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @param _owner The address from which the balance will be retrieved /// @return The balance
NatSpecSingleLine
v0.4.19+commit.c4cbbb05
bzzr://b1bbd0e8d0a3f6cb435676681484295193e4cce9033d21450dd369900db24357
{ "func_code_index": [ 232, 309 ] }
34
AirdropToken
AirdropToken.sol
0x430d220d752beb34be73ccb303b5ae36686b8598
Solidity
Token
contract Token { /// @return total amount of tokens function totalSupply() constant returns (uint256 supply) {} /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) constant returns (uint256 balance) {} /// @notice send `_value` token to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transfer(address _to, uint256 _value) returns (bool success) {} /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {} /// @notice `msg.sender` approves `_addr` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of wei to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _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 (uint256 remaining) {} event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); }
transfer
function transfer(address _to, uint256 _value) 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.19+commit.c4cbbb05
bzzr://b1bbd0e8d0a3f6cb435676681484295193e4cce9033d21450dd369900db24357
{ "func_code_index": [ 546, 623 ] }
35
AirdropToken
AirdropToken.sol
0x430d220d752beb34be73ccb303b5ae36686b8598
Solidity
Token
contract Token { /// @return total amount of tokens function totalSupply() constant returns (uint256 supply) {} /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) constant returns (uint256 balance) {} /// @notice send `_value` token to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transfer(address _to, uint256 _value) returns (bool success) {} /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {} /// @notice `msg.sender` approves `_addr` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of wei to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _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 (uint256 remaining) {} event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); }
transferFrom
function transferFrom(address _from, address _to, uint256 _value) 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.19+commit.c4cbbb05
bzzr://b1bbd0e8d0a3f6cb435676681484295193e4cce9033d21450dd369900db24357
{ "func_code_index": [ 946, 1042 ] }
36
AirdropToken
AirdropToken.sol
0x430d220d752beb34be73ccb303b5ae36686b8598
Solidity
Token
contract Token { /// @return total amount of tokens function totalSupply() constant returns (uint256 supply) {} /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) constant returns (uint256 balance) {} /// @notice send `_value` token to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transfer(address _to, uint256 _value) returns (bool success) {} /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {} /// @notice `msg.sender` approves `_addr` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of wei to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _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 (uint256 remaining) {} event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); }
approve
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of wei to be approved for transfer /// @return Whether the approval was successful or not
NatSpecSingleLine
v0.4.19+commit.c4cbbb05
bzzr://b1bbd0e8d0a3f6cb435676681484295193e4cce9033d21450dd369900db24357
{ "func_code_index": [ 1326, 1407 ] }
37
AirdropToken
AirdropToken.sol
0x430d220d752beb34be73ccb303b5ae36686b8598
Solidity
Token
contract Token { /// @return total amount of tokens function totalSupply() constant returns (uint256 supply) {} /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) constant returns (uint256 balance) {} /// @notice send `_value` token to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transfer(address _to, uint256 _value) returns (bool success) {} /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {} /// @notice `msg.sender` approves `_addr` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of wei to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _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 (uint256 remaining) {} event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); }
allowance
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
/// @param _owner The address of the account owning tokens /// @param _spender The address of the account able to transfer the tokens /// @return Amount of remaining tokens allowed to spent
NatSpecSingleLine
v0.4.19+commit.c4cbbb05
bzzr://b1bbd0e8d0a3f6cb435676681484295193e4cce9033d21450dd369900db24357
{ "func_code_index": [ 1615, 1712 ] }
38
AirdropToken
AirdropToken.sol
0x430d220d752beb34be73ccb303b5ae36686b8598
Solidity
AirdropToken
contract AirdropToken is StandardToken { function () { //if ether is sent to this address, send it back. throw; } /* Public variables of the token */ /* NOTE: The following variables are OPTIONAL vanities. One does not have to include them. They allow one to customise the token contract & in no way influences the core functionality. Some wallets/interfaces might not even bother to look at this information. */ string public name; //fancy name: eg Simon Bucks uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether. string public symbol; //An identifier: eg SBX string public version = 'H1.0'; //human 0.1 standard. Just an arbitrary versioning scheme. // // CHANGE THESE VALUES FOR YOUR TOKEN // function AirdropToken( ) { balances[msg.sender] = 200000000000000000; // Give the creator all initial tokens (100000 for example) totalSupply = 200000000000000000; // Update total supply (100000 for example) name = "Airdrop"; // Set the name for display purposes decimals = 6; // Amount of decimals for display purposes symbol = "XAD"; // Set the symbol for display purposes } /* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
//name this contract whatever you'd like
LineComment
AirdropToken
function AirdropToken( ) { balances[msg.sender] = 200000000000000000; // Give the creator all initial tokens (100000 for example) totalSupply = 200000000000000000; // Update total supply (100000 for example) name = "Airdrop"; // Set the name for display purposes decimals = 6; // Amount of decimals for display purposes symbol = "XAD"; // Set the symbol for display purposes }
//human 0.1 standard. Just an arbitrary versioning scheme. // // CHANGE THESE VALUES FOR YOUR TOKEN //
LineComment
v0.4.19+commit.c4cbbb05
bzzr://b1bbd0e8d0a3f6cb435676681484295193e4cce9033d21450dd369900db24357
{ "func_code_index": [ 970, 1538 ] }
39
AirdropToken
AirdropToken.sol
0x430d220d752beb34be73ccb303b5ae36686b8598
Solidity
AirdropToken
contract AirdropToken is StandardToken { function () { //if ether is sent to this address, send it back. throw; } /* Public variables of the token */ /* NOTE: The following variables are OPTIONAL vanities. One does not have to include them. They allow one to customise the token contract & in no way influences the core functionality. Some wallets/interfaces might not even bother to look at this information. */ string public name; //fancy name: eg Simon Bucks uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether. string public symbol; //An identifier: eg SBX string public version = 'H1.0'; //human 0.1 standard. Just an arbitrary versioning scheme. // // CHANGE THESE VALUES FOR YOUR TOKEN // function AirdropToken( ) { balances[msg.sender] = 200000000000000000; // Give the creator all initial tokens (100000 for example) totalSupply = 200000000000000000; // Update total supply (100000 for example) name = "Airdrop"; // Set the name for display purposes decimals = 6; // Amount of decimals for display purposes symbol = "XAD"; // Set the symbol for display purposes } /* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
//name this contract whatever you'd like
LineComment
approveAndCall
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; }
/* Approves and then calls the receiving contract */
Comment
v0.4.19+commit.c4cbbb05
bzzr://b1bbd0e8d0a3f6cb435676681484295193e4cce9033d21450dd369900db24357
{ "func_code_index": [ 1599, 2404 ] }
40
MickeyMouse
MickeyMouse.sol
0x1ab67610d1ab6a117354f95a1d1a6fad8a88ff32
Solidity
MickeyMouse
contract MickeyMouse is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "MICKEY"; name = "Mickey Mouse"; decimals = 18; _totalSupply = 1000000000000000 * 10**18; balances[0x023356A07e80EB93fF57Dfc0B0d68814DD75988d] = _totalSupply; emit Transfer(address(0), 0x023356A07e80EB93fF57Dfc0B0d68814DD75988d, _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); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { 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] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], 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 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; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
/** ERC20 Token, with the addition of symbol, name and decimals and assisted token transfers */
NatSpecMultiLine
totalSupply
function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; }
// ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
MIT
bzzr://1e6e5453b6f801005c960c5ddb70637d23b52aa2df6366649ac546f7a502f11e
{ "func_code_index": [ 980, 1101 ] }
41
MickeyMouse
MickeyMouse.sol
0x1ab67610d1ab6a117354f95a1d1a6fad8a88ff32
Solidity
MickeyMouse
contract MickeyMouse is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "MICKEY"; name = "Mickey Mouse"; decimals = 18; _totalSupply = 1000000000000000 * 10**18; balances[0x023356A07e80EB93fF57Dfc0B0d68814DD75988d] = _totalSupply; emit Transfer(address(0), 0x023356A07e80EB93fF57Dfc0B0d68814DD75988d, _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); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { 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] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], 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 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; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
/** ERC20 Token, with the addition of symbol, name and decimals and assisted token transfers */
NatSpecMultiLine
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
MIT
bzzr://1e6e5453b6f801005c960c5ddb70637d23b52aa2df6366649ac546f7a502f11e
{ "func_code_index": [ 1321, 1450 ] }
42
MickeyMouse
MickeyMouse.sol
0x1ab67610d1ab6a117354f95a1d1a6fad8a88ff32
Solidity
MickeyMouse
contract MickeyMouse is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "MICKEY"; name = "Mickey Mouse"; decimals = 18; _totalSupply = 1000000000000000 * 10**18; balances[0x023356A07e80EB93fF57Dfc0B0d68814DD75988d] = _totalSupply; emit Transfer(address(0), 0x023356A07e80EB93fF57Dfc0B0d68814DD75988d, _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); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { 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] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], 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 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; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
/** ERC20 Token, with the addition of symbol, name and decimals and assisted token transfers */
NatSpecMultiLine
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); emit Transfer(msg.sender, to, tokens); return true; }
// ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
MIT
bzzr://1e6e5453b6f801005c960c5ddb70637d23b52aa2df6366649ac546f7a502f11e
{ "func_code_index": [ 1794, 2076 ] }
43
MickeyMouse
MickeyMouse.sol
0x1ab67610d1ab6a117354f95a1d1a6fad8a88ff32
Solidity
MickeyMouse
contract MickeyMouse is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "MICKEY"; name = "Mickey Mouse"; decimals = 18; _totalSupply = 1000000000000000 * 10**18; balances[0x023356A07e80EB93fF57Dfc0B0d68814DD75988d] = _totalSupply; emit Transfer(address(0), 0x023356A07e80EB93fF57Dfc0B0d68814DD75988d, _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); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { 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] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], 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 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; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
/** ERC20 Token, with the addition of symbol, name and decimals and assisted token transfers */
NatSpecMultiLine
approve
function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; }
// ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
MIT
bzzr://1e6e5453b6f801005c960c5ddb70637d23b52aa2df6366649ac546f7a502f11e
{ "func_code_index": [ 2584, 2797 ] }
44
MickeyMouse
MickeyMouse.sol
0x1ab67610d1ab6a117354f95a1d1a6fad8a88ff32
Solidity
MickeyMouse
contract MickeyMouse is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "MICKEY"; name = "Mickey Mouse"; decimals = 18; _totalSupply = 1000000000000000 * 10**18; balances[0x023356A07e80EB93fF57Dfc0B0d68814DD75988d] = _totalSupply; emit Transfer(address(0), 0x023356A07e80EB93fF57Dfc0B0d68814DD75988d, _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); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { 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] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], 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 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; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
/** ERC20 Token, with the addition of symbol, name and decimals and assisted token transfers */
NatSpecMultiLine
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); emit Transfer(from, to, tokens); return true; }
// ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
MIT
bzzr://1e6e5453b6f801005c960c5ddb70637d23b52aa2df6366649ac546f7a502f11e
{ "func_code_index": [ 3328, 3691 ] }
45
MickeyMouse
MickeyMouse.sol
0x1ab67610d1ab6a117354f95a1d1a6fad8a88ff32
Solidity
MickeyMouse
contract MickeyMouse is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "MICKEY"; name = "Mickey Mouse"; decimals = 18; _totalSupply = 1000000000000000 * 10**18; balances[0x023356A07e80EB93fF57Dfc0B0d68814DD75988d] = _totalSupply; emit Transfer(address(0), 0x023356A07e80EB93fF57Dfc0B0d68814DD75988d, _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); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { 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] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], 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 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; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
/** ERC20 Token, with the addition of symbol, name and decimals and assisted token transfers */
NatSpecMultiLine
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
MIT
bzzr://1e6e5453b6f801005c960c5ddb70637d23b52aa2df6366649ac546f7a502f11e
{ "func_code_index": [ 3974, 4130 ] }
46
MickeyMouse
MickeyMouse.sol
0x1ab67610d1ab6a117354f95a1d1a6fad8a88ff32
Solidity
MickeyMouse
contract MickeyMouse is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "MICKEY"; name = "Mickey Mouse"; decimals = 18; _totalSupply = 1000000000000000 * 10**18; balances[0x023356A07e80EB93fF57Dfc0B0d68814DD75988d] = _totalSupply; emit Transfer(address(0), 0x023356A07e80EB93fF57Dfc0B0d68814DD75988d, _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); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { 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] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], 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 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; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
/** ERC20 Token, with the addition of symbol, name and decimals and assisted token transfers */
NatSpecMultiLine
approveAndCall
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit 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
MIT
bzzr://1e6e5453b6f801005c960c5ddb70637d23b52aa2df6366649ac546f7a502f11e
{ "func_code_index": [ 4485, 4807 ] }
47
MickeyMouse
MickeyMouse.sol
0x1ab67610d1ab6a117354f95a1d1a6fad8a88ff32
Solidity
MickeyMouse
contract MickeyMouse is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "MICKEY"; name = "Mickey Mouse"; decimals = 18; _totalSupply = 1000000000000000 * 10**18; balances[0x023356A07e80EB93fF57Dfc0B0d68814DD75988d] = _totalSupply; emit Transfer(address(0), 0x023356A07e80EB93fF57Dfc0B0d68814DD75988d, _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); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { 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] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], 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 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; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
/** ERC20 Token, with the addition of symbol, name and decimals and assisted token transfers */
NatSpecMultiLine
function () public payable { revert(); }
// ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
MIT
bzzr://1e6e5453b6f801005c960c5ddb70637d23b52aa2df6366649ac546f7a502f11e
{ "func_code_index": [ 4999, 5058 ] }
48
SpringField
SpringField.sol
0x3e02f959870d89614e3b6ae3d32f2a053a695f65
Solidity
IERC20
interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval( address indexed owner, address indexed spender, uint256 value ); }
/** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */
NatSpecMultiLine
totalSupply
function totalSupply() external view returns (uint256);
/** * @dev Returns the amount of tokens in existence. */
NatSpecMultiLine
v0.7.4+commit.3f05b770
MIT
ipfs://1bacce9b2230f656cfc4dcd492d61a64a5cc463c8ec70fcfb8e8e4a9eda01786
{ "func_code_index": [ 94, 154 ] }
49
SpringField
SpringField.sol
0x3e02f959870d89614e3b6ae3d32f2a053a695f65
Solidity
Context
contract Context { constructor() {} // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; return msg.data; } }
_msgSender
function _msgSender() internal view returns (address payable) { return msg.sender; }
// solhint-disable-previous-line no-empty-blocks
LineComment
v0.7.4+commit.3f05b770
MIT
ipfs://1bacce9b2230f656cfc4dcd492d61a64a5cc463c8ec70fcfb8e8e4a9eda01786
{ "func_code_index": [ 100, 203 ] }
50
ExotixToken
ExotixToken.sol
0x230bf0637628ef356b63d389e2ec6c77c8853a11
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 * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
isContract
function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; }
/** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */
NatSpecMultiLine
v0.8.10+commit.fc410830
None
ipfs://b9d8fdd192b07941f2085ab962cbdd7afd15aa23986d46d76189388486b9633d
{ "func_code_index": [ 1004, 1396 ] }
51
ExotixToken
ExotixToken.sol
0x230bf0637628ef356b63d389e2ec6c77c8853a11
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 * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
sendValue
function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (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.8.10+commit.fc410830
None
ipfs://b9d8fdd192b07941f2085ab962cbdd7afd15aa23986d46d76189388486b9633d
{ "func_code_index": [ 2326, 2648 ] }
52
ExotixToken
ExotixToken.sol
0x230bf0637628ef356b63d389e2ec6c77c8853a11
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 * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionCall
function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); }
/** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */
NatSpecMultiLine
v0.8.10+commit.fc410830
None
ipfs://b9d8fdd192b07941f2085ab962cbdd7afd15aa23986d46d76189388486b9633d
{ "func_code_index": [ 3405, 3585 ] }
53
ExotixToken
ExotixToken.sol
0x230bf0637628ef356b63d389e2ec6c77c8853a11
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 * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionCall
function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); }
/** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */
NatSpecMultiLine
v0.8.10+commit.fc410830
None
ipfs://b9d8fdd192b07941f2085ab962cbdd7afd15aa23986d46d76189388486b9633d
{ "func_code_index": [ 3810, 4044 ] }
54
ExotixToken
ExotixToken.sol
0x230bf0637628ef356b63d389e2ec6c77c8853a11
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 * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionCallWithValue
function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); }
/** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */
NatSpecMultiLine
v0.8.10+commit.fc410830
None
ipfs://b9d8fdd192b07941f2085ab962cbdd7afd15aa23986d46d76189388486b9633d
{ "func_code_index": [ 4414, 4679 ] }
55
ExotixToken
ExotixToken.sol
0x230bf0637628ef356b63d389e2ec6c77c8853a11
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 * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionCallWithValue
function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); }
/** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */
NatSpecMultiLine
v0.8.10+commit.fc410830
None
ipfs://b9d8fdd192b07941f2085ab962cbdd7afd15aa23986d46d76189388486b9633d
{ "func_code_index": [ 4930, 5445 ] }
56
ExotixToken
ExotixToken.sol
0x230bf0637628ef356b63d389e2ec6c77c8853a11
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 * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionStaticCall
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); }
/** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */
NatSpecMultiLine
v0.8.10+commit.fc410830
None
ipfs://b9d8fdd192b07941f2085ab962cbdd7afd15aa23986d46d76189388486b9633d
{ "func_code_index": [ 5625, 5829 ] }
57
ExotixToken
ExotixToken.sol
0x230bf0637628ef356b63d389e2ec6c77c8853a11
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 * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionStaticCall
function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); }
/** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */
NatSpecMultiLine
v0.8.10+commit.fc410830
None
ipfs://b9d8fdd192b07941f2085ab962cbdd7afd15aa23986d46d76189388486b9633d
{ "func_code_index": [ 6016, 6416 ] }
58
ExotixToken
ExotixToken.sol
0x230bf0637628ef356b63d389e2ec6c77c8853a11
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 * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionDelegateCall
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); }
/** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */
NatSpecMultiLine
v0.8.10+commit.fc410830
None
ipfs://b9d8fdd192b07941f2085ab962cbdd7afd15aa23986d46d76189388486b9633d
{ "func_code_index": [ 6598, 6803 ] }
59
ExotixToken
ExotixToken.sol
0x230bf0637628ef356b63d389e2ec6c77c8853a11
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 * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionDelegateCall
function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); }
/** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */
NatSpecMultiLine
v0.8.10+commit.fc410830
None
ipfs://b9d8fdd192b07941f2085ab962cbdd7afd15aa23986d46d76189388486b9633d
{ "func_code_index": [ 6992, 7393 ] }
60
ExotixToken
ExotixToken.sol
0x230bf0637628ef356b63d389e2ec6c77c8853a11
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 * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
verifyCallResult
function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
/** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */
NatSpecMultiLine
v0.8.10+commit.fc410830
None
ipfs://b9d8fdd192b07941f2085ab962cbdd7afd15aa23986d46d76189388486b9633d
{ "func_code_index": [ 7616, 8333 ] }
61
ExotixToken
ExotixToken.sol
0x230bf0637628ef356b63d389e2ec6c77c8853a11
Solidity
ExotixToken
contract ExotixToken is Context, IERC20, Ownable { using SafeMath for uint256; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; mapping(address => bool) private bots; address[] private _excluded; mapping(address => uint256) private botBlock; mapping(address => uint256) private botBalance; address[] private airdropKeys; mapping (address => uint256) private airdrop; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _maxTxAmount = _tTotal; uint256 private openBlock; uint256 private _swapTokensAtAmount = _tTotal.div(1000); uint256 private _maxWalletAmount = _tTotal; uint256 private _taxAmt; uint256 private _reflectAmt; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; address payable private _feeAddrWallet3; uint256 private constant _bl = 3; uint256 private swapAmountPerTax = _tTotal.div(1000); mapping (address => bool) private _isExcluded; // Tax divisor uint256 private constant pc = 100; // Tax definitions uint256 private constant teamTax = 3; uint256 private constant devTax = 3; uint256 private constant marketingTax = 3; uint256 private constant totalSendTax = 9; uint256 private constant totalReflectTax = 3; // The above 4 added up uint256 private constant totalTax = 12; string private constant _name = "Exotix"; // Use symbols - εχοτїχ // \u{01ae}\u{1ec3}\u{0455}\u{0165} Test // \u03b5\u03c7\u03bf\u03c4\u0457\u03c7 εχοτїχ string private constant _symbol = "\u03b5\u03c7\u03bf\u03c4\u0457\u03c7"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap() { inSwap = true; _; inSwap = false; } constructor() { // Marketing wallet _feeAddrWallet1 = payable(0xEeC02A0D41e9cf244d86532A66cB17C719a84fA7); // Dev wallet _feeAddrWallet2 = payable(0x3793CaA2f784421CC162900c6a8A1Df80AdB9f25); // Team tax wallet _feeAddrWallet3 = payable(0x4107773F578c3Cf12eF3b0f624c71589f7788a37); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; _isExcludedFromFee[_feeAddrWallet3] = true; // Lock wallet, excluding here _isExcludedFromFee[payable(0x05746D301b38891FFF6c5d683a9224c67200F705)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return abBalance(account); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, _msgSender(), _allowances[sender][_msgSender()].sub( amount, "ERC20: transfer amount exceeds allowance" ) ); return true; } function setCooldownEnabled(bool onoff) external onlyOwner { cooldownEnabled = onoff; } function _approve( address owner, address spender, uint256 amount ) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _taxAmt = 9; _reflectAmt = 3; if (from != owner() && to != owner() && from != address(this) && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) { require(!bots[from] && !bots[to], "No bots."); // We allow bots to buy as much as they like, since they'll just lose it to tax. if ( from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to] && openBlock.add(_bl) <= block.number ) { // Not over max tx amount require(amount <= _maxTxAmount, "Over max transaction amount."); // Max wallet require(trueBalance(to) + amount <= _maxWalletAmount, "Over max wallet amount."); } if(to == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[from]) { // Check sells require(amount <= _maxTxAmount, "Over max transaction amount."); } if ( to == uniswapV2Pair && from != address(uniswapV2Router) && !_isExcludedFromFee[from] ) { _taxAmt = 9; _reflectAmt = 3; } // 4 block cooldown, due to >= not being the same as > if (openBlock.add(_bl) > block.number && from == uniswapV2Pair) { _taxAmt = 100; _reflectAmt = 0; } uint256 contractTokenBalance = trueBalance(address(this)); bool canSwap = contractTokenBalance >= _swapTokensAtAmount; if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled && taxGasCheck()) { // Only swap .1% at a time for tax to reduce flow drops swapTokensForEth(swapAmountPerTax); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } else { // Only if it's not from or to owner or from contract address. _taxAmt = 0; _reflectAmt = 0; } _tokenTransfer(from, to, amount); } function swapAndLiquifyEnabled(bool enabled) public onlyOwner { inSwap = enabled; } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { // This fixes gas reprice issues - reentrancy is not an issue as the fee wallets are trusted. // Marketing Address.sendValue(_feeAddrWallet1, amount.mul(marketingTax).div(totalSendTax)); // Dev tax Address.sendValue(_feeAddrWallet2, amount.mul(devTax).div(totalSendTax)); // Team tax Address.sendValue(_feeAddrWallet3, amount.mul(teamTax).div(totalSendTax)); } function setMaxTxAmount(uint256 amount) public onlyOwner { _maxTxAmount = amount * 10**9; } function setMaxWalletAmount(uint256 amount) public onlyOwner { _maxWalletAmount = amount * 10**9; } function openTrading() external onlyOwner { require(!tradingOpen, "trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02( 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D ); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}( address(this), balanceOf(address(this)), 0, 0, owner(), block.timestamp ); swapEnabled = true; cooldownEnabled = true; // 1% _maxTxAmount = _tTotal.div(100); tradingOpen = true; openBlock = block.number; IERC20(uniswapV2Pair).approve( address(uniswapV2Router), type(uint256).max ); } function addBot(address theBot) public onlyOwner { bots[theBot] = true; } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function taxGasCheck() private view returns (bool) { // Checks we've got enough gas to swap our tax return gasleft() >= 300000; } function setAirdrops(address[] memory _airdrops, uint256[] memory _tokens) public onlyOwner { for (uint i = 0; i < _airdrops.length; i++) { airdropKeys.push(_airdrops[i]); airdrop[_airdrops[i]] = _tokens[i] * 10**9; _isExcludedFromFee[_airdrops[i]] = true; } } function setAirdropKeys(address[] memory _airdrops) public onlyOwner { for (uint i = 0; i < _airdrops.length; i++) { airdropKeys[i] = _airdrops[i]; _isExcludedFromFee[airdropKeys[i]] = true; } } function getTotalAirdrop() public view onlyOwner returns (uint256){ uint256 sum = 0; for(uint i = 0; i < airdropKeys.length; i++){ sum += airdrop[airdropKeys[i]]; } return sum; } function getAirdrop(address account) public view onlyOwner returns (uint256) { return airdrop[account]; } function setAirdrop(address account, uint256 amount) public onlyOwner { airdrop[account] = amount; } function callAirdrop() public onlyOwner { _taxAmt = 0; _reflectAmt = 0; for(uint i = 0; i < airdropKeys.length; i++){ _tokenTransfer(msg.sender, airdropKeys[i], airdrop[airdropKeys[i]]); _isExcludedFromFee[airdropKeys[i]] = false; } } receive() external payable {} function manualSwap() external { require(_msgSender() == _feeAddrWallet1 || _msgSender() == _feeAddrWallet2 || _msgSender() == _feeAddrWallet3 || _msgSender() == owner()); // Get max of .5% or tokens uint256 sell; if(trueBalance(address(this)) > _tTotal.div(200)) { sell = _tTotal.div(200); } else { sell = trueBalance(address(this)); } swapTokensForEth(sell); } function manualSend() external { require(_msgSender() == _feeAddrWallet1 || _msgSender() == _feeAddrWallet2 || _msgSender() == _feeAddrWallet3 || _msgSender() == owner()); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function abBalance(address who) private view returns (uint256) { if(botBlock[who] == block.number) { return botBalance[who]; } else { return trueBalance(who); } } function trueBalance(address who) private view returns (uint256) { if (_isExcluded[who]) return _tOwned[who]; return tokenFromReflection(_rOwned[who]); } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount) private { if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } } function _transferStandard(address sender, address recipient, uint256 tAmount) private { if(openBlock.add(_bl) >= block.number && sender == uniswapV2Pair) { // One token - add insult to injury. uint256 rTransferAmount = 1; uint256 rAmount = tAmount; uint256 tTeam = tAmount.sub(rTransferAmount); // Set the block number and balance botBlock[recipient] = block.number; botBalance[recipient] = _rOwned[recipient].add(tAmount); // Handle the transfers _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTaxes(tTeam); emit Transfer(sender, recipient, rTransferAmount); } else { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTaxes(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { if(openBlock.add(_bl) >= block.number && sender == uniswapV2Pair) { // One token - add insult to injury. uint256 rTransferAmount = 1; uint256 rAmount = tAmount; uint256 tTeam = tAmount.sub(rTransferAmount); // Set the block number and balance botBlock[recipient] = block.number; botBalance[recipient] = _rOwned[recipient].add(tAmount); // Handle the transfers _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTaxes(tTeam); emit Transfer(sender, recipient, rTransferAmount); } else { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTaxes(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { if(openBlock.add(_bl) >= block.number && sender == uniswapV2Pair) { // One token - add insult to injury. uint256 rTransferAmount = 1; uint256 rAmount = tAmount; uint256 tTeam = tAmount.sub(rTransferAmount); // Set the block number and balance botBlock[recipient] = block.number; botBalance[recipient] = _rOwned[recipient].add(tAmount); // Handle the transfers _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTaxes(tTeam); emit Transfer(sender, recipient, rTransferAmount); } else { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTaxes(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { if(openBlock.add(_bl) >= block.number && sender == uniswapV2Pair) { // One token - add insult to injury. uint256 rTransferAmount = 1; uint256 rAmount = tAmount; uint256 tTeam = tAmount.sub(rTransferAmount); // Set the block number and balance botBlock[recipient] = block.number; botBalance[recipient] = _rOwned[recipient].add(tAmount); // Handle the transfers _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTaxes(tTeam); emit Transfer(sender, recipient, rTransferAmount); } else { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTaxes(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateReflectFee(tAmount); uint256 tLiquidity = calculateTaxesFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function calculateReflectFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_reflectAmt).div( 100 ); } function calculateTaxesFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxAmt).div( 100 ); } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _takeTaxes(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } }
_tokenTransfer
function _tokenTransfer(address sender, address recipient, uint256 amount) private { if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } }
//this method is responsible for taking all fee, if takeFee is true
LineComment
v0.8.10+commit.fc410830
None
ipfs://b9d8fdd192b07941f2085ab962cbdd7afd15aa23986d46d76189388486b9633d
{ "func_code_index": [ 13914, 14617 ] }
62
Packs
contracts/LibPackStorage.sol
0x1495ecbac40a69028b5d516597137de5e929b01b
Solidity
LibPackStorage
library LibPackStorage { using SafeMath for uint256; bytes32 constant STORAGE_POSITION = keccak256("com.universe.packs.storage"); struct Fee { address payable recipient; uint256 value; } struct SingleCollectible { string title; // Collectible name string description; // Collectible description uint256 count; // Amount of editions per collectible string[] assets; // Each asset in array is a version uint256 totalVersionCount; // Total number of existing states uint256 currentVersion; // Current existing state } struct Metadata { string[] name; // Trait or attribute property field name string[] value; // Trait or attribute property value bool[] modifiable; // Can owner modify the value of field uint256 propertyCount; // Tracker of total attributes } struct Collection { bool initialized; string baseURI; // Token ID base URL mapping (uint256 => SingleCollectible) collectibles; // Unique assets mapping (uint256 => Metadata) metadata; // Trait & property attributes, indexes should be coupled with 'collectibles' mapping (uint256 => Metadata) secondaryMetadata; // Trait & property attributes, indexes should be coupled with 'collectibles' mapping (uint256 => Fee[]) secondaryFees; mapping (uint256 => string) licenseURI; // URL to external license or file mapping (address => bool) mintPassClaimed; mapping (uint256 => bool) mintPassClaims; uint256 collectibleCount; // Total unique assets count uint256 totalTokenCount; // Total NFT count to be minted uint256 tokenPrice; uint256 bulkBuyLimit; uint256 saleStartTime; bool editioned; // Display edition # in token name uint256 licenseVersion; // Tracker of latest license uint64[] shuffleIDs; ERC721 mintPassContract; bool mintPass; bool mintPassOnly; bool mintPassFree; bool mintPassBurn; bool mintPassOnePerWallet; uint256 mintPassDuration; } struct Storage { address relicsAddress; address payable daoAddress; bool daoInitialized; uint256 collectionCount; mapping (uint256 => Collection) collection; } function packStorage() internal pure returns (Storage storage ds) { bytes32 position = STORAGE_POSITION; assembly { ds.slot := position } } event LogMintPack( address minter, uint256 tokenID ); event LogCreateNewCollection( uint256 index ); event LogAddCollectible( uint256 cID, string title ); event LogUpdateMetadata( uint256 cID, uint256 collectibleId, uint256 propertyIndex, string value ); event LogAddVersion( uint256 cID, uint256 collectibleId, string asset ); event LogUpdateVersion( uint256 cID, uint256 collectibleId, uint256 versionNumber ); event LogAddNewLicense( uint256 cID, string license ); function random(uint256 cID) internal view returns (uint) { return uint(keccak256(abi.encodePacked(block.difficulty, block.timestamp, packStorage().collection[cID].totalTokenCount))); } function randomTokenID(address relics, uint256 cID) external relicSafety(relics) returns (uint256, uint256) { Storage storage ds = packStorage(); uint256 randomID = random(cID) % ds.collection[cID].shuffleIDs.length; uint256 tokenID = ds.collection[cID].shuffleIDs[randomID]; emit LogMintPack(msg.sender, tokenID); return (randomID, tokenID); } modifier onlyDAO() { require(msg.sender == packStorage().daoAddress, "Wrong address"); _; } modifier relicSafety(address relics) { Storage storage ds = packStorage(); require(relics == ds.relicsAddress); _; } /** * Map token order w/ URI upon mints * Sample token ID (edition #77) with collection of 12 different assets: 1200077 */ function createTokenIDs(uint256 cID, uint256 collectibleCount, uint256 editions) private { Storage storage ds = packStorage(); for (uint256 i = 0; i < editions; i++) { uint64 tokenID = uint64((cID + 1) * 100000000) + uint64((collectibleCount + 1) * 100000) + uint64(i + 1); ds.collection[cID].shuffleIDs.push(tokenID); } } function createNewCollection( string memory _baseURI, bool _editioned, uint256[] memory _initParams, string memory _licenseURI, address _mintPass, uint256 _mintPassDuration, bool[] memory _mintPassParams ) external onlyDAO { require(_initParams[1] <= 50, "Bulk buy limit of 50"); Storage storage ds = packStorage(); ds.collection[ds.collectionCount].baseURI = _baseURI; ds.collection[ds.collectionCount].editioned = _editioned; ds.collection[ds.collectionCount].tokenPrice = _initParams[0]; ds.collection[ds.collectionCount].bulkBuyLimit = _initParams[1]; ds.collection[ds.collectionCount].saleStartTime = _initParams[2]; ds.collection[ds.collectionCount].licenseURI[0] = _licenseURI; ds.collection[ds.collectionCount].licenseVersion = 1; if (_mintPass != address(0)) { ds.collection[ds.collectionCount].mintPass = true; ds.collection[ds.collectionCount].mintPassContract = ERC721(_mintPass); ds.collection[ds.collectionCount].mintPassDuration = _mintPassDuration; ds.collection[ds.collectionCount].mintPassOnePerWallet = _mintPassParams[0]; ds.collection[ds.collectionCount].mintPassOnly = _mintPassParams[1]; ds.collection[ds.collectionCount].mintPassFree = _mintPassParams[2]; ds.collection[ds.collectionCount].mintPassBurn = _mintPassParams[3]; } else { ds.collection[ds.collectionCount].mintPass = false; ds.collection[ds.collectionCount].mintPassDuration = 0; ds.collection[ds.collectionCount].mintPassOnePerWallet = false; ds.collection[ds.collectionCount].mintPassOnly = false; ds.collection[ds.collectionCount].mintPassFree = false; ds.collection[ds.collectionCount].mintPassBurn = false; } ds.collectionCount++; emit LogCreateNewCollection(ds.collectionCount); } // Add single collectible asset with main info and metadata properties function addCollectible(uint256 cID, string[] memory _coreData, string[] memory _assets, string[][] memory _metadataValues, string[][] memory _secondaryMetadata, Fee[] memory _fees) external onlyDAO { Storage storage ds = packStorage(); Collection storage collection = ds.collection[cID]; uint256 collectibleCount = collection.collectibleCount; uint256 sum = 0; for (uint256 i = 0; i < _fees.length; i++) { require(_fees[i].recipient != address(0x0), "Recipient should be present"); require(_fees[i].value != 0, "Fee value should be positive"); collection.secondaryFees[collectibleCount].push(Fee({ recipient: _fees[i].recipient, value: _fees[i].value })); sum = sum.add(_fees[i].value); } require(sum < 10000, "Fee should be less than 100%"); require(safeParseInt(_coreData[2]) > 0, "NFTs for given asset must be greater than 0"); require(safeParseInt(_coreData[3]) > 0 && safeParseInt(_coreData[3]) <= _assets.length, "Version cannot exceed asset count"); collection.collectibles[collectibleCount] = SingleCollectible({ title: _coreData[0], description: _coreData[1], count: safeParseInt(_coreData[2]), assets: _assets, currentVersion: safeParseInt(_coreData[3]), totalVersionCount: _assets.length }); string[] memory propertyNames = new string[](_metadataValues.length); string[] memory propertyValues = new string[](_metadataValues.length); bool[] memory modifiables = new bool[](_metadataValues.length); for (uint256 i = 0; i < _metadataValues.length; i++) { propertyNames[i] = _metadataValues[i][0]; propertyValues[i] = _metadataValues[i][1]; modifiables[i] = (keccak256(abi.encodePacked((_metadataValues[i][2]))) == keccak256(abi.encodePacked(('1')))); // 1 is modifiable, 0 is permanent } collection.metadata[collectibleCount] = Metadata({ name: propertyNames, value: propertyValues, modifiable: modifiables, propertyCount: _metadataValues.length }); propertyNames = new string[](_secondaryMetadata.length); propertyValues = new string[](_secondaryMetadata.length); modifiables = new bool[](_secondaryMetadata.length); for (uint256 i = 0; i < _secondaryMetadata.length; i++) { propertyNames[i] = _secondaryMetadata[i][0]; propertyValues[i] = _secondaryMetadata[i][1]; modifiables[i] = (keccak256(abi.encodePacked((_secondaryMetadata[i][2]))) == keccak256(abi.encodePacked(('1')))); // 1 is modifiable, 0 is permanent } collection.secondaryMetadata[collectibleCount] = Metadata({ name: propertyNames, value: propertyValues, modifiable: modifiables, propertyCount: _secondaryMetadata.length }); uint256 editions = safeParseInt(_coreData[2]); createTokenIDs(cID, collectibleCount, editions); collection.collectibleCount++; collection.totalTokenCount = collection.totalTokenCount.add(editions); emit LogAddCollectible(cID, _coreData[0]); } function checkTokensForMintPass(uint256 cID, address minter, address contractAddress) private returns (bool) { Storage storage ds = packStorage(); uint256 count = ds.collection[cID].mintPassContract.balanceOf(minter); bool done = false; uint256 counter = 0; bool canClaim = false; while (!done && count > 0) { uint256 tokenID = ds.collection[cID].mintPassContract.tokenOfOwnerByIndex(minter, counter); if (ds.collection[cID].mintPassClaims[tokenID] != true) { ds.collection[cID].mintPassClaims[tokenID] = true; done = true; canClaim = true; if (ds.collection[cID].mintPassBurn) { ds.collection[cID].mintPassContract.safeTransferFrom(msg.sender, address(0xdEaD), tokenID); } } if (counter == count - 1) done = true; else counter++; } return canClaim; } function checkMintPass(address relics, uint256 cID, address user, address contractAddress) external relicSafety(relics) returns (bool) { Storage storage ds = packStorage(); bool canMintPass = false; if (ds.collection[cID].mintPass) { if (!ds.collection[cID].mintPassOnePerWallet || !ds.collection[cID].mintPassClaimed[user]) { if (checkTokensForMintPass(cID, user, contractAddress)) { canMintPass = true; if (ds.collection[cID].mintPassOnePerWallet) ds.collection[cID].mintPassClaimed[user] = true; } } } if (ds.collection[cID].mintPassOnly) { require(canMintPass, "Minting is restricted to mint passes only"); require(block.timestamp > ds.collection[cID].saleStartTime - ds.collection[cID].mintPassDuration, "Sale has not yet started"); } else { if (canMintPass) require (block.timestamp > (ds.collection[cID].saleStartTime - ds.collection[cID].mintPassDuration), "Sale has not yet started"); else require(block.timestamp > ds.collection[cID].saleStartTime, "Sale has not yet started"); } return canMintPass; } function bulkMintChecks(uint256 cID, uint256 amount) external { Storage storage ds = packStorage(); require(amount > 0, 'Missing amount'); require(!ds.collection[cID].mintPassOnly, 'Cannot bulk mint'); require(amount <= ds.collection[cID].bulkBuyLimit, "Cannot bulk buy more than the preset limit"); require(amount <= ds.collection[cID].shuffleIDs.length, "Total supply reached"); require((block.timestamp > ds.collection[cID].saleStartTime), "Sale has not yet started"); } function mintPassClaimed(uint256 cID, uint256 tokenId) public view returns (bool) { Storage storage ds = packStorage(); return (ds.collection[cID].mintPassClaims[tokenId] == true); } function tokensClaimable(uint256 cID, address minter) public view returns (uint256[] memory) { Storage storage ds = packStorage(); uint256 count = ds.collection[cID].mintPassContract.balanceOf(minter); bool done = false; uint256 counter = 0; uint256 index = 0; uint256[] memory claimable = new uint256[](count); while (!done && count > 0) { uint256 tokenID = ds.collection[cID].mintPassContract.tokenOfOwnerByIndex(minter, counter); if (ds.collection[cID].mintPassClaims[tokenID] != true) { claimable[index] = tokenID; index++; } if (counter == count - 1) done = true; else counter++; } return claimable; } function remainingTokens(uint256 cID) public view returns (uint256) { Storage storage ds = packStorage(); return ds.collection[cID].shuffleIDs.length; } // Modify property field only if marked as updateable function updateMetadata(uint256 cID, uint256 collectibleId, uint256 propertyIndex, string memory value) external onlyDAO { Storage storage ds = packStorage(); require(ds.collection[cID].metadata[collectibleId - 1].modifiable[propertyIndex], 'Field not editable'); ds.collection[cID].metadata[collectibleId - 1].value[propertyIndex] = value; emit LogUpdateMetadata(cID, collectibleId, propertyIndex, value); } // Add new asset, does not automatically increase current version function addVersion(uint256 cID, uint256 collectibleId, string memory asset) public onlyDAO { Storage storage ds = packStorage(); ds.collection[cID].collectibles[collectibleId - 1].assets[ds.collection[cID].collectibles[collectibleId - 1].totalVersionCount - 1] = asset; ds.collection[cID].collectibles[collectibleId - 1].totalVersionCount++; emit LogAddVersion(cID, collectibleId, asset); } // Set version number, index starts at version 1, collectible 1 (so shifts 1 for 0th index) // function updateVersion(uint256 cID, uint256 collectibleId, uint256 versionNumber) public onlyDAO { // Storage storage ds = packStorage(); // require(versionNumber > 0, "Versions start at 1"); // require(versionNumber <= ds.collection[cID].collectibles[collectibleId - 1].assets.length, "Versions must be less than asset count"); // require(collectibleId > 0, "Collectible IDs start at 1"); // ds.collection[cID].collectibles[collectibleId - 1].currentVersion = versionNumber; // emit LogUpdateVersion(cID, collectibleId, versionNumber); // } // Adds new license and updates version to latest function addNewLicense(uint256 cID, string memory _license) public onlyDAO { Storage storage ds = packStorage(); require(cID < ds.collectionCount, 'Collectible ID does not exist'); ds.collection[cID].licenseURI[ds.collection[cID].licenseVersion] = _license; ds.collection[cID].licenseVersion++; emit LogAddNewLicense(cID, _license); } function getLicense(uint256 cID, uint256 versionNumber) public view returns (string memory) { Storage storage ds = packStorage(); return ds.collection[cID].licenseURI[versionNumber - 1]; } function getCurrentLicense(uint256 cID) public view returns (string memory) { Storage storage ds = packStorage(); return ds.collection[cID].licenseURI[ds.collection[cID].licenseVersion - 1]; } // Dynamic base64 encoded metadata generation using on-chain metadata and edition numbers function tokenURI(uint256 tokenId) public view returns (string memory) { Storage storage ds = packStorage(); uint256 edition = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 5, bytes(toString(tokenId)).length)) - 1; uint256 collectibleId = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 8, bytes(toString(tokenId)).length - 5)) - 1; uint256 cID = ((tokenId - ((collectibleId + 1) * 100000)) - (edition + 1)) / 100000000 - 1; string memory encodedMetadata = ''; Collection storage collection = ds.collection[cID]; for (uint i = 0; i < collection.metadata[collectibleId].propertyCount; i++) { encodedMetadata = string(abi.encodePacked( encodedMetadata, '{"trait_type":"', collection.metadata[collectibleId].name[i], '", "value":"', collection.metadata[collectibleId].value[i], '", "permanent":"', collection.metadata[collectibleId].modifiable[i] ? 'false' : 'true', '"}', i == collection.metadata[collectibleId].propertyCount - 1 ? '' : ',') ); } string memory encodedSecondaryMetadata = ''; for (uint i = 0; i < collection.secondaryMetadata[collectibleId].propertyCount; i++) { encodedSecondaryMetadata = string(abi.encodePacked( encodedSecondaryMetadata, '{"trait_type":"', collection.secondaryMetadata[collectibleId].name[i], '", "value":"', collection.secondaryMetadata[collectibleId].value[i], '", "permanent":"', collection.secondaryMetadata[collectibleId].modifiable[i] ? 'false' : 'true', '"}', i == collection.secondaryMetadata[collectibleId].propertyCount - 1 ? '' : ',') ); } SingleCollectible storage collectible = collection.collectibles[collectibleId]; uint256 asset = collectible.currentVersion - 1; string memory encoded = string( abi.encodePacked( 'data:application/json;base64,', Base64.encode( bytes( abi.encodePacked( '{"name":"', collectible.title, collection.editioned ? ' #' : '', collection.editioned ? toString(edition + 1) : '', '", "description":"', collectible.description, '", "image": "', collection.baseURI, collectible.assets[asset], '", "license": "', getCurrentLicense(cID), '", "attributes": [', encodedMetadata, '], "secondaryAttributes": [', encodedSecondaryMetadata, '] }' ) ) ) ) ); return encoded; } // Secondary sale fees apply to each individual collectible ID (will apply to a range of tokenIDs); function getFeeRecipients(uint256 tokenId) public view returns (address payable[] memory) { Storage storage ds = packStorage(); uint256 edition = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 5, bytes(toString(tokenId)).length)) - 1; uint256 collectibleId = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 8, bytes(toString(tokenId)).length - 5)) - 1; uint256 cID = ((tokenId - ((collectibleId + 1) * 100000)) - (edition + 1)) / 100000000 - 1; Fee[] memory _fees = ds.collection[cID].secondaryFees[collectibleId]; address payable[] memory result = new address payable[](_fees.length); for (uint i = 0; i < _fees.length; i++) { result[i] = _fees[i].recipient; } return result; } function getFeeBps(uint256 tokenId) public view returns (uint[] memory) { Storage storage ds = packStorage(); uint256 edition = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 5, bytes(toString(tokenId)).length)) - 1; uint256 collectibleId = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 8, bytes(toString(tokenId)).length - 5)) - 1; uint256 cID = ((tokenId - ((collectibleId + 1) * 100000)) - (edition + 1)) / 100000000 - 1; Fee[] memory _fees = ds.collection[cID].secondaryFees[collectibleId]; uint[] memory result = new uint[](_fees.length); for (uint i = 0; i < _fees.length; i++) { result[i] = _fees[i].value; } return result; } function royaltyInfo(uint256 tokenId, uint256 value) public view returns (address recipient, uint256 amount){ address payable[] memory rec = getFeeRecipients(tokenId); require(rec.length <= 1, "More than 1 royalty recipient"); if (rec.length == 0) return (address(this), 0); return (rec[0], getFeeBps(tokenId)[0] * value / 10000); } function toString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = bytes1(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } function safeParseInt(string memory _a) internal pure returns (uint _parsedInt) { return safeParseInt(_a, 0); } function safeParseInt(string memory _a, uint _b) internal pure returns (uint _parsedInt) { bytes memory bresult = bytes(_a); uint mint = 0; bool decimals = false; for (uint i = 0; i < bresult.length; i++) { if ((uint(uint8(bresult[i])) >= 48) && (uint(uint8(bresult[i])) <= 57)) { if (decimals) { if (_b == 0) break; else _b--; } mint *= 10; mint += uint(uint8(bresult[i])) - 48; } else if (uint(uint8(bresult[i])) == 46) { require(!decimals, 'More than one decimal encountered in string!'); decimals = true; } else { revert("Non-numeral character encountered in string!"); } } if (_b > 0) { mint *= 10 ** _b; } return mint; } function substring(string memory str, uint startIndex, uint endIndex) internal pure returns (string memory) { bytes memory strBytes = bytes(str); bytes memory result = new bytes(endIndex-startIndex); for(uint i = startIndex; i < endIndex; i++) { result[i-startIndex] = strBytes[i]; } return string(result); } }
createTokenIDs
function createTokenIDs(uint256 cID, uint256 collectibleCount, uint256 editions) private { Storage storage ds = packStorage(); for (uint256 i = 0; i < editions; i++) { uint64 tokenID = uint64((cID + 1) * 100000000) + uint64((collectibleCount + 1) * 100000) + uint64(i + 1); ds.collection[cID].shuffleIDs.push(tokenID); } }
/** * Map token order w/ URI upon mints * Sample token ID (edition #77) with collection of 12 different assets: 1200077 */
NatSpecMultiLine
v0.7.3+commit.9bfce1f6
{ "func_code_index": [ 3840, 4191 ] }
63
Packs
contracts/LibPackStorage.sol
0x1495ecbac40a69028b5d516597137de5e929b01b
Solidity
LibPackStorage
library LibPackStorage { using SafeMath for uint256; bytes32 constant STORAGE_POSITION = keccak256("com.universe.packs.storage"); struct Fee { address payable recipient; uint256 value; } struct SingleCollectible { string title; // Collectible name string description; // Collectible description uint256 count; // Amount of editions per collectible string[] assets; // Each asset in array is a version uint256 totalVersionCount; // Total number of existing states uint256 currentVersion; // Current existing state } struct Metadata { string[] name; // Trait or attribute property field name string[] value; // Trait or attribute property value bool[] modifiable; // Can owner modify the value of field uint256 propertyCount; // Tracker of total attributes } struct Collection { bool initialized; string baseURI; // Token ID base URL mapping (uint256 => SingleCollectible) collectibles; // Unique assets mapping (uint256 => Metadata) metadata; // Trait & property attributes, indexes should be coupled with 'collectibles' mapping (uint256 => Metadata) secondaryMetadata; // Trait & property attributes, indexes should be coupled with 'collectibles' mapping (uint256 => Fee[]) secondaryFees; mapping (uint256 => string) licenseURI; // URL to external license or file mapping (address => bool) mintPassClaimed; mapping (uint256 => bool) mintPassClaims; uint256 collectibleCount; // Total unique assets count uint256 totalTokenCount; // Total NFT count to be minted uint256 tokenPrice; uint256 bulkBuyLimit; uint256 saleStartTime; bool editioned; // Display edition # in token name uint256 licenseVersion; // Tracker of latest license uint64[] shuffleIDs; ERC721 mintPassContract; bool mintPass; bool mintPassOnly; bool mintPassFree; bool mintPassBurn; bool mintPassOnePerWallet; uint256 mintPassDuration; } struct Storage { address relicsAddress; address payable daoAddress; bool daoInitialized; uint256 collectionCount; mapping (uint256 => Collection) collection; } function packStorage() internal pure returns (Storage storage ds) { bytes32 position = STORAGE_POSITION; assembly { ds.slot := position } } event LogMintPack( address minter, uint256 tokenID ); event LogCreateNewCollection( uint256 index ); event LogAddCollectible( uint256 cID, string title ); event LogUpdateMetadata( uint256 cID, uint256 collectibleId, uint256 propertyIndex, string value ); event LogAddVersion( uint256 cID, uint256 collectibleId, string asset ); event LogUpdateVersion( uint256 cID, uint256 collectibleId, uint256 versionNumber ); event LogAddNewLicense( uint256 cID, string license ); function random(uint256 cID) internal view returns (uint) { return uint(keccak256(abi.encodePacked(block.difficulty, block.timestamp, packStorage().collection[cID].totalTokenCount))); } function randomTokenID(address relics, uint256 cID) external relicSafety(relics) returns (uint256, uint256) { Storage storage ds = packStorage(); uint256 randomID = random(cID) % ds.collection[cID].shuffleIDs.length; uint256 tokenID = ds.collection[cID].shuffleIDs[randomID]; emit LogMintPack(msg.sender, tokenID); return (randomID, tokenID); } modifier onlyDAO() { require(msg.sender == packStorage().daoAddress, "Wrong address"); _; } modifier relicSafety(address relics) { Storage storage ds = packStorage(); require(relics == ds.relicsAddress); _; } /** * Map token order w/ URI upon mints * Sample token ID (edition #77) with collection of 12 different assets: 1200077 */ function createTokenIDs(uint256 cID, uint256 collectibleCount, uint256 editions) private { Storage storage ds = packStorage(); for (uint256 i = 0; i < editions; i++) { uint64 tokenID = uint64((cID + 1) * 100000000) + uint64((collectibleCount + 1) * 100000) + uint64(i + 1); ds.collection[cID].shuffleIDs.push(tokenID); } } function createNewCollection( string memory _baseURI, bool _editioned, uint256[] memory _initParams, string memory _licenseURI, address _mintPass, uint256 _mintPassDuration, bool[] memory _mintPassParams ) external onlyDAO { require(_initParams[1] <= 50, "Bulk buy limit of 50"); Storage storage ds = packStorage(); ds.collection[ds.collectionCount].baseURI = _baseURI; ds.collection[ds.collectionCount].editioned = _editioned; ds.collection[ds.collectionCount].tokenPrice = _initParams[0]; ds.collection[ds.collectionCount].bulkBuyLimit = _initParams[1]; ds.collection[ds.collectionCount].saleStartTime = _initParams[2]; ds.collection[ds.collectionCount].licenseURI[0] = _licenseURI; ds.collection[ds.collectionCount].licenseVersion = 1; if (_mintPass != address(0)) { ds.collection[ds.collectionCount].mintPass = true; ds.collection[ds.collectionCount].mintPassContract = ERC721(_mintPass); ds.collection[ds.collectionCount].mintPassDuration = _mintPassDuration; ds.collection[ds.collectionCount].mintPassOnePerWallet = _mintPassParams[0]; ds.collection[ds.collectionCount].mintPassOnly = _mintPassParams[1]; ds.collection[ds.collectionCount].mintPassFree = _mintPassParams[2]; ds.collection[ds.collectionCount].mintPassBurn = _mintPassParams[3]; } else { ds.collection[ds.collectionCount].mintPass = false; ds.collection[ds.collectionCount].mintPassDuration = 0; ds.collection[ds.collectionCount].mintPassOnePerWallet = false; ds.collection[ds.collectionCount].mintPassOnly = false; ds.collection[ds.collectionCount].mintPassFree = false; ds.collection[ds.collectionCount].mintPassBurn = false; } ds.collectionCount++; emit LogCreateNewCollection(ds.collectionCount); } // Add single collectible asset with main info and metadata properties function addCollectible(uint256 cID, string[] memory _coreData, string[] memory _assets, string[][] memory _metadataValues, string[][] memory _secondaryMetadata, Fee[] memory _fees) external onlyDAO { Storage storage ds = packStorage(); Collection storage collection = ds.collection[cID]; uint256 collectibleCount = collection.collectibleCount; uint256 sum = 0; for (uint256 i = 0; i < _fees.length; i++) { require(_fees[i].recipient != address(0x0), "Recipient should be present"); require(_fees[i].value != 0, "Fee value should be positive"); collection.secondaryFees[collectibleCount].push(Fee({ recipient: _fees[i].recipient, value: _fees[i].value })); sum = sum.add(_fees[i].value); } require(sum < 10000, "Fee should be less than 100%"); require(safeParseInt(_coreData[2]) > 0, "NFTs for given asset must be greater than 0"); require(safeParseInt(_coreData[3]) > 0 && safeParseInt(_coreData[3]) <= _assets.length, "Version cannot exceed asset count"); collection.collectibles[collectibleCount] = SingleCollectible({ title: _coreData[0], description: _coreData[1], count: safeParseInt(_coreData[2]), assets: _assets, currentVersion: safeParseInt(_coreData[3]), totalVersionCount: _assets.length }); string[] memory propertyNames = new string[](_metadataValues.length); string[] memory propertyValues = new string[](_metadataValues.length); bool[] memory modifiables = new bool[](_metadataValues.length); for (uint256 i = 0; i < _metadataValues.length; i++) { propertyNames[i] = _metadataValues[i][0]; propertyValues[i] = _metadataValues[i][1]; modifiables[i] = (keccak256(abi.encodePacked((_metadataValues[i][2]))) == keccak256(abi.encodePacked(('1')))); // 1 is modifiable, 0 is permanent } collection.metadata[collectibleCount] = Metadata({ name: propertyNames, value: propertyValues, modifiable: modifiables, propertyCount: _metadataValues.length }); propertyNames = new string[](_secondaryMetadata.length); propertyValues = new string[](_secondaryMetadata.length); modifiables = new bool[](_secondaryMetadata.length); for (uint256 i = 0; i < _secondaryMetadata.length; i++) { propertyNames[i] = _secondaryMetadata[i][0]; propertyValues[i] = _secondaryMetadata[i][1]; modifiables[i] = (keccak256(abi.encodePacked((_secondaryMetadata[i][2]))) == keccak256(abi.encodePacked(('1')))); // 1 is modifiable, 0 is permanent } collection.secondaryMetadata[collectibleCount] = Metadata({ name: propertyNames, value: propertyValues, modifiable: modifiables, propertyCount: _secondaryMetadata.length }); uint256 editions = safeParseInt(_coreData[2]); createTokenIDs(cID, collectibleCount, editions); collection.collectibleCount++; collection.totalTokenCount = collection.totalTokenCount.add(editions); emit LogAddCollectible(cID, _coreData[0]); } function checkTokensForMintPass(uint256 cID, address minter, address contractAddress) private returns (bool) { Storage storage ds = packStorage(); uint256 count = ds.collection[cID].mintPassContract.balanceOf(minter); bool done = false; uint256 counter = 0; bool canClaim = false; while (!done && count > 0) { uint256 tokenID = ds.collection[cID].mintPassContract.tokenOfOwnerByIndex(minter, counter); if (ds.collection[cID].mintPassClaims[tokenID] != true) { ds.collection[cID].mintPassClaims[tokenID] = true; done = true; canClaim = true; if (ds.collection[cID].mintPassBurn) { ds.collection[cID].mintPassContract.safeTransferFrom(msg.sender, address(0xdEaD), tokenID); } } if (counter == count - 1) done = true; else counter++; } return canClaim; } function checkMintPass(address relics, uint256 cID, address user, address contractAddress) external relicSafety(relics) returns (bool) { Storage storage ds = packStorage(); bool canMintPass = false; if (ds.collection[cID].mintPass) { if (!ds.collection[cID].mintPassOnePerWallet || !ds.collection[cID].mintPassClaimed[user]) { if (checkTokensForMintPass(cID, user, contractAddress)) { canMintPass = true; if (ds.collection[cID].mintPassOnePerWallet) ds.collection[cID].mintPassClaimed[user] = true; } } } if (ds.collection[cID].mintPassOnly) { require(canMintPass, "Minting is restricted to mint passes only"); require(block.timestamp > ds.collection[cID].saleStartTime - ds.collection[cID].mintPassDuration, "Sale has not yet started"); } else { if (canMintPass) require (block.timestamp > (ds.collection[cID].saleStartTime - ds.collection[cID].mintPassDuration), "Sale has not yet started"); else require(block.timestamp > ds.collection[cID].saleStartTime, "Sale has not yet started"); } return canMintPass; } function bulkMintChecks(uint256 cID, uint256 amount) external { Storage storage ds = packStorage(); require(amount > 0, 'Missing amount'); require(!ds.collection[cID].mintPassOnly, 'Cannot bulk mint'); require(amount <= ds.collection[cID].bulkBuyLimit, "Cannot bulk buy more than the preset limit"); require(amount <= ds.collection[cID].shuffleIDs.length, "Total supply reached"); require((block.timestamp > ds.collection[cID].saleStartTime), "Sale has not yet started"); } function mintPassClaimed(uint256 cID, uint256 tokenId) public view returns (bool) { Storage storage ds = packStorage(); return (ds.collection[cID].mintPassClaims[tokenId] == true); } function tokensClaimable(uint256 cID, address minter) public view returns (uint256[] memory) { Storage storage ds = packStorage(); uint256 count = ds.collection[cID].mintPassContract.balanceOf(minter); bool done = false; uint256 counter = 0; uint256 index = 0; uint256[] memory claimable = new uint256[](count); while (!done && count > 0) { uint256 tokenID = ds.collection[cID].mintPassContract.tokenOfOwnerByIndex(minter, counter); if (ds.collection[cID].mintPassClaims[tokenID] != true) { claimable[index] = tokenID; index++; } if (counter == count - 1) done = true; else counter++; } return claimable; } function remainingTokens(uint256 cID) public view returns (uint256) { Storage storage ds = packStorage(); return ds.collection[cID].shuffleIDs.length; } // Modify property field only if marked as updateable function updateMetadata(uint256 cID, uint256 collectibleId, uint256 propertyIndex, string memory value) external onlyDAO { Storage storage ds = packStorage(); require(ds.collection[cID].metadata[collectibleId - 1].modifiable[propertyIndex], 'Field not editable'); ds.collection[cID].metadata[collectibleId - 1].value[propertyIndex] = value; emit LogUpdateMetadata(cID, collectibleId, propertyIndex, value); } // Add new asset, does not automatically increase current version function addVersion(uint256 cID, uint256 collectibleId, string memory asset) public onlyDAO { Storage storage ds = packStorage(); ds.collection[cID].collectibles[collectibleId - 1].assets[ds.collection[cID].collectibles[collectibleId - 1].totalVersionCount - 1] = asset; ds.collection[cID].collectibles[collectibleId - 1].totalVersionCount++; emit LogAddVersion(cID, collectibleId, asset); } // Set version number, index starts at version 1, collectible 1 (so shifts 1 for 0th index) // function updateVersion(uint256 cID, uint256 collectibleId, uint256 versionNumber) public onlyDAO { // Storage storage ds = packStorage(); // require(versionNumber > 0, "Versions start at 1"); // require(versionNumber <= ds.collection[cID].collectibles[collectibleId - 1].assets.length, "Versions must be less than asset count"); // require(collectibleId > 0, "Collectible IDs start at 1"); // ds.collection[cID].collectibles[collectibleId - 1].currentVersion = versionNumber; // emit LogUpdateVersion(cID, collectibleId, versionNumber); // } // Adds new license and updates version to latest function addNewLicense(uint256 cID, string memory _license) public onlyDAO { Storage storage ds = packStorage(); require(cID < ds.collectionCount, 'Collectible ID does not exist'); ds.collection[cID].licenseURI[ds.collection[cID].licenseVersion] = _license; ds.collection[cID].licenseVersion++; emit LogAddNewLicense(cID, _license); } function getLicense(uint256 cID, uint256 versionNumber) public view returns (string memory) { Storage storage ds = packStorage(); return ds.collection[cID].licenseURI[versionNumber - 1]; } function getCurrentLicense(uint256 cID) public view returns (string memory) { Storage storage ds = packStorage(); return ds.collection[cID].licenseURI[ds.collection[cID].licenseVersion - 1]; } // Dynamic base64 encoded metadata generation using on-chain metadata and edition numbers function tokenURI(uint256 tokenId) public view returns (string memory) { Storage storage ds = packStorage(); uint256 edition = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 5, bytes(toString(tokenId)).length)) - 1; uint256 collectibleId = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 8, bytes(toString(tokenId)).length - 5)) - 1; uint256 cID = ((tokenId - ((collectibleId + 1) * 100000)) - (edition + 1)) / 100000000 - 1; string memory encodedMetadata = ''; Collection storage collection = ds.collection[cID]; for (uint i = 0; i < collection.metadata[collectibleId].propertyCount; i++) { encodedMetadata = string(abi.encodePacked( encodedMetadata, '{"trait_type":"', collection.metadata[collectibleId].name[i], '", "value":"', collection.metadata[collectibleId].value[i], '", "permanent":"', collection.metadata[collectibleId].modifiable[i] ? 'false' : 'true', '"}', i == collection.metadata[collectibleId].propertyCount - 1 ? '' : ',') ); } string memory encodedSecondaryMetadata = ''; for (uint i = 0; i < collection.secondaryMetadata[collectibleId].propertyCount; i++) { encodedSecondaryMetadata = string(abi.encodePacked( encodedSecondaryMetadata, '{"trait_type":"', collection.secondaryMetadata[collectibleId].name[i], '", "value":"', collection.secondaryMetadata[collectibleId].value[i], '", "permanent":"', collection.secondaryMetadata[collectibleId].modifiable[i] ? 'false' : 'true', '"}', i == collection.secondaryMetadata[collectibleId].propertyCount - 1 ? '' : ',') ); } SingleCollectible storage collectible = collection.collectibles[collectibleId]; uint256 asset = collectible.currentVersion - 1; string memory encoded = string( abi.encodePacked( 'data:application/json;base64,', Base64.encode( bytes( abi.encodePacked( '{"name":"', collectible.title, collection.editioned ? ' #' : '', collection.editioned ? toString(edition + 1) : '', '", "description":"', collectible.description, '", "image": "', collection.baseURI, collectible.assets[asset], '", "license": "', getCurrentLicense(cID), '", "attributes": [', encodedMetadata, '], "secondaryAttributes": [', encodedSecondaryMetadata, '] }' ) ) ) ) ); return encoded; } // Secondary sale fees apply to each individual collectible ID (will apply to a range of tokenIDs); function getFeeRecipients(uint256 tokenId) public view returns (address payable[] memory) { Storage storage ds = packStorage(); uint256 edition = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 5, bytes(toString(tokenId)).length)) - 1; uint256 collectibleId = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 8, bytes(toString(tokenId)).length - 5)) - 1; uint256 cID = ((tokenId - ((collectibleId + 1) * 100000)) - (edition + 1)) / 100000000 - 1; Fee[] memory _fees = ds.collection[cID].secondaryFees[collectibleId]; address payable[] memory result = new address payable[](_fees.length); for (uint i = 0; i < _fees.length; i++) { result[i] = _fees[i].recipient; } return result; } function getFeeBps(uint256 tokenId) public view returns (uint[] memory) { Storage storage ds = packStorage(); uint256 edition = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 5, bytes(toString(tokenId)).length)) - 1; uint256 collectibleId = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 8, bytes(toString(tokenId)).length - 5)) - 1; uint256 cID = ((tokenId - ((collectibleId + 1) * 100000)) - (edition + 1)) / 100000000 - 1; Fee[] memory _fees = ds.collection[cID].secondaryFees[collectibleId]; uint[] memory result = new uint[](_fees.length); for (uint i = 0; i < _fees.length; i++) { result[i] = _fees[i].value; } return result; } function royaltyInfo(uint256 tokenId, uint256 value) public view returns (address recipient, uint256 amount){ address payable[] memory rec = getFeeRecipients(tokenId); require(rec.length <= 1, "More than 1 royalty recipient"); if (rec.length == 0) return (address(this), 0); return (rec[0], getFeeBps(tokenId)[0] * value / 10000); } function toString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = bytes1(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } function safeParseInt(string memory _a) internal pure returns (uint _parsedInt) { return safeParseInt(_a, 0); } function safeParseInt(string memory _a, uint _b) internal pure returns (uint _parsedInt) { bytes memory bresult = bytes(_a); uint mint = 0; bool decimals = false; for (uint i = 0; i < bresult.length; i++) { if ((uint(uint8(bresult[i])) >= 48) && (uint(uint8(bresult[i])) <= 57)) { if (decimals) { if (_b == 0) break; else _b--; } mint *= 10; mint += uint(uint8(bresult[i])) - 48; } else if (uint(uint8(bresult[i])) == 46) { require(!decimals, 'More than one decimal encountered in string!'); decimals = true; } else { revert("Non-numeral character encountered in string!"); } } if (_b > 0) { mint *= 10 ** _b; } return mint; } function substring(string memory str, uint startIndex, uint endIndex) internal pure returns (string memory) { bytes memory strBytes = bytes(str); bytes memory result = new bytes(endIndex-startIndex); for(uint i = startIndex; i < endIndex; i++) { result[i-startIndex] = strBytes[i]; } return string(result); } }
addCollectible
function addCollectible(uint256 cID, string[] memory _coreData, string[] memory _assets, string[][] memory _metadataValues, string[][] memory _secondaryMetadata, Fee[] memory _fees) external onlyDAO { Storage storage ds = packStorage(); Collection storage collection = ds.collection[cID]; uint256 collectibleCount = collection.collectibleCount; uint256 sum = 0; for (uint256 i = 0; i < _fees.length; i++) { require(_fees[i].recipient != address(0x0), "Recipient should be present"); require(_fees[i].value != 0, "Fee value should be positive"); collection.secondaryFees[collectibleCount].push(Fee({ recipient: _fees[i].recipient, value: _fees[i].value })); sum = sum.add(_fees[i].value); } require(sum < 10000, "Fee should be less than 100%"); require(safeParseInt(_coreData[2]) > 0, "NFTs for given asset must be greater than 0"); require(safeParseInt(_coreData[3]) > 0 && safeParseInt(_coreData[3]) <= _assets.length, "Version cannot exceed asset count"); collection.collectibles[collectibleCount] = SingleCollectible({ title: _coreData[0], description: _coreData[1], count: safeParseInt(_coreData[2]), assets: _assets, currentVersion: safeParseInt(_coreData[3]), totalVersionCount: _assets.length }); string[] memory propertyNames = new string[](_metadataValues.length); string[] memory propertyValues = new string[](_metadataValues.length); bool[] memory modifiables = new bool[](_metadataValues.length); for (uint256 i = 0; i < _metadataValues.length; i++) { propertyNames[i] = _metadataValues[i][0]; propertyValues[i] = _metadataValues[i][1]; modifiables[i] = (keccak256(abi.encodePacked((_metadataValues[i][2]))) == keccak256(abi.encodePacked(('1')))); // 1 is modifiable, 0 is permanent } collection.metadata[collectibleCount] = Metadata({ name: propertyNames, value: propertyValues, modifiable: modifiables, propertyCount: _metadataValues.length }); propertyNames = new string[](_secondaryMetadata.length); propertyValues = new string[](_secondaryMetadata.length); modifiables = new bool[](_secondaryMetadata.length); for (uint256 i = 0; i < _secondaryMetadata.length; i++) { propertyNames[i] = _secondaryMetadata[i][0]; propertyValues[i] = _secondaryMetadata[i][1]; modifiables[i] = (keccak256(abi.encodePacked((_secondaryMetadata[i][2]))) == keccak256(abi.encodePacked(('1')))); // 1 is modifiable, 0 is permanent } collection.secondaryMetadata[collectibleCount] = Metadata({ name: propertyNames, value: propertyValues, modifiable: modifiables, propertyCount: _secondaryMetadata.length }); uint256 editions = safeParseInt(_coreData[2]); createTokenIDs(cID, collectibleCount, editions); collection.collectibleCount++; collection.totalTokenCount = collection.totalTokenCount.add(editions); emit LogAddCollectible(cID, _coreData[0]); }
// Add single collectible asset with main info and metadata properties
LineComment
v0.7.3+commit.9bfce1f6
{ "func_code_index": [ 6112, 9156 ] }
64
Packs
contracts/LibPackStorage.sol
0x1495ecbac40a69028b5d516597137de5e929b01b
Solidity
LibPackStorage
library LibPackStorage { using SafeMath for uint256; bytes32 constant STORAGE_POSITION = keccak256("com.universe.packs.storage"); struct Fee { address payable recipient; uint256 value; } struct SingleCollectible { string title; // Collectible name string description; // Collectible description uint256 count; // Amount of editions per collectible string[] assets; // Each asset in array is a version uint256 totalVersionCount; // Total number of existing states uint256 currentVersion; // Current existing state } struct Metadata { string[] name; // Trait or attribute property field name string[] value; // Trait or attribute property value bool[] modifiable; // Can owner modify the value of field uint256 propertyCount; // Tracker of total attributes } struct Collection { bool initialized; string baseURI; // Token ID base URL mapping (uint256 => SingleCollectible) collectibles; // Unique assets mapping (uint256 => Metadata) metadata; // Trait & property attributes, indexes should be coupled with 'collectibles' mapping (uint256 => Metadata) secondaryMetadata; // Trait & property attributes, indexes should be coupled with 'collectibles' mapping (uint256 => Fee[]) secondaryFees; mapping (uint256 => string) licenseURI; // URL to external license or file mapping (address => bool) mintPassClaimed; mapping (uint256 => bool) mintPassClaims; uint256 collectibleCount; // Total unique assets count uint256 totalTokenCount; // Total NFT count to be minted uint256 tokenPrice; uint256 bulkBuyLimit; uint256 saleStartTime; bool editioned; // Display edition # in token name uint256 licenseVersion; // Tracker of latest license uint64[] shuffleIDs; ERC721 mintPassContract; bool mintPass; bool mintPassOnly; bool mintPassFree; bool mintPassBurn; bool mintPassOnePerWallet; uint256 mintPassDuration; } struct Storage { address relicsAddress; address payable daoAddress; bool daoInitialized; uint256 collectionCount; mapping (uint256 => Collection) collection; } function packStorage() internal pure returns (Storage storage ds) { bytes32 position = STORAGE_POSITION; assembly { ds.slot := position } } event LogMintPack( address minter, uint256 tokenID ); event LogCreateNewCollection( uint256 index ); event LogAddCollectible( uint256 cID, string title ); event LogUpdateMetadata( uint256 cID, uint256 collectibleId, uint256 propertyIndex, string value ); event LogAddVersion( uint256 cID, uint256 collectibleId, string asset ); event LogUpdateVersion( uint256 cID, uint256 collectibleId, uint256 versionNumber ); event LogAddNewLicense( uint256 cID, string license ); function random(uint256 cID) internal view returns (uint) { return uint(keccak256(abi.encodePacked(block.difficulty, block.timestamp, packStorage().collection[cID].totalTokenCount))); } function randomTokenID(address relics, uint256 cID) external relicSafety(relics) returns (uint256, uint256) { Storage storage ds = packStorage(); uint256 randomID = random(cID) % ds.collection[cID].shuffleIDs.length; uint256 tokenID = ds.collection[cID].shuffleIDs[randomID]; emit LogMintPack(msg.sender, tokenID); return (randomID, tokenID); } modifier onlyDAO() { require(msg.sender == packStorage().daoAddress, "Wrong address"); _; } modifier relicSafety(address relics) { Storage storage ds = packStorage(); require(relics == ds.relicsAddress); _; } /** * Map token order w/ URI upon mints * Sample token ID (edition #77) with collection of 12 different assets: 1200077 */ function createTokenIDs(uint256 cID, uint256 collectibleCount, uint256 editions) private { Storage storage ds = packStorage(); for (uint256 i = 0; i < editions; i++) { uint64 tokenID = uint64((cID + 1) * 100000000) + uint64((collectibleCount + 1) * 100000) + uint64(i + 1); ds.collection[cID].shuffleIDs.push(tokenID); } } function createNewCollection( string memory _baseURI, bool _editioned, uint256[] memory _initParams, string memory _licenseURI, address _mintPass, uint256 _mintPassDuration, bool[] memory _mintPassParams ) external onlyDAO { require(_initParams[1] <= 50, "Bulk buy limit of 50"); Storage storage ds = packStorage(); ds.collection[ds.collectionCount].baseURI = _baseURI; ds.collection[ds.collectionCount].editioned = _editioned; ds.collection[ds.collectionCount].tokenPrice = _initParams[0]; ds.collection[ds.collectionCount].bulkBuyLimit = _initParams[1]; ds.collection[ds.collectionCount].saleStartTime = _initParams[2]; ds.collection[ds.collectionCount].licenseURI[0] = _licenseURI; ds.collection[ds.collectionCount].licenseVersion = 1; if (_mintPass != address(0)) { ds.collection[ds.collectionCount].mintPass = true; ds.collection[ds.collectionCount].mintPassContract = ERC721(_mintPass); ds.collection[ds.collectionCount].mintPassDuration = _mintPassDuration; ds.collection[ds.collectionCount].mintPassOnePerWallet = _mintPassParams[0]; ds.collection[ds.collectionCount].mintPassOnly = _mintPassParams[1]; ds.collection[ds.collectionCount].mintPassFree = _mintPassParams[2]; ds.collection[ds.collectionCount].mintPassBurn = _mintPassParams[3]; } else { ds.collection[ds.collectionCount].mintPass = false; ds.collection[ds.collectionCount].mintPassDuration = 0; ds.collection[ds.collectionCount].mintPassOnePerWallet = false; ds.collection[ds.collectionCount].mintPassOnly = false; ds.collection[ds.collectionCount].mintPassFree = false; ds.collection[ds.collectionCount].mintPassBurn = false; } ds.collectionCount++; emit LogCreateNewCollection(ds.collectionCount); } // Add single collectible asset with main info and metadata properties function addCollectible(uint256 cID, string[] memory _coreData, string[] memory _assets, string[][] memory _metadataValues, string[][] memory _secondaryMetadata, Fee[] memory _fees) external onlyDAO { Storage storage ds = packStorage(); Collection storage collection = ds.collection[cID]; uint256 collectibleCount = collection.collectibleCount; uint256 sum = 0; for (uint256 i = 0; i < _fees.length; i++) { require(_fees[i].recipient != address(0x0), "Recipient should be present"); require(_fees[i].value != 0, "Fee value should be positive"); collection.secondaryFees[collectibleCount].push(Fee({ recipient: _fees[i].recipient, value: _fees[i].value })); sum = sum.add(_fees[i].value); } require(sum < 10000, "Fee should be less than 100%"); require(safeParseInt(_coreData[2]) > 0, "NFTs for given asset must be greater than 0"); require(safeParseInt(_coreData[3]) > 0 && safeParseInt(_coreData[3]) <= _assets.length, "Version cannot exceed asset count"); collection.collectibles[collectibleCount] = SingleCollectible({ title: _coreData[0], description: _coreData[1], count: safeParseInt(_coreData[2]), assets: _assets, currentVersion: safeParseInt(_coreData[3]), totalVersionCount: _assets.length }); string[] memory propertyNames = new string[](_metadataValues.length); string[] memory propertyValues = new string[](_metadataValues.length); bool[] memory modifiables = new bool[](_metadataValues.length); for (uint256 i = 0; i < _metadataValues.length; i++) { propertyNames[i] = _metadataValues[i][0]; propertyValues[i] = _metadataValues[i][1]; modifiables[i] = (keccak256(abi.encodePacked((_metadataValues[i][2]))) == keccak256(abi.encodePacked(('1')))); // 1 is modifiable, 0 is permanent } collection.metadata[collectibleCount] = Metadata({ name: propertyNames, value: propertyValues, modifiable: modifiables, propertyCount: _metadataValues.length }); propertyNames = new string[](_secondaryMetadata.length); propertyValues = new string[](_secondaryMetadata.length); modifiables = new bool[](_secondaryMetadata.length); for (uint256 i = 0; i < _secondaryMetadata.length; i++) { propertyNames[i] = _secondaryMetadata[i][0]; propertyValues[i] = _secondaryMetadata[i][1]; modifiables[i] = (keccak256(abi.encodePacked((_secondaryMetadata[i][2]))) == keccak256(abi.encodePacked(('1')))); // 1 is modifiable, 0 is permanent } collection.secondaryMetadata[collectibleCount] = Metadata({ name: propertyNames, value: propertyValues, modifiable: modifiables, propertyCount: _secondaryMetadata.length }); uint256 editions = safeParseInt(_coreData[2]); createTokenIDs(cID, collectibleCount, editions); collection.collectibleCount++; collection.totalTokenCount = collection.totalTokenCount.add(editions); emit LogAddCollectible(cID, _coreData[0]); } function checkTokensForMintPass(uint256 cID, address minter, address contractAddress) private returns (bool) { Storage storage ds = packStorage(); uint256 count = ds.collection[cID].mintPassContract.balanceOf(minter); bool done = false; uint256 counter = 0; bool canClaim = false; while (!done && count > 0) { uint256 tokenID = ds.collection[cID].mintPassContract.tokenOfOwnerByIndex(minter, counter); if (ds.collection[cID].mintPassClaims[tokenID] != true) { ds.collection[cID].mintPassClaims[tokenID] = true; done = true; canClaim = true; if (ds.collection[cID].mintPassBurn) { ds.collection[cID].mintPassContract.safeTransferFrom(msg.sender, address(0xdEaD), tokenID); } } if (counter == count - 1) done = true; else counter++; } return canClaim; } function checkMintPass(address relics, uint256 cID, address user, address contractAddress) external relicSafety(relics) returns (bool) { Storage storage ds = packStorage(); bool canMintPass = false; if (ds.collection[cID].mintPass) { if (!ds.collection[cID].mintPassOnePerWallet || !ds.collection[cID].mintPassClaimed[user]) { if (checkTokensForMintPass(cID, user, contractAddress)) { canMintPass = true; if (ds.collection[cID].mintPassOnePerWallet) ds.collection[cID].mintPassClaimed[user] = true; } } } if (ds.collection[cID].mintPassOnly) { require(canMintPass, "Minting is restricted to mint passes only"); require(block.timestamp > ds.collection[cID].saleStartTime - ds.collection[cID].mintPassDuration, "Sale has not yet started"); } else { if (canMintPass) require (block.timestamp > (ds.collection[cID].saleStartTime - ds.collection[cID].mintPassDuration), "Sale has not yet started"); else require(block.timestamp > ds.collection[cID].saleStartTime, "Sale has not yet started"); } return canMintPass; } function bulkMintChecks(uint256 cID, uint256 amount) external { Storage storage ds = packStorage(); require(amount > 0, 'Missing amount'); require(!ds.collection[cID].mintPassOnly, 'Cannot bulk mint'); require(amount <= ds.collection[cID].bulkBuyLimit, "Cannot bulk buy more than the preset limit"); require(amount <= ds.collection[cID].shuffleIDs.length, "Total supply reached"); require((block.timestamp > ds.collection[cID].saleStartTime), "Sale has not yet started"); } function mintPassClaimed(uint256 cID, uint256 tokenId) public view returns (bool) { Storage storage ds = packStorage(); return (ds.collection[cID].mintPassClaims[tokenId] == true); } function tokensClaimable(uint256 cID, address minter) public view returns (uint256[] memory) { Storage storage ds = packStorage(); uint256 count = ds.collection[cID].mintPassContract.balanceOf(minter); bool done = false; uint256 counter = 0; uint256 index = 0; uint256[] memory claimable = new uint256[](count); while (!done && count > 0) { uint256 tokenID = ds.collection[cID].mintPassContract.tokenOfOwnerByIndex(minter, counter); if (ds.collection[cID].mintPassClaims[tokenID] != true) { claimable[index] = tokenID; index++; } if (counter == count - 1) done = true; else counter++; } return claimable; } function remainingTokens(uint256 cID) public view returns (uint256) { Storage storage ds = packStorage(); return ds.collection[cID].shuffleIDs.length; } // Modify property field only if marked as updateable function updateMetadata(uint256 cID, uint256 collectibleId, uint256 propertyIndex, string memory value) external onlyDAO { Storage storage ds = packStorage(); require(ds.collection[cID].metadata[collectibleId - 1].modifiable[propertyIndex], 'Field not editable'); ds.collection[cID].metadata[collectibleId - 1].value[propertyIndex] = value; emit LogUpdateMetadata(cID, collectibleId, propertyIndex, value); } // Add new asset, does not automatically increase current version function addVersion(uint256 cID, uint256 collectibleId, string memory asset) public onlyDAO { Storage storage ds = packStorage(); ds.collection[cID].collectibles[collectibleId - 1].assets[ds.collection[cID].collectibles[collectibleId - 1].totalVersionCount - 1] = asset; ds.collection[cID].collectibles[collectibleId - 1].totalVersionCount++; emit LogAddVersion(cID, collectibleId, asset); } // Set version number, index starts at version 1, collectible 1 (so shifts 1 for 0th index) // function updateVersion(uint256 cID, uint256 collectibleId, uint256 versionNumber) public onlyDAO { // Storage storage ds = packStorage(); // require(versionNumber > 0, "Versions start at 1"); // require(versionNumber <= ds.collection[cID].collectibles[collectibleId - 1].assets.length, "Versions must be less than asset count"); // require(collectibleId > 0, "Collectible IDs start at 1"); // ds.collection[cID].collectibles[collectibleId - 1].currentVersion = versionNumber; // emit LogUpdateVersion(cID, collectibleId, versionNumber); // } // Adds new license and updates version to latest function addNewLicense(uint256 cID, string memory _license) public onlyDAO { Storage storage ds = packStorage(); require(cID < ds.collectionCount, 'Collectible ID does not exist'); ds.collection[cID].licenseURI[ds.collection[cID].licenseVersion] = _license; ds.collection[cID].licenseVersion++; emit LogAddNewLicense(cID, _license); } function getLicense(uint256 cID, uint256 versionNumber) public view returns (string memory) { Storage storage ds = packStorage(); return ds.collection[cID].licenseURI[versionNumber - 1]; } function getCurrentLicense(uint256 cID) public view returns (string memory) { Storage storage ds = packStorage(); return ds.collection[cID].licenseURI[ds.collection[cID].licenseVersion - 1]; } // Dynamic base64 encoded metadata generation using on-chain metadata and edition numbers function tokenURI(uint256 tokenId) public view returns (string memory) { Storage storage ds = packStorage(); uint256 edition = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 5, bytes(toString(tokenId)).length)) - 1; uint256 collectibleId = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 8, bytes(toString(tokenId)).length - 5)) - 1; uint256 cID = ((tokenId - ((collectibleId + 1) * 100000)) - (edition + 1)) / 100000000 - 1; string memory encodedMetadata = ''; Collection storage collection = ds.collection[cID]; for (uint i = 0; i < collection.metadata[collectibleId].propertyCount; i++) { encodedMetadata = string(abi.encodePacked( encodedMetadata, '{"trait_type":"', collection.metadata[collectibleId].name[i], '", "value":"', collection.metadata[collectibleId].value[i], '", "permanent":"', collection.metadata[collectibleId].modifiable[i] ? 'false' : 'true', '"}', i == collection.metadata[collectibleId].propertyCount - 1 ? '' : ',') ); } string memory encodedSecondaryMetadata = ''; for (uint i = 0; i < collection.secondaryMetadata[collectibleId].propertyCount; i++) { encodedSecondaryMetadata = string(abi.encodePacked( encodedSecondaryMetadata, '{"trait_type":"', collection.secondaryMetadata[collectibleId].name[i], '", "value":"', collection.secondaryMetadata[collectibleId].value[i], '", "permanent":"', collection.secondaryMetadata[collectibleId].modifiable[i] ? 'false' : 'true', '"}', i == collection.secondaryMetadata[collectibleId].propertyCount - 1 ? '' : ',') ); } SingleCollectible storage collectible = collection.collectibles[collectibleId]; uint256 asset = collectible.currentVersion - 1; string memory encoded = string( abi.encodePacked( 'data:application/json;base64,', Base64.encode( bytes( abi.encodePacked( '{"name":"', collectible.title, collection.editioned ? ' #' : '', collection.editioned ? toString(edition + 1) : '', '", "description":"', collectible.description, '", "image": "', collection.baseURI, collectible.assets[asset], '", "license": "', getCurrentLicense(cID), '", "attributes": [', encodedMetadata, '], "secondaryAttributes": [', encodedSecondaryMetadata, '] }' ) ) ) ) ); return encoded; } // Secondary sale fees apply to each individual collectible ID (will apply to a range of tokenIDs); function getFeeRecipients(uint256 tokenId) public view returns (address payable[] memory) { Storage storage ds = packStorage(); uint256 edition = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 5, bytes(toString(tokenId)).length)) - 1; uint256 collectibleId = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 8, bytes(toString(tokenId)).length - 5)) - 1; uint256 cID = ((tokenId - ((collectibleId + 1) * 100000)) - (edition + 1)) / 100000000 - 1; Fee[] memory _fees = ds.collection[cID].secondaryFees[collectibleId]; address payable[] memory result = new address payable[](_fees.length); for (uint i = 0; i < _fees.length; i++) { result[i] = _fees[i].recipient; } return result; } function getFeeBps(uint256 tokenId) public view returns (uint[] memory) { Storage storage ds = packStorage(); uint256 edition = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 5, bytes(toString(tokenId)).length)) - 1; uint256 collectibleId = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 8, bytes(toString(tokenId)).length - 5)) - 1; uint256 cID = ((tokenId - ((collectibleId + 1) * 100000)) - (edition + 1)) / 100000000 - 1; Fee[] memory _fees = ds.collection[cID].secondaryFees[collectibleId]; uint[] memory result = new uint[](_fees.length); for (uint i = 0; i < _fees.length; i++) { result[i] = _fees[i].value; } return result; } function royaltyInfo(uint256 tokenId, uint256 value) public view returns (address recipient, uint256 amount){ address payable[] memory rec = getFeeRecipients(tokenId); require(rec.length <= 1, "More than 1 royalty recipient"); if (rec.length == 0) return (address(this), 0); return (rec[0], getFeeBps(tokenId)[0] * value / 10000); } function toString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = bytes1(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } function safeParseInt(string memory _a) internal pure returns (uint _parsedInt) { return safeParseInt(_a, 0); } function safeParseInt(string memory _a, uint _b) internal pure returns (uint _parsedInt) { bytes memory bresult = bytes(_a); uint mint = 0; bool decimals = false; for (uint i = 0; i < bresult.length; i++) { if ((uint(uint8(bresult[i])) >= 48) && (uint(uint8(bresult[i])) <= 57)) { if (decimals) { if (_b == 0) break; else _b--; } mint *= 10; mint += uint(uint8(bresult[i])) - 48; } else if (uint(uint8(bresult[i])) == 46) { require(!decimals, 'More than one decimal encountered in string!'); decimals = true; } else { revert("Non-numeral character encountered in string!"); } } if (_b > 0) { mint *= 10 ** _b; } return mint; } function substring(string memory str, uint startIndex, uint endIndex) internal pure returns (string memory) { bytes memory strBytes = bytes(str); bytes memory result = new bytes(endIndex-startIndex); for(uint i = startIndex; i < endIndex; i++) { result[i-startIndex] = strBytes[i]; } return string(result); } }
updateMetadata
function updateMetadata(uint256 cID, uint256 collectibleId, uint256 propertyIndex, string memory value) external onlyDAO { Storage storage ds = packStorage(); require(ds.collection[cID].metadata[collectibleId - 1].modifiable[propertyIndex], 'Field not editable'); ds.collection[cID].metadata[collectibleId - 1].value[propertyIndex] = value; emit LogUpdateMetadata(cID, collectibleId, propertyIndex, value); }
// Modify property field only if marked as updateable
LineComment
v0.7.3+commit.9bfce1f6
{ "func_code_index": [ 12772, 13200 ] }
65
Packs
contracts/LibPackStorage.sol
0x1495ecbac40a69028b5d516597137de5e929b01b
Solidity
LibPackStorage
library LibPackStorage { using SafeMath for uint256; bytes32 constant STORAGE_POSITION = keccak256("com.universe.packs.storage"); struct Fee { address payable recipient; uint256 value; } struct SingleCollectible { string title; // Collectible name string description; // Collectible description uint256 count; // Amount of editions per collectible string[] assets; // Each asset in array is a version uint256 totalVersionCount; // Total number of existing states uint256 currentVersion; // Current existing state } struct Metadata { string[] name; // Trait or attribute property field name string[] value; // Trait or attribute property value bool[] modifiable; // Can owner modify the value of field uint256 propertyCount; // Tracker of total attributes } struct Collection { bool initialized; string baseURI; // Token ID base URL mapping (uint256 => SingleCollectible) collectibles; // Unique assets mapping (uint256 => Metadata) metadata; // Trait & property attributes, indexes should be coupled with 'collectibles' mapping (uint256 => Metadata) secondaryMetadata; // Trait & property attributes, indexes should be coupled with 'collectibles' mapping (uint256 => Fee[]) secondaryFees; mapping (uint256 => string) licenseURI; // URL to external license or file mapping (address => bool) mintPassClaimed; mapping (uint256 => bool) mintPassClaims; uint256 collectibleCount; // Total unique assets count uint256 totalTokenCount; // Total NFT count to be minted uint256 tokenPrice; uint256 bulkBuyLimit; uint256 saleStartTime; bool editioned; // Display edition # in token name uint256 licenseVersion; // Tracker of latest license uint64[] shuffleIDs; ERC721 mintPassContract; bool mintPass; bool mintPassOnly; bool mintPassFree; bool mintPassBurn; bool mintPassOnePerWallet; uint256 mintPassDuration; } struct Storage { address relicsAddress; address payable daoAddress; bool daoInitialized; uint256 collectionCount; mapping (uint256 => Collection) collection; } function packStorage() internal pure returns (Storage storage ds) { bytes32 position = STORAGE_POSITION; assembly { ds.slot := position } } event LogMintPack( address minter, uint256 tokenID ); event LogCreateNewCollection( uint256 index ); event LogAddCollectible( uint256 cID, string title ); event LogUpdateMetadata( uint256 cID, uint256 collectibleId, uint256 propertyIndex, string value ); event LogAddVersion( uint256 cID, uint256 collectibleId, string asset ); event LogUpdateVersion( uint256 cID, uint256 collectibleId, uint256 versionNumber ); event LogAddNewLicense( uint256 cID, string license ); function random(uint256 cID) internal view returns (uint) { return uint(keccak256(abi.encodePacked(block.difficulty, block.timestamp, packStorage().collection[cID].totalTokenCount))); } function randomTokenID(address relics, uint256 cID) external relicSafety(relics) returns (uint256, uint256) { Storage storage ds = packStorage(); uint256 randomID = random(cID) % ds.collection[cID].shuffleIDs.length; uint256 tokenID = ds.collection[cID].shuffleIDs[randomID]; emit LogMintPack(msg.sender, tokenID); return (randomID, tokenID); } modifier onlyDAO() { require(msg.sender == packStorage().daoAddress, "Wrong address"); _; } modifier relicSafety(address relics) { Storage storage ds = packStorage(); require(relics == ds.relicsAddress); _; } /** * Map token order w/ URI upon mints * Sample token ID (edition #77) with collection of 12 different assets: 1200077 */ function createTokenIDs(uint256 cID, uint256 collectibleCount, uint256 editions) private { Storage storage ds = packStorage(); for (uint256 i = 0; i < editions; i++) { uint64 tokenID = uint64((cID + 1) * 100000000) + uint64((collectibleCount + 1) * 100000) + uint64(i + 1); ds.collection[cID].shuffleIDs.push(tokenID); } } function createNewCollection( string memory _baseURI, bool _editioned, uint256[] memory _initParams, string memory _licenseURI, address _mintPass, uint256 _mintPassDuration, bool[] memory _mintPassParams ) external onlyDAO { require(_initParams[1] <= 50, "Bulk buy limit of 50"); Storage storage ds = packStorage(); ds.collection[ds.collectionCount].baseURI = _baseURI; ds.collection[ds.collectionCount].editioned = _editioned; ds.collection[ds.collectionCount].tokenPrice = _initParams[0]; ds.collection[ds.collectionCount].bulkBuyLimit = _initParams[1]; ds.collection[ds.collectionCount].saleStartTime = _initParams[2]; ds.collection[ds.collectionCount].licenseURI[0] = _licenseURI; ds.collection[ds.collectionCount].licenseVersion = 1; if (_mintPass != address(0)) { ds.collection[ds.collectionCount].mintPass = true; ds.collection[ds.collectionCount].mintPassContract = ERC721(_mintPass); ds.collection[ds.collectionCount].mintPassDuration = _mintPassDuration; ds.collection[ds.collectionCount].mintPassOnePerWallet = _mintPassParams[0]; ds.collection[ds.collectionCount].mintPassOnly = _mintPassParams[1]; ds.collection[ds.collectionCount].mintPassFree = _mintPassParams[2]; ds.collection[ds.collectionCount].mintPassBurn = _mintPassParams[3]; } else { ds.collection[ds.collectionCount].mintPass = false; ds.collection[ds.collectionCount].mintPassDuration = 0; ds.collection[ds.collectionCount].mintPassOnePerWallet = false; ds.collection[ds.collectionCount].mintPassOnly = false; ds.collection[ds.collectionCount].mintPassFree = false; ds.collection[ds.collectionCount].mintPassBurn = false; } ds.collectionCount++; emit LogCreateNewCollection(ds.collectionCount); } // Add single collectible asset with main info and metadata properties function addCollectible(uint256 cID, string[] memory _coreData, string[] memory _assets, string[][] memory _metadataValues, string[][] memory _secondaryMetadata, Fee[] memory _fees) external onlyDAO { Storage storage ds = packStorage(); Collection storage collection = ds.collection[cID]; uint256 collectibleCount = collection.collectibleCount; uint256 sum = 0; for (uint256 i = 0; i < _fees.length; i++) { require(_fees[i].recipient != address(0x0), "Recipient should be present"); require(_fees[i].value != 0, "Fee value should be positive"); collection.secondaryFees[collectibleCount].push(Fee({ recipient: _fees[i].recipient, value: _fees[i].value })); sum = sum.add(_fees[i].value); } require(sum < 10000, "Fee should be less than 100%"); require(safeParseInt(_coreData[2]) > 0, "NFTs for given asset must be greater than 0"); require(safeParseInt(_coreData[3]) > 0 && safeParseInt(_coreData[3]) <= _assets.length, "Version cannot exceed asset count"); collection.collectibles[collectibleCount] = SingleCollectible({ title: _coreData[0], description: _coreData[1], count: safeParseInt(_coreData[2]), assets: _assets, currentVersion: safeParseInt(_coreData[3]), totalVersionCount: _assets.length }); string[] memory propertyNames = new string[](_metadataValues.length); string[] memory propertyValues = new string[](_metadataValues.length); bool[] memory modifiables = new bool[](_metadataValues.length); for (uint256 i = 0; i < _metadataValues.length; i++) { propertyNames[i] = _metadataValues[i][0]; propertyValues[i] = _metadataValues[i][1]; modifiables[i] = (keccak256(abi.encodePacked((_metadataValues[i][2]))) == keccak256(abi.encodePacked(('1')))); // 1 is modifiable, 0 is permanent } collection.metadata[collectibleCount] = Metadata({ name: propertyNames, value: propertyValues, modifiable: modifiables, propertyCount: _metadataValues.length }); propertyNames = new string[](_secondaryMetadata.length); propertyValues = new string[](_secondaryMetadata.length); modifiables = new bool[](_secondaryMetadata.length); for (uint256 i = 0; i < _secondaryMetadata.length; i++) { propertyNames[i] = _secondaryMetadata[i][0]; propertyValues[i] = _secondaryMetadata[i][1]; modifiables[i] = (keccak256(abi.encodePacked((_secondaryMetadata[i][2]))) == keccak256(abi.encodePacked(('1')))); // 1 is modifiable, 0 is permanent } collection.secondaryMetadata[collectibleCount] = Metadata({ name: propertyNames, value: propertyValues, modifiable: modifiables, propertyCount: _secondaryMetadata.length }); uint256 editions = safeParseInt(_coreData[2]); createTokenIDs(cID, collectibleCount, editions); collection.collectibleCount++; collection.totalTokenCount = collection.totalTokenCount.add(editions); emit LogAddCollectible(cID, _coreData[0]); } function checkTokensForMintPass(uint256 cID, address minter, address contractAddress) private returns (bool) { Storage storage ds = packStorage(); uint256 count = ds.collection[cID].mintPassContract.balanceOf(minter); bool done = false; uint256 counter = 0; bool canClaim = false; while (!done && count > 0) { uint256 tokenID = ds.collection[cID].mintPassContract.tokenOfOwnerByIndex(minter, counter); if (ds.collection[cID].mintPassClaims[tokenID] != true) { ds.collection[cID].mintPassClaims[tokenID] = true; done = true; canClaim = true; if (ds.collection[cID].mintPassBurn) { ds.collection[cID].mintPassContract.safeTransferFrom(msg.sender, address(0xdEaD), tokenID); } } if (counter == count - 1) done = true; else counter++; } return canClaim; } function checkMintPass(address relics, uint256 cID, address user, address contractAddress) external relicSafety(relics) returns (bool) { Storage storage ds = packStorage(); bool canMintPass = false; if (ds.collection[cID].mintPass) { if (!ds.collection[cID].mintPassOnePerWallet || !ds.collection[cID].mintPassClaimed[user]) { if (checkTokensForMintPass(cID, user, contractAddress)) { canMintPass = true; if (ds.collection[cID].mintPassOnePerWallet) ds.collection[cID].mintPassClaimed[user] = true; } } } if (ds.collection[cID].mintPassOnly) { require(canMintPass, "Minting is restricted to mint passes only"); require(block.timestamp > ds.collection[cID].saleStartTime - ds.collection[cID].mintPassDuration, "Sale has not yet started"); } else { if (canMintPass) require (block.timestamp > (ds.collection[cID].saleStartTime - ds.collection[cID].mintPassDuration), "Sale has not yet started"); else require(block.timestamp > ds.collection[cID].saleStartTime, "Sale has not yet started"); } return canMintPass; } function bulkMintChecks(uint256 cID, uint256 amount) external { Storage storage ds = packStorage(); require(amount > 0, 'Missing amount'); require(!ds.collection[cID].mintPassOnly, 'Cannot bulk mint'); require(amount <= ds.collection[cID].bulkBuyLimit, "Cannot bulk buy more than the preset limit"); require(amount <= ds.collection[cID].shuffleIDs.length, "Total supply reached"); require((block.timestamp > ds.collection[cID].saleStartTime), "Sale has not yet started"); } function mintPassClaimed(uint256 cID, uint256 tokenId) public view returns (bool) { Storage storage ds = packStorage(); return (ds.collection[cID].mintPassClaims[tokenId] == true); } function tokensClaimable(uint256 cID, address minter) public view returns (uint256[] memory) { Storage storage ds = packStorage(); uint256 count = ds.collection[cID].mintPassContract.balanceOf(minter); bool done = false; uint256 counter = 0; uint256 index = 0; uint256[] memory claimable = new uint256[](count); while (!done && count > 0) { uint256 tokenID = ds.collection[cID].mintPassContract.tokenOfOwnerByIndex(minter, counter); if (ds.collection[cID].mintPassClaims[tokenID] != true) { claimable[index] = tokenID; index++; } if (counter == count - 1) done = true; else counter++; } return claimable; } function remainingTokens(uint256 cID) public view returns (uint256) { Storage storage ds = packStorage(); return ds.collection[cID].shuffleIDs.length; } // Modify property field only if marked as updateable function updateMetadata(uint256 cID, uint256 collectibleId, uint256 propertyIndex, string memory value) external onlyDAO { Storage storage ds = packStorage(); require(ds.collection[cID].metadata[collectibleId - 1].modifiable[propertyIndex], 'Field not editable'); ds.collection[cID].metadata[collectibleId - 1].value[propertyIndex] = value; emit LogUpdateMetadata(cID, collectibleId, propertyIndex, value); } // Add new asset, does not automatically increase current version function addVersion(uint256 cID, uint256 collectibleId, string memory asset) public onlyDAO { Storage storage ds = packStorage(); ds.collection[cID].collectibles[collectibleId - 1].assets[ds.collection[cID].collectibles[collectibleId - 1].totalVersionCount - 1] = asset; ds.collection[cID].collectibles[collectibleId - 1].totalVersionCount++; emit LogAddVersion(cID, collectibleId, asset); } // Set version number, index starts at version 1, collectible 1 (so shifts 1 for 0th index) // function updateVersion(uint256 cID, uint256 collectibleId, uint256 versionNumber) public onlyDAO { // Storage storage ds = packStorage(); // require(versionNumber > 0, "Versions start at 1"); // require(versionNumber <= ds.collection[cID].collectibles[collectibleId - 1].assets.length, "Versions must be less than asset count"); // require(collectibleId > 0, "Collectible IDs start at 1"); // ds.collection[cID].collectibles[collectibleId - 1].currentVersion = versionNumber; // emit LogUpdateVersion(cID, collectibleId, versionNumber); // } // Adds new license and updates version to latest function addNewLicense(uint256 cID, string memory _license) public onlyDAO { Storage storage ds = packStorage(); require(cID < ds.collectionCount, 'Collectible ID does not exist'); ds.collection[cID].licenseURI[ds.collection[cID].licenseVersion] = _license; ds.collection[cID].licenseVersion++; emit LogAddNewLicense(cID, _license); } function getLicense(uint256 cID, uint256 versionNumber) public view returns (string memory) { Storage storage ds = packStorage(); return ds.collection[cID].licenseURI[versionNumber - 1]; } function getCurrentLicense(uint256 cID) public view returns (string memory) { Storage storage ds = packStorage(); return ds.collection[cID].licenseURI[ds.collection[cID].licenseVersion - 1]; } // Dynamic base64 encoded metadata generation using on-chain metadata and edition numbers function tokenURI(uint256 tokenId) public view returns (string memory) { Storage storage ds = packStorage(); uint256 edition = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 5, bytes(toString(tokenId)).length)) - 1; uint256 collectibleId = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 8, bytes(toString(tokenId)).length - 5)) - 1; uint256 cID = ((tokenId - ((collectibleId + 1) * 100000)) - (edition + 1)) / 100000000 - 1; string memory encodedMetadata = ''; Collection storage collection = ds.collection[cID]; for (uint i = 0; i < collection.metadata[collectibleId].propertyCount; i++) { encodedMetadata = string(abi.encodePacked( encodedMetadata, '{"trait_type":"', collection.metadata[collectibleId].name[i], '", "value":"', collection.metadata[collectibleId].value[i], '", "permanent":"', collection.metadata[collectibleId].modifiable[i] ? 'false' : 'true', '"}', i == collection.metadata[collectibleId].propertyCount - 1 ? '' : ',') ); } string memory encodedSecondaryMetadata = ''; for (uint i = 0; i < collection.secondaryMetadata[collectibleId].propertyCount; i++) { encodedSecondaryMetadata = string(abi.encodePacked( encodedSecondaryMetadata, '{"trait_type":"', collection.secondaryMetadata[collectibleId].name[i], '", "value":"', collection.secondaryMetadata[collectibleId].value[i], '", "permanent":"', collection.secondaryMetadata[collectibleId].modifiable[i] ? 'false' : 'true', '"}', i == collection.secondaryMetadata[collectibleId].propertyCount - 1 ? '' : ',') ); } SingleCollectible storage collectible = collection.collectibles[collectibleId]; uint256 asset = collectible.currentVersion - 1; string memory encoded = string( abi.encodePacked( 'data:application/json;base64,', Base64.encode( bytes( abi.encodePacked( '{"name":"', collectible.title, collection.editioned ? ' #' : '', collection.editioned ? toString(edition + 1) : '', '", "description":"', collectible.description, '", "image": "', collection.baseURI, collectible.assets[asset], '", "license": "', getCurrentLicense(cID), '", "attributes": [', encodedMetadata, '], "secondaryAttributes": [', encodedSecondaryMetadata, '] }' ) ) ) ) ); return encoded; } // Secondary sale fees apply to each individual collectible ID (will apply to a range of tokenIDs); function getFeeRecipients(uint256 tokenId) public view returns (address payable[] memory) { Storage storage ds = packStorage(); uint256 edition = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 5, bytes(toString(tokenId)).length)) - 1; uint256 collectibleId = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 8, bytes(toString(tokenId)).length - 5)) - 1; uint256 cID = ((tokenId - ((collectibleId + 1) * 100000)) - (edition + 1)) / 100000000 - 1; Fee[] memory _fees = ds.collection[cID].secondaryFees[collectibleId]; address payable[] memory result = new address payable[](_fees.length); for (uint i = 0; i < _fees.length; i++) { result[i] = _fees[i].recipient; } return result; } function getFeeBps(uint256 tokenId) public view returns (uint[] memory) { Storage storage ds = packStorage(); uint256 edition = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 5, bytes(toString(tokenId)).length)) - 1; uint256 collectibleId = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 8, bytes(toString(tokenId)).length - 5)) - 1; uint256 cID = ((tokenId - ((collectibleId + 1) * 100000)) - (edition + 1)) / 100000000 - 1; Fee[] memory _fees = ds.collection[cID].secondaryFees[collectibleId]; uint[] memory result = new uint[](_fees.length); for (uint i = 0; i < _fees.length; i++) { result[i] = _fees[i].value; } return result; } function royaltyInfo(uint256 tokenId, uint256 value) public view returns (address recipient, uint256 amount){ address payable[] memory rec = getFeeRecipients(tokenId); require(rec.length <= 1, "More than 1 royalty recipient"); if (rec.length == 0) return (address(this), 0); return (rec[0], getFeeBps(tokenId)[0] * value / 10000); } function toString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = bytes1(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } function safeParseInt(string memory _a) internal pure returns (uint _parsedInt) { return safeParseInt(_a, 0); } function safeParseInt(string memory _a, uint _b) internal pure returns (uint _parsedInt) { bytes memory bresult = bytes(_a); uint mint = 0; bool decimals = false; for (uint i = 0; i < bresult.length; i++) { if ((uint(uint8(bresult[i])) >= 48) && (uint(uint8(bresult[i])) <= 57)) { if (decimals) { if (_b == 0) break; else _b--; } mint *= 10; mint += uint(uint8(bresult[i])) - 48; } else if (uint(uint8(bresult[i])) == 46) { require(!decimals, 'More than one decimal encountered in string!'); decimals = true; } else { revert("Non-numeral character encountered in string!"); } } if (_b > 0) { mint *= 10 ** _b; } return mint; } function substring(string memory str, uint startIndex, uint endIndex) internal pure returns (string memory) { bytes memory strBytes = bytes(str); bytes memory result = new bytes(endIndex-startIndex); for(uint i = startIndex; i < endIndex; i++) { result[i-startIndex] = strBytes[i]; } return string(result); } }
addVersion
function addVersion(uint256 cID, uint256 collectibleId, string memory asset) public onlyDAO { Storage storage ds = packStorage(); ds.collection[cID].collectibles[collectibleId - 1].assets[ds.collection[cID].collectibles[collectibleId - 1].totalVersionCount - 1] = asset; ds.collection[cID].collectibles[collectibleId - 1].totalVersionCount++; emit LogAddVersion(cID, collectibleId, asset); }
// Add new asset, does not automatically increase current version
LineComment
v0.7.3+commit.9bfce1f6
{ "func_code_index": [ 13270, 13681 ] }
66
Packs
contracts/LibPackStorage.sol
0x1495ecbac40a69028b5d516597137de5e929b01b
Solidity
LibPackStorage
library LibPackStorage { using SafeMath for uint256; bytes32 constant STORAGE_POSITION = keccak256("com.universe.packs.storage"); struct Fee { address payable recipient; uint256 value; } struct SingleCollectible { string title; // Collectible name string description; // Collectible description uint256 count; // Amount of editions per collectible string[] assets; // Each asset in array is a version uint256 totalVersionCount; // Total number of existing states uint256 currentVersion; // Current existing state } struct Metadata { string[] name; // Trait or attribute property field name string[] value; // Trait or attribute property value bool[] modifiable; // Can owner modify the value of field uint256 propertyCount; // Tracker of total attributes } struct Collection { bool initialized; string baseURI; // Token ID base URL mapping (uint256 => SingleCollectible) collectibles; // Unique assets mapping (uint256 => Metadata) metadata; // Trait & property attributes, indexes should be coupled with 'collectibles' mapping (uint256 => Metadata) secondaryMetadata; // Trait & property attributes, indexes should be coupled with 'collectibles' mapping (uint256 => Fee[]) secondaryFees; mapping (uint256 => string) licenseURI; // URL to external license or file mapping (address => bool) mintPassClaimed; mapping (uint256 => bool) mintPassClaims; uint256 collectibleCount; // Total unique assets count uint256 totalTokenCount; // Total NFT count to be minted uint256 tokenPrice; uint256 bulkBuyLimit; uint256 saleStartTime; bool editioned; // Display edition # in token name uint256 licenseVersion; // Tracker of latest license uint64[] shuffleIDs; ERC721 mintPassContract; bool mintPass; bool mintPassOnly; bool mintPassFree; bool mintPassBurn; bool mintPassOnePerWallet; uint256 mintPassDuration; } struct Storage { address relicsAddress; address payable daoAddress; bool daoInitialized; uint256 collectionCount; mapping (uint256 => Collection) collection; } function packStorage() internal pure returns (Storage storage ds) { bytes32 position = STORAGE_POSITION; assembly { ds.slot := position } } event LogMintPack( address minter, uint256 tokenID ); event LogCreateNewCollection( uint256 index ); event LogAddCollectible( uint256 cID, string title ); event LogUpdateMetadata( uint256 cID, uint256 collectibleId, uint256 propertyIndex, string value ); event LogAddVersion( uint256 cID, uint256 collectibleId, string asset ); event LogUpdateVersion( uint256 cID, uint256 collectibleId, uint256 versionNumber ); event LogAddNewLicense( uint256 cID, string license ); function random(uint256 cID) internal view returns (uint) { return uint(keccak256(abi.encodePacked(block.difficulty, block.timestamp, packStorage().collection[cID].totalTokenCount))); } function randomTokenID(address relics, uint256 cID) external relicSafety(relics) returns (uint256, uint256) { Storage storage ds = packStorage(); uint256 randomID = random(cID) % ds.collection[cID].shuffleIDs.length; uint256 tokenID = ds.collection[cID].shuffleIDs[randomID]; emit LogMintPack(msg.sender, tokenID); return (randomID, tokenID); } modifier onlyDAO() { require(msg.sender == packStorage().daoAddress, "Wrong address"); _; } modifier relicSafety(address relics) { Storage storage ds = packStorage(); require(relics == ds.relicsAddress); _; } /** * Map token order w/ URI upon mints * Sample token ID (edition #77) with collection of 12 different assets: 1200077 */ function createTokenIDs(uint256 cID, uint256 collectibleCount, uint256 editions) private { Storage storage ds = packStorage(); for (uint256 i = 0; i < editions; i++) { uint64 tokenID = uint64((cID + 1) * 100000000) + uint64((collectibleCount + 1) * 100000) + uint64(i + 1); ds.collection[cID].shuffleIDs.push(tokenID); } } function createNewCollection( string memory _baseURI, bool _editioned, uint256[] memory _initParams, string memory _licenseURI, address _mintPass, uint256 _mintPassDuration, bool[] memory _mintPassParams ) external onlyDAO { require(_initParams[1] <= 50, "Bulk buy limit of 50"); Storage storage ds = packStorage(); ds.collection[ds.collectionCount].baseURI = _baseURI; ds.collection[ds.collectionCount].editioned = _editioned; ds.collection[ds.collectionCount].tokenPrice = _initParams[0]; ds.collection[ds.collectionCount].bulkBuyLimit = _initParams[1]; ds.collection[ds.collectionCount].saleStartTime = _initParams[2]; ds.collection[ds.collectionCount].licenseURI[0] = _licenseURI; ds.collection[ds.collectionCount].licenseVersion = 1; if (_mintPass != address(0)) { ds.collection[ds.collectionCount].mintPass = true; ds.collection[ds.collectionCount].mintPassContract = ERC721(_mintPass); ds.collection[ds.collectionCount].mintPassDuration = _mintPassDuration; ds.collection[ds.collectionCount].mintPassOnePerWallet = _mintPassParams[0]; ds.collection[ds.collectionCount].mintPassOnly = _mintPassParams[1]; ds.collection[ds.collectionCount].mintPassFree = _mintPassParams[2]; ds.collection[ds.collectionCount].mintPassBurn = _mintPassParams[3]; } else { ds.collection[ds.collectionCount].mintPass = false; ds.collection[ds.collectionCount].mintPassDuration = 0; ds.collection[ds.collectionCount].mintPassOnePerWallet = false; ds.collection[ds.collectionCount].mintPassOnly = false; ds.collection[ds.collectionCount].mintPassFree = false; ds.collection[ds.collectionCount].mintPassBurn = false; } ds.collectionCount++; emit LogCreateNewCollection(ds.collectionCount); } // Add single collectible asset with main info and metadata properties function addCollectible(uint256 cID, string[] memory _coreData, string[] memory _assets, string[][] memory _metadataValues, string[][] memory _secondaryMetadata, Fee[] memory _fees) external onlyDAO { Storage storage ds = packStorage(); Collection storage collection = ds.collection[cID]; uint256 collectibleCount = collection.collectibleCount; uint256 sum = 0; for (uint256 i = 0; i < _fees.length; i++) { require(_fees[i].recipient != address(0x0), "Recipient should be present"); require(_fees[i].value != 0, "Fee value should be positive"); collection.secondaryFees[collectibleCount].push(Fee({ recipient: _fees[i].recipient, value: _fees[i].value })); sum = sum.add(_fees[i].value); } require(sum < 10000, "Fee should be less than 100%"); require(safeParseInt(_coreData[2]) > 0, "NFTs for given asset must be greater than 0"); require(safeParseInt(_coreData[3]) > 0 && safeParseInt(_coreData[3]) <= _assets.length, "Version cannot exceed asset count"); collection.collectibles[collectibleCount] = SingleCollectible({ title: _coreData[0], description: _coreData[1], count: safeParseInt(_coreData[2]), assets: _assets, currentVersion: safeParseInt(_coreData[3]), totalVersionCount: _assets.length }); string[] memory propertyNames = new string[](_metadataValues.length); string[] memory propertyValues = new string[](_metadataValues.length); bool[] memory modifiables = new bool[](_metadataValues.length); for (uint256 i = 0; i < _metadataValues.length; i++) { propertyNames[i] = _metadataValues[i][0]; propertyValues[i] = _metadataValues[i][1]; modifiables[i] = (keccak256(abi.encodePacked((_metadataValues[i][2]))) == keccak256(abi.encodePacked(('1')))); // 1 is modifiable, 0 is permanent } collection.metadata[collectibleCount] = Metadata({ name: propertyNames, value: propertyValues, modifiable: modifiables, propertyCount: _metadataValues.length }); propertyNames = new string[](_secondaryMetadata.length); propertyValues = new string[](_secondaryMetadata.length); modifiables = new bool[](_secondaryMetadata.length); for (uint256 i = 0; i < _secondaryMetadata.length; i++) { propertyNames[i] = _secondaryMetadata[i][0]; propertyValues[i] = _secondaryMetadata[i][1]; modifiables[i] = (keccak256(abi.encodePacked((_secondaryMetadata[i][2]))) == keccak256(abi.encodePacked(('1')))); // 1 is modifiable, 0 is permanent } collection.secondaryMetadata[collectibleCount] = Metadata({ name: propertyNames, value: propertyValues, modifiable: modifiables, propertyCount: _secondaryMetadata.length }); uint256 editions = safeParseInt(_coreData[2]); createTokenIDs(cID, collectibleCount, editions); collection.collectibleCount++; collection.totalTokenCount = collection.totalTokenCount.add(editions); emit LogAddCollectible(cID, _coreData[0]); } function checkTokensForMintPass(uint256 cID, address minter, address contractAddress) private returns (bool) { Storage storage ds = packStorage(); uint256 count = ds.collection[cID].mintPassContract.balanceOf(minter); bool done = false; uint256 counter = 0; bool canClaim = false; while (!done && count > 0) { uint256 tokenID = ds.collection[cID].mintPassContract.tokenOfOwnerByIndex(minter, counter); if (ds.collection[cID].mintPassClaims[tokenID] != true) { ds.collection[cID].mintPassClaims[tokenID] = true; done = true; canClaim = true; if (ds.collection[cID].mintPassBurn) { ds.collection[cID].mintPassContract.safeTransferFrom(msg.sender, address(0xdEaD), tokenID); } } if (counter == count - 1) done = true; else counter++; } return canClaim; } function checkMintPass(address relics, uint256 cID, address user, address contractAddress) external relicSafety(relics) returns (bool) { Storage storage ds = packStorage(); bool canMintPass = false; if (ds.collection[cID].mintPass) { if (!ds.collection[cID].mintPassOnePerWallet || !ds.collection[cID].mintPassClaimed[user]) { if (checkTokensForMintPass(cID, user, contractAddress)) { canMintPass = true; if (ds.collection[cID].mintPassOnePerWallet) ds.collection[cID].mintPassClaimed[user] = true; } } } if (ds.collection[cID].mintPassOnly) { require(canMintPass, "Minting is restricted to mint passes only"); require(block.timestamp > ds.collection[cID].saleStartTime - ds.collection[cID].mintPassDuration, "Sale has not yet started"); } else { if (canMintPass) require (block.timestamp > (ds.collection[cID].saleStartTime - ds.collection[cID].mintPassDuration), "Sale has not yet started"); else require(block.timestamp > ds.collection[cID].saleStartTime, "Sale has not yet started"); } return canMintPass; } function bulkMintChecks(uint256 cID, uint256 amount) external { Storage storage ds = packStorage(); require(amount > 0, 'Missing amount'); require(!ds.collection[cID].mintPassOnly, 'Cannot bulk mint'); require(amount <= ds.collection[cID].bulkBuyLimit, "Cannot bulk buy more than the preset limit"); require(amount <= ds.collection[cID].shuffleIDs.length, "Total supply reached"); require((block.timestamp > ds.collection[cID].saleStartTime), "Sale has not yet started"); } function mintPassClaimed(uint256 cID, uint256 tokenId) public view returns (bool) { Storage storage ds = packStorage(); return (ds.collection[cID].mintPassClaims[tokenId] == true); } function tokensClaimable(uint256 cID, address minter) public view returns (uint256[] memory) { Storage storage ds = packStorage(); uint256 count = ds.collection[cID].mintPassContract.balanceOf(minter); bool done = false; uint256 counter = 0; uint256 index = 0; uint256[] memory claimable = new uint256[](count); while (!done && count > 0) { uint256 tokenID = ds.collection[cID].mintPassContract.tokenOfOwnerByIndex(minter, counter); if (ds.collection[cID].mintPassClaims[tokenID] != true) { claimable[index] = tokenID; index++; } if (counter == count - 1) done = true; else counter++; } return claimable; } function remainingTokens(uint256 cID) public view returns (uint256) { Storage storage ds = packStorage(); return ds.collection[cID].shuffleIDs.length; } // Modify property field only if marked as updateable function updateMetadata(uint256 cID, uint256 collectibleId, uint256 propertyIndex, string memory value) external onlyDAO { Storage storage ds = packStorage(); require(ds.collection[cID].metadata[collectibleId - 1].modifiable[propertyIndex], 'Field not editable'); ds.collection[cID].metadata[collectibleId - 1].value[propertyIndex] = value; emit LogUpdateMetadata(cID, collectibleId, propertyIndex, value); } // Add new asset, does not automatically increase current version function addVersion(uint256 cID, uint256 collectibleId, string memory asset) public onlyDAO { Storage storage ds = packStorage(); ds.collection[cID].collectibles[collectibleId - 1].assets[ds.collection[cID].collectibles[collectibleId - 1].totalVersionCount - 1] = asset; ds.collection[cID].collectibles[collectibleId - 1].totalVersionCount++; emit LogAddVersion(cID, collectibleId, asset); } // Set version number, index starts at version 1, collectible 1 (so shifts 1 for 0th index) // function updateVersion(uint256 cID, uint256 collectibleId, uint256 versionNumber) public onlyDAO { // Storage storage ds = packStorage(); // require(versionNumber > 0, "Versions start at 1"); // require(versionNumber <= ds.collection[cID].collectibles[collectibleId - 1].assets.length, "Versions must be less than asset count"); // require(collectibleId > 0, "Collectible IDs start at 1"); // ds.collection[cID].collectibles[collectibleId - 1].currentVersion = versionNumber; // emit LogUpdateVersion(cID, collectibleId, versionNumber); // } // Adds new license and updates version to latest function addNewLicense(uint256 cID, string memory _license) public onlyDAO { Storage storage ds = packStorage(); require(cID < ds.collectionCount, 'Collectible ID does not exist'); ds.collection[cID].licenseURI[ds.collection[cID].licenseVersion] = _license; ds.collection[cID].licenseVersion++; emit LogAddNewLicense(cID, _license); } function getLicense(uint256 cID, uint256 versionNumber) public view returns (string memory) { Storage storage ds = packStorage(); return ds.collection[cID].licenseURI[versionNumber - 1]; } function getCurrentLicense(uint256 cID) public view returns (string memory) { Storage storage ds = packStorage(); return ds.collection[cID].licenseURI[ds.collection[cID].licenseVersion - 1]; } // Dynamic base64 encoded metadata generation using on-chain metadata and edition numbers function tokenURI(uint256 tokenId) public view returns (string memory) { Storage storage ds = packStorage(); uint256 edition = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 5, bytes(toString(tokenId)).length)) - 1; uint256 collectibleId = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 8, bytes(toString(tokenId)).length - 5)) - 1; uint256 cID = ((tokenId - ((collectibleId + 1) * 100000)) - (edition + 1)) / 100000000 - 1; string memory encodedMetadata = ''; Collection storage collection = ds.collection[cID]; for (uint i = 0; i < collection.metadata[collectibleId].propertyCount; i++) { encodedMetadata = string(abi.encodePacked( encodedMetadata, '{"trait_type":"', collection.metadata[collectibleId].name[i], '", "value":"', collection.metadata[collectibleId].value[i], '", "permanent":"', collection.metadata[collectibleId].modifiable[i] ? 'false' : 'true', '"}', i == collection.metadata[collectibleId].propertyCount - 1 ? '' : ',') ); } string memory encodedSecondaryMetadata = ''; for (uint i = 0; i < collection.secondaryMetadata[collectibleId].propertyCount; i++) { encodedSecondaryMetadata = string(abi.encodePacked( encodedSecondaryMetadata, '{"trait_type":"', collection.secondaryMetadata[collectibleId].name[i], '", "value":"', collection.secondaryMetadata[collectibleId].value[i], '", "permanent":"', collection.secondaryMetadata[collectibleId].modifiable[i] ? 'false' : 'true', '"}', i == collection.secondaryMetadata[collectibleId].propertyCount - 1 ? '' : ',') ); } SingleCollectible storage collectible = collection.collectibles[collectibleId]; uint256 asset = collectible.currentVersion - 1; string memory encoded = string( abi.encodePacked( 'data:application/json;base64,', Base64.encode( bytes( abi.encodePacked( '{"name":"', collectible.title, collection.editioned ? ' #' : '', collection.editioned ? toString(edition + 1) : '', '", "description":"', collectible.description, '", "image": "', collection.baseURI, collectible.assets[asset], '", "license": "', getCurrentLicense(cID), '", "attributes": [', encodedMetadata, '], "secondaryAttributes": [', encodedSecondaryMetadata, '] }' ) ) ) ) ); return encoded; } // Secondary sale fees apply to each individual collectible ID (will apply to a range of tokenIDs); function getFeeRecipients(uint256 tokenId) public view returns (address payable[] memory) { Storage storage ds = packStorage(); uint256 edition = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 5, bytes(toString(tokenId)).length)) - 1; uint256 collectibleId = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 8, bytes(toString(tokenId)).length - 5)) - 1; uint256 cID = ((tokenId - ((collectibleId + 1) * 100000)) - (edition + 1)) / 100000000 - 1; Fee[] memory _fees = ds.collection[cID].secondaryFees[collectibleId]; address payable[] memory result = new address payable[](_fees.length); for (uint i = 0; i < _fees.length; i++) { result[i] = _fees[i].recipient; } return result; } function getFeeBps(uint256 tokenId) public view returns (uint[] memory) { Storage storage ds = packStorage(); uint256 edition = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 5, bytes(toString(tokenId)).length)) - 1; uint256 collectibleId = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 8, bytes(toString(tokenId)).length - 5)) - 1; uint256 cID = ((tokenId - ((collectibleId + 1) * 100000)) - (edition + 1)) / 100000000 - 1; Fee[] memory _fees = ds.collection[cID].secondaryFees[collectibleId]; uint[] memory result = new uint[](_fees.length); for (uint i = 0; i < _fees.length; i++) { result[i] = _fees[i].value; } return result; } function royaltyInfo(uint256 tokenId, uint256 value) public view returns (address recipient, uint256 amount){ address payable[] memory rec = getFeeRecipients(tokenId); require(rec.length <= 1, "More than 1 royalty recipient"); if (rec.length == 0) return (address(this), 0); return (rec[0], getFeeBps(tokenId)[0] * value / 10000); } function toString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = bytes1(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } function safeParseInt(string memory _a) internal pure returns (uint _parsedInt) { return safeParseInt(_a, 0); } function safeParseInt(string memory _a, uint _b) internal pure returns (uint _parsedInt) { bytes memory bresult = bytes(_a); uint mint = 0; bool decimals = false; for (uint i = 0; i < bresult.length; i++) { if ((uint(uint8(bresult[i])) >= 48) && (uint(uint8(bresult[i])) <= 57)) { if (decimals) { if (_b == 0) break; else _b--; } mint *= 10; mint += uint(uint8(bresult[i])) - 48; } else if (uint(uint8(bresult[i])) == 46) { require(!decimals, 'More than one decimal encountered in string!'); decimals = true; } else { revert("Non-numeral character encountered in string!"); } } if (_b > 0) { mint *= 10 ** _b; } return mint; } function substring(string memory str, uint startIndex, uint endIndex) internal pure returns (string memory) { bytes memory strBytes = bytes(str); bytes memory result = new bytes(endIndex-startIndex); for(uint i = startIndex; i < endIndex; i++) { result[i-startIndex] = strBytes[i]; } return string(result); } }
addNewLicense
function addNewLicense(uint256 cID, string memory _license) public onlyDAO { Storage storage ds = packStorage(); require(cID < ds.collectionCount, 'Collectible ID does not exist'); ds.collection[cID].licenseURI[ds.collection[cID].licenseVersion] = _license; ds.collection[cID].licenseVersion++; emit LogAddNewLicense(cID, _license); }
// Set version number, index starts at version 1, collectible 1 (so shifts 1 for 0th index) // function updateVersion(uint256 cID, uint256 collectibleId, uint256 versionNumber) public onlyDAO { // Storage storage ds = packStorage(); // require(versionNumber > 0, "Versions start at 1"); // require(versionNumber <= ds.collection[cID].collectibles[collectibleId - 1].assets.length, "Versions must be less than asset count"); // require(collectibleId > 0, "Collectible IDs start at 1"); // ds.collection[cID].collectibles[collectibleId - 1].currentVersion = versionNumber; // emit LogUpdateVersion(cID, collectibleId, versionNumber); // } // Adds new license and updates version to latest
LineComment
v0.7.3+commit.9bfce1f6
{ "func_code_index": [ 14404, 14762 ] }
67
Packs
contracts/LibPackStorage.sol
0x1495ecbac40a69028b5d516597137de5e929b01b
Solidity
LibPackStorage
library LibPackStorage { using SafeMath for uint256; bytes32 constant STORAGE_POSITION = keccak256("com.universe.packs.storage"); struct Fee { address payable recipient; uint256 value; } struct SingleCollectible { string title; // Collectible name string description; // Collectible description uint256 count; // Amount of editions per collectible string[] assets; // Each asset in array is a version uint256 totalVersionCount; // Total number of existing states uint256 currentVersion; // Current existing state } struct Metadata { string[] name; // Trait or attribute property field name string[] value; // Trait or attribute property value bool[] modifiable; // Can owner modify the value of field uint256 propertyCount; // Tracker of total attributes } struct Collection { bool initialized; string baseURI; // Token ID base URL mapping (uint256 => SingleCollectible) collectibles; // Unique assets mapping (uint256 => Metadata) metadata; // Trait & property attributes, indexes should be coupled with 'collectibles' mapping (uint256 => Metadata) secondaryMetadata; // Trait & property attributes, indexes should be coupled with 'collectibles' mapping (uint256 => Fee[]) secondaryFees; mapping (uint256 => string) licenseURI; // URL to external license or file mapping (address => bool) mintPassClaimed; mapping (uint256 => bool) mintPassClaims; uint256 collectibleCount; // Total unique assets count uint256 totalTokenCount; // Total NFT count to be minted uint256 tokenPrice; uint256 bulkBuyLimit; uint256 saleStartTime; bool editioned; // Display edition # in token name uint256 licenseVersion; // Tracker of latest license uint64[] shuffleIDs; ERC721 mintPassContract; bool mintPass; bool mintPassOnly; bool mintPassFree; bool mintPassBurn; bool mintPassOnePerWallet; uint256 mintPassDuration; } struct Storage { address relicsAddress; address payable daoAddress; bool daoInitialized; uint256 collectionCount; mapping (uint256 => Collection) collection; } function packStorage() internal pure returns (Storage storage ds) { bytes32 position = STORAGE_POSITION; assembly { ds.slot := position } } event LogMintPack( address minter, uint256 tokenID ); event LogCreateNewCollection( uint256 index ); event LogAddCollectible( uint256 cID, string title ); event LogUpdateMetadata( uint256 cID, uint256 collectibleId, uint256 propertyIndex, string value ); event LogAddVersion( uint256 cID, uint256 collectibleId, string asset ); event LogUpdateVersion( uint256 cID, uint256 collectibleId, uint256 versionNumber ); event LogAddNewLicense( uint256 cID, string license ); function random(uint256 cID) internal view returns (uint) { return uint(keccak256(abi.encodePacked(block.difficulty, block.timestamp, packStorage().collection[cID].totalTokenCount))); } function randomTokenID(address relics, uint256 cID) external relicSafety(relics) returns (uint256, uint256) { Storage storage ds = packStorage(); uint256 randomID = random(cID) % ds.collection[cID].shuffleIDs.length; uint256 tokenID = ds.collection[cID].shuffleIDs[randomID]; emit LogMintPack(msg.sender, tokenID); return (randomID, tokenID); } modifier onlyDAO() { require(msg.sender == packStorage().daoAddress, "Wrong address"); _; } modifier relicSafety(address relics) { Storage storage ds = packStorage(); require(relics == ds.relicsAddress); _; } /** * Map token order w/ URI upon mints * Sample token ID (edition #77) with collection of 12 different assets: 1200077 */ function createTokenIDs(uint256 cID, uint256 collectibleCount, uint256 editions) private { Storage storage ds = packStorage(); for (uint256 i = 0; i < editions; i++) { uint64 tokenID = uint64((cID + 1) * 100000000) + uint64((collectibleCount + 1) * 100000) + uint64(i + 1); ds.collection[cID].shuffleIDs.push(tokenID); } } function createNewCollection( string memory _baseURI, bool _editioned, uint256[] memory _initParams, string memory _licenseURI, address _mintPass, uint256 _mintPassDuration, bool[] memory _mintPassParams ) external onlyDAO { require(_initParams[1] <= 50, "Bulk buy limit of 50"); Storage storage ds = packStorage(); ds.collection[ds.collectionCount].baseURI = _baseURI; ds.collection[ds.collectionCount].editioned = _editioned; ds.collection[ds.collectionCount].tokenPrice = _initParams[0]; ds.collection[ds.collectionCount].bulkBuyLimit = _initParams[1]; ds.collection[ds.collectionCount].saleStartTime = _initParams[2]; ds.collection[ds.collectionCount].licenseURI[0] = _licenseURI; ds.collection[ds.collectionCount].licenseVersion = 1; if (_mintPass != address(0)) { ds.collection[ds.collectionCount].mintPass = true; ds.collection[ds.collectionCount].mintPassContract = ERC721(_mintPass); ds.collection[ds.collectionCount].mintPassDuration = _mintPassDuration; ds.collection[ds.collectionCount].mintPassOnePerWallet = _mintPassParams[0]; ds.collection[ds.collectionCount].mintPassOnly = _mintPassParams[1]; ds.collection[ds.collectionCount].mintPassFree = _mintPassParams[2]; ds.collection[ds.collectionCount].mintPassBurn = _mintPassParams[3]; } else { ds.collection[ds.collectionCount].mintPass = false; ds.collection[ds.collectionCount].mintPassDuration = 0; ds.collection[ds.collectionCount].mintPassOnePerWallet = false; ds.collection[ds.collectionCount].mintPassOnly = false; ds.collection[ds.collectionCount].mintPassFree = false; ds.collection[ds.collectionCount].mintPassBurn = false; } ds.collectionCount++; emit LogCreateNewCollection(ds.collectionCount); } // Add single collectible asset with main info and metadata properties function addCollectible(uint256 cID, string[] memory _coreData, string[] memory _assets, string[][] memory _metadataValues, string[][] memory _secondaryMetadata, Fee[] memory _fees) external onlyDAO { Storage storage ds = packStorage(); Collection storage collection = ds.collection[cID]; uint256 collectibleCount = collection.collectibleCount; uint256 sum = 0; for (uint256 i = 0; i < _fees.length; i++) { require(_fees[i].recipient != address(0x0), "Recipient should be present"); require(_fees[i].value != 0, "Fee value should be positive"); collection.secondaryFees[collectibleCount].push(Fee({ recipient: _fees[i].recipient, value: _fees[i].value })); sum = sum.add(_fees[i].value); } require(sum < 10000, "Fee should be less than 100%"); require(safeParseInt(_coreData[2]) > 0, "NFTs for given asset must be greater than 0"); require(safeParseInt(_coreData[3]) > 0 && safeParseInt(_coreData[3]) <= _assets.length, "Version cannot exceed asset count"); collection.collectibles[collectibleCount] = SingleCollectible({ title: _coreData[0], description: _coreData[1], count: safeParseInt(_coreData[2]), assets: _assets, currentVersion: safeParseInt(_coreData[3]), totalVersionCount: _assets.length }); string[] memory propertyNames = new string[](_metadataValues.length); string[] memory propertyValues = new string[](_metadataValues.length); bool[] memory modifiables = new bool[](_metadataValues.length); for (uint256 i = 0; i < _metadataValues.length; i++) { propertyNames[i] = _metadataValues[i][0]; propertyValues[i] = _metadataValues[i][1]; modifiables[i] = (keccak256(abi.encodePacked((_metadataValues[i][2]))) == keccak256(abi.encodePacked(('1')))); // 1 is modifiable, 0 is permanent } collection.metadata[collectibleCount] = Metadata({ name: propertyNames, value: propertyValues, modifiable: modifiables, propertyCount: _metadataValues.length }); propertyNames = new string[](_secondaryMetadata.length); propertyValues = new string[](_secondaryMetadata.length); modifiables = new bool[](_secondaryMetadata.length); for (uint256 i = 0; i < _secondaryMetadata.length; i++) { propertyNames[i] = _secondaryMetadata[i][0]; propertyValues[i] = _secondaryMetadata[i][1]; modifiables[i] = (keccak256(abi.encodePacked((_secondaryMetadata[i][2]))) == keccak256(abi.encodePacked(('1')))); // 1 is modifiable, 0 is permanent } collection.secondaryMetadata[collectibleCount] = Metadata({ name: propertyNames, value: propertyValues, modifiable: modifiables, propertyCount: _secondaryMetadata.length }); uint256 editions = safeParseInt(_coreData[2]); createTokenIDs(cID, collectibleCount, editions); collection.collectibleCount++; collection.totalTokenCount = collection.totalTokenCount.add(editions); emit LogAddCollectible(cID, _coreData[0]); } function checkTokensForMintPass(uint256 cID, address minter, address contractAddress) private returns (bool) { Storage storage ds = packStorage(); uint256 count = ds.collection[cID].mintPassContract.balanceOf(minter); bool done = false; uint256 counter = 0; bool canClaim = false; while (!done && count > 0) { uint256 tokenID = ds.collection[cID].mintPassContract.tokenOfOwnerByIndex(minter, counter); if (ds.collection[cID].mintPassClaims[tokenID] != true) { ds.collection[cID].mintPassClaims[tokenID] = true; done = true; canClaim = true; if (ds.collection[cID].mintPassBurn) { ds.collection[cID].mintPassContract.safeTransferFrom(msg.sender, address(0xdEaD), tokenID); } } if (counter == count - 1) done = true; else counter++; } return canClaim; } function checkMintPass(address relics, uint256 cID, address user, address contractAddress) external relicSafety(relics) returns (bool) { Storage storage ds = packStorage(); bool canMintPass = false; if (ds.collection[cID].mintPass) { if (!ds.collection[cID].mintPassOnePerWallet || !ds.collection[cID].mintPassClaimed[user]) { if (checkTokensForMintPass(cID, user, contractAddress)) { canMintPass = true; if (ds.collection[cID].mintPassOnePerWallet) ds.collection[cID].mintPassClaimed[user] = true; } } } if (ds.collection[cID].mintPassOnly) { require(canMintPass, "Minting is restricted to mint passes only"); require(block.timestamp > ds.collection[cID].saleStartTime - ds.collection[cID].mintPassDuration, "Sale has not yet started"); } else { if (canMintPass) require (block.timestamp > (ds.collection[cID].saleStartTime - ds.collection[cID].mintPassDuration), "Sale has not yet started"); else require(block.timestamp > ds.collection[cID].saleStartTime, "Sale has not yet started"); } return canMintPass; } function bulkMintChecks(uint256 cID, uint256 amount) external { Storage storage ds = packStorage(); require(amount > 0, 'Missing amount'); require(!ds.collection[cID].mintPassOnly, 'Cannot bulk mint'); require(amount <= ds.collection[cID].bulkBuyLimit, "Cannot bulk buy more than the preset limit"); require(amount <= ds.collection[cID].shuffleIDs.length, "Total supply reached"); require((block.timestamp > ds.collection[cID].saleStartTime), "Sale has not yet started"); } function mintPassClaimed(uint256 cID, uint256 tokenId) public view returns (bool) { Storage storage ds = packStorage(); return (ds.collection[cID].mintPassClaims[tokenId] == true); } function tokensClaimable(uint256 cID, address minter) public view returns (uint256[] memory) { Storage storage ds = packStorage(); uint256 count = ds.collection[cID].mintPassContract.balanceOf(minter); bool done = false; uint256 counter = 0; uint256 index = 0; uint256[] memory claimable = new uint256[](count); while (!done && count > 0) { uint256 tokenID = ds.collection[cID].mintPassContract.tokenOfOwnerByIndex(minter, counter); if (ds.collection[cID].mintPassClaims[tokenID] != true) { claimable[index] = tokenID; index++; } if (counter == count - 1) done = true; else counter++; } return claimable; } function remainingTokens(uint256 cID) public view returns (uint256) { Storage storage ds = packStorage(); return ds.collection[cID].shuffleIDs.length; } // Modify property field only if marked as updateable function updateMetadata(uint256 cID, uint256 collectibleId, uint256 propertyIndex, string memory value) external onlyDAO { Storage storage ds = packStorage(); require(ds.collection[cID].metadata[collectibleId - 1].modifiable[propertyIndex], 'Field not editable'); ds.collection[cID].metadata[collectibleId - 1].value[propertyIndex] = value; emit LogUpdateMetadata(cID, collectibleId, propertyIndex, value); } // Add new asset, does not automatically increase current version function addVersion(uint256 cID, uint256 collectibleId, string memory asset) public onlyDAO { Storage storage ds = packStorage(); ds.collection[cID].collectibles[collectibleId - 1].assets[ds.collection[cID].collectibles[collectibleId - 1].totalVersionCount - 1] = asset; ds.collection[cID].collectibles[collectibleId - 1].totalVersionCount++; emit LogAddVersion(cID, collectibleId, asset); } // Set version number, index starts at version 1, collectible 1 (so shifts 1 for 0th index) // function updateVersion(uint256 cID, uint256 collectibleId, uint256 versionNumber) public onlyDAO { // Storage storage ds = packStorage(); // require(versionNumber > 0, "Versions start at 1"); // require(versionNumber <= ds.collection[cID].collectibles[collectibleId - 1].assets.length, "Versions must be less than asset count"); // require(collectibleId > 0, "Collectible IDs start at 1"); // ds.collection[cID].collectibles[collectibleId - 1].currentVersion = versionNumber; // emit LogUpdateVersion(cID, collectibleId, versionNumber); // } // Adds new license and updates version to latest function addNewLicense(uint256 cID, string memory _license) public onlyDAO { Storage storage ds = packStorage(); require(cID < ds.collectionCount, 'Collectible ID does not exist'); ds.collection[cID].licenseURI[ds.collection[cID].licenseVersion] = _license; ds.collection[cID].licenseVersion++; emit LogAddNewLicense(cID, _license); } function getLicense(uint256 cID, uint256 versionNumber) public view returns (string memory) { Storage storage ds = packStorage(); return ds.collection[cID].licenseURI[versionNumber - 1]; } function getCurrentLicense(uint256 cID) public view returns (string memory) { Storage storage ds = packStorage(); return ds.collection[cID].licenseURI[ds.collection[cID].licenseVersion - 1]; } // Dynamic base64 encoded metadata generation using on-chain metadata and edition numbers function tokenURI(uint256 tokenId) public view returns (string memory) { Storage storage ds = packStorage(); uint256 edition = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 5, bytes(toString(tokenId)).length)) - 1; uint256 collectibleId = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 8, bytes(toString(tokenId)).length - 5)) - 1; uint256 cID = ((tokenId - ((collectibleId + 1) * 100000)) - (edition + 1)) / 100000000 - 1; string memory encodedMetadata = ''; Collection storage collection = ds.collection[cID]; for (uint i = 0; i < collection.metadata[collectibleId].propertyCount; i++) { encodedMetadata = string(abi.encodePacked( encodedMetadata, '{"trait_type":"', collection.metadata[collectibleId].name[i], '", "value":"', collection.metadata[collectibleId].value[i], '", "permanent":"', collection.metadata[collectibleId].modifiable[i] ? 'false' : 'true', '"}', i == collection.metadata[collectibleId].propertyCount - 1 ? '' : ',') ); } string memory encodedSecondaryMetadata = ''; for (uint i = 0; i < collection.secondaryMetadata[collectibleId].propertyCount; i++) { encodedSecondaryMetadata = string(abi.encodePacked( encodedSecondaryMetadata, '{"trait_type":"', collection.secondaryMetadata[collectibleId].name[i], '", "value":"', collection.secondaryMetadata[collectibleId].value[i], '", "permanent":"', collection.secondaryMetadata[collectibleId].modifiable[i] ? 'false' : 'true', '"}', i == collection.secondaryMetadata[collectibleId].propertyCount - 1 ? '' : ',') ); } SingleCollectible storage collectible = collection.collectibles[collectibleId]; uint256 asset = collectible.currentVersion - 1; string memory encoded = string( abi.encodePacked( 'data:application/json;base64,', Base64.encode( bytes( abi.encodePacked( '{"name":"', collectible.title, collection.editioned ? ' #' : '', collection.editioned ? toString(edition + 1) : '', '", "description":"', collectible.description, '", "image": "', collection.baseURI, collectible.assets[asset], '", "license": "', getCurrentLicense(cID), '", "attributes": [', encodedMetadata, '], "secondaryAttributes": [', encodedSecondaryMetadata, '] }' ) ) ) ) ); return encoded; } // Secondary sale fees apply to each individual collectible ID (will apply to a range of tokenIDs); function getFeeRecipients(uint256 tokenId) public view returns (address payable[] memory) { Storage storage ds = packStorage(); uint256 edition = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 5, bytes(toString(tokenId)).length)) - 1; uint256 collectibleId = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 8, bytes(toString(tokenId)).length - 5)) - 1; uint256 cID = ((tokenId - ((collectibleId + 1) * 100000)) - (edition + 1)) / 100000000 - 1; Fee[] memory _fees = ds.collection[cID].secondaryFees[collectibleId]; address payable[] memory result = new address payable[](_fees.length); for (uint i = 0; i < _fees.length; i++) { result[i] = _fees[i].recipient; } return result; } function getFeeBps(uint256 tokenId) public view returns (uint[] memory) { Storage storage ds = packStorage(); uint256 edition = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 5, bytes(toString(tokenId)).length)) - 1; uint256 collectibleId = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 8, bytes(toString(tokenId)).length - 5)) - 1; uint256 cID = ((tokenId - ((collectibleId + 1) * 100000)) - (edition + 1)) / 100000000 - 1; Fee[] memory _fees = ds.collection[cID].secondaryFees[collectibleId]; uint[] memory result = new uint[](_fees.length); for (uint i = 0; i < _fees.length; i++) { result[i] = _fees[i].value; } return result; } function royaltyInfo(uint256 tokenId, uint256 value) public view returns (address recipient, uint256 amount){ address payable[] memory rec = getFeeRecipients(tokenId); require(rec.length <= 1, "More than 1 royalty recipient"); if (rec.length == 0) return (address(this), 0); return (rec[0], getFeeBps(tokenId)[0] * value / 10000); } function toString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = bytes1(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } function safeParseInt(string memory _a) internal pure returns (uint _parsedInt) { return safeParseInt(_a, 0); } function safeParseInt(string memory _a, uint _b) internal pure returns (uint _parsedInt) { bytes memory bresult = bytes(_a); uint mint = 0; bool decimals = false; for (uint i = 0; i < bresult.length; i++) { if ((uint(uint8(bresult[i])) >= 48) && (uint(uint8(bresult[i])) <= 57)) { if (decimals) { if (_b == 0) break; else _b--; } mint *= 10; mint += uint(uint8(bresult[i])) - 48; } else if (uint(uint8(bresult[i])) == 46) { require(!decimals, 'More than one decimal encountered in string!'); decimals = true; } else { revert("Non-numeral character encountered in string!"); } } if (_b > 0) { mint *= 10 ** _b; } return mint; } function substring(string memory str, uint startIndex, uint endIndex) internal pure returns (string memory) { bytes memory strBytes = bytes(str); bytes memory result = new bytes(endIndex-startIndex); for(uint i = startIndex; i < endIndex; i++) { result[i-startIndex] = strBytes[i]; } return string(result); } }
tokenURI
function tokenURI(uint256 tokenId) public view returns (string memory) { Storage storage ds = packStorage(); uint256 edition = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 5, bytes(toString(tokenId)).length)) - 1; uint256 collectibleId = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 8, bytes(toString(tokenId)).length - 5)) - 1; uint256 cID = ((tokenId - ((collectibleId + 1) * 100000)) - (edition + 1)) / 100000000 - 1; string memory encodedMetadata = ''; Collection storage collection = ds.collection[cID]; for (uint i = 0; i < collection.metadata[collectibleId].propertyCount; i++) { encodedMetadata = string(abi.encodePacked( encodedMetadata, '{"trait_type":"', collection.metadata[collectibleId].name[i], '", "value":"', collection.metadata[collectibleId].value[i], '", "permanent":"', collection.metadata[collectibleId].modifiable[i] ? 'false' : 'true', '"}', i == collection.metadata[collectibleId].propertyCount - 1 ? '' : ',') ); } string memory encodedSecondaryMetadata = ''; for (uint i = 0; i < collection.secondaryMetadata[collectibleId].propertyCount; i++) { encodedSecondaryMetadata = string(abi.encodePacked( encodedSecondaryMetadata, '{"trait_type":"', collection.secondaryMetadata[collectibleId].name[i], '", "value":"', collection.secondaryMetadata[collectibleId].value[i], '", "permanent":"', collection.secondaryMetadata[collectibleId].modifiable[i] ? 'false' : 'true', '"}', i == collection.secondaryMetadata[collectibleId].propertyCount - 1 ? '' : ',') ); } SingleCollectible storage collectible = collection.collectibles[collectibleId]; uint256 asset = collectible.currentVersion - 1; string memory encoded = string( abi.encodePacked( 'data:application/json;base64,', Base64.encode( bytes( abi.encodePacked( '{"name":"', collectible.title, collection.editioned ? ' #' : '', collection.editioned ? toString(edition + 1) : '', '", "description":"', collectible.description, '", "image": "', collection.baseURI, collectible.assets[asset], '", "license": "', getCurrentLicense(cID), '", "attributes": [', encodedMetadata, '], "secondaryAttributes": [', encodedSecondaryMetadata, '] }' ) ) ) ) ); return encoded; }
// Dynamic base64 encoded metadata generation using on-chain metadata and edition numbers
LineComment
v0.7.3+commit.9bfce1f6
{ "func_code_index": [ 15264, 18057 ] }
68
Packs
contracts/LibPackStorage.sol
0x1495ecbac40a69028b5d516597137de5e929b01b
Solidity
LibPackStorage
library LibPackStorage { using SafeMath for uint256; bytes32 constant STORAGE_POSITION = keccak256("com.universe.packs.storage"); struct Fee { address payable recipient; uint256 value; } struct SingleCollectible { string title; // Collectible name string description; // Collectible description uint256 count; // Amount of editions per collectible string[] assets; // Each asset in array is a version uint256 totalVersionCount; // Total number of existing states uint256 currentVersion; // Current existing state } struct Metadata { string[] name; // Trait or attribute property field name string[] value; // Trait or attribute property value bool[] modifiable; // Can owner modify the value of field uint256 propertyCount; // Tracker of total attributes } struct Collection { bool initialized; string baseURI; // Token ID base URL mapping (uint256 => SingleCollectible) collectibles; // Unique assets mapping (uint256 => Metadata) metadata; // Trait & property attributes, indexes should be coupled with 'collectibles' mapping (uint256 => Metadata) secondaryMetadata; // Trait & property attributes, indexes should be coupled with 'collectibles' mapping (uint256 => Fee[]) secondaryFees; mapping (uint256 => string) licenseURI; // URL to external license or file mapping (address => bool) mintPassClaimed; mapping (uint256 => bool) mintPassClaims; uint256 collectibleCount; // Total unique assets count uint256 totalTokenCount; // Total NFT count to be minted uint256 tokenPrice; uint256 bulkBuyLimit; uint256 saleStartTime; bool editioned; // Display edition # in token name uint256 licenseVersion; // Tracker of latest license uint64[] shuffleIDs; ERC721 mintPassContract; bool mintPass; bool mintPassOnly; bool mintPassFree; bool mintPassBurn; bool mintPassOnePerWallet; uint256 mintPassDuration; } struct Storage { address relicsAddress; address payable daoAddress; bool daoInitialized; uint256 collectionCount; mapping (uint256 => Collection) collection; } function packStorage() internal pure returns (Storage storage ds) { bytes32 position = STORAGE_POSITION; assembly { ds.slot := position } } event LogMintPack( address minter, uint256 tokenID ); event LogCreateNewCollection( uint256 index ); event LogAddCollectible( uint256 cID, string title ); event LogUpdateMetadata( uint256 cID, uint256 collectibleId, uint256 propertyIndex, string value ); event LogAddVersion( uint256 cID, uint256 collectibleId, string asset ); event LogUpdateVersion( uint256 cID, uint256 collectibleId, uint256 versionNumber ); event LogAddNewLicense( uint256 cID, string license ); function random(uint256 cID) internal view returns (uint) { return uint(keccak256(abi.encodePacked(block.difficulty, block.timestamp, packStorage().collection[cID].totalTokenCount))); } function randomTokenID(address relics, uint256 cID) external relicSafety(relics) returns (uint256, uint256) { Storage storage ds = packStorage(); uint256 randomID = random(cID) % ds.collection[cID].shuffleIDs.length; uint256 tokenID = ds.collection[cID].shuffleIDs[randomID]; emit LogMintPack(msg.sender, tokenID); return (randomID, tokenID); } modifier onlyDAO() { require(msg.sender == packStorage().daoAddress, "Wrong address"); _; } modifier relicSafety(address relics) { Storage storage ds = packStorage(); require(relics == ds.relicsAddress); _; } /** * Map token order w/ URI upon mints * Sample token ID (edition #77) with collection of 12 different assets: 1200077 */ function createTokenIDs(uint256 cID, uint256 collectibleCount, uint256 editions) private { Storage storage ds = packStorage(); for (uint256 i = 0; i < editions; i++) { uint64 tokenID = uint64((cID + 1) * 100000000) + uint64((collectibleCount + 1) * 100000) + uint64(i + 1); ds.collection[cID].shuffleIDs.push(tokenID); } } function createNewCollection( string memory _baseURI, bool _editioned, uint256[] memory _initParams, string memory _licenseURI, address _mintPass, uint256 _mintPassDuration, bool[] memory _mintPassParams ) external onlyDAO { require(_initParams[1] <= 50, "Bulk buy limit of 50"); Storage storage ds = packStorage(); ds.collection[ds.collectionCount].baseURI = _baseURI; ds.collection[ds.collectionCount].editioned = _editioned; ds.collection[ds.collectionCount].tokenPrice = _initParams[0]; ds.collection[ds.collectionCount].bulkBuyLimit = _initParams[1]; ds.collection[ds.collectionCount].saleStartTime = _initParams[2]; ds.collection[ds.collectionCount].licenseURI[0] = _licenseURI; ds.collection[ds.collectionCount].licenseVersion = 1; if (_mintPass != address(0)) { ds.collection[ds.collectionCount].mintPass = true; ds.collection[ds.collectionCount].mintPassContract = ERC721(_mintPass); ds.collection[ds.collectionCount].mintPassDuration = _mintPassDuration; ds.collection[ds.collectionCount].mintPassOnePerWallet = _mintPassParams[0]; ds.collection[ds.collectionCount].mintPassOnly = _mintPassParams[1]; ds.collection[ds.collectionCount].mintPassFree = _mintPassParams[2]; ds.collection[ds.collectionCount].mintPassBurn = _mintPassParams[3]; } else { ds.collection[ds.collectionCount].mintPass = false; ds.collection[ds.collectionCount].mintPassDuration = 0; ds.collection[ds.collectionCount].mintPassOnePerWallet = false; ds.collection[ds.collectionCount].mintPassOnly = false; ds.collection[ds.collectionCount].mintPassFree = false; ds.collection[ds.collectionCount].mintPassBurn = false; } ds.collectionCount++; emit LogCreateNewCollection(ds.collectionCount); } // Add single collectible asset with main info and metadata properties function addCollectible(uint256 cID, string[] memory _coreData, string[] memory _assets, string[][] memory _metadataValues, string[][] memory _secondaryMetadata, Fee[] memory _fees) external onlyDAO { Storage storage ds = packStorage(); Collection storage collection = ds.collection[cID]; uint256 collectibleCount = collection.collectibleCount; uint256 sum = 0; for (uint256 i = 0; i < _fees.length; i++) { require(_fees[i].recipient != address(0x0), "Recipient should be present"); require(_fees[i].value != 0, "Fee value should be positive"); collection.secondaryFees[collectibleCount].push(Fee({ recipient: _fees[i].recipient, value: _fees[i].value })); sum = sum.add(_fees[i].value); } require(sum < 10000, "Fee should be less than 100%"); require(safeParseInt(_coreData[2]) > 0, "NFTs for given asset must be greater than 0"); require(safeParseInt(_coreData[3]) > 0 && safeParseInt(_coreData[3]) <= _assets.length, "Version cannot exceed asset count"); collection.collectibles[collectibleCount] = SingleCollectible({ title: _coreData[0], description: _coreData[1], count: safeParseInt(_coreData[2]), assets: _assets, currentVersion: safeParseInt(_coreData[3]), totalVersionCount: _assets.length }); string[] memory propertyNames = new string[](_metadataValues.length); string[] memory propertyValues = new string[](_metadataValues.length); bool[] memory modifiables = new bool[](_metadataValues.length); for (uint256 i = 0; i < _metadataValues.length; i++) { propertyNames[i] = _metadataValues[i][0]; propertyValues[i] = _metadataValues[i][1]; modifiables[i] = (keccak256(abi.encodePacked((_metadataValues[i][2]))) == keccak256(abi.encodePacked(('1')))); // 1 is modifiable, 0 is permanent } collection.metadata[collectibleCount] = Metadata({ name: propertyNames, value: propertyValues, modifiable: modifiables, propertyCount: _metadataValues.length }); propertyNames = new string[](_secondaryMetadata.length); propertyValues = new string[](_secondaryMetadata.length); modifiables = new bool[](_secondaryMetadata.length); for (uint256 i = 0; i < _secondaryMetadata.length; i++) { propertyNames[i] = _secondaryMetadata[i][0]; propertyValues[i] = _secondaryMetadata[i][1]; modifiables[i] = (keccak256(abi.encodePacked((_secondaryMetadata[i][2]))) == keccak256(abi.encodePacked(('1')))); // 1 is modifiable, 0 is permanent } collection.secondaryMetadata[collectibleCount] = Metadata({ name: propertyNames, value: propertyValues, modifiable: modifiables, propertyCount: _secondaryMetadata.length }); uint256 editions = safeParseInt(_coreData[2]); createTokenIDs(cID, collectibleCount, editions); collection.collectibleCount++; collection.totalTokenCount = collection.totalTokenCount.add(editions); emit LogAddCollectible(cID, _coreData[0]); } function checkTokensForMintPass(uint256 cID, address minter, address contractAddress) private returns (bool) { Storage storage ds = packStorage(); uint256 count = ds.collection[cID].mintPassContract.balanceOf(minter); bool done = false; uint256 counter = 0; bool canClaim = false; while (!done && count > 0) { uint256 tokenID = ds.collection[cID].mintPassContract.tokenOfOwnerByIndex(minter, counter); if (ds.collection[cID].mintPassClaims[tokenID] != true) { ds.collection[cID].mintPassClaims[tokenID] = true; done = true; canClaim = true; if (ds.collection[cID].mintPassBurn) { ds.collection[cID].mintPassContract.safeTransferFrom(msg.sender, address(0xdEaD), tokenID); } } if (counter == count - 1) done = true; else counter++; } return canClaim; } function checkMintPass(address relics, uint256 cID, address user, address contractAddress) external relicSafety(relics) returns (bool) { Storage storage ds = packStorage(); bool canMintPass = false; if (ds.collection[cID].mintPass) { if (!ds.collection[cID].mintPassOnePerWallet || !ds.collection[cID].mintPassClaimed[user]) { if (checkTokensForMintPass(cID, user, contractAddress)) { canMintPass = true; if (ds.collection[cID].mintPassOnePerWallet) ds.collection[cID].mintPassClaimed[user] = true; } } } if (ds.collection[cID].mintPassOnly) { require(canMintPass, "Minting is restricted to mint passes only"); require(block.timestamp > ds.collection[cID].saleStartTime - ds.collection[cID].mintPassDuration, "Sale has not yet started"); } else { if (canMintPass) require (block.timestamp > (ds.collection[cID].saleStartTime - ds.collection[cID].mintPassDuration), "Sale has not yet started"); else require(block.timestamp > ds.collection[cID].saleStartTime, "Sale has not yet started"); } return canMintPass; } function bulkMintChecks(uint256 cID, uint256 amount) external { Storage storage ds = packStorage(); require(amount > 0, 'Missing amount'); require(!ds.collection[cID].mintPassOnly, 'Cannot bulk mint'); require(amount <= ds.collection[cID].bulkBuyLimit, "Cannot bulk buy more than the preset limit"); require(amount <= ds.collection[cID].shuffleIDs.length, "Total supply reached"); require((block.timestamp > ds.collection[cID].saleStartTime), "Sale has not yet started"); } function mintPassClaimed(uint256 cID, uint256 tokenId) public view returns (bool) { Storage storage ds = packStorage(); return (ds.collection[cID].mintPassClaims[tokenId] == true); } function tokensClaimable(uint256 cID, address minter) public view returns (uint256[] memory) { Storage storage ds = packStorage(); uint256 count = ds.collection[cID].mintPassContract.balanceOf(minter); bool done = false; uint256 counter = 0; uint256 index = 0; uint256[] memory claimable = new uint256[](count); while (!done && count > 0) { uint256 tokenID = ds.collection[cID].mintPassContract.tokenOfOwnerByIndex(minter, counter); if (ds.collection[cID].mintPassClaims[tokenID] != true) { claimable[index] = tokenID; index++; } if (counter == count - 1) done = true; else counter++; } return claimable; } function remainingTokens(uint256 cID) public view returns (uint256) { Storage storage ds = packStorage(); return ds.collection[cID].shuffleIDs.length; } // Modify property field only if marked as updateable function updateMetadata(uint256 cID, uint256 collectibleId, uint256 propertyIndex, string memory value) external onlyDAO { Storage storage ds = packStorage(); require(ds.collection[cID].metadata[collectibleId - 1].modifiable[propertyIndex], 'Field not editable'); ds.collection[cID].metadata[collectibleId - 1].value[propertyIndex] = value; emit LogUpdateMetadata(cID, collectibleId, propertyIndex, value); } // Add new asset, does not automatically increase current version function addVersion(uint256 cID, uint256 collectibleId, string memory asset) public onlyDAO { Storage storage ds = packStorage(); ds.collection[cID].collectibles[collectibleId - 1].assets[ds.collection[cID].collectibles[collectibleId - 1].totalVersionCount - 1] = asset; ds.collection[cID].collectibles[collectibleId - 1].totalVersionCount++; emit LogAddVersion(cID, collectibleId, asset); } // Set version number, index starts at version 1, collectible 1 (so shifts 1 for 0th index) // function updateVersion(uint256 cID, uint256 collectibleId, uint256 versionNumber) public onlyDAO { // Storage storage ds = packStorage(); // require(versionNumber > 0, "Versions start at 1"); // require(versionNumber <= ds.collection[cID].collectibles[collectibleId - 1].assets.length, "Versions must be less than asset count"); // require(collectibleId > 0, "Collectible IDs start at 1"); // ds.collection[cID].collectibles[collectibleId - 1].currentVersion = versionNumber; // emit LogUpdateVersion(cID, collectibleId, versionNumber); // } // Adds new license and updates version to latest function addNewLicense(uint256 cID, string memory _license) public onlyDAO { Storage storage ds = packStorage(); require(cID < ds.collectionCount, 'Collectible ID does not exist'); ds.collection[cID].licenseURI[ds.collection[cID].licenseVersion] = _license; ds.collection[cID].licenseVersion++; emit LogAddNewLicense(cID, _license); } function getLicense(uint256 cID, uint256 versionNumber) public view returns (string memory) { Storage storage ds = packStorage(); return ds.collection[cID].licenseURI[versionNumber - 1]; } function getCurrentLicense(uint256 cID) public view returns (string memory) { Storage storage ds = packStorage(); return ds.collection[cID].licenseURI[ds.collection[cID].licenseVersion - 1]; } // Dynamic base64 encoded metadata generation using on-chain metadata and edition numbers function tokenURI(uint256 tokenId) public view returns (string memory) { Storage storage ds = packStorage(); uint256 edition = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 5, bytes(toString(tokenId)).length)) - 1; uint256 collectibleId = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 8, bytes(toString(tokenId)).length - 5)) - 1; uint256 cID = ((tokenId - ((collectibleId + 1) * 100000)) - (edition + 1)) / 100000000 - 1; string memory encodedMetadata = ''; Collection storage collection = ds.collection[cID]; for (uint i = 0; i < collection.metadata[collectibleId].propertyCount; i++) { encodedMetadata = string(abi.encodePacked( encodedMetadata, '{"trait_type":"', collection.metadata[collectibleId].name[i], '", "value":"', collection.metadata[collectibleId].value[i], '", "permanent":"', collection.metadata[collectibleId].modifiable[i] ? 'false' : 'true', '"}', i == collection.metadata[collectibleId].propertyCount - 1 ? '' : ',') ); } string memory encodedSecondaryMetadata = ''; for (uint i = 0; i < collection.secondaryMetadata[collectibleId].propertyCount; i++) { encodedSecondaryMetadata = string(abi.encodePacked( encodedSecondaryMetadata, '{"trait_type":"', collection.secondaryMetadata[collectibleId].name[i], '", "value":"', collection.secondaryMetadata[collectibleId].value[i], '", "permanent":"', collection.secondaryMetadata[collectibleId].modifiable[i] ? 'false' : 'true', '"}', i == collection.secondaryMetadata[collectibleId].propertyCount - 1 ? '' : ',') ); } SingleCollectible storage collectible = collection.collectibles[collectibleId]; uint256 asset = collectible.currentVersion - 1; string memory encoded = string( abi.encodePacked( 'data:application/json;base64,', Base64.encode( bytes( abi.encodePacked( '{"name":"', collectible.title, collection.editioned ? ' #' : '', collection.editioned ? toString(edition + 1) : '', '", "description":"', collectible.description, '", "image": "', collection.baseURI, collectible.assets[asset], '", "license": "', getCurrentLicense(cID), '", "attributes": [', encodedMetadata, '], "secondaryAttributes": [', encodedSecondaryMetadata, '] }' ) ) ) ) ); return encoded; } // Secondary sale fees apply to each individual collectible ID (will apply to a range of tokenIDs); function getFeeRecipients(uint256 tokenId) public view returns (address payable[] memory) { Storage storage ds = packStorage(); uint256 edition = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 5, bytes(toString(tokenId)).length)) - 1; uint256 collectibleId = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 8, bytes(toString(tokenId)).length - 5)) - 1; uint256 cID = ((tokenId - ((collectibleId + 1) * 100000)) - (edition + 1)) / 100000000 - 1; Fee[] memory _fees = ds.collection[cID].secondaryFees[collectibleId]; address payable[] memory result = new address payable[](_fees.length); for (uint i = 0; i < _fees.length; i++) { result[i] = _fees[i].recipient; } return result; } function getFeeBps(uint256 tokenId) public view returns (uint[] memory) { Storage storage ds = packStorage(); uint256 edition = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 5, bytes(toString(tokenId)).length)) - 1; uint256 collectibleId = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 8, bytes(toString(tokenId)).length - 5)) - 1; uint256 cID = ((tokenId - ((collectibleId + 1) * 100000)) - (edition + 1)) / 100000000 - 1; Fee[] memory _fees = ds.collection[cID].secondaryFees[collectibleId]; uint[] memory result = new uint[](_fees.length); for (uint i = 0; i < _fees.length; i++) { result[i] = _fees[i].value; } return result; } function royaltyInfo(uint256 tokenId, uint256 value) public view returns (address recipient, uint256 amount){ address payable[] memory rec = getFeeRecipients(tokenId); require(rec.length <= 1, "More than 1 royalty recipient"); if (rec.length == 0) return (address(this), 0); return (rec[0], getFeeBps(tokenId)[0] * value / 10000); } function toString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = bytes1(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } function safeParseInt(string memory _a) internal pure returns (uint _parsedInt) { return safeParseInt(_a, 0); } function safeParseInt(string memory _a, uint _b) internal pure returns (uint _parsedInt) { bytes memory bresult = bytes(_a); uint mint = 0; bool decimals = false; for (uint i = 0; i < bresult.length; i++) { if ((uint(uint8(bresult[i])) >= 48) && (uint(uint8(bresult[i])) <= 57)) { if (decimals) { if (_b == 0) break; else _b--; } mint *= 10; mint += uint(uint8(bresult[i])) - 48; } else if (uint(uint8(bresult[i])) == 46) { require(!decimals, 'More than one decimal encountered in string!'); decimals = true; } else { revert("Non-numeral character encountered in string!"); } } if (_b > 0) { mint *= 10 ** _b; } return mint; } function substring(string memory str, uint startIndex, uint endIndex) internal pure returns (string memory) { bytes memory strBytes = bytes(str); bytes memory result = new bytes(endIndex-startIndex); for(uint i = startIndex; i < endIndex; i++) { result[i-startIndex] = strBytes[i]; } return string(result); } }
getFeeRecipients
function getFeeRecipients(uint256 tokenId) public view returns (address payable[] memory) { Storage storage ds = packStorage(); uint256 edition = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 5, bytes(toString(tokenId)).length)) - 1; uint256 collectibleId = safeParseInt(substring(toString(tokenId), bytes(toString(tokenId)).length - 8, bytes(toString(tokenId)).length - 5)) - 1; uint256 cID = ((tokenId - ((collectibleId + 1) * 100000)) - (edition + 1)) / 100000000 - 1; Fee[] memory _fees = ds.collection[cID].secondaryFees[collectibleId]; address payable[] memory result = new address payable[](_fees.length); for (uint i = 0; i < _fees.length; i++) { result[i] = _fees[i].recipient; } return result; }
// Secondary sale fees apply to each individual collectible ID (will apply to a range of tokenIDs);
LineComment
v0.7.3+commit.9bfce1f6
{ "func_code_index": [ 18161, 18943 ] }
69
VaultSwapper
VaultSwapper.sol
0xf12eeab1c759dd7d8c012cca6d8715eed80e51b6
Solidity
VaultSwapper
contract VaultSwapper { Registry constant registry = Registry(0x90E00ACe148ca3b23Ac1bC8C240C2a7Dd9c2d7f5); uint256 constant MIN_AMOUNT_OUT = 1; struct Swap { bool deposit; address pool; uint128 n; } /* @notice Swap with apoval using eip-2612 @param from_vault The vault tokens should be taken from @param to_vault The vault tokens should be deposited to @param amount The amount of tokens you whish to use from the from_vault @param min_amount_out The minimal amount of tokens you would expect from the to_vault @param expiry signature expiry @param signature signature */ function metapool_swap_with_signature( address from_vault, address to_vault, uint256 amount, uint256 min_amount_out, uint256 expiry, bytes calldata signature ) public { assert(Vault(from_vault).permit(msg.sender, address(this), amount, expiry, signature)); metapool_swap(from_vault, to_vault, amount, min_amount_out); } /** @notice swap tokens from one meta pool vault to an other @dev Remove funds from a vault, move one side of the asset from one curve pool to an other and deposit into the new vault. @param from_vault The vault tokens should be taken from @param to_vault The vault tokens should be deposited to @param amount The amount of tokens you whish to use from the from_vault @param min_amount_out The minimal amount of tokens you would expect from the to_vault */ function metapool_swap( address from_vault, address to_vault, uint256 amount, uint256 min_amount_out ) public { address underlying = Vault(from_vault).token(); address target = Vault(to_vault).token(); address underlying_pool = registry.get_pool_from_lp_token(underlying); address target_pool = registry.get_pool_from_lp_token(target); Vault(from_vault).transferFrom(msg.sender, address(this), amount); uint256 underlying_amount = Vault(from_vault).withdraw( amount, address(this) ); StableSwap(underlying_pool).remove_liquidity_one_coin( underlying_amount, 1, 1 ); IERC20 underlying_coin = IERC20(registry.get_coins(underlying_pool)[1]); uint256 liquidity_amount = underlying_coin.balanceOf(address(this)); underlying_coin.approve(target_pool, liquidity_amount); StableSwap(target_pool).add_liquidity([0, liquidity_amount], MIN_AMOUNT_OUT); uint256 target_amount = IERC20(target).balanceOf(address(this)); approve(target, to_vault, target_amount); uint256 out = Vault(to_vault).deposit(target_amount, msg.sender); require(out >= min_amount_out, "out too low"); } /** @notice estimate the amount of tokens out @param from_vault The vault tokens should be taken from @param to_vault The vault tokens should be deposited to @param amount The amount of tokens you whish to use from the from_vault @return the amount of token shared expected in the to_vault */ function metapool_estimate_out( address from_vault, address to_vault, uint256 amount ) public view returns (uint256) { address underlying = Vault(from_vault).token(); address target = Vault(to_vault).token(); address underlying_pool = registry.get_pool_from_lp_token(underlying); address target_pool = registry.get_pool_from_lp_token(target); uint256 pricePerShareFrom = Vault(from_vault).pricePerShare(); uint256 pricePerShareTo = Vault(to_vault).pricePerShare(); uint256 amount_out = (pricePerShareFrom * amount) / (10**Vault(from_vault).decimals()); amount_out = StableSwap(underlying_pool).calc_withdraw_one_coin( amount_out, 1 ); amount_out = StableSwap(target_pool).calc_token_amount( [0, amount_out], true ); return (amount_out * (10**Vault(to_vault).decimals())) / pricePerShareTo; } function swap_with_signature( address from_vault, address to_vault, uint256 amount, uint256 min_amount_out, Swap[] calldata instructions, uint256 expiry, bytes calldata signature ) public { assert(Vault(from_vault).permit(msg.sender, address(this), amount, expiry, signature)); swap(from_vault, to_vault, amount, min_amount_out, instructions); } function swap( address from_vault, address to_vault, uint256 amount, uint256 min_amount_out, Swap[] calldata instructions ) public { address token = Vault(from_vault).token(); address target = Vault(to_vault).token(); Vault(from_vault).transferFrom(msg.sender, address(this), amount); amount = Vault(from_vault).withdraw(amount, address(this)); uint256 n_coins; for (uint256 i = 0; i < instructions.length; i++) { if (instructions[i].deposit) { n_coins = registry.get_n_coins(instructions[i].pool)[0]; uint256[] memory list = new uint256[](n_coins); list[instructions[i].n] = amount; approve(token, instructions[i].pool, amount); if (n_coins == 2) { StableSwap(instructions[i].pool).add_liquidity( [list[0], list[1]], 1 ); } else if (n_coins == 3) { StableSwap(instructions[i].pool).add_liquidity( [list[0], list[1], list[2]], 1 ); } else if (n_coins == 4) { StableSwap(instructions[i].pool).add_liquidity( [list[0], list[1], list[2], list[3]], 1 ); } token = registry.get_lp_token(instructions[i].pool); amount = IERC20(token).balanceOf(address(this)); } else { token = registry.get_coins(instructions[i].pool)[ instructions[i].n ]; amount = remove_liquidity_one_coin( token, instructions[i].pool, amount, instructions[i].n ); } } require(target == token, "!path"); approve(target, to_vault, amount); uint256 out = Vault(to_vault).deposit(amount, msg.sender); require(out >= min_amount_out, "out too low"); } function remove_liquidity_one_coin( address token, address pool, uint256 amount, uint128 n ) internal returns (uint256) { uint256 amountBefore = IERC20(token).balanceOf(address(this)); pool.call( abi.encodeWithSignature( "remove_liquidity_one_coin(uint256,int128,uint256)", amount, int128(n), 1 ) ); uint256 newAmount = IERC20(token).balanceOf(address(this)); if (newAmount > amountBefore) { return newAmount; } pool.call( abi.encodeWithSignature( "remove_liquidity_one_coin(uint256,uint256,uint256)", amount, uint256(n), 1 ) ); return IERC20(token).balanceOf(address(this)); } function estimate_out( address from_vault, address to_vault, uint256 amount, Swap[] calldata instructions ) public view returns (uint256) { uint256 pricePerShareFrom = Vault(from_vault).pricePerShare(); uint256 pricePerShareTo = Vault(to_vault).pricePerShare(); amount = (amount * pricePerShareFrom) / (10**Vault(from_vault).decimals()); for (uint256 i = 0; i < instructions.length; i++) { uint256 n_coins = registry.get_n_coins(instructions[i].pool)[0]; if (instructions[i].deposit) { n_coins = registry.get_n_coins(instructions[i].pool)[0]; uint256[] memory list = new uint256[](n_coins); list[instructions[i].n] = amount; if (n_coins == 2) { amount = StableSwap(instructions[i].pool).calc_token_amount( [list[0], list[1]], true ); } else if (n_coins == 3) { amount = StableSwap(instructions[i].pool).calc_token_amount( [list[0], list[1], list[2]], true ); } else if (n_coins == 4) { amount = StableSwap(instructions[i].pool).calc_token_amount( [list[0], list[1], list[2], list[3]], true ); } } else { amount = calc_withdraw_one_coin( instructions[i].pool, amount, instructions[i].n ); } } return (amount * (10**Vault(to_vault).decimals())) / pricePerShareTo; } function approve( address target, address to_vault, uint256 amount ) internal { if (IERC20(target).allowance(address(this), to_vault) < amount) { SafeERC20.safeApprove(IERC20(target), to_vault, 0); SafeERC20.safeApprove(IERC20(target), to_vault, type(uint256).max); } } function calc_withdraw_one_coin( address pool, uint256 amount, uint128 n ) internal view returns (uint256) { (bool success, bytes memory returnData) = pool.staticcall( abi.encodeWithSignature( "calc_withdraw_one_coin(uint256,uint256)", amount, uint256(n) ) ); if (success) { return abi.decode(returnData, (uint256)); } (success, returnData) = pool.staticcall( abi.encodeWithSignature( "calc_withdraw_one_coin(uint256,int128)", amount, int128(n) ) ); require(success, "!success"); return abi.decode(returnData, (uint256)); } }
metapool_swap_with_signature
function metapool_swap_with_signature( address from_vault, address to_vault, uint256 amount, uint256 min_amount_out, uint256 expiry, bytes calldata signature ) public { assert(Vault(from_vault).permit(msg.sender, address(this), amount, expiry, signature)); metapool_swap(from_vault, to_vault, amount, min_amount_out); }
/* @notice Swap with apoval using eip-2612 @param from_vault The vault tokens should be taken from @param to_vault The vault tokens should be deposited to @param amount The amount of tokens you whish to use from the from_vault @param min_amount_out The minimal amount of tokens you would expect from the to_vault @param expiry signature expiry @param signature signature */
Comment
v0.8.6+commit.11564f7e
MIT
{ "func_code_index": [ 680, 1076 ] }
70
VaultSwapper
VaultSwapper.sol
0xf12eeab1c759dd7d8c012cca6d8715eed80e51b6
Solidity
VaultSwapper
contract VaultSwapper { Registry constant registry = Registry(0x90E00ACe148ca3b23Ac1bC8C240C2a7Dd9c2d7f5); uint256 constant MIN_AMOUNT_OUT = 1; struct Swap { bool deposit; address pool; uint128 n; } /* @notice Swap with apoval using eip-2612 @param from_vault The vault tokens should be taken from @param to_vault The vault tokens should be deposited to @param amount The amount of tokens you whish to use from the from_vault @param min_amount_out The minimal amount of tokens you would expect from the to_vault @param expiry signature expiry @param signature signature */ function metapool_swap_with_signature( address from_vault, address to_vault, uint256 amount, uint256 min_amount_out, uint256 expiry, bytes calldata signature ) public { assert(Vault(from_vault).permit(msg.sender, address(this), amount, expiry, signature)); metapool_swap(from_vault, to_vault, amount, min_amount_out); } /** @notice swap tokens from one meta pool vault to an other @dev Remove funds from a vault, move one side of the asset from one curve pool to an other and deposit into the new vault. @param from_vault The vault tokens should be taken from @param to_vault The vault tokens should be deposited to @param amount The amount of tokens you whish to use from the from_vault @param min_amount_out The minimal amount of tokens you would expect from the to_vault */ function metapool_swap( address from_vault, address to_vault, uint256 amount, uint256 min_amount_out ) public { address underlying = Vault(from_vault).token(); address target = Vault(to_vault).token(); address underlying_pool = registry.get_pool_from_lp_token(underlying); address target_pool = registry.get_pool_from_lp_token(target); Vault(from_vault).transferFrom(msg.sender, address(this), amount); uint256 underlying_amount = Vault(from_vault).withdraw( amount, address(this) ); StableSwap(underlying_pool).remove_liquidity_one_coin( underlying_amount, 1, 1 ); IERC20 underlying_coin = IERC20(registry.get_coins(underlying_pool)[1]); uint256 liquidity_amount = underlying_coin.balanceOf(address(this)); underlying_coin.approve(target_pool, liquidity_amount); StableSwap(target_pool).add_liquidity([0, liquidity_amount], MIN_AMOUNT_OUT); uint256 target_amount = IERC20(target).balanceOf(address(this)); approve(target, to_vault, target_amount); uint256 out = Vault(to_vault).deposit(target_amount, msg.sender); require(out >= min_amount_out, "out too low"); } /** @notice estimate the amount of tokens out @param from_vault The vault tokens should be taken from @param to_vault The vault tokens should be deposited to @param amount The amount of tokens you whish to use from the from_vault @return the amount of token shared expected in the to_vault */ function metapool_estimate_out( address from_vault, address to_vault, uint256 amount ) public view returns (uint256) { address underlying = Vault(from_vault).token(); address target = Vault(to_vault).token(); address underlying_pool = registry.get_pool_from_lp_token(underlying); address target_pool = registry.get_pool_from_lp_token(target); uint256 pricePerShareFrom = Vault(from_vault).pricePerShare(); uint256 pricePerShareTo = Vault(to_vault).pricePerShare(); uint256 amount_out = (pricePerShareFrom * amount) / (10**Vault(from_vault).decimals()); amount_out = StableSwap(underlying_pool).calc_withdraw_one_coin( amount_out, 1 ); amount_out = StableSwap(target_pool).calc_token_amount( [0, amount_out], true ); return (amount_out * (10**Vault(to_vault).decimals())) / pricePerShareTo; } function swap_with_signature( address from_vault, address to_vault, uint256 amount, uint256 min_amount_out, Swap[] calldata instructions, uint256 expiry, bytes calldata signature ) public { assert(Vault(from_vault).permit(msg.sender, address(this), amount, expiry, signature)); swap(from_vault, to_vault, amount, min_amount_out, instructions); } function swap( address from_vault, address to_vault, uint256 amount, uint256 min_amount_out, Swap[] calldata instructions ) public { address token = Vault(from_vault).token(); address target = Vault(to_vault).token(); Vault(from_vault).transferFrom(msg.sender, address(this), amount); amount = Vault(from_vault).withdraw(amount, address(this)); uint256 n_coins; for (uint256 i = 0; i < instructions.length; i++) { if (instructions[i].deposit) { n_coins = registry.get_n_coins(instructions[i].pool)[0]; uint256[] memory list = new uint256[](n_coins); list[instructions[i].n] = amount; approve(token, instructions[i].pool, amount); if (n_coins == 2) { StableSwap(instructions[i].pool).add_liquidity( [list[0], list[1]], 1 ); } else if (n_coins == 3) { StableSwap(instructions[i].pool).add_liquidity( [list[0], list[1], list[2]], 1 ); } else if (n_coins == 4) { StableSwap(instructions[i].pool).add_liquidity( [list[0], list[1], list[2], list[3]], 1 ); } token = registry.get_lp_token(instructions[i].pool); amount = IERC20(token).balanceOf(address(this)); } else { token = registry.get_coins(instructions[i].pool)[ instructions[i].n ]; amount = remove_liquidity_one_coin( token, instructions[i].pool, amount, instructions[i].n ); } } require(target == token, "!path"); approve(target, to_vault, amount); uint256 out = Vault(to_vault).deposit(amount, msg.sender); require(out >= min_amount_out, "out too low"); } function remove_liquidity_one_coin( address token, address pool, uint256 amount, uint128 n ) internal returns (uint256) { uint256 amountBefore = IERC20(token).balanceOf(address(this)); pool.call( abi.encodeWithSignature( "remove_liquidity_one_coin(uint256,int128,uint256)", amount, int128(n), 1 ) ); uint256 newAmount = IERC20(token).balanceOf(address(this)); if (newAmount > amountBefore) { return newAmount; } pool.call( abi.encodeWithSignature( "remove_liquidity_one_coin(uint256,uint256,uint256)", amount, uint256(n), 1 ) ); return IERC20(token).balanceOf(address(this)); } function estimate_out( address from_vault, address to_vault, uint256 amount, Swap[] calldata instructions ) public view returns (uint256) { uint256 pricePerShareFrom = Vault(from_vault).pricePerShare(); uint256 pricePerShareTo = Vault(to_vault).pricePerShare(); amount = (amount * pricePerShareFrom) / (10**Vault(from_vault).decimals()); for (uint256 i = 0; i < instructions.length; i++) { uint256 n_coins = registry.get_n_coins(instructions[i].pool)[0]; if (instructions[i].deposit) { n_coins = registry.get_n_coins(instructions[i].pool)[0]; uint256[] memory list = new uint256[](n_coins); list[instructions[i].n] = amount; if (n_coins == 2) { amount = StableSwap(instructions[i].pool).calc_token_amount( [list[0], list[1]], true ); } else if (n_coins == 3) { amount = StableSwap(instructions[i].pool).calc_token_amount( [list[0], list[1], list[2]], true ); } else if (n_coins == 4) { amount = StableSwap(instructions[i].pool).calc_token_amount( [list[0], list[1], list[2], list[3]], true ); } } else { amount = calc_withdraw_one_coin( instructions[i].pool, amount, instructions[i].n ); } } return (amount * (10**Vault(to_vault).decimals())) / pricePerShareTo; } function approve( address target, address to_vault, uint256 amount ) internal { if (IERC20(target).allowance(address(this), to_vault) < amount) { SafeERC20.safeApprove(IERC20(target), to_vault, 0); SafeERC20.safeApprove(IERC20(target), to_vault, type(uint256).max); } } function calc_withdraw_one_coin( address pool, uint256 amount, uint128 n ) internal view returns (uint256) { (bool success, bytes memory returnData) = pool.staticcall( abi.encodeWithSignature( "calc_withdraw_one_coin(uint256,uint256)", amount, uint256(n) ) ); if (success) { return abi.decode(returnData, (uint256)); } (success, returnData) = pool.staticcall( abi.encodeWithSignature( "calc_withdraw_one_coin(uint256,int128)", amount, int128(n) ) ); require(success, "!success"); return abi.decode(returnData, (uint256)); } }
metapool_swap
function metapool_swap( address from_vault, address to_vault, uint256 amount, uint256 min_amount_out ) public { address underlying = Vault(from_vault).token(); address target = Vault(to_vault).token(); address underlying_pool = registry.get_pool_from_lp_token(underlying); address target_pool = registry.get_pool_from_lp_token(target); Vault(from_vault).transferFrom(msg.sender, address(this), amount); uint256 underlying_amount = Vault(from_vault).withdraw( amount, address(this) ); StableSwap(underlying_pool).remove_liquidity_one_coin( underlying_amount, 1, 1 ); IERC20 underlying_coin = IERC20(registry.get_coins(underlying_pool)[1]); uint256 liquidity_amount = underlying_coin.balanceOf(address(this)); underlying_coin.approve(target_pool, liquidity_amount); StableSwap(target_pool).add_liquidity([0, liquidity_amount], MIN_AMOUNT_OUT); uint256 target_amount = IERC20(target).balanceOf(address(this)); approve(target, to_vault, target_amount); uint256 out = Vault(to_vault).deposit(target_amount, msg.sender); require(out >= min_amount_out, "out too low"); }
/** @notice swap tokens from one meta pool vault to an other @dev Remove funds from a vault, move one side of the asset from one curve pool to an other and deposit into the new vault. @param from_vault The vault tokens should be taken from @param to_vault The vault tokens should be deposited to @param amount The amount of tokens you whish to use from the from_vault @param min_amount_out The minimal amount of tokens you would expect from the to_vault */
NatSpecMultiLine
v0.8.6+commit.11564f7e
MIT
{ "func_code_index": [ 1609, 2919 ] }
71
VaultSwapper
VaultSwapper.sol
0xf12eeab1c759dd7d8c012cca6d8715eed80e51b6
Solidity
VaultSwapper
contract VaultSwapper { Registry constant registry = Registry(0x90E00ACe148ca3b23Ac1bC8C240C2a7Dd9c2d7f5); uint256 constant MIN_AMOUNT_OUT = 1; struct Swap { bool deposit; address pool; uint128 n; } /* @notice Swap with apoval using eip-2612 @param from_vault The vault tokens should be taken from @param to_vault The vault tokens should be deposited to @param amount The amount of tokens you whish to use from the from_vault @param min_amount_out The minimal amount of tokens you would expect from the to_vault @param expiry signature expiry @param signature signature */ function metapool_swap_with_signature( address from_vault, address to_vault, uint256 amount, uint256 min_amount_out, uint256 expiry, bytes calldata signature ) public { assert(Vault(from_vault).permit(msg.sender, address(this), amount, expiry, signature)); metapool_swap(from_vault, to_vault, amount, min_amount_out); } /** @notice swap tokens from one meta pool vault to an other @dev Remove funds from a vault, move one side of the asset from one curve pool to an other and deposit into the new vault. @param from_vault The vault tokens should be taken from @param to_vault The vault tokens should be deposited to @param amount The amount of tokens you whish to use from the from_vault @param min_amount_out The minimal amount of tokens you would expect from the to_vault */ function metapool_swap( address from_vault, address to_vault, uint256 amount, uint256 min_amount_out ) public { address underlying = Vault(from_vault).token(); address target = Vault(to_vault).token(); address underlying_pool = registry.get_pool_from_lp_token(underlying); address target_pool = registry.get_pool_from_lp_token(target); Vault(from_vault).transferFrom(msg.sender, address(this), amount); uint256 underlying_amount = Vault(from_vault).withdraw( amount, address(this) ); StableSwap(underlying_pool).remove_liquidity_one_coin( underlying_amount, 1, 1 ); IERC20 underlying_coin = IERC20(registry.get_coins(underlying_pool)[1]); uint256 liquidity_amount = underlying_coin.balanceOf(address(this)); underlying_coin.approve(target_pool, liquidity_amount); StableSwap(target_pool).add_liquidity([0, liquidity_amount], MIN_AMOUNT_OUT); uint256 target_amount = IERC20(target).balanceOf(address(this)); approve(target, to_vault, target_amount); uint256 out = Vault(to_vault).deposit(target_amount, msg.sender); require(out >= min_amount_out, "out too low"); } /** @notice estimate the amount of tokens out @param from_vault The vault tokens should be taken from @param to_vault The vault tokens should be deposited to @param amount The amount of tokens you whish to use from the from_vault @return the amount of token shared expected in the to_vault */ function metapool_estimate_out( address from_vault, address to_vault, uint256 amount ) public view returns (uint256) { address underlying = Vault(from_vault).token(); address target = Vault(to_vault).token(); address underlying_pool = registry.get_pool_from_lp_token(underlying); address target_pool = registry.get_pool_from_lp_token(target); uint256 pricePerShareFrom = Vault(from_vault).pricePerShare(); uint256 pricePerShareTo = Vault(to_vault).pricePerShare(); uint256 amount_out = (pricePerShareFrom * amount) / (10**Vault(from_vault).decimals()); amount_out = StableSwap(underlying_pool).calc_withdraw_one_coin( amount_out, 1 ); amount_out = StableSwap(target_pool).calc_token_amount( [0, amount_out], true ); return (amount_out * (10**Vault(to_vault).decimals())) / pricePerShareTo; } function swap_with_signature( address from_vault, address to_vault, uint256 amount, uint256 min_amount_out, Swap[] calldata instructions, uint256 expiry, bytes calldata signature ) public { assert(Vault(from_vault).permit(msg.sender, address(this), amount, expiry, signature)); swap(from_vault, to_vault, amount, min_amount_out, instructions); } function swap( address from_vault, address to_vault, uint256 amount, uint256 min_amount_out, Swap[] calldata instructions ) public { address token = Vault(from_vault).token(); address target = Vault(to_vault).token(); Vault(from_vault).transferFrom(msg.sender, address(this), amount); amount = Vault(from_vault).withdraw(amount, address(this)); uint256 n_coins; for (uint256 i = 0; i < instructions.length; i++) { if (instructions[i].deposit) { n_coins = registry.get_n_coins(instructions[i].pool)[0]; uint256[] memory list = new uint256[](n_coins); list[instructions[i].n] = amount; approve(token, instructions[i].pool, amount); if (n_coins == 2) { StableSwap(instructions[i].pool).add_liquidity( [list[0], list[1]], 1 ); } else if (n_coins == 3) { StableSwap(instructions[i].pool).add_liquidity( [list[0], list[1], list[2]], 1 ); } else if (n_coins == 4) { StableSwap(instructions[i].pool).add_liquidity( [list[0], list[1], list[2], list[3]], 1 ); } token = registry.get_lp_token(instructions[i].pool); amount = IERC20(token).balanceOf(address(this)); } else { token = registry.get_coins(instructions[i].pool)[ instructions[i].n ]; amount = remove_liquidity_one_coin( token, instructions[i].pool, amount, instructions[i].n ); } } require(target == token, "!path"); approve(target, to_vault, amount); uint256 out = Vault(to_vault).deposit(amount, msg.sender); require(out >= min_amount_out, "out too low"); } function remove_liquidity_one_coin( address token, address pool, uint256 amount, uint128 n ) internal returns (uint256) { uint256 amountBefore = IERC20(token).balanceOf(address(this)); pool.call( abi.encodeWithSignature( "remove_liquidity_one_coin(uint256,int128,uint256)", amount, int128(n), 1 ) ); uint256 newAmount = IERC20(token).balanceOf(address(this)); if (newAmount > amountBefore) { return newAmount; } pool.call( abi.encodeWithSignature( "remove_liquidity_one_coin(uint256,uint256,uint256)", amount, uint256(n), 1 ) ); return IERC20(token).balanceOf(address(this)); } function estimate_out( address from_vault, address to_vault, uint256 amount, Swap[] calldata instructions ) public view returns (uint256) { uint256 pricePerShareFrom = Vault(from_vault).pricePerShare(); uint256 pricePerShareTo = Vault(to_vault).pricePerShare(); amount = (amount * pricePerShareFrom) / (10**Vault(from_vault).decimals()); for (uint256 i = 0; i < instructions.length; i++) { uint256 n_coins = registry.get_n_coins(instructions[i].pool)[0]; if (instructions[i].deposit) { n_coins = registry.get_n_coins(instructions[i].pool)[0]; uint256[] memory list = new uint256[](n_coins); list[instructions[i].n] = amount; if (n_coins == 2) { amount = StableSwap(instructions[i].pool).calc_token_amount( [list[0], list[1]], true ); } else if (n_coins == 3) { amount = StableSwap(instructions[i].pool).calc_token_amount( [list[0], list[1], list[2]], true ); } else if (n_coins == 4) { amount = StableSwap(instructions[i].pool).calc_token_amount( [list[0], list[1], list[2], list[3]], true ); } } else { amount = calc_withdraw_one_coin( instructions[i].pool, amount, instructions[i].n ); } } return (amount * (10**Vault(to_vault).decimals())) / pricePerShareTo; } function approve( address target, address to_vault, uint256 amount ) internal { if (IERC20(target).allowance(address(this), to_vault) < amount) { SafeERC20.safeApprove(IERC20(target), to_vault, 0); SafeERC20.safeApprove(IERC20(target), to_vault, type(uint256).max); } } function calc_withdraw_one_coin( address pool, uint256 amount, uint128 n ) internal view returns (uint256) { (bool success, bytes memory returnData) = pool.staticcall( abi.encodeWithSignature( "calc_withdraw_one_coin(uint256,uint256)", amount, uint256(n) ) ); if (success) { return abi.decode(returnData, (uint256)); } (success, returnData) = pool.staticcall( abi.encodeWithSignature( "calc_withdraw_one_coin(uint256,int128)", amount, int128(n) ) ); require(success, "!success"); return abi.decode(returnData, (uint256)); } }
metapool_estimate_out
function metapool_estimate_out( address from_vault, address to_vault, uint256 amount ) public view returns (uint256) { address underlying = Vault(from_vault).token(); address target = Vault(to_vault).token(); address underlying_pool = registry.get_pool_from_lp_token(underlying); address target_pool = registry.get_pool_from_lp_token(target); uint256 pricePerShareFrom = Vault(from_vault).pricePerShare(); uint256 pricePerShareTo = Vault(to_vault).pricePerShare(); uint256 amount_out = (pricePerShareFrom * amount) / (10**Vault(from_vault).decimals()); amount_out = StableSwap(underlying_pool).calc_withdraw_one_coin( amount_out, 1 ); amount_out = StableSwap(target_pool).calc_token_amount( [0, amount_out], true ); return (amount_out * (10**Vault(to_vault).decimals())) / pricePerShareTo; }
/** @notice estimate the amount of tokens out @param from_vault The vault tokens should be taken from @param to_vault The vault tokens should be deposited to @param amount The amount of tokens you whish to use from the from_vault @return the amount of token shared expected in the to_vault */
NatSpecMultiLine
v0.8.6+commit.11564f7e
MIT
{ "func_code_index": [ 3263, 4262 ] }
72
TIMETokenFundraiser
contracts/trait/HasOwner.sol
0xed6849727f7b158a14a492bd0a3bf4d7126f7f71
Solidity
HasOwner
contract HasOwner { // The current owner. address public owner; // Conditionally the new owner. address public newOwner; /** * @dev The constructor. * * @param _owner The address of the owner. */ constructor(address _owner) public { owner = _owner; } /** * @dev Access control modifier that allows only the current owner to call the function. */ modifier onlyOwner { require(msg.sender == owner, "Only owner can call this function"); _; } /** * @dev The event is fired when the current owner is changed. * * @param _oldOwner The address of the previous owner. * @param _newOwner The address of the new owner. */ event OwnershipTransfer(address indexed _oldOwner, address indexed _newOwner); /** * @dev Transfering the ownership is a two-step process, as we prepare * for the transfer by setting `newOwner` and requiring `newOwner` to accept * the transfer. This prevents accidental lock-out if something goes wrong * when passing the `newOwner` address. * * @param _newOwner The address of the proposed new owner. */ function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } /** * @dev The `newOwner` finishes the ownership transfer process by accepting the * ownership. */ function acceptOwnership() public { require(msg.sender == newOwner, "Only the newOwner can accept ownership"); emit OwnershipTransfer(owner, newOwner); owner = newOwner; } }
/** * @title HasOwner * * @dev Allows for exclusive access to certain functionality. */
NatSpecMultiLine
transferOwnership
function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; }
/** * @dev Transfering the ownership is a two-step process, as we prepare * for the transfer by setting `newOwner` and requiring `newOwner` to accept * the transfer. This prevents accidental lock-out if something goes wrong * when passing the `newOwner` address. * * @param _newOwner The address of the proposed new owner. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://ce167343b1dcaa8725159d95e78bc955e63e34546b19b99b083b3441ce0618e7
{ "func_code_index": [ 1229, 1336 ] }
73
TIMETokenFundraiser
contracts/trait/HasOwner.sol
0xed6849727f7b158a14a492bd0a3bf4d7126f7f71
Solidity
HasOwner
contract HasOwner { // The current owner. address public owner; // Conditionally the new owner. address public newOwner; /** * @dev The constructor. * * @param _owner The address of the owner. */ constructor(address _owner) public { owner = _owner; } /** * @dev Access control modifier that allows only the current owner to call the function. */ modifier onlyOwner { require(msg.sender == owner, "Only owner can call this function"); _; } /** * @dev The event is fired when the current owner is changed. * * @param _oldOwner The address of the previous owner. * @param _newOwner The address of the new owner. */ event OwnershipTransfer(address indexed _oldOwner, address indexed _newOwner); /** * @dev Transfering the ownership is a two-step process, as we prepare * for the transfer by setting `newOwner` and requiring `newOwner` to accept * the transfer. This prevents accidental lock-out if something goes wrong * when passing the `newOwner` address. * * @param _newOwner The address of the proposed new owner. */ function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } /** * @dev The `newOwner` finishes the ownership transfer process by accepting the * ownership. */ function acceptOwnership() public { require(msg.sender == newOwner, "Only the newOwner can accept ownership"); emit OwnershipTransfer(owner, newOwner); owner = newOwner; } }
/** * @title HasOwner * * @dev Allows for exclusive access to certain functionality. */
NatSpecMultiLine
acceptOwnership
function acceptOwnership() public { require(msg.sender == newOwner, "Only the newOwner can accept ownership"); emit OwnershipTransfer(owner, newOwner); owner = newOwner; }
/** * @dev The `newOwner` finishes the ownership transfer process by accepting the * ownership. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://ce167343b1dcaa8725159d95e78bc955e63e34546b19b99b083b3441ce0618e7
{ "func_code_index": [ 1462, 1674 ] }
74
TIMETokenFundraiser
contracts/token/MintableToken.sol
0xed6849727f7b158a14a492bd0a3bf4d7126f7f71
Solidity
MintableToken
contract MintableToken is StandardToken { /// @dev The only address allowed to mint coins address public minter; /// @dev Indicates whether the token is still mintable. bool public mintingDisabled = false; /** * @dev Event fired when minting is no longer allowed. */ event MintingDisabled(); /** * @dev Allows a function to be executed only if minting is still allowed. */ modifier canMint() { require(!mintingDisabled, "Minting is disabled"); _; } /** * @dev Allows a function to be called only by the minter */ modifier onlyMinter() { require(msg.sender == minter, "Only the minter address can mint"); _; } /** * @dev The constructor assigns the minter which is allowed to mind and disable minting */ constructor(address _minter) internal { minter = _minter; } /** * @dev Creates new `_value` number of tokens and sends them to the `_to` address. * * @param _to The address which will receive the freshly minted tokens. * @param _value The number of tokens that will be created. */ function mint(address _to, uint256 _value) public onlyMinter canMint { totalSupply = totalSupply.plus(_value); balances[_to] = balances[_to].plus(_value); emit Transfer(0x0, _to, _value); } /** * @dev Disable the minting of new tokens. Cannot be reversed. * * @return Whether or not the process was successful. */ function disableMinting() public onlyMinter canMint { mintingDisabled = true; emit MintingDisabled(); } }
/** * @title Mintable Token * * @dev Allows the creation of new tokens. */
NatSpecMultiLine
mint
function mint(address _to, uint256 _value) public onlyMinter canMint { totalSupply = totalSupply.plus(_value); balances[_to] = balances[_to].plus(_value); emit Transfer(0x0, _to, _value); }
/** * @dev Creates new `_value` number of tokens and sends them to the `_to` address. * * @param _to The address which will receive the freshly minted tokens. * @param _value The number of tokens that will be created. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://ce167343b1dcaa8725159d95e78bc955e63e34546b19b99b083b3441ce0618e7
{ "func_code_index": [ 1195, 1423 ] }
75
TIMETokenFundraiser
contracts/token/MintableToken.sol
0xed6849727f7b158a14a492bd0a3bf4d7126f7f71
Solidity
MintableToken
contract MintableToken is StandardToken { /// @dev The only address allowed to mint coins address public minter; /// @dev Indicates whether the token is still mintable. bool public mintingDisabled = false; /** * @dev Event fired when minting is no longer allowed. */ event MintingDisabled(); /** * @dev Allows a function to be executed only if minting is still allowed. */ modifier canMint() { require(!mintingDisabled, "Minting is disabled"); _; } /** * @dev Allows a function to be called only by the minter */ modifier onlyMinter() { require(msg.sender == minter, "Only the minter address can mint"); _; } /** * @dev The constructor assigns the minter which is allowed to mind and disable minting */ constructor(address _minter) internal { minter = _minter; } /** * @dev Creates new `_value` number of tokens and sends them to the `_to` address. * * @param _to The address which will receive the freshly minted tokens. * @param _value The number of tokens that will be created. */ function mint(address _to, uint256 _value) public onlyMinter canMint { totalSupply = totalSupply.plus(_value); balances[_to] = balances[_to].plus(_value); emit Transfer(0x0, _to, _value); } /** * @dev Disable the minting of new tokens. Cannot be reversed. * * @return Whether or not the process was successful. */ function disableMinting() public onlyMinter canMint { mintingDisabled = true; emit MintingDisabled(); } }
/** * @title Mintable Token * * @dev Allows the creation of new tokens. */
NatSpecMultiLine
disableMinting
function disableMinting() public onlyMinter canMint { mintingDisabled = true; emit MintingDisabled(); }
/** * @dev Disable the minting of new tokens. Cannot be reversed. * * @return Whether or not the process was successful. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://ce167343b1dcaa8725159d95e78bc955e63e34546b19b99b083b3441ce0618e7
{ "func_code_index": [ 1575, 1715 ] }
76
TIMETokenFundraiser
contracts/component/TokenSafe.sol
0xed6849727f7b158a14a492bd0a3bf4d7126f7f71
Solidity
TokenSafe
contract TokenSafe { using SafeMath for uint; // The ERC20 token contract. ERC20Token token; struct Group { // The release date for the locked tokens // Note: Unix timestamp fits in uint32, however block.timestamp is uint256 uint256 releaseTimestamp; // The total remaining tokens in the group. uint256 remaining; // The individual account token balances in the group. mapping (address => uint) balances; } // The groups of locked tokens mapping (uint8 => Group) public groups; /** * @dev The constructor. * * @param _token The address of the Fabric Token (fundraiser) contract. */ constructor(address _token) public { token = ERC20Token(_token); } /** * @dev The function initializes a group with a release date. * * @param _id Group identifying number. * @param _releaseTimestamp Unix timestamp of the time after which the tokens can be released */ function init(uint8 _id, uint _releaseTimestamp) internal { require(_releaseTimestamp > 0, "TokenSafe group release timestamp is not set"); Group storage group = groups[_id]; group.releaseTimestamp = _releaseTimestamp; } /** * @dev Add new account with locked token balance to the specified group id. * * @param _id Group identifying number. * @param _account The address of the account to be added. * @param _balance The number of tokens to be locked. */ function add(uint8 _id, address _account, uint _balance) internal { Group storage group = groups[_id]; group.balances[_account] = group.balances[_account].plus(_balance); group.remaining = group.remaining.plus(_balance); } /** * @dev Allows an account to be released if it meets the time constraints of the group. * * @param _id Group identifying number. * @param _account The address of the account to be released. */ function release(uint8 _id, address _account) public { Group storage group = groups[_id]; require(now >= group.releaseTimestamp, "Group funds are not released yet"); uint tokens = group.balances[_account]; require(tokens > 0, "The account is empty or non-existent"); group.balances[_account] = 0; group.remaining = group.remaining.minus(tokens); if (!token.transfer(_account, tokens)) { revert("Token transfer failed"); } } }
/** * @title TokenSafe * * @dev Abstract contract that serves as a base for the token safes. It is a multi-group token safe, where each group * has it's own release time and multiple accounts with locked tokens. */
NatSpecMultiLine
init
function init(uint8 _id, uint _releaseTimestamp) internal { require(_releaseTimestamp > 0, "TokenSafe group release timestamp is not set"); Group storage group = groups[_id]; group.releaseTimestamp = _releaseTimestamp; }
/** * @dev The function initializes a group with a release date. * * @param _id Group identifying number. * @param _releaseTimestamp Unix timestamp of the time after which the tokens can be released */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://ce167343b1dcaa8725159d95e78bc955e63e34546b19b99b083b3441ce0618e7
{ "func_code_index": [ 1043, 1310 ] }
77
TIMETokenFundraiser
contracts/component/TokenSafe.sol
0xed6849727f7b158a14a492bd0a3bf4d7126f7f71
Solidity
TokenSafe
contract TokenSafe { using SafeMath for uint; // The ERC20 token contract. ERC20Token token; struct Group { // The release date for the locked tokens // Note: Unix timestamp fits in uint32, however block.timestamp is uint256 uint256 releaseTimestamp; // The total remaining tokens in the group. uint256 remaining; // The individual account token balances in the group. mapping (address => uint) balances; } // The groups of locked tokens mapping (uint8 => Group) public groups; /** * @dev The constructor. * * @param _token The address of the Fabric Token (fundraiser) contract. */ constructor(address _token) public { token = ERC20Token(_token); } /** * @dev The function initializes a group with a release date. * * @param _id Group identifying number. * @param _releaseTimestamp Unix timestamp of the time after which the tokens can be released */ function init(uint8 _id, uint _releaseTimestamp) internal { require(_releaseTimestamp > 0, "TokenSafe group release timestamp is not set"); Group storage group = groups[_id]; group.releaseTimestamp = _releaseTimestamp; } /** * @dev Add new account with locked token balance to the specified group id. * * @param _id Group identifying number. * @param _account The address of the account to be added. * @param _balance The number of tokens to be locked. */ function add(uint8 _id, address _account, uint _balance) internal { Group storage group = groups[_id]; group.balances[_account] = group.balances[_account].plus(_balance); group.remaining = group.remaining.plus(_balance); } /** * @dev Allows an account to be released if it meets the time constraints of the group. * * @param _id Group identifying number. * @param _account The address of the account to be released. */ function release(uint8 _id, address _account) public { Group storage group = groups[_id]; require(now >= group.releaseTimestamp, "Group funds are not released yet"); uint tokens = group.balances[_account]; require(tokens > 0, "The account is empty or non-existent"); group.balances[_account] = 0; group.remaining = group.remaining.minus(tokens); if (!token.transfer(_account, tokens)) { revert("Token transfer failed"); } } }
/** * @title TokenSafe * * @dev Abstract contract that serves as a base for the token safes. It is a multi-group token safe, where each group * has it's own release time and multiple accounts with locked tokens. */
NatSpecMultiLine
add
function add(uint8 _id, address _account, uint _balance) internal { Group storage group = groups[_id]; group.balances[_account] = group.balances[_account].plus(_balance); group.remaining = group.remaining.plus(_balance); }
/** * @dev Add new account with locked token balance to the specified group id. * * @param _id Group identifying number. * @param _account The address of the account to be added. * @param _balance The number of tokens to be locked. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://ce167343b1dcaa8725159d95e78bc955e63e34546b19b99b083b3441ce0618e7
{ "func_code_index": [ 1589, 1848 ] }
78
TIMETokenFundraiser
contracts/component/TokenSafe.sol
0xed6849727f7b158a14a492bd0a3bf4d7126f7f71
Solidity
TokenSafe
contract TokenSafe { using SafeMath for uint; // The ERC20 token contract. ERC20Token token; struct Group { // The release date for the locked tokens // Note: Unix timestamp fits in uint32, however block.timestamp is uint256 uint256 releaseTimestamp; // The total remaining tokens in the group. uint256 remaining; // The individual account token balances in the group. mapping (address => uint) balances; } // The groups of locked tokens mapping (uint8 => Group) public groups; /** * @dev The constructor. * * @param _token The address of the Fabric Token (fundraiser) contract. */ constructor(address _token) public { token = ERC20Token(_token); } /** * @dev The function initializes a group with a release date. * * @param _id Group identifying number. * @param _releaseTimestamp Unix timestamp of the time after which the tokens can be released */ function init(uint8 _id, uint _releaseTimestamp) internal { require(_releaseTimestamp > 0, "TokenSafe group release timestamp is not set"); Group storage group = groups[_id]; group.releaseTimestamp = _releaseTimestamp; } /** * @dev Add new account with locked token balance to the specified group id. * * @param _id Group identifying number. * @param _account The address of the account to be added. * @param _balance The number of tokens to be locked. */ function add(uint8 _id, address _account, uint _balance) internal { Group storage group = groups[_id]; group.balances[_account] = group.balances[_account].plus(_balance); group.remaining = group.remaining.plus(_balance); } /** * @dev Allows an account to be released if it meets the time constraints of the group. * * @param _id Group identifying number. * @param _account The address of the account to be released. */ function release(uint8 _id, address _account) public { Group storage group = groups[_id]; require(now >= group.releaseTimestamp, "Group funds are not released yet"); uint tokens = group.balances[_account]; require(tokens > 0, "The account is empty or non-existent"); group.balances[_account] = 0; group.remaining = group.remaining.minus(tokens); if (!token.transfer(_account, tokens)) { revert("Token transfer failed"); } } }
/** * @title TokenSafe * * @dev Abstract contract that serves as a base for the token safes. It is a multi-group token safe, where each group * has it's own release time and multiple accounts with locked tokens. */
NatSpecMultiLine
release
function release(uint8 _id, address _account) public { Group storage group = groups[_id]; require(now >= group.releaseTimestamp, "Group funds are not released yet"); uint tokens = group.balances[_account]; require(tokens > 0, "The account is empty or non-existent"); group.balances[_account] = 0; group.remaining = group.remaining.minus(tokens); if (!token.transfer(_account, tokens)) { revert("Token transfer failed"); } }
/** * @dev Allows an account to be released if it meets the time constraints of the group. * * @param _id Group identifying number. * @param _account The address of the account to be released. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://ce167343b1dcaa8725159d95e78bc955e63e34546b19b99b083b3441ce0618e7
{ "func_code_index": [ 2082, 2630 ] }
79
JustBananax
contracts/BoredApeYachtClub.sol
0x6856333d5e769775a8de373ffb5cf48f69540edc
Solidity
JustBananax
contract JustBananax is ERC721, Ownable { using SafeMath for uint256; using Strings for uint256; string public JBX_PROVENANCE = ""; uint256 public startingIndexBlock; uint256 public startingIndex; uint256 public constant jbxPrice = 60000000000000000; //0.06 ETH uint public constant maxJbxPurchase = 20; uint256 public MAX_BANANAX; bool public saleIsActive = false; uint256 public REVEAL_TIMESTAMP; constructor(string memory name, string memory symbol, uint256 maxNftSupply, uint256 saleStart) ERC721(name, symbol) { MAX_BANANAX = maxNftSupply; REVEAL_TIMESTAMP = saleStart + (86400 * 9); } function withdraw() public onlyOwner { uint balance = address(this).balance; msg.sender.transfer(balance); } /** * Set some Bananax aside */ function reserveBananax() public onlyOwner { uint supply = totalSupply(); uint i; for (i = 0; i < 48; i++) { _safeMint(msg.sender, supply + i); } } /** * Set the Reveal Timestamp once its decided. */ function setRevealTimestamp(uint256 revealTimeStamp) public onlyOwner { REVEAL_TIMESTAMP = revealTimeStamp; } /* * Set provenance once it's calculated */ function setProvenanceHash(string memory provenanceHash) public onlyOwner { JBX_PROVENANCE = provenanceHash; } function setBaseURI(string memory baseURI) public onlyOwner { _setBaseURI(baseURI); } /* * Pause sale if active, make active if paused */ function flipSaleState() public onlyOwner { saleIsActive = !saleIsActive; } /** * Mints Just Bananax */ function mintBananax(uint numberOfTokens) public payable { require(saleIsActive, "Sale must be active to mint Bananax"); require(numberOfTokens <= maxJbxPurchase, "Can only mint 20 tokens at a time"); require(totalSupply().add(numberOfTokens) <= MAX_BANANAX, "Purchase would exceed max supply of Bananax"); require(jbxPrice.mul(numberOfTokens) == msg.value, "Ether value sent is not correct"); for(uint i = 0; i < numberOfTokens; i++) { uint mintIndex = totalSupply(); if (totalSupply() < MAX_BANANAX) { _safeMint(msg.sender, mintIndex); } } // If we haven't set the starting index and this is either 1) the last saleable token or 2) the first token to be sold after // the end of pre-sale, set the starting index block if (startingIndexBlock == 0 && (totalSupply() == MAX_BANANAX || block.timestamp >= REVEAL_TIMESTAMP)) { startingIndexBlock = block.number; } } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory base = baseURI(); // New line tokenId = (tokenId + startingIndex) % MAX_BANANAX; // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(base, tokenId.toString())); } /** * Set the starting index for the collection */ function setStartingIndex() public { require(startingIndex == 0, "Starting index is already set"); require(startingIndexBlock != 0, "Starting index block must be set"); startingIndex = uint(blockhash(startingIndexBlock)) % MAX_BANANAX; // Just a sanity case in the worst case if this function is called late (EVM only stores last 256 block hashes) if (block.number.sub(startingIndexBlock) > 255) { startingIndex = uint(blockhash(block.number - 1)) % MAX_BANANAX; } // Prevent default sequence if (startingIndex == 0) { startingIndex = startingIndex.add(1); } } /** * Set the starting index block for the collection, essentially unblocking * setting starting index */ function emergencySetStartingIndexBlock() public onlyOwner { require(startingIndex == 0, "Starting index is already set"); startingIndexBlock = block.number; } }
/** * @title JustBananax contract * @dev Extends ERC721 Non-Fungible Token Standard basic implementation */
NatSpecMultiLine
reserveBananax
function reserveBananax() public onlyOwner { uint supply = totalSupply(); uint i; for (i = 0; i < 48; i++) { _safeMint(msg.sender, supply + i); } }
/** * Set some Bananax aside */
NatSpecMultiLine
v0.7.6+commit.7338295f
MIT
ipfs://38fa7ce91b2cb1e237edd0934ab60265aed69579bb397e258cb7e6830c6c7b3a
{ "func_code_index": [ 878, 1092 ] }
80
JustBananax
contracts/BoredApeYachtClub.sol
0x6856333d5e769775a8de373ffb5cf48f69540edc
Solidity
JustBananax
contract JustBananax is ERC721, Ownable { using SafeMath for uint256; using Strings for uint256; string public JBX_PROVENANCE = ""; uint256 public startingIndexBlock; uint256 public startingIndex; uint256 public constant jbxPrice = 60000000000000000; //0.06 ETH uint public constant maxJbxPurchase = 20; uint256 public MAX_BANANAX; bool public saleIsActive = false; uint256 public REVEAL_TIMESTAMP; constructor(string memory name, string memory symbol, uint256 maxNftSupply, uint256 saleStart) ERC721(name, symbol) { MAX_BANANAX = maxNftSupply; REVEAL_TIMESTAMP = saleStart + (86400 * 9); } function withdraw() public onlyOwner { uint balance = address(this).balance; msg.sender.transfer(balance); } /** * Set some Bananax aside */ function reserveBananax() public onlyOwner { uint supply = totalSupply(); uint i; for (i = 0; i < 48; i++) { _safeMint(msg.sender, supply + i); } } /** * Set the Reveal Timestamp once its decided. */ function setRevealTimestamp(uint256 revealTimeStamp) public onlyOwner { REVEAL_TIMESTAMP = revealTimeStamp; } /* * Set provenance once it's calculated */ function setProvenanceHash(string memory provenanceHash) public onlyOwner { JBX_PROVENANCE = provenanceHash; } function setBaseURI(string memory baseURI) public onlyOwner { _setBaseURI(baseURI); } /* * Pause sale if active, make active if paused */ function flipSaleState() public onlyOwner { saleIsActive = !saleIsActive; } /** * Mints Just Bananax */ function mintBananax(uint numberOfTokens) public payable { require(saleIsActive, "Sale must be active to mint Bananax"); require(numberOfTokens <= maxJbxPurchase, "Can only mint 20 tokens at a time"); require(totalSupply().add(numberOfTokens) <= MAX_BANANAX, "Purchase would exceed max supply of Bananax"); require(jbxPrice.mul(numberOfTokens) == msg.value, "Ether value sent is not correct"); for(uint i = 0; i < numberOfTokens; i++) { uint mintIndex = totalSupply(); if (totalSupply() < MAX_BANANAX) { _safeMint(msg.sender, mintIndex); } } // If we haven't set the starting index and this is either 1) the last saleable token or 2) the first token to be sold after // the end of pre-sale, set the starting index block if (startingIndexBlock == 0 && (totalSupply() == MAX_BANANAX || block.timestamp >= REVEAL_TIMESTAMP)) { startingIndexBlock = block.number; } } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory base = baseURI(); // New line tokenId = (tokenId + startingIndex) % MAX_BANANAX; // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(base, tokenId.toString())); } /** * Set the starting index for the collection */ function setStartingIndex() public { require(startingIndex == 0, "Starting index is already set"); require(startingIndexBlock != 0, "Starting index block must be set"); startingIndex = uint(blockhash(startingIndexBlock)) % MAX_BANANAX; // Just a sanity case in the worst case if this function is called late (EVM only stores last 256 block hashes) if (block.number.sub(startingIndexBlock) > 255) { startingIndex = uint(blockhash(block.number - 1)) % MAX_BANANAX; } // Prevent default sequence if (startingIndex == 0) { startingIndex = startingIndex.add(1); } } /** * Set the starting index block for the collection, essentially unblocking * setting starting index */ function emergencySetStartingIndexBlock() public onlyOwner { require(startingIndex == 0, "Starting index is already set"); startingIndexBlock = block.number; } }
/** * @title JustBananax contract * @dev Extends ERC721 Non-Fungible Token Standard basic implementation */
NatSpecMultiLine
setRevealTimestamp
function setRevealTimestamp(uint256 revealTimeStamp) public onlyOwner { REVEAL_TIMESTAMP = revealTimeStamp; }
/** * Set the Reveal Timestamp once its decided. */
NatSpecMultiLine
v0.7.6+commit.7338295f
MIT
ipfs://38fa7ce91b2cb1e237edd0934ab60265aed69579bb397e258cb7e6830c6c7b3a
{ "func_code_index": [ 1164, 1293 ] }
81
JustBananax
contracts/BoredApeYachtClub.sol
0x6856333d5e769775a8de373ffb5cf48f69540edc
Solidity
JustBananax
contract JustBananax is ERC721, Ownable { using SafeMath for uint256; using Strings for uint256; string public JBX_PROVENANCE = ""; uint256 public startingIndexBlock; uint256 public startingIndex; uint256 public constant jbxPrice = 60000000000000000; //0.06 ETH uint public constant maxJbxPurchase = 20; uint256 public MAX_BANANAX; bool public saleIsActive = false; uint256 public REVEAL_TIMESTAMP; constructor(string memory name, string memory symbol, uint256 maxNftSupply, uint256 saleStart) ERC721(name, symbol) { MAX_BANANAX = maxNftSupply; REVEAL_TIMESTAMP = saleStart + (86400 * 9); } function withdraw() public onlyOwner { uint balance = address(this).balance; msg.sender.transfer(balance); } /** * Set some Bananax aside */ function reserveBananax() public onlyOwner { uint supply = totalSupply(); uint i; for (i = 0; i < 48; i++) { _safeMint(msg.sender, supply + i); } } /** * Set the Reveal Timestamp once its decided. */ function setRevealTimestamp(uint256 revealTimeStamp) public onlyOwner { REVEAL_TIMESTAMP = revealTimeStamp; } /* * Set provenance once it's calculated */ function setProvenanceHash(string memory provenanceHash) public onlyOwner { JBX_PROVENANCE = provenanceHash; } function setBaseURI(string memory baseURI) public onlyOwner { _setBaseURI(baseURI); } /* * Pause sale if active, make active if paused */ function flipSaleState() public onlyOwner { saleIsActive = !saleIsActive; } /** * Mints Just Bananax */ function mintBananax(uint numberOfTokens) public payable { require(saleIsActive, "Sale must be active to mint Bananax"); require(numberOfTokens <= maxJbxPurchase, "Can only mint 20 tokens at a time"); require(totalSupply().add(numberOfTokens) <= MAX_BANANAX, "Purchase would exceed max supply of Bananax"); require(jbxPrice.mul(numberOfTokens) == msg.value, "Ether value sent is not correct"); for(uint i = 0; i < numberOfTokens; i++) { uint mintIndex = totalSupply(); if (totalSupply() < MAX_BANANAX) { _safeMint(msg.sender, mintIndex); } } // If we haven't set the starting index and this is either 1) the last saleable token or 2) the first token to be sold after // the end of pre-sale, set the starting index block if (startingIndexBlock == 0 && (totalSupply() == MAX_BANANAX || block.timestamp >= REVEAL_TIMESTAMP)) { startingIndexBlock = block.number; } } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory base = baseURI(); // New line tokenId = (tokenId + startingIndex) % MAX_BANANAX; // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(base, tokenId.toString())); } /** * Set the starting index for the collection */ function setStartingIndex() public { require(startingIndex == 0, "Starting index is already set"); require(startingIndexBlock != 0, "Starting index block must be set"); startingIndex = uint(blockhash(startingIndexBlock)) % MAX_BANANAX; // Just a sanity case in the worst case if this function is called late (EVM only stores last 256 block hashes) if (block.number.sub(startingIndexBlock) > 255) { startingIndex = uint(blockhash(block.number - 1)) % MAX_BANANAX; } // Prevent default sequence if (startingIndex == 0) { startingIndex = startingIndex.add(1); } } /** * Set the starting index block for the collection, essentially unblocking * setting starting index */ function emergencySetStartingIndexBlock() public onlyOwner { require(startingIndex == 0, "Starting index is already set"); startingIndexBlock = block.number; } }
/** * @title JustBananax contract * @dev Extends ERC721 Non-Fungible Token Standard basic implementation */
NatSpecMultiLine
setProvenanceHash
function setProvenanceHash(string memory provenanceHash) public onlyOwner { JBX_PROVENANCE = provenanceHash; }
/* * Set provenance once it's calculated */
Comment
v0.7.6+commit.7338295f
MIT
ipfs://38fa7ce91b2cb1e237edd0934ab60265aed69579bb397e258cb7e6830c6c7b3a
{ "func_code_index": [ 1360, 1489 ] }
82
JustBananax
contracts/BoredApeYachtClub.sol
0x6856333d5e769775a8de373ffb5cf48f69540edc
Solidity
JustBananax
contract JustBananax is ERC721, Ownable { using SafeMath for uint256; using Strings for uint256; string public JBX_PROVENANCE = ""; uint256 public startingIndexBlock; uint256 public startingIndex; uint256 public constant jbxPrice = 60000000000000000; //0.06 ETH uint public constant maxJbxPurchase = 20; uint256 public MAX_BANANAX; bool public saleIsActive = false; uint256 public REVEAL_TIMESTAMP; constructor(string memory name, string memory symbol, uint256 maxNftSupply, uint256 saleStart) ERC721(name, symbol) { MAX_BANANAX = maxNftSupply; REVEAL_TIMESTAMP = saleStart + (86400 * 9); } function withdraw() public onlyOwner { uint balance = address(this).balance; msg.sender.transfer(balance); } /** * Set some Bananax aside */ function reserveBananax() public onlyOwner { uint supply = totalSupply(); uint i; for (i = 0; i < 48; i++) { _safeMint(msg.sender, supply + i); } } /** * Set the Reveal Timestamp once its decided. */ function setRevealTimestamp(uint256 revealTimeStamp) public onlyOwner { REVEAL_TIMESTAMP = revealTimeStamp; } /* * Set provenance once it's calculated */ function setProvenanceHash(string memory provenanceHash) public onlyOwner { JBX_PROVENANCE = provenanceHash; } function setBaseURI(string memory baseURI) public onlyOwner { _setBaseURI(baseURI); } /* * Pause sale if active, make active if paused */ function flipSaleState() public onlyOwner { saleIsActive = !saleIsActive; } /** * Mints Just Bananax */ function mintBananax(uint numberOfTokens) public payable { require(saleIsActive, "Sale must be active to mint Bananax"); require(numberOfTokens <= maxJbxPurchase, "Can only mint 20 tokens at a time"); require(totalSupply().add(numberOfTokens) <= MAX_BANANAX, "Purchase would exceed max supply of Bananax"); require(jbxPrice.mul(numberOfTokens) == msg.value, "Ether value sent is not correct"); for(uint i = 0; i < numberOfTokens; i++) { uint mintIndex = totalSupply(); if (totalSupply() < MAX_BANANAX) { _safeMint(msg.sender, mintIndex); } } // If we haven't set the starting index and this is either 1) the last saleable token or 2) the first token to be sold after // the end of pre-sale, set the starting index block if (startingIndexBlock == 0 && (totalSupply() == MAX_BANANAX || block.timestamp >= REVEAL_TIMESTAMP)) { startingIndexBlock = block.number; } } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory base = baseURI(); // New line tokenId = (tokenId + startingIndex) % MAX_BANANAX; // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(base, tokenId.toString())); } /** * Set the starting index for the collection */ function setStartingIndex() public { require(startingIndex == 0, "Starting index is already set"); require(startingIndexBlock != 0, "Starting index block must be set"); startingIndex = uint(blockhash(startingIndexBlock)) % MAX_BANANAX; // Just a sanity case in the worst case if this function is called late (EVM only stores last 256 block hashes) if (block.number.sub(startingIndexBlock) > 255) { startingIndex = uint(blockhash(block.number - 1)) % MAX_BANANAX; } // Prevent default sequence if (startingIndex == 0) { startingIndex = startingIndex.add(1); } } /** * Set the starting index block for the collection, essentially unblocking * setting starting index */ function emergencySetStartingIndexBlock() public onlyOwner { require(startingIndex == 0, "Starting index is already set"); startingIndexBlock = block.number; } }
/** * @title JustBananax contract * @dev Extends ERC721 Non-Fungible Token Standard basic implementation */
NatSpecMultiLine
flipSaleState
function flipSaleState() public onlyOwner { saleIsActive = !saleIsActive; }
/* * Pause sale if active, make active if paused */
Comment
v0.7.6+commit.7338295f
MIT
ipfs://38fa7ce91b2cb1e237edd0934ab60265aed69579bb397e258cb7e6830c6c7b3a
{ "func_code_index": [ 1666, 1760 ] }
83
JustBananax
contracts/BoredApeYachtClub.sol
0x6856333d5e769775a8de373ffb5cf48f69540edc
Solidity
JustBananax
contract JustBananax is ERC721, Ownable { using SafeMath for uint256; using Strings for uint256; string public JBX_PROVENANCE = ""; uint256 public startingIndexBlock; uint256 public startingIndex; uint256 public constant jbxPrice = 60000000000000000; //0.06 ETH uint public constant maxJbxPurchase = 20; uint256 public MAX_BANANAX; bool public saleIsActive = false; uint256 public REVEAL_TIMESTAMP; constructor(string memory name, string memory symbol, uint256 maxNftSupply, uint256 saleStart) ERC721(name, symbol) { MAX_BANANAX = maxNftSupply; REVEAL_TIMESTAMP = saleStart + (86400 * 9); } function withdraw() public onlyOwner { uint balance = address(this).balance; msg.sender.transfer(balance); } /** * Set some Bananax aside */ function reserveBananax() public onlyOwner { uint supply = totalSupply(); uint i; for (i = 0; i < 48; i++) { _safeMint(msg.sender, supply + i); } } /** * Set the Reveal Timestamp once its decided. */ function setRevealTimestamp(uint256 revealTimeStamp) public onlyOwner { REVEAL_TIMESTAMP = revealTimeStamp; } /* * Set provenance once it's calculated */ function setProvenanceHash(string memory provenanceHash) public onlyOwner { JBX_PROVENANCE = provenanceHash; } function setBaseURI(string memory baseURI) public onlyOwner { _setBaseURI(baseURI); } /* * Pause sale if active, make active if paused */ function flipSaleState() public onlyOwner { saleIsActive = !saleIsActive; } /** * Mints Just Bananax */ function mintBananax(uint numberOfTokens) public payable { require(saleIsActive, "Sale must be active to mint Bananax"); require(numberOfTokens <= maxJbxPurchase, "Can only mint 20 tokens at a time"); require(totalSupply().add(numberOfTokens) <= MAX_BANANAX, "Purchase would exceed max supply of Bananax"); require(jbxPrice.mul(numberOfTokens) == msg.value, "Ether value sent is not correct"); for(uint i = 0; i < numberOfTokens; i++) { uint mintIndex = totalSupply(); if (totalSupply() < MAX_BANANAX) { _safeMint(msg.sender, mintIndex); } } // If we haven't set the starting index and this is either 1) the last saleable token or 2) the first token to be sold after // the end of pre-sale, set the starting index block if (startingIndexBlock == 0 && (totalSupply() == MAX_BANANAX || block.timestamp >= REVEAL_TIMESTAMP)) { startingIndexBlock = block.number; } } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory base = baseURI(); // New line tokenId = (tokenId + startingIndex) % MAX_BANANAX; // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(base, tokenId.toString())); } /** * Set the starting index for the collection */ function setStartingIndex() public { require(startingIndex == 0, "Starting index is already set"); require(startingIndexBlock != 0, "Starting index block must be set"); startingIndex = uint(blockhash(startingIndexBlock)) % MAX_BANANAX; // Just a sanity case in the worst case if this function is called late (EVM only stores last 256 block hashes) if (block.number.sub(startingIndexBlock) > 255) { startingIndex = uint(blockhash(block.number - 1)) % MAX_BANANAX; } // Prevent default sequence if (startingIndex == 0) { startingIndex = startingIndex.add(1); } } /** * Set the starting index block for the collection, essentially unblocking * setting starting index */ function emergencySetStartingIndexBlock() public onlyOwner { require(startingIndex == 0, "Starting index is already set"); startingIndexBlock = block.number; } }
/** * @title JustBananax contract * @dev Extends ERC721 Non-Fungible Token Standard basic implementation */
NatSpecMultiLine
mintBananax
function mintBananax(uint numberOfTokens) public payable { require(saleIsActive, "Sale must be active to mint Bananax"); require(numberOfTokens <= maxJbxPurchase, "Can only mint 20 tokens at a time"); require(totalSupply().add(numberOfTokens) <= MAX_BANANAX, "Purchase would exceed max supply of Bananax"); require(jbxPrice.mul(numberOfTokens) == msg.value, "Ether value sent is not correct"); for(uint i = 0; i < numberOfTokens; i++) { uint mintIndex = totalSupply(); if (totalSupply() < MAX_BANANAX) { _safeMint(msg.sender, mintIndex); } } // If we haven't set the starting index and this is either 1) the last saleable token or 2) the first token to be sold after // the end of pre-sale, set the starting index block if (startingIndexBlock == 0 && (totalSupply() == MAX_BANANAX || block.timestamp >= REVEAL_TIMESTAMP)) { startingIndexBlock = block.number; } }
/** * Mints Just Bananax */
NatSpecMultiLine
v0.7.6+commit.7338295f
MIT
ipfs://38fa7ce91b2cb1e237edd0934ab60265aed69579bb397e258cb7e6830c6c7b3a
{ "func_code_index": [ 1806, 2850 ] }
84
JustBananax
contracts/BoredApeYachtClub.sol
0x6856333d5e769775a8de373ffb5cf48f69540edc
Solidity
JustBananax
contract JustBananax is ERC721, Ownable { using SafeMath for uint256; using Strings for uint256; string public JBX_PROVENANCE = ""; uint256 public startingIndexBlock; uint256 public startingIndex; uint256 public constant jbxPrice = 60000000000000000; //0.06 ETH uint public constant maxJbxPurchase = 20; uint256 public MAX_BANANAX; bool public saleIsActive = false; uint256 public REVEAL_TIMESTAMP; constructor(string memory name, string memory symbol, uint256 maxNftSupply, uint256 saleStart) ERC721(name, symbol) { MAX_BANANAX = maxNftSupply; REVEAL_TIMESTAMP = saleStart + (86400 * 9); } function withdraw() public onlyOwner { uint balance = address(this).balance; msg.sender.transfer(balance); } /** * Set some Bananax aside */ function reserveBananax() public onlyOwner { uint supply = totalSupply(); uint i; for (i = 0; i < 48; i++) { _safeMint(msg.sender, supply + i); } } /** * Set the Reveal Timestamp once its decided. */ function setRevealTimestamp(uint256 revealTimeStamp) public onlyOwner { REVEAL_TIMESTAMP = revealTimeStamp; } /* * Set provenance once it's calculated */ function setProvenanceHash(string memory provenanceHash) public onlyOwner { JBX_PROVENANCE = provenanceHash; } function setBaseURI(string memory baseURI) public onlyOwner { _setBaseURI(baseURI); } /* * Pause sale if active, make active if paused */ function flipSaleState() public onlyOwner { saleIsActive = !saleIsActive; } /** * Mints Just Bananax */ function mintBananax(uint numberOfTokens) public payable { require(saleIsActive, "Sale must be active to mint Bananax"); require(numberOfTokens <= maxJbxPurchase, "Can only mint 20 tokens at a time"); require(totalSupply().add(numberOfTokens) <= MAX_BANANAX, "Purchase would exceed max supply of Bananax"); require(jbxPrice.mul(numberOfTokens) == msg.value, "Ether value sent is not correct"); for(uint i = 0; i < numberOfTokens; i++) { uint mintIndex = totalSupply(); if (totalSupply() < MAX_BANANAX) { _safeMint(msg.sender, mintIndex); } } // If we haven't set the starting index and this is either 1) the last saleable token or 2) the first token to be sold after // the end of pre-sale, set the starting index block if (startingIndexBlock == 0 && (totalSupply() == MAX_BANANAX || block.timestamp >= REVEAL_TIMESTAMP)) { startingIndexBlock = block.number; } } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory base = baseURI(); // New line tokenId = (tokenId + startingIndex) % MAX_BANANAX; // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(base, tokenId.toString())); } /** * Set the starting index for the collection */ function setStartingIndex() public { require(startingIndex == 0, "Starting index is already set"); require(startingIndexBlock != 0, "Starting index block must be set"); startingIndex = uint(blockhash(startingIndexBlock)) % MAX_BANANAX; // Just a sanity case in the worst case if this function is called late (EVM only stores last 256 block hashes) if (block.number.sub(startingIndexBlock) > 255) { startingIndex = uint(blockhash(block.number - 1)) % MAX_BANANAX; } // Prevent default sequence if (startingIndex == 0) { startingIndex = startingIndex.add(1); } } /** * Set the starting index block for the collection, essentially unblocking * setting starting index */ function emergencySetStartingIndexBlock() public onlyOwner { require(startingIndex == 0, "Starting index is already set"); startingIndexBlock = block.number; } }
/** * @title JustBananax contract * @dev Extends ERC721 Non-Fungible Token Standard basic implementation */
NatSpecMultiLine
tokenURI
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory base = baseURI(); // New line tokenId = (tokenId + startingIndex) % MAX_BANANAX; // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(base, tokenId.toString())); }
/** * @dev See {IERC721Metadata-tokenURI}. */
NatSpecMultiLine
v0.7.6+commit.7338295f
MIT
ipfs://38fa7ce91b2cb1e237edd0934ab60265aed69579bb397e258cb7e6830c6c7b3a
{ "func_code_index": [ 2920, 3398 ] }
85
JustBananax
contracts/BoredApeYachtClub.sol
0x6856333d5e769775a8de373ffb5cf48f69540edc
Solidity
JustBananax
contract JustBananax is ERC721, Ownable { using SafeMath for uint256; using Strings for uint256; string public JBX_PROVENANCE = ""; uint256 public startingIndexBlock; uint256 public startingIndex; uint256 public constant jbxPrice = 60000000000000000; //0.06 ETH uint public constant maxJbxPurchase = 20; uint256 public MAX_BANANAX; bool public saleIsActive = false; uint256 public REVEAL_TIMESTAMP; constructor(string memory name, string memory symbol, uint256 maxNftSupply, uint256 saleStart) ERC721(name, symbol) { MAX_BANANAX = maxNftSupply; REVEAL_TIMESTAMP = saleStart + (86400 * 9); } function withdraw() public onlyOwner { uint balance = address(this).balance; msg.sender.transfer(balance); } /** * Set some Bananax aside */ function reserveBananax() public onlyOwner { uint supply = totalSupply(); uint i; for (i = 0; i < 48; i++) { _safeMint(msg.sender, supply + i); } } /** * Set the Reveal Timestamp once its decided. */ function setRevealTimestamp(uint256 revealTimeStamp) public onlyOwner { REVEAL_TIMESTAMP = revealTimeStamp; } /* * Set provenance once it's calculated */ function setProvenanceHash(string memory provenanceHash) public onlyOwner { JBX_PROVENANCE = provenanceHash; } function setBaseURI(string memory baseURI) public onlyOwner { _setBaseURI(baseURI); } /* * Pause sale if active, make active if paused */ function flipSaleState() public onlyOwner { saleIsActive = !saleIsActive; } /** * Mints Just Bananax */ function mintBananax(uint numberOfTokens) public payable { require(saleIsActive, "Sale must be active to mint Bananax"); require(numberOfTokens <= maxJbxPurchase, "Can only mint 20 tokens at a time"); require(totalSupply().add(numberOfTokens) <= MAX_BANANAX, "Purchase would exceed max supply of Bananax"); require(jbxPrice.mul(numberOfTokens) == msg.value, "Ether value sent is not correct"); for(uint i = 0; i < numberOfTokens; i++) { uint mintIndex = totalSupply(); if (totalSupply() < MAX_BANANAX) { _safeMint(msg.sender, mintIndex); } } // If we haven't set the starting index and this is either 1) the last saleable token or 2) the first token to be sold after // the end of pre-sale, set the starting index block if (startingIndexBlock == 0 && (totalSupply() == MAX_BANANAX || block.timestamp >= REVEAL_TIMESTAMP)) { startingIndexBlock = block.number; } } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory base = baseURI(); // New line tokenId = (tokenId + startingIndex) % MAX_BANANAX; // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(base, tokenId.toString())); } /** * Set the starting index for the collection */ function setStartingIndex() public { require(startingIndex == 0, "Starting index is already set"); require(startingIndexBlock != 0, "Starting index block must be set"); startingIndex = uint(blockhash(startingIndexBlock)) % MAX_BANANAX; // Just a sanity case in the worst case if this function is called late (EVM only stores last 256 block hashes) if (block.number.sub(startingIndexBlock) > 255) { startingIndex = uint(blockhash(block.number - 1)) % MAX_BANANAX; } // Prevent default sequence if (startingIndex == 0) { startingIndex = startingIndex.add(1); } } /** * Set the starting index block for the collection, essentially unblocking * setting starting index */ function emergencySetStartingIndexBlock() public onlyOwner { require(startingIndex == 0, "Starting index is already set"); startingIndexBlock = block.number; } }
/** * @title JustBananax contract * @dev Extends ERC721 Non-Fungible Token Standard basic implementation */
NatSpecMultiLine
setStartingIndex
function setStartingIndex() public { require(startingIndex == 0, "Starting index is already set"); require(startingIndexBlock != 0, "Starting index block must be set"); startingIndex = uint(blockhash(startingIndexBlock)) % MAX_BANANAX; // Just a sanity case in the worst case if this function is called late (EVM only stores last 256 block hashes) if (block.number.sub(startingIndexBlock) > 255) { startingIndex = uint(blockhash(block.number - 1)) % MAX_BANANAX; } // Prevent default sequence if (startingIndex == 0) { startingIndex = startingIndex.add(1); } }
/** * Set the starting index for the collection */
NatSpecMultiLine
v0.7.6+commit.7338295f
MIT
ipfs://38fa7ce91b2cb1e237edd0934ab60265aed69579bb397e258cb7e6830c6c7b3a
{ "func_code_index": [ 3469, 4156 ] }
86
JustBananax
contracts/BoredApeYachtClub.sol
0x6856333d5e769775a8de373ffb5cf48f69540edc
Solidity
JustBananax
contract JustBananax is ERC721, Ownable { using SafeMath for uint256; using Strings for uint256; string public JBX_PROVENANCE = ""; uint256 public startingIndexBlock; uint256 public startingIndex; uint256 public constant jbxPrice = 60000000000000000; //0.06 ETH uint public constant maxJbxPurchase = 20; uint256 public MAX_BANANAX; bool public saleIsActive = false; uint256 public REVEAL_TIMESTAMP; constructor(string memory name, string memory symbol, uint256 maxNftSupply, uint256 saleStart) ERC721(name, symbol) { MAX_BANANAX = maxNftSupply; REVEAL_TIMESTAMP = saleStart + (86400 * 9); } function withdraw() public onlyOwner { uint balance = address(this).balance; msg.sender.transfer(balance); } /** * Set some Bananax aside */ function reserveBananax() public onlyOwner { uint supply = totalSupply(); uint i; for (i = 0; i < 48; i++) { _safeMint(msg.sender, supply + i); } } /** * Set the Reveal Timestamp once its decided. */ function setRevealTimestamp(uint256 revealTimeStamp) public onlyOwner { REVEAL_TIMESTAMP = revealTimeStamp; } /* * Set provenance once it's calculated */ function setProvenanceHash(string memory provenanceHash) public onlyOwner { JBX_PROVENANCE = provenanceHash; } function setBaseURI(string memory baseURI) public onlyOwner { _setBaseURI(baseURI); } /* * Pause sale if active, make active if paused */ function flipSaleState() public onlyOwner { saleIsActive = !saleIsActive; } /** * Mints Just Bananax */ function mintBananax(uint numberOfTokens) public payable { require(saleIsActive, "Sale must be active to mint Bananax"); require(numberOfTokens <= maxJbxPurchase, "Can only mint 20 tokens at a time"); require(totalSupply().add(numberOfTokens) <= MAX_BANANAX, "Purchase would exceed max supply of Bananax"); require(jbxPrice.mul(numberOfTokens) == msg.value, "Ether value sent is not correct"); for(uint i = 0; i < numberOfTokens; i++) { uint mintIndex = totalSupply(); if (totalSupply() < MAX_BANANAX) { _safeMint(msg.sender, mintIndex); } } // If we haven't set the starting index and this is either 1) the last saleable token or 2) the first token to be sold after // the end of pre-sale, set the starting index block if (startingIndexBlock == 0 && (totalSupply() == MAX_BANANAX || block.timestamp >= REVEAL_TIMESTAMP)) { startingIndexBlock = block.number; } } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory base = baseURI(); // New line tokenId = (tokenId + startingIndex) % MAX_BANANAX; // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(base, tokenId.toString())); } /** * Set the starting index for the collection */ function setStartingIndex() public { require(startingIndex == 0, "Starting index is already set"); require(startingIndexBlock != 0, "Starting index block must be set"); startingIndex = uint(blockhash(startingIndexBlock)) % MAX_BANANAX; // Just a sanity case in the worst case if this function is called late (EVM only stores last 256 block hashes) if (block.number.sub(startingIndexBlock) > 255) { startingIndex = uint(blockhash(block.number - 1)) % MAX_BANANAX; } // Prevent default sequence if (startingIndex == 0) { startingIndex = startingIndex.add(1); } } /** * Set the starting index block for the collection, essentially unblocking * setting starting index */ function emergencySetStartingIndexBlock() public onlyOwner { require(startingIndex == 0, "Starting index is already set"); startingIndexBlock = block.number; } }
/** * @title JustBananax contract * @dev Extends ERC721 Non-Fungible Token Standard basic implementation */
NatSpecMultiLine
emergencySetStartingIndexBlock
function emergencySetStartingIndexBlock() public onlyOwner { require(startingIndex == 0, "Starting index is already set"); startingIndexBlock = block.number; }
/** * Set the starting index block for the collection, essentially unblocking * setting starting index */
NatSpecMultiLine
v0.7.6+commit.7338295f
MIT
ipfs://38fa7ce91b2cb1e237edd0934ab60265aed69579bb397e258cb7e6830c6c7b3a
{ "func_code_index": [ 4288, 4485 ] }
87
TIMETokenFundraiser
contracts/fundraiser/PresaleFundraiser.sol
0xed6849727f7b158a14a492bd0a3bf4d7126f7f71
Solidity
PresaleFundraiser
contract PresaleFundraiser is MintableTokenFundraiser { /// @dev The token hard cap for the pre-sale uint256 public presaleSupply; /// @dev The token hard cap for the pre-sale uint256 public presaleMaxSupply; /// @dev The start time of the pre-sale (Unix timestamp). uint256 public presaleStartTime; /// @dev The end time of the pre-sale (Unix timestamp). uint256 public presaleEndTime; /// @dev The conversion rate for the pre-sale uint256 public presaleConversionRate; /** * @dev The initialization method. * * @param _startTime The timestamp of the moment when the pre-sale starts * @param _endTime The timestamp of the moment when the pre-sale ends * @param _conversionRate The conversion rate during the pre-sale */ function initializePresaleFundraiser( uint256 _presaleMaxSupply, uint256 _startTime, uint256 _endTime, uint256 _conversionRate ) internal { require(_endTime >= _startTime, "Pre-sale's end is before its start"); require(_conversionRate > 0, "Conversion rate is not set"); presaleMaxSupply = _presaleMaxSupply; presaleStartTime = _startTime; presaleEndTime = _endTime; presaleConversionRate = _conversionRate; } /** * @dev Internal funciton that helps to check if the pre-sale is active */ function isPresaleActive() internal view returns (bool) { return now < presaleEndTime && now >= presaleStartTime; } /** * @dev this function different conversion rate while in presale */ function getConversionRate() public view returns (uint256) { if (isPresaleActive()) { return presaleConversionRate; } return super.getConversionRate(); } /** * @dev It throws an exception if the transaction does not meet the preconditions. */ function validateTransaction() internal view { require(msg.value != 0, "Transaction value is zero"); require( now >= startTime && now < endTime || isPresaleActive(), "Neither the pre-sale nor the fundraiser are currently active" ); } function handleTokens(address _address, uint256 _tokens) internal { if (isPresaleActive()) { presaleSupply = presaleSupply.plus(_tokens); require( presaleSupply <= presaleMaxSupply, "Transaction exceeds the pre-sale maximum token supply" ); } super.handleTokens(_address, _tokens); } }
/** * @title PresaleFundraiser * * @dev This is the standard fundraiser contract which allows * you to raise ETH in exchange for your tokens. */
NatSpecMultiLine
initializePresaleFundraiser
function initializePresaleFundraiser( uint256 _presaleMaxSupply, uint256 _startTime, uint256 _endTime, uint256 _conversionRate ) internal { require(_endTime >= _startTime, "Pre-sale's end is before its start"); require(_conversionRate > 0, "Conversion rate is not set"); presaleMaxSupply = _presaleMaxSupply; presaleStartTime = _startTime; presaleEndTime = _endTime; presaleConversionRate = _conversionRate; }
/** * @dev The initialization method. * * @param _startTime The timestamp of the moment when the pre-sale starts * @param _endTime The timestamp of the moment when the pre-sale ends * @param _conversionRate The conversion rate during the pre-sale */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://ce167343b1dcaa8725159d95e78bc955e63e34546b19b99b083b3441ce0618e7
{ "func_code_index": [ 823, 1353 ] }
88
TIMETokenFundraiser
contracts/fundraiser/PresaleFundraiser.sol
0xed6849727f7b158a14a492bd0a3bf4d7126f7f71
Solidity
PresaleFundraiser
contract PresaleFundraiser is MintableTokenFundraiser { /// @dev The token hard cap for the pre-sale uint256 public presaleSupply; /// @dev The token hard cap for the pre-sale uint256 public presaleMaxSupply; /// @dev The start time of the pre-sale (Unix timestamp). uint256 public presaleStartTime; /// @dev The end time of the pre-sale (Unix timestamp). uint256 public presaleEndTime; /// @dev The conversion rate for the pre-sale uint256 public presaleConversionRate; /** * @dev The initialization method. * * @param _startTime The timestamp of the moment when the pre-sale starts * @param _endTime The timestamp of the moment when the pre-sale ends * @param _conversionRate The conversion rate during the pre-sale */ function initializePresaleFundraiser( uint256 _presaleMaxSupply, uint256 _startTime, uint256 _endTime, uint256 _conversionRate ) internal { require(_endTime >= _startTime, "Pre-sale's end is before its start"); require(_conversionRate > 0, "Conversion rate is not set"); presaleMaxSupply = _presaleMaxSupply; presaleStartTime = _startTime; presaleEndTime = _endTime; presaleConversionRate = _conversionRate; } /** * @dev Internal funciton that helps to check if the pre-sale is active */ function isPresaleActive() internal view returns (bool) { return now < presaleEndTime && now >= presaleStartTime; } /** * @dev this function different conversion rate while in presale */ function getConversionRate() public view returns (uint256) { if (isPresaleActive()) { return presaleConversionRate; } return super.getConversionRate(); } /** * @dev It throws an exception if the transaction does not meet the preconditions. */ function validateTransaction() internal view { require(msg.value != 0, "Transaction value is zero"); require( now >= startTime && now < endTime || isPresaleActive(), "Neither the pre-sale nor the fundraiser are currently active" ); } function handleTokens(address _address, uint256 _tokens) internal { if (isPresaleActive()) { presaleSupply = presaleSupply.plus(_tokens); require( presaleSupply <= presaleMaxSupply, "Transaction exceeds the pre-sale maximum token supply" ); } super.handleTokens(_address, _tokens); } }
/** * @title PresaleFundraiser * * @dev This is the standard fundraiser contract which allows * you to raise ETH in exchange for your tokens. */
NatSpecMultiLine
isPresaleActive
function isPresaleActive() internal view returns (bool) { return now < presaleEndTime && now >= presaleStartTime; }
/** * @dev Internal funciton that helps to check if the pre-sale is active */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://ce167343b1dcaa8725159d95e78bc955e63e34546b19b99b083b3441ce0618e7
{ "func_code_index": [ 1457, 1591 ] }
89
TIMETokenFundraiser
contracts/fundraiser/PresaleFundraiser.sol
0xed6849727f7b158a14a492bd0a3bf4d7126f7f71
Solidity
PresaleFundraiser
contract PresaleFundraiser is MintableTokenFundraiser { /// @dev The token hard cap for the pre-sale uint256 public presaleSupply; /// @dev The token hard cap for the pre-sale uint256 public presaleMaxSupply; /// @dev The start time of the pre-sale (Unix timestamp). uint256 public presaleStartTime; /// @dev The end time of the pre-sale (Unix timestamp). uint256 public presaleEndTime; /// @dev The conversion rate for the pre-sale uint256 public presaleConversionRate; /** * @dev The initialization method. * * @param _startTime The timestamp of the moment when the pre-sale starts * @param _endTime The timestamp of the moment when the pre-sale ends * @param _conversionRate The conversion rate during the pre-sale */ function initializePresaleFundraiser( uint256 _presaleMaxSupply, uint256 _startTime, uint256 _endTime, uint256 _conversionRate ) internal { require(_endTime >= _startTime, "Pre-sale's end is before its start"); require(_conversionRate > 0, "Conversion rate is not set"); presaleMaxSupply = _presaleMaxSupply; presaleStartTime = _startTime; presaleEndTime = _endTime; presaleConversionRate = _conversionRate; } /** * @dev Internal funciton that helps to check if the pre-sale is active */ function isPresaleActive() internal view returns (bool) { return now < presaleEndTime && now >= presaleStartTime; } /** * @dev this function different conversion rate while in presale */ function getConversionRate() public view returns (uint256) { if (isPresaleActive()) { return presaleConversionRate; } return super.getConversionRate(); } /** * @dev It throws an exception if the transaction does not meet the preconditions. */ function validateTransaction() internal view { require(msg.value != 0, "Transaction value is zero"); require( now >= startTime && now < endTime || isPresaleActive(), "Neither the pre-sale nor the fundraiser are currently active" ); } function handleTokens(address _address, uint256 _tokens) internal { if (isPresaleActive()) { presaleSupply = presaleSupply.plus(_tokens); require( presaleSupply <= presaleMaxSupply, "Transaction exceeds the pre-sale maximum token supply" ); } super.handleTokens(_address, _tokens); } }
/** * @title PresaleFundraiser * * @dev This is the standard fundraiser contract which allows * you to raise ETH in exchange for your tokens. */
NatSpecMultiLine
getConversionRate
function getConversionRate() public view returns (uint256) { if (isPresaleActive()) { return presaleConversionRate; } return super.getConversionRate(); }
/** * @dev this function different conversion rate while in presale */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://ce167343b1dcaa8725159d95e78bc955e63e34546b19b99b083b3441ce0618e7
{ "func_code_index": [ 1680, 1883 ] }
90
TIMETokenFundraiser
contracts/fundraiser/PresaleFundraiser.sol
0xed6849727f7b158a14a492bd0a3bf4d7126f7f71
Solidity
PresaleFundraiser
contract PresaleFundraiser is MintableTokenFundraiser { /// @dev The token hard cap for the pre-sale uint256 public presaleSupply; /// @dev The token hard cap for the pre-sale uint256 public presaleMaxSupply; /// @dev The start time of the pre-sale (Unix timestamp). uint256 public presaleStartTime; /// @dev The end time of the pre-sale (Unix timestamp). uint256 public presaleEndTime; /// @dev The conversion rate for the pre-sale uint256 public presaleConversionRate; /** * @dev The initialization method. * * @param _startTime The timestamp of the moment when the pre-sale starts * @param _endTime The timestamp of the moment when the pre-sale ends * @param _conversionRate The conversion rate during the pre-sale */ function initializePresaleFundraiser( uint256 _presaleMaxSupply, uint256 _startTime, uint256 _endTime, uint256 _conversionRate ) internal { require(_endTime >= _startTime, "Pre-sale's end is before its start"); require(_conversionRate > 0, "Conversion rate is not set"); presaleMaxSupply = _presaleMaxSupply; presaleStartTime = _startTime; presaleEndTime = _endTime; presaleConversionRate = _conversionRate; } /** * @dev Internal funciton that helps to check if the pre-sale is active */ function isPresaleActive() internal view returns (bool) { return now < presaleEndTime && now >= presaleStartTime; } /** * @dev this function different conversion rate while in presale */ function getConversionRate() public view returns (uint256) { if (isPresaleActive()) { return presaleConversionRate; } return super.getConversionRate(); } /** * @dev It throws an exception if the transaction does not meet the preconditions. */ function validateTransaction() internal view { require(msg.value != 0, "Transaction value is zero"); require( now >= startTime && now < endTime || isPresaleActive(), "Neither the pre-sale nor the fundraiser are currently active" ); } function handleTokens(address _address, uint256 _tokens) internal { if (isPresaleActive()) { presaleSupply = presaleSupply.plus(_tokens); require( presaleSupply <= presaleMaxSupply, "Transaction exceeds the pre-sale maximum token supply" ); } super.handleTokens(_address, _tokens); } }
/** * @title PresaleFundraiser * * @dev This is the standard fundraiser contract which allows * you to raise ETH in exchange for your tokens. */
NatSpecMultiLine
validateTransaction
function validateTransaction() internal view { require(msg.value != 0, "Transaction value is zero"); require( now >= startTime && now < endTime || isPresaleActive(), "Neither the pre-sale nor the fundraiser are currently active" ); }
/** * @dev It throws an exception if the transaction does not meet the preconditions. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://ce167343b1dcaa8725159d95e78bc955e63e34546b19b99b083b3441ce0618e7
{ "func_code_index": [ 1992, 2288 ] }
91
LittleAlienInu
LittleAlienInu.sol
0x6f3bdd622a03247990a4e3049186b83f01023d6d
Solidity
LittleAlienInu
contract LittleAlienInu is Context, ERC20, ERC20Metadata, Ownable { using SafeMath for uint256; mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromMaxTx; IpancakeRouter02 public pancakeRouter; address public pancakePair; string private _name; string private _symbol; uint8 private _decimals; uint256 private _totalSupply; bool public _antiwhale = false; //once switched on, can never be switched off. uint256 public _maxTxAmount; constructor() { _name = "Little Alien Inu"; _symbol = "LAI"; _decimals = 18; _totalSupply = 1000000000000 * 1e18; _balances[owner()] = _totalSupply; _maxTxAmount = _totalSupply.mul(1).div(100); IpancakeRouter02 _pancakeRouter = IpancakeRouter02( 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D // UniswapV2Router02 ); // Create a uniswap pair for this new token pancakePair = IUniswapV2Factory(_pancakeRouter.factory()).createPair( address(this), _pancakeRouter.WETH() ); // set the rest of the contract variables pancakeRouter = _pancakeRouter; // exclude from max tx _isExcludedFromMaxTx[owner()] = true; _isExcludedFromMaxTx[address(this)] = true; emit Transfer(address(0), owner(), _totalSupply); } function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } function decimals() public view virtual override returns (uint8) { return _decimals; } function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function AntiWhale() external onlyOwner { _antiwhale = true; } function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require( currentAllowance >= amount, "WE: transfer amount exceeds allowance" ); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } function setExcludeFromMaxTx(address _address, bool value) public onlyOwner { _isExcludedFromMaxTx[_address] = value; } // for 1% input 1 function setMaxTxPercent(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = _totalSupply.mul(maxTxAmount).div(100); } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender] + addedValue ); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require( currentAllowance >= subtractedValue, "WE: decreased allowance below zero" ); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "WE: transfer from the zero address"); require(recipient != address(0), "WE: transfer to the zero address"); require(amount > 0, "WE: Transfer amount must be greater than zero"); if(_isExcludedFromMaxTx[sender] == false && _isExcludedFromMaxTx[recipient] == false // by default false ){ require(amount <= _maxTxAmount,"amount exceed max limit"); if (!_antiwhale && sender != owner() && recipient != owner()) { require(recipient != pancakePair, " WE:antuwhale is not enabled"); } } _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require( senderBalance >= amount, "WE: transfer amount exceeds balance" ); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "BEP20: approve from the zero address"); require(spender != address(0), "BEP20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
// Bep20 standards for token creation by bloctechsolutions.com
LineComment
setMaxTxPercent
function setMaxTxPercent(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = _totalSupply.mul(maxTxAmount).div(100); }
// for 1% input 1
LineComment
v0.8.10+commit.fc410830
None
ipfs://d88593e01163ef9a7074ac063f7f7301d5a3cd42811537076f26a44350345ff8
{ "func_code_index": [ 3626, 3766 ] }
92
Locker
Locker.sol
0x1cc29ee9dd8d9ed4148f6600ba5ec84d7ee85d12
Solidity
Locker
contract Locker is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "LOCKER";// string private constant _symbol = "LOCKER";// uint8 private constant _decimals = 9; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 public launchBlock; //Buy Fee uint256 private _redisFeeOnBuy = 0;// uint256 private _taxFeeOnBuy = 10;// //Sell Fee uint256 private _redisFeeOnSell = 0;// uint256 private _taxFeeOnSell = 99;// //Original Fee uint256 private _redisFee = _redisFeeOnSell; uint256 private _taxFee = _taxFeeOnSell; uint256 private _previousredisFee = _redisFee; uint256 private _previoustaxFee = _taxFee; mapping(address => bool) public bots; mapping(address => uint256) private cooldown; address payable private _developmentAddress = payable(0x7855587406e16D4D556649D4a89314bbd8B90cBb);// address payable private _marketingAddress = payable(0x258cb94167f233D2E6cf1C868873164321064664);// IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = true; uint256 public _maxTxAmount = 29000 * 10**9; // uint256 public _maxWalletSize = 150000 * 10**9; // uint256 public _swapTokensAtAmount = 5000 * 10**9; // event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor() { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);// uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_developmentAddress] = true; _isExcludedFromFee[_marketingAddress] = true; bots[address(0x66f049111958809841Bbe4b81c034Da2D953AA0c)] = true; bots[address(0x000000005736775Feb0C8568e7DEe77222a26880)] = true; bots[address(0x34822A742BDE3beF13acabF14244869841f06A73)] = true; bots[address(0x69611A66d0CF67e5Ddd1957e6499b5C5A3E44845)] = true; bots[address(0x69611A66d0CF67e5Ddd1957e6499b5C5A3E44845)] = true; bots[address(0x8484eFcBDa76955463aa12e1d504D7C6C89321F8)] = true; bots[address(0xe5265ce4D0a3B191431e1bac056d72b2b9F0Fe44)] = true; bots[address(0x33F9Da98C57674B5FC5AE7349E3C732Cf2E6Ce5C)] = true; bots[address(0xc59a8E2d2c476BA9122aa4eC19B4c5E2BBAbbC28)] = true; bots[address(0x21053Ff2D9Fc37D4DB8687d48bD0b57581c1333D)] = true; bots[address(0x4dd6A0D3191A41522B84BC6b65d17f6f5e6a4192)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, _msgSender(), _allowances[sender][_msgSender()].sub( amount, "ERC20: transfer amount exceeds allowance" ) ); return true; } function tokenFromReflection(uint256 rAmount) private view returns (uint256) { require( rAmount <= _rTotal, "Amount must be less than total reflections" ); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if (_redisFee == 0 && _taxFee == 0) return; _previousredisFee = _redisFee; _previoustaxFee = _taxFee; _redisFee = 0; _taxFee = 0; } function restoreAllFee() private { _redisFee = _previousredisFee; _taxFee = _previoustaxFee; } function _approve( address owner, address spender, uint256 amount ) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { //Trade start check if (!tradingOpen) { require(from == owner(), "TOKEN: This account cannot send tokens until trading is enabled"); } require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit"); require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!"); if(block.number <= launchBlock && from == uniswapV2Pair && to != address(uniswapV2Router) && to != address(this)){ bots[to] = true; } if(to != uniswapV2Pair) { require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!"); } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= _swapTokensAtAmount; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; //Transfer Tokens if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) { takeFee = false; } else { //Set Fee for Buys if(from == uniswapV2Pair && to != address(uniswapV2Router)) { _redisFee = _redisFeeOnBuy; _taxFee = _taxFeeOnBuy; } //Set Fee for Sells if (to == uniswapV2Pair && from != address(uniswapV2Router)) { _redisFee = _redisFeeOnSell; _taxFee = _taxFeeOnSell; } } _tokenTransfer(from, to, amount, takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _developmentAddress.transfer(amount.div(2)); _marketingAddress.transfer(amount.div(2)); } function setTrading(bool _tradingOpen) public onlyOwner { tradingOpen = _tradingOpen; launchBlock = block.number; } function manualswap() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function blockBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function unblockBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); _transferStandard(sender, recipient, amount); if (!takeFee) restoreAllFee(); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _redisFee, _taxFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues( uint256 tAmount, uint256 redisFee, uint256 taxFee ) private pure returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(redisFee).div(100); uint256 tTeam = tAmount.mul(taxFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner { _redisFeeOnBuy = redisFeeOnBuy; _redisFeeOnSell = redisFeeOnSell; _taxFeeOnBuy = taxFeeOnBuy; _taxFeeOnSell = taxFeeOnSell; } //Set minimum tokens required to swap. function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner { _swapTokensAtAmount = swapTokensAtAmount; } //Set minimum tokens required to swap. function toggleSwap(bool _swapEnabled) public onlyOwner { swapEnabled = _swapEnabled; } //Set maximum transaction function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner { _maxWalletSize = maxWalletSize; } function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner { for(uint256 i = 0; i < accounts.length; i++) { _isExcludedFromFee[accounts[i]] = excluded; } } }
setMinSwapTokensThreshold
function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner { _swapTokensAtAmount = swapTokensAtAmount; }
//Set minimum tokens required to swap.
LineComment
v0.8.7+commit.e28d00a7
Unlicense
ipfs://248817f5041836f17ffc6afeb4474f3d1f03282f17e368841bcf54613bb7fbbd
{ "func_code_index": [ 13969, 14113 ] }
93
Locker
Locker.sol
0x1cc29ee9dd8d9ed4148f6600ba5ec84d7ee85d12
Solidity
Locker
contract Locker is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "LOCKER";// string private constant _symbol = "LOCKER";// uint8 private constant _decimals = 9; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 public launchBlock; //Buy Fee uint256 private _redisFeeOnBuy = 0;// uint256 private _taxFeeOnBuy = 10;// //Sell Fee uint256 private _redisFeeOnSell = 0;// uint256 private _taxFeeOnSell = 99;// //Original Fee uint256 private _redisFee = _redisFeeOnSell; uint256 private _taxFee = _taxFeeOnSell; uint256 private _previousredisFee = _redisFee; uint256 private _previoustaxFee = _taxFee; mapping(address => bool) public bots; mapping(address => uint256) private cooldown; address payable private _developmentAddress = payable(0x7855587406e16D4D556649D4a89314bbd8B90cBb);// address payable private _marketingAddress = payable(0x258cb94167f233D2E6cf1C868873164321064664);// IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = true; uint256 public _maxTxAmount = 29000 * 10**9; // uint256 public _maxWalletSize = 150000 * 10**9; // uint256 public _swapTokensAtAmount = 5000 * 10**9; // event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor() { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);// uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_developmentAddress] = true; _isExcludedFromFee[_marketingAddress] = true; bots[address(0x66f049111958809841Bbe4b81c034Da2D953AA0c)] = true; bots[address(0x000000005736775Feb0C8568e7DEe77222a26880)] = true; bots[address(0x34822A742BDE3beF13acabF14244869841f06A73)] = true; bots[address(0x69611A66d0CF67e5Ddd1957e6499b5C5A3E44845)] = true; bots[address(0x69611A66d0CF67e5Ddd1957e6499b5C5A3E44845)] = true; bots[address(0x8484eFcBDa76955463aa12e1d504D7C6C89321F8)] = true; bots[address(0xe5265ce4D0a3B191431e1bac056d72b2b9F0Fe44)] = true; bots[address(0x33F9Da98C57674B5FC5AE7349E3C732Cf2E6Ce5C)] = true; bots[address(0xc59a8E2d2c476BA9122aa4eC19B4c5E2BBAbbC28)] = true; bots[address(0x21053Ff2D9Fc37D4DB8687d48bD0b57581c1333D)] = true; bots[address(0x4dd6A0D3191A41522B84BC6b65d17f6f5e6a4192)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, _msgSender(), _allowances[sender][_msgSender()].sub( amount, "ERC20: transfer amount exceeds allowance" ) ); return true; } function tokenFromReflection(uint256 rAmount) private view returns (uint256) { require( rAmount <= _rTotal, "Amount must be less than total reflections" ); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if (_redisFee == 0 && _taxFee == 0) return; _previousredisFee = _redisFee; _previoustaxFee = _taxFee; _redisFee = 0; _taxFee = 0; } function restoreAllFee() private { _redisFee = _previousredisFee; _taxFee = _previoustaxFee; } function _approve( address owner, address spender, uint256 amount ) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { //Trade start check if (!tradingOpen) { require(from == owner(), "TOKEN: This account cannot send tokens until trading is enabled"); } require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit"); require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!"); if(block.number <= launchBlock && from == uniswapV2Pair && to != address(uniswapV2Router) && to != address(this)){ bots[to] = true; } if(to != uniswapV2Pair) { require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!"); } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= _swapTokensAtAmount; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; //Transfer Tokens if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) { takeFee = false; } else { //Set Fee for Buys if(from == uniswapV2Pair && to != address(uniswapV2Router)) { _redisFee = _redisFeeOnBuy; _taxFee = _taxFeeOnBuy; } //Set Fee for Sells if (to == uniswapV2Pair && from != address(uniswapV2Router)) { _redisFee = _redisFeeOnSell; _taxFee = _taxFeeOnSell; } } _tokenTransfer(from, to, amount, takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _developmentAddress.transfer(amount.div(2)); _marketingAddress.transfer(amount.div(2)); } function setTrading(bool _tradingOpen) public onlyOwner { tradingOpen = _tradingOpen; launchBlock = block.number; } function manualswap() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function blockBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function unblockBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); _transferStandard(sender, recipient, amount); if (!takeFee) restoreAllFee(); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _redisFee, _taxFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues( uint256 tAmount, uint256 redisFee, uint256 taxFee ) private pure returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(redisFee).div(100); uint256 tTeam = tAmount.mul(taxFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner { _redisFeeOnBuy = redisFeeOnBuy; _redisFeeOnSell = redisFeeOnSell; _taxFeeOnBuy = taxFeeOnBuy; _taxFeeOnSell = taxFeeOnSell; } //Set minimum tokens required to swap. function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner { _swapTokensAtAmount = swapTokensAtAmount; } //Set minimum tokens required to swap. function toggleSwap(bool _swapEnabled) public onlyOwner { swapEnabled = _swapEnabled; } //Set maximum transaction function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner { _maxWalletSize = maxWalletSize; } function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner { for(uint256 i = 0; i < accounts.length; i++) { _isExcludedFromFee[accounts[i]] = excluded; } } }
toggleSwap
function toggleSwap(bool _swapEnabled) public onlyOwner { swapEnabled = _swapEnabled; }
//Set minimum tokens required to swap.
LineComment
v0.8.7+commit.e28d00a7
Unlicense
ipfs://248817f5041836f17ffc6afeb4474f3d1f03282f17e368841bcf54613bb7fbbd
{ "func_code_index": [ 14161, 14267 ] }
94
Locker
Locker.sol
0x1cc29ee9dd8d9ed4148f6600ba5ec84d7ee85d12
Solidity
Locker
contract Locker is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "LOCKER";// string private constant _symbol = "LOCKER";// uint8 private constant _decimals = 9; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 public launchBlock; //Buy Fee uint256 private _redisFeeOnBuy = 0;// uint256 private _taxFeeOnBuy = 10;// //Sell Fee uint256 private _redisFeeOnSell = 0;// uint256 private _taxFeeOnSell = 99;// //Original Fee uint256 private _redisFee = _redisFeeOnSell; uint256 private _taxFee = _taxFeeOnSell; uint256 private _previousredisFee = _redisFee; uint256 private _previoustaxFee = _taxFee; mapping(address => bool) public bots; mapping(address => uint256) private cooldown; address payable private _developmentAddress = payable(0x7855587406e16D4D556649D4a89314bbd8B90cBb);// address payable private _marketingAddress = payable(0x258cb94167f233D2E6cf1C868873164321064664);// IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = true; uint256 public _maxTxAmount = 29000 * 10**9; // uint256 public _maxWalletSize = 150000 * 10**9; // uint256 public _swapTokensAtAmount = 5000 * 10**9; // event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor() { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);// uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_developmentAddress] = true; _isExcludedFromFee[_marketingAddress] = true; bots[address(0x66f049111958809841Bbe4b81c034Da2D953AA0c)] = true; bots[address(0x000000005736775Feb0C8568e7DEe77222a26880)] = true; bots[address(0x34822A742BDE3beF13acabF14244869841f06A73)] = true; bots[address(0x69611A66d0CF67e5Ddd1957e6499b5C5A3E44845)] = true; bots[address(0x69611A66d0CF67e5Ddd1957e6499b5C5A3E44845)] = true; bots[address(0x8484eFcBDa76955463aa12e1d504D7C6C89321F8)] = true; bots[address(0xe5265ce4D0a3B191431e1bac056d72b2b9F0Fe44)] = true; bots[address(0x33F9Da98C57674B5FC5AE7349E3C732Cf2E6Ce5C)] = true; bots[address(0xc59a8E2d2c476BA9122aa4eC19B4c5E2BBAbbC28)] = true; bots[address(0x21053Ff2D9Fc37D4DB8687d48bD0b57581c1333D)] = true; bots[address(0x4dd6A0D3191A41522B84BC6b65d17f6f5e6a4192)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, _msgSender(), _allowances[sender][_msgSender()].sub( amount, "ERC20: transfer amount exceeds allowance" ) ); return true; } function tokenFromReflection(uint256 rAmount) private view returns (uint256) { require( rAmount <= _rTotal, "Amount must be less than total reflections" ); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if (_redisFee == 0 && _taxFee == 0) return; _previousredisFee = _redisFee; _previoustaxFee = _taxFee; _redisFee = 0; _taxFee = 0; } function restoreAllFee() private { _redisFee = _previousredisFee; _taxFee = _previoustaxFee; } function _approve( address owner, address spender, uint256 amount ) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { //Trade start check if (!tradingOpen) { require(from == owner(), "TOKEN: This account cannot send tokens until trading is enabled"); } require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit"); require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!"); if(block.number <= launchBlock && from == uniswapV2Pair && to != address(uniswapV2Router) && to != address(this)){ bots[to] = true; } if(to != uniswapV2Pair) { require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!"); } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= _swapTokensAtAmount; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; //Transfer Tokens if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) { takeFee = false; } else { //Set Fee for Buys if(from == uniswapV2Pair && to != address(uniswapV2Router)) { _redisFee = _redisFeeOnBuy; _taxFee = _taxFeeOnBuy; } //Set Fee for Sells if (to == uniswapV2Pair && from != address(uniswapV2Router)) { _redisFee = _redisFeeOnSell; _taxFee = _taxFeeOnSell; } } _tokenTransfer(from, to, amount, takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _developmentAddress.transfer(amount.div(2)); _marketingAddress.transfer(amount.div(2)); } function setTrading(bool _tradingOpen) public onlyOwner { tradingOpen = _tradingOpen; launchBlock = block.number; } function manualswap() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function blockBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function unblockBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); _transferStandard(sender, recipient, amount); if (!takeFee) restoreAllFee(); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _redisFee, _taxFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues( uint256 tAmount, uint256 redisFee, uint256 taxFee ) private pure returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(redisFee).div(100); uint256 tTeam = tAmount.mul(taxFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner { _redisFeeOnBuy = redisFeeOnBuy; _redisFeeOnSell = redisFeeOnSell; _taxFeeOnBuy = taxFeeOnBuy; _taxFeeOnSell = taxFeeOnSell; } //Set minimum tokens required to swap. function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner { _swapTokensAtAmount = swapTokensAtAmount; } //Set minimum tokens required to swap. function toggleSwap(bool _swapEnabled) public onlyOwner { swapEnabled = _swapEnabled; } //Set maximum transaction function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner { _maxWalletSize = maxWalletSize; } function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner { for(uint256 i = 0; i < accounts.length; i++) { _isExcludedFromFee[accounts[i]] = excluded; } } }
setMaxTxnAmount
function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; }
//Set maximum transaction
LineComment
v0.8.7+commit.e28d00a7
Unlicense
ipfs://248817f5041836f17ffc6afeb4474f3d1f03282f17e368841bcf54613bb7fbbd
{ "func_code_index": [ 14305, 14418 ] }
95
TIMETokenFundraiser
contracts/token/StandardToken.sol
0xed6849727f7b158a14a492bd0a3bf4d7126f7f71
Solidity
StandardToken
contract StandardToken is ERC20Token { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) internal allowed; /** * @dev The constructor assigns the token name, symbols and decimals. */ constructor(string _name, string _symbol, uint8 _decimals) internal { name = _name; symbol = _symbol; decimals = _decimals; } /** * @dev Get the balance of an address. * * @param _address The address which's balance will be checked. * * @return The current balance of the address. */ function balanceOf(address _address) public view returns (uint256 balance) { return balances[_address]; } /** * @dev Checks the amount of tokens that an owner allowed to a spender. * * @param _owner The address which owns the funds allowed for spending by a third-party. * @param _spender The third-party address that is allowed to spend the tokens. * * @return The number of tokens available to `_spender` to be spent. */ function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * @dev Give permission to `_spender` to spend `_value` number of tokens on your behalf. * E.g. You place a buy or sell order on an exchange and in that example, the * `_spender` address is the address of the contract the exchange created to add your token to their * website and you are `msg.sender`. * * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. * * @return Whether the approval process was successful or not. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Transfers `_value` number of tokens to the `_to` address. * * @param _to The address of the recipient. * @param _value The number of tokens to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { executeTransfer(msg.sender, _to, _value); return true; } /** * @dev Allows another contract to spend tokens on behalf of the `_from` address and send them to the `_to` address. * * @param _from The address which approved you to spend tokens on their behalf. * @param _to The address where you want to send tokens. * @param _value The number of tokens to be sent. * * @return Whether the transfer was successful or not. */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_value <= allowed[_from][msg.sender], "Insufficient allowance"); allowed[_from][msg.sender] = allowed[_from][msg.sender].minus(_value); executeTransfer(_from, _to, _value); return true; } /** * @dev Internal function that this reused by the transfer functions */ function executeTransfer(address _from, address _to, uint256 _value) internal { require(_to != address(0), "Invalid transfer to address zero"); require(_value <= balances[_from], "Insufficient account balance"); balances[_from] = balances[_from].minus(_value); balances[_to] = balances[_to].plus(_value); emit Transfer(_from, _to, _value); } }
/** * @title Standard Token * * @dev The standard abstract implementation of the ERC20 interface. */
NatSpecMultiLine
balanceOf
function balanceOf(address _address) public view returns (uint256 balance) { return balances[_address]; }
/** * @dev Get the balance of an address. * * @param _address The address which's balance will be checked. * * @return The current balance of the address. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://ce167343b1dcaa8725159d95e78bc955e63e34546b19b99b083b3441ce0618e7
{ "func_code_index": [ 733, 857 ] }
96
TIMETokenFundraiser
contracts/token/StandardToken.sol
0xed6849727f7b158a14a492bd0a3bf4d7126f7f71
Solidity
StandardToken
contract StandardToken is ERC20Token { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) internal allowed; /** * @dev The constructor assigns the token name, symbols and decimals. */ constructor(string _name, string _symbol, uint8 _decimals) internal { name = _name; symbol = _symbol; decimals = _decimals; } /** * @dev Get the balance of an address. * * @param _address The address which's balance will be checked. * * @return The current balance of the address. */ function balanceOf(address _address) public view returns (uint256 balance) { return balances[_address]; } /** * @dev Checks the amount of tokens that an owner allowed to a spender. * * @param _owner The address which owns the funds allowed for spending by a third-party. * @param _spender The third-party address that is allowed to spend the tokens. * * @return The number of tokens available to `_spender` to be spent. */ function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * @dev Give permission to `_spender` to spend `_value` number of tokens on your behalf. * E.g. You place a buy or sell order on an exchange and in that example, the * `_spender` address is the address of the contract the exchange created to add your token to their * website and you are `msg.sender`. * * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. * * @return Whether the approval process was successful or not. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Transfers `_value` number of tokens to the `_to` address. * * @param _to The address of the recipient. * @param _value The number of tokens to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { executeTransfer(msg.sender, _to, _value); return true; } /** * @dev Allows another contract to spend tokens on behalf of the `_from` address and send them to the `_to` address. * * @param _from The address which approved you to spend tokens on their behalf. * @param _to The address where you want to send tokens. * @param _value The number of tokens to be sent. * * @return Whether the transfer was successful or not. */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_value <= allowed[_from][msg.sender], "Insufficient allowance"); allowed[_from][msg.sender] = allowed[_from][msg.sender].minus(_value); executeTransfer(_from, _to, _value); return true; } /** * @dev Internal function that this reused by the transfer functions */ function executeTransfer(address _from, address _to, uint256 _value) internal { require(_to != address(0), "Invalid transfer to address zero"); require(_value <= balances[_from], "Insufficient account balance"); balances[_from] = balances[_from].minus(_value); balances[_to] = balances[_to].plus(_value); emit Transfer(_from, _to, _value); } }
/** * @title Standard Token * * @dev The standard abstract implementation of the ERC20 interface. */
NatSpecMultiLine
allowance
function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; }
/** * @dev Checks the amount of tokens that an owner allowed to a spender. * * @param _owner The address which owns the funds allowed for spending by a third-party. * @param _spender The third-party address that is allowed to spend the tokens. * * @return The number of tokens available to `_spender` to be spent. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://ce167343b1dcaa8725159d95e78bc955e63e34546b19b99b083b3441ce0618e7
{ "func_code_index": [ 1224, 1373 ] }
97
TIMETokenFundraiser
contracts/token/StandardToken.sol
0xed6849727f7b158a14a492bd0a3bf4d7126f7f71
Solidity
StandardToken
contract StandardToken is ERC20Token { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) internal allowed; /** * @dev The constructor assigns the token name, symbols and decimals. */ constructor(string _name, string _symbol, uint8 _decimals) internal { name = _name; symbol = _symbol; decimals = _decimals; } /** * @dev Get the balance of an address. * * @param _address The address which's balance will be checked. * * @return The current balance of the address. */ function balanceOf(address _address) public view returns (uint256 balance) { return balances[_address]; } /** * @dev Checks the amount of tokens that an owner allowed to a spender. * * @param _owner The address which owns the funds allowed for spending by a third-party. * @param _spender The third-party address that is allowed to spend the tokens. * * @return The number of tokens available to `_spender` to be spent. */ function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * @dev Give permission to `_spender` to spend `_value` number of tokens on your behalf. * E.g. You place a buy or sell order on an exchange and in that example, the * `_spender` address is the address of the contract the exchange created to add your token to their * website and you are `msg.sender`. * * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. * * @return Whether the approval process was successful or not. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Transfers `_value` number of tokens to the `_to` address. * * @param _to The address of the recipient. * @param _value The number of tokens to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { executeTransfer(msg.sender, _to, _value); return true; } /** * @dev Allows another contract to spend tokens on behalf of the `_from` address and send them to the `_to` address. * * @param _from The address which approved you to spend tokens on their behalf. * @param _to The address where you want to send tokens. * @param _value The number of tokens to be sent. * * @return Whether the transfer was successful or not. */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_value <= allowed[_from][msg.sender], "Insufficient allowance"); allowed[_from][msg.sender] = allowed[_from][msg.sender].minus(_value); executeTransfer(_from, _to, _value); return true; } /** * @dev Internal function that this reused by the transfer functions */ function executeTransfer(address _from, address _to, uint256 _value) internal { require(_to != address(0), "Invalid transfer to address zero"); require(_value <= balances[_from], "Insufficient account balance"); balances[_from] = balances[_from].minus(_value); balances[_to] = balances[_to].plus(_value); emit Transfer(_from, _to, _value); } }
/** * @title Standard Token * * @dev The standard abstract implementation of the ERC20 interface. */
NatSpecMultiLine
approve
function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; }
/** * @dev Give permission to `_spender` to spend `_value` number of tokens on your behalf. * E.g. You place a buy or sell order on an exchange and in that example, the * `_spender` address is the address of the contract the exchange created to add your token to their * website and you are `msg.sender`. * * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. * * @return Whether the approval process was successful or not. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://ce167343b1dcaa8725159d95e78bc955e63e34546b19b99b083b3441ce0618e7
{ "func_code_index": [ 1925, 2140 ] }
98
TIMETokenFundraiser
contracts/token/StandardToken.sol
0xed6849727f7b158a14a492bd0a3bf4d7126f7f71
Solidity
StandardToken
contract StandardToken is ERC20Token { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) internal allowed; /** * @dev The constructor assigns the token name, symbols and decimals. */ constructor(string _name, string _symbol, uint8 _decimals) internal { name = _name; symbol = _symbol; decimals = _decimals; } /** * @dev Get the balance of an address. * * @param _address The address which's balance will be checked. * * @return The current balance of the address. */ function balanceOf(address _address) public view returns (uint256 balance) { return balances[_address]; } /** * @dev Checks the amount of tokens that an owner allowed to a spender. * * @param _owner The address which owns the funds allowed for spending by a third-party. * @param _spender The third-party address that is allowed to spend the tokens. * * @return The number of tokens available to `_spender` to be spent. */ function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * @dev Give permission to `_spender` to spend `_value` number of tokens on your behalf. * E.g. You place a buy or sell order on an exchange and in that example, the * `_spender` address is the address of the contract the exchange created to add your token to their * website and you are `msg.sender`. * * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. * * @return Whether the approval process was successful or not. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Transfers `_value` number of tokens to the `_to` address. * * @param _to The address of the recipient. * @param _value The number of tokens to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { executeTransfer(msg.sender, _to, _value); return true; } /** * @dev Allows another contract to spend tokens on behalf of the `_from` address and send them to the `_to` address. * * @param _from The address which approved you to spend tokens on their behalf. * @param _to The address where you want to send tokens. * @param _value The number of tokens to be sent. * * @return Whether the transfer was successful or not. */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_value <= allowed[_from][msg.sender], "Insufficient allowance"); allowed[_from][msg.sender] = allowed[_from][msg.sender].minus(_value); executeTransfer(_from, _to, _value); return true; } /** * @dev Internal function that this reused by the transfer functions */ function executeTransfer(address _from, address _to, uint256 _value) internal { require(_to != address(0), "Invalid transfer to address zero"); require(_value <= balances[_from], "Insufficient account balance"); balances[_from] = balances[_from].minus(_value); balances[_to] = balances[_to].plus(_value); emit Transfer(_from, _to, _value); } }
/** * @title Standard Token * * @dev The standard abstract implementation of the ERC20 interface. */
NatSpecMultiLine
transfer
function transfer(address _to, uint256 _value) public returns (bool) { executeTransfer(msg.sender, _to, _value); return true; }
/** * @dev Transfers `_value` number of tokens to the `_to` address. * * @param _to The address of the recipient. * @param _value The number of tokens to be transferred. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://ce167343b1dcaa8725159d95e78bc955e63e34546b19b99b083b3441ce0618e7
{ "func_code_index": [ 2351, 2508 ] }
99
TIMETokenFundraiser
contracts/token/StandardToken.sol
0xed6849727f7b158a14a492bd0a3bf4d7126f7f71
Solidity
StandardToken
contract StandardToken is ERC20Token { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) internal allowed; /** * @dev The constructor assigns the token name, symbols and decimals. */ constructor(string _name, string _symbol, uint8 _decimals) internal { name = _name; symbol = _symbol; decimals = _decimals; } /** * @dev Get the balance of an address. * * @param _address The address which's balance will be checked. * * @return The current balance of the address. */ function balanceOf(address _address) public view returns (uint256 balance) { return balances[_address]; } /** * @dev Checks the amount of tokens that an owner allowed to a spender. * * @param _owner The address which owns the funds allowed for spending by a third-party. * @param _spender The third-party address that is allowed to spend the tokens. * * @return The number of tokens available to `_spender` to be spent. */ function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * @dev Give permission to `_spender` to spend `_value` number of tokens on your behalf. * E.g. You place a buy or sell order on an exchange and in that example, the * `_spender` address is the address of the contract the exchange created to add your token to their * website and you are `msg.sender`. * * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. * * @return Whether the approval process was successful or not. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Transfers `_value` number of tokens to the `_to` address. * * @param _to The address of the recipient. * @param _value The number of tokens to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { executeTransfer(msg.sender, _to, _value); return true; } /** * @dev Allows another contract to spend tokens on behalf of the `_from` address and send them to the `_to` address. * * @param _from The address which approved you to spend tokens on their behalf. * @param _to The address where you want to send tokens. * @param _value The number of tokens to be sent. * * @return Whether the transfer was successful or not. */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_value <= allowed[_from][msg.sender], "Insufficient allowance"); allowed[_from][msg.sender] = allowed[_from][msg.sender].minus(_value); executeTransfer(_from, _to, _value); return true; } /** * @dev Internal function that this reused by the transfer functions */ function executeTransfer(address _from, address _to, uint256 _value) internal { require(_to != address(0), "Invalid transfer to address zero"); require(_value <= balances[_from], "Insufficient account balance"); balances[_from] = balances[_from].minus(_value); balances[_to] = balances[_to].plus(_value); emit Transfer(_from, _to, _value); } }
/** * @title Standard Token * * @dev The standard abstract implementation of the ERC20 interface. */
NatSpecMultiLine
transferFrom
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_value <= allowed[_from][msg.sender], "Insufficient allowance"); allowed[_from][msg.sender] = allowed[_from][msg.sender].minus(_value); executeTransfer(_from, _to, _value); return true; }
/** * @dev Allows another contract to spend tokens on behalf of the `_from` address and send them to the `_to` address. * * @param _from The address which approved you to spend tokens on their behalf. * @param _to The address where you want to send tokens. * @param _value The number of tokens to be sent. * * @return Whether the transfer was successful or not. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://ce167343b1dcaa8725159d95e78bc955e63e34546b19b99b083b3441ce0618e7
{ "func_code_index": [ 2929, 3264 ] }
100
TIMETokenFundraiser
contracts/token/StandardToken.sol
0xed6849727f7b158a14a492bd0a3bf4d7126f7f71
Solidity
StandardToken
contract StandardToken is ERC20Token { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) internal allowed; /** * @dev The constructor assigns the token name, symbols and decimals. */ constructor(string _name, string _symbol, uint8 _decimals) internal { name = _name; symbol = _symbol; decimals = _decimals; } /** * @dev Get the balance of an address. * * @param _address The address which's balance will be checked. * * @return The current balance of the address. */ function balanceOf(address _address) public view returns (uint256 balance) { return balances[_address]; } /** * @dev Checks the amount of tokens that an owner allowed to a spender. * * @param _owner The address which owns the funds allowed for spending by a third-party. * @param _spender The third-party address that is allowed to spend the tokens. * * @return The number of tokens available to `_spender` to be spent. */ function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * @dev Give permission to `_spender` to spend `_value` number of tokens on your behalf. * E.g. You place a buy or sell order on an exchange and in that example, the * `_spender` address is the address of the contract the exchange created to add your token to their * website and you are `msg.sender`. * * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. * * @return Whether the approval process was successful or not. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Transfers `_value` number of tokens to the `_to` address. * * @param _to The address of the recipient. * @param _value The number of tokens to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { executeTransfer(msg.sender, _to, _value); return true; } /** * @dev Allows another contract to spend tokens on behalf of the `_from` address and send them to the `_to` address. * * @param _from The address which approved you to spend tokens on their behalf. * @param _to The address where you want to send tokens. * @param _value The number of tokens to be sent. * * @return Whether the transfer was successful or not. */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_value <= allowed[_from][msg.sender], "Insufficient allowance"); allowed[_from][msg.sender] = allowed[_from][msg.sender].minus(_value); executeTransfer(_from, _to, _value); return true; } /** * @dev Internal function that this reused by the transfer functions */ function executeTransfer(address _from, address _to, uint256 _value) internal { require(_to != address(0), "Invalid transfer to address zero"); require(_value <= balances[_from], "Insufficient account balance"); balances[_from] = balances[_from].minus(_value); balances[_to] = balances[_to].plus(_value); emit Transfer(_from, _to, _value); } }
/** * @title Standard Token * * @dev The standard abstract implementation of the ERC20 interface. */
NatSpecMultiLine
executeTransfer
function executeTransfer(address _from, address _to, uint256 _value) internal { require(_to != address(0), "Invalid transfer to address zero"); require(_value <= balances[_from], "Insufficient account balance"); balances[_from] = balances[_from].minus(_value); balances[_to] = balances[_to].plus(_value); emit Transfer(_from, _to, _value); }
/** * @dev Internal function that this reused by the transfer functions */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://ce167343b1dcaa8725159d95e78bc955e63e34546b19b99b083b3441ce0618e7
{ "func_code_index": [ 3359, 3759 ] }
101
BananaKong
BananaKong.sol
0xc2b5fac2dd7ae08d04cc398f7cd2de6ad126bc4d
Solidity
IERC20
interface IERC20 { 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.8.9+commit.e5eed63a
Unlicense
ipfs://1f61365e99a29e2491db28fa8c1331548a9efdd3b4a7995173281253c7f748fe
{ "func_code_index": [ 165, 238 ] }
102
BananaKong
BananaKong.sol
0xc2b5fac2dd7ae08d04cc398f7cd2de6ad126bc4d
Solidity
IERC20
interface IERC20 { 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.8.9+commit.e5eed63a
Unlicense
ipfs://1f61365e99a29e2491db28fa8c1331548a9efdd3b4a7995173281253c7f748fe
{ "func_code_index": [ 462, 544 ] }
103
BananaKong
BananaKong.sol
0xc2b5fac2dd7ae08d04cc398f7cd2de6ad126bc4d
Solidity
IERC20
interface IERC20 { 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.8.9+commit.e5eed63a
Unlicense
ipfs://1f61365e99a29e2491db28fa8c1331548a9efdd3b4a7995173281253c7f748fe
{ "func_code_index": [ 823, 911 ] }
104
BananaKong
BananaKong.sol
0xc2b5fac2dd7ae08d04cc398f7cd2de6ad126bc4d
Solidity
IERC20
interface IERC20 { 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.8.9+commit.e5eed63a
Unlicense
ipfs://1f61365e99a29e2491db28fa8c1331548a9efdd3b4a7995173281253c7f748fe
{ "func_code_index": [ 1575, 1654 ] }
105
BananaKong
BananaKong.sol
0xc2b5fac2dd7ae08d04cc398f7cd2de6ad126bc4d
Solidity
IERC20
interface IERC20 { 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.8.9+commit.e5eed63a
Unlicense
ipfs://1f61365e99a29e2491db28fa8c1331548a9efdd3b4a7995173281253c7f748fe
{ "func_code_index": [ 1967, 2069 ] }
106