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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
SpiritSeed | contracts/SpiritSeed.sol | 0x9b07bb421df4e2d52d5997da54a99cff33d5ed6b | Solidity | SpiritSeed | contract SpiritSeed is ERC1155, Ownable, Pausable, ERC1155Burnable
{
using SafeMath for uint256;
//Initialization
string public constant name = "SpiritSeed";
string public constant symbol = "SEED";
string public _BASE_URI = "https://ipfs.io/ipfs/QmXXAE5fQmPkx7Jkeoj1Kq6ANWSqVov5mCzgmAwf8Fmcxs/";
//Token Amounts
uint256 public _SEEDS_MINTED = 0;
uint256 public _MAX_SEEDS = 100;
uint256 public _MAX_SEEDS_PURCHASE = 5;
//Price
uint256 public _SEED_PRICE = 0.55 ether;
//Sale State
bool public _SALE_IS_ACTIVE = false;
bool public _ALLOW_MULTIPLE_PURCHASES = false;
//Mint Mapping
mapping (address => bool) private minted;
//Constructor
constructor() ERC1155("https://ipfs.io/ipfs/QmXXAE5fQmPkx7Jkeoj1Kq6ANWSqVov5mCzgmAwf8Fmcxs/{id}.json") { }
//URI for decoding storage of tokenIDs
function uri(uint256 tokenId) override public view returns (string memory) { return(string(abi.encodePacked(_BASE_URI, Strings.toString(tokenId), ".json"))); }
//Mints SpiritSeed Seeds
function SpiritSeedMint(uint numberOfTokens) public payable
{
require(_SALE_IS_ACTIVE, "Sale must be active to mint Seeds");
require(numberOfTokens <= _MAX_SEEDS_PURCHASE, "Can only mint 5 Seeds at a time");
require(_SEEDS_MINTED.add(numberOfTokens) <= _MAX_SEEDS, "Purchase would exceed max supply of Seeds");
require(_SEED_PRICE.mul(numberOfTokens) <= msg.value, "Ether value sent is not correct. 0.55 ETH Per Seed | 550000000000000000 WEI");
if(!_ALLOW_MULTIPLE_PURCHASES) { require(!minted[msg.sender], "Address Has Already Minted"); }
//Mints Seeds
for(uint i = 0; i < numberOfTokens; i++)
{
if (_SEEDS_MINTED < _MAX_SEEDS)
{
_mint(msg.sender, _SEEDS_MINTED, 1, "");
_SEEDS_MINTED += 1;
}
}
minted[msg.sender] = true;
}
//Conforms to ERC-1155 Standard
function _beforeTokenTransfer(address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) internal whenNotPaused override
{
super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
}
//Batch Transfers Tokens
function __batchTransfer(address[] memory recipients, uint256[] memory tokenIDs, uint256[] memory amounts) public onlyOwner
{
for(uint i=0; i < recipients.length; i++)
{
_safeTransferFrom(msg.sender, recipients[i], tokenIDs[i], amounts[i], "");
}
}
//Reserves Seeds
function __reserveSeeds(uint256 amt) public onlyOwner
{
for(uint i=0; i<amt; i++)
{
_mint(msg.sender, i, 1, "");
_SEEDS_MINTED += 1;
}
}
//Sets Base URI For .json hosting
function __setBaseURI(string memory BASE_URI) public onlyOwner { _BASE_URI = BASE_URI; }
//Sets Max Seeds for future Seed Expansion Packs
function __setMaxSeeds(uint256 MAX_SEEDS) public onlyOwner { _MAX_SEEDS = MAX_SEEDS; }
//Sets Max Seeds Purchaseable by Wallet
function __setMaxSeedsPurchase(uint256 MAX_SEEDS_PURCHASE) public onlyOwner { _MAX_SEEDS_PURCHASE = MAX_SEEDS_PURCHASE; }
//Sets Future Seed Price
function __setSeedPrice(uint256 SEED_PRICE) public onlyOwner { _SEED_PRICE = SEED_PRICE; }
//Flips Allowing Multiple Purchases for future Seed Expansion Packs
function __flip_allowMultiplePurchases() public onlyOwner { _ALLOW_MULTIPLE_PURCHASES = !_ALLOW_MULTIPLE_PURCHASES; }
//Flips Sale State
function __flip_saleState() public onlyOwner { _SALE_IS_ACTIVE = !_SALE_IS_ACTIVE; }
//Withdraws Ether from Contract
function __withdraw() public onlyOwner { payable(msg.sender).transfer(address(this).balance); }
//Pauses Contract
function __pause() public onlyOwner { _pause(); }
//Unpauses Contract
function __unpause() public onlyOwner { _unpause(); }
} | __unpause | function __unpause() public onlyOwner { _unpause(); }
| //Unpauses Contract | LineComment | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
3942,
3999
]
} | 8,307 |
||||
ETHGain | ETHGain.sol | 0x8b866c709bf85303abf9fb9082475c31aaf02ea5 | Solidity | ETHGain | contract ETHGain is Ownable {
event Register(uint indexed _user, uint indexed _referrer, uint indexed _introducer, uint _time);
event SponsorChange(uint indexed _user, uint indexed _referrer, uint indexed _introducer, uint _time);
event Upgrade(uint indexed _user, uint _star, uint _price, uint _time);
event Payment(uint indexed _user, uint indexed _referrer, uint indexed _introducer, uint _star, uint _money, uint _fee, uint _time);
event LostMoney(uint indexed _referrer, uint indexed _referral, uint _star, uint _money, uint _time);
mapping (uint => uint) public STAR_PRICE;
mapping (uint => uint) public STAR_FEE;
uint REFERRER_1_STAR_LIMIT = 3;
struct UserStruct {
bool isExist;
address wallet;
uint referrerID;
uint introducerID;
address[] referral;
mapping (uint => bool) starActive;
}
mapping (uint => UserStruct) public users;
mapping (address => uint) public userList;
uint public currentUserID = 0;
uint public total = 0 ether;
uint public totalFees = 0 ether;
bool public paused = false;
bool public allowSponsorChange = true;
constructor() public {
//Cycle 1
STAR_PRICE[1] = 0.08 ether;
STAR_PRICE[2] = 0.18 ether;
STAR_PRICE[3] = 1.00 ether;
STAR_PRICE[4] = 3.24 ether;
//Cycle 2
STAR_PRICE[5] = 40.00 ether;
STAR_PRICE[6] = 45.00 ether;
STAR_PRICE[7] = 90.00 ether;
STAR_PRICE[8] = 300.00 ether;
//Cycle 3
STAR_PRICE[9] = 585.00 ether;
STAR_PRICE[10] = 900.00 ether;
STAR_PRICE[11] = 1450.00 ether;
STAR_PRICE[12] = 2700.00 ether;
//Cycle 4
STAR_PRICE[13] = 5700.00 ether;
STAR_PRICE[14] = 7700.00 ether;
STAR_PRICE[15] = 12000.00 ether;
STAR_PRICE[16] = 18000.00 ether;
STAR_FEE[1] = 0.02 ether;
STAR_FEE[3] = 0.50 ether;
STAR_FEE[5] = 8.00 ether;
STAR_FEE[7] = 13.00 ether;
STAR_FEE[8] = 25.00 ether;
STAR_FEE[9] = 45.00 ether;
STAR_FEE[13] = 500.00 ether;
UserStruct memory userStruct;
currentUserID++;
userStruct = UserStruct({
isExist : true,
wallet : mainAddress,
referrerID : 0,
introducerID : 0,
referral : new address[](0)
});
users[currentUserID] = userStruct;
userList[mainAddress] = currentUserID;
users[currentUserID].starActive[1] = true;
users[currentUserID].starActive[2] = true;
users[currentUserID].starActive[3] = true;
users[currentUserID].starActive[4] = true;
users[currentUserID].starActive[5] = true;
users[currentUserID].starActive[6] = true;
users[currentUserID].starActive[7] = true;
users[currentUserID].starActive[8] = true;
users[currentUserID].starActive[9] = true;
users[currentUserID].starActive[10] = true;
users[currentUserID].starActive[11] = true;
users[currentUserID].starActive[12] = true;
users[currentUserID].starActive[13] = true;
users[currentUserID].starActive[14] = true;
users[currentUserID].starActive[15] = true;
users[currentUserID].starActive[16] = true;
}
function setMainAddress(address _mainAddress) public onlyOwner {
require(userList[_mainAddress] == 0, 'Address is already in use by another user');
delete userList[mainAddress];
userList[_mainAddress] = uint(1);
mainAddress = _mainAddress;
users[1].wallet = _mainAddress;
}
function setPaused(bool _paused) public onlyOwner {
paused = _paused;
}
function setAllowSponsorChange(bool _allowSponsorChange) public onlyOwner {
allowSponsorChange = _allowSponsorChange;
}
//https://etherconverter.online to Ether
function setStarPrice(uint _star, uint _price) public onlyOwner {
STAR_PRICE[_star] = _price;
}
//https://etherconverter.online to Ether
function setStarFee(uint _star, uint _price) public onlyOwner {
STAR_FEE[_star] = _price;
}
function setCurrentUserID(uint _currentUserID) public onlyOwner {
currentUserID = _currentUserID;
}
//Null address is 0x0000000000000000000000000000000000000000
function setUserData(uint _userID, address _wallet, uint _referrerID, uint _introducerID, address _referral1, address _referral2, address _referral3, uint star) public onlyOwner {
require(_userID > 0, 'Invalid user ID');
require(_wallet != address(0), 'Invalid user wallet');
require(_referrerID > 0, 'Invalid referrer ID');
require(_introducerID > 0, 'Invalid introducer ID');
if(_userID > currentUserID){
currentUserID++;
}
if(users[_userID].isExist){
delete userList[users[_userID].wallet];
delete users[_userID];
}
UserStruct memory userStruct;
userStruct = UserStruct({
isExist : true,
wallet : _wallet,
referrerID : _referrerID,
introducerID : _introducerID,
referral : new address[](0)
});
users[_userID] = userStruct;
userList[_wallet] = _userID;
for(uint a = 1; a <= uint(16); a++){
if(a <= star){
users[_userID].starActive[a] = true;
} else {
users[_userID].starActive[a] = false;
}
}
if(_referral1 != address(0)){
users[_userID].referral.push(_referral1);
}
if(_referral2 != address(0)){
users[_userID].referral.push(_referral2);
}
if(_referral3 != address(0)){
users[_userID].referral.push(_referral3);
}
}
function () external payable {
require(!paused, 'Temporarily not accepting new users and Star upgrades');
uint star;
if(msg.value == STAR_PRICE[1]){
star = 1;
}else if(msg.value == STAR_PRICE[2]){
star = 2;
}else if(msg.value == STAR_PRICE[3]){
star = 3;
}else if(msg.value == STAR_PRICE[4]){
star = 4;
}else if(msg.value == STAR_PRICE[5]){
star = 5;
}else if(msg.value == STAR_PRICE[6]){
star = 6;
}else if(msg.value == STAR_PRICE[7]){
star = 7;
}else if(msg.value == STAR_PRICE[8]){
star = 8;
}else if(msg.value == STAR_PRICE[9]){
star = 9;
}else if(msg.value == STAR_PRICE[10]){
star = 10;
}else if(msg.value == STAR_PRICE[11]){
star = 11;
}else if(msg.value == STAR_PRICE[12]){
star = 12;
}else if(msg.value == STAR_PRICE[13]){
star = 13;
}else if(msg.value == STAR_PRICE[14]){
star = 14;
}else if(msg.value == STAR_PRICE[15]){
star = 15;
}else if(msg.value == STAR_PRICE[16]){
star = 16;
}else {
revert('You have sent incorrect payment amount');
}
if(star == 1){
uint referrerID = 0;
address referrer = bytesToAddress(msg.data);
if (userList[referrer] > 0 && userList[referrer] <= currentUserID){
referrerID = userList[referrer];
} else {
revert('Incorrect referrer');
}
if(users[userList[msg.sender]].isExist){
changeSponsor(referrerID);
} else {
registerUser(referrerID);
}
} else if(users[userList[msg.sender]].isExist){
upgradeUser(star);
} else {
revert("Please buy first star");
}
}
function changeSponsor(uint _referrerID) internal {
require(allowSponsorChange, 'You are already signed up. Sponsor change not allowed');
require(users[userList[msg.sender]].isExist, 'You are not signed up');
require(userList[msg.sender] != _referrerID, 'You cannot sponsor yourself');
require(users[userList[msg.sender]].referrerID != _referrerID && users[userList[msg.sender]].introducerID != _referrerID, 'You are already under this sponsor');
require(_referrerID > 0 && _referrerID <= currentUserID, 'Incorrect referrer ID');
require(msg.value==STAR_PRICE[1], 'You have sent incorrect payment amount');
require(users[userList[msg.sender]].starActive[2] == false, 'Sponsor change is allowed only on Star 1');
uint _introducerID = _referrerID;
uint oldReferrer = users[userList[msg.sender]].referrerID;
if(users[_referrerID].referral.length >= REFERRER_1_STAR_LIMIT)
{
_referrerID = userList[findFreeReferrer(_referrerID)];
}
users[userList[msg.sender]].referrerID = _referrerID;
users[userList[msg.sender]].introducerID = _introducerID;
users[_referrerID].referral.push(msg.sender);
uint arrayLength = SafeMath.sub(uint(users[oldReferrer].referral.length),uint(1));
address[] memory referrals = new address[](arrayLength);
for(uint a = 0; a <= arrayLength; a++){
if(users[oldReferrer].referral[a] != msg.sender){
referrals[a] = users[oldReferrer].referral[a];
}
}
for(uint b = 0; b <= arrayLength; b++){
users[oldReferrer].referral.pop();
}
uint arrayLengthSecond = SafeMath.sub(uint(referrals.length),uint(1));
for(uint c = 0; c <= arrayLengthSecond; c++){
if(referrals[c] != address(0)){
users[oldReferrer].referral.push(referrals[c]);
}
}
upgradePayment(userList[msg.sender], 1);
emit SponsorChange(userList[msg.sender], _referrerID, _introducerID, now);
}
function registerUser(uint _referrerID) internal {
require(!users[userList[msg.sender]].isExist, 'You are already signed up');
require(_referrerID > 0 && _referrerID <= currentUserID, 'Incorrect referrer ID');
require(msg.value==STAR_PRICE[1], 'You have sent incorrect payment amount');
uint _introducerID = _referrerID;
if(users[_referrerID].referral.length >= REFERRER_1_STAR_LIMIT)
{
_referrerID = userList[findFreeReferrer(_referrerID)];
}
UserStruct memory userStruct;
currentUserID++;
userStruct = UserStruct({
isExist : true,
wallet : msg.sender,
referrerID : _referrerID,
introducerID : _introducerID,
referral : new address[](0)
});
users[currentUserID] = userStruct;
userList[msg.sender] = currentUserID;
users[currentUserID].starActive[1] = true;
users[currentUserID].starActive[2] = false;
users[currentUserID].starActive[3] = false;
users[currentUserID].starActive[4] = false;
users[currentUserID].starActive[5] = false;
users[currentUserID].starActive[6] = false;
users[currentUserID].starActive[7] = false;
users[currentUserID].starActive[8] = false;
users[currentUserID].starActive[9] = false;
users[currentUserID].starActive[10] = false;
users[currentUserID].starActive[11] = false;
users[currentUserID].starActive[12] = false;
users[currentUserID].starActive[13] = false;
users[currentUserID].starActive[14] = false;
users[currentUserID].starActive[15] = false;
users[currentUserID].starActive[16] = false;
users[_referrerID].referral.push(msg.sender);
upgradePayment(currentUserID, 1);
emit Register(currentUserID, _referrerID, _introducerID, now);
}
function upgradeUser(uint _star) internal {
require(users[userList[msg.sender]].isExist, 'You are not signed up yet');
require( _star >= 2 && _star <= 16, 'Incorrect star');
require(msg.value==STAR_PRICE[_star], 'You have sent incorrect payment amount');
require(users[userList[msg.sender]].starActive[_star] == false, 'You have already activated this star');
uint previousStar = SafeMath.sub(_star,uint(1));
require(users[userList[msg.sender]].starActive[previousStar] == true, 'Buy the previous star first');
users[userList[msg.sender]].starActive[_star] = true;
upgradePayment(userList[msg.sender], _star);
emit Upgrade(userList[msg.sender], _star, STAR_PRICE[_star], now);
}
function upgradePayment(uint _user, uint _star) internal {
address referrer;
address introducer;
uint referrerFinal;
uint referrer1;
uint referrer2;
uint referrer3;
uint money;
if(_star == 1){
referrerFinal = users[_user].introducerID;
}else if(_star == 5 || _star == 9 || _star == 13){
referrer1 = users[_user].referrerID;
referrerFinal = users[referrer1].referrerID;
} else if(_star == 2 || _star == 6 || _star == 10 || _star == 14){
referrer1 = users[_user].referrerID;
referrerFinal = users[referrer1].referrerID;
} else if(_star == 3 || _star == 7 || _star == 11 || _star == 15){
referrer1 = users[_user].referrerID;
referrer2 = users[referrer1].referrerID;
referrerFinal = users[referrer2].referrerID;
} else if(_star == 4 || _star == 8 || _star == 12 || _star == 16){
referrer1 = users[_user].referrerID;
referrer2 = users[referrer1].referrerID;
referrer3 = users[referrer2].referrerID;
referrerFinal = users[referrer3].referrerID;
}
if(!users[referrerFinal].isExist || users[referrerFinal].starActive[_star] == false){
referrer = mainAddress;
} else {
referrer = users[referrerFinal].wallet;
}
money = STAR_PRICE[_star];
if(STAR_FEE[_star] > 0){
bool result;
result = address(uint160(mainAddress)).send(STAR_FEE[_star]);
money = SafeMath.sub(money,STAR_FEE[_star]);
totalFees = SafeMath.add(totalFees,money);
}
total = SafeMath.add(total,money);
if(_star>=3){
if(!users[users[_user].introducerID].isExist){
introducer = mainAddress;
} else {
if(users[referrer1].starActive[_star] == false){
introducer = mainAddress;
} else {
introducer = users[referrer1].wallet;
}
}
money = SafeMath.div(money,2);
bool result_one;
result_one = address(uint160(referrer)).send(money);
bool result_two;
result_two = address(uint160(introducer)).send(money);
} else {
bool result_three;
result_three = address(uint160(referrer)).send(money);
}
if(users[referrerFinal].starActive[_star] == false ){
emit LostMoney(referrerFinal, userList[msg.sender], _star, money, now);
}
emit Payment(userList[msg.sender], userList[referrer], userList[introducer], _star, money, STAR_FEE[_star], now);
}
function findFreeReferrer(uint _user) public view returns(address) {
require(users[_user].isExist, 'User does not exist');
if(users[_user].referral.length < REFERRER_1_STAR_LIMIT){
return users[_user].wallet;
}
address[] memory referrals = new address[](363);
referrals[0] = users[_user].referral[0];
referrals[1] = users[_user].referral[1];
referrals[2] = users[_user].referral[2];
address freeReferrer;
bool noFreeReferrer = true;
for(uint i = 0; i < 363; i++){
if(users[userList[referrals[i]]].referral.length == REFERRER_1_STAR_LIMIT){
if(i < 120){
referrals[(i+1)*3] = users[userList[referrals[i]]].referral[0];
referrals[(i+1)*3+1] = users[userList[referrals[i]]].referral[1];
referrals[(i+1)*3+2] = users[userList[referrals[i]]].referral[2];
}
} else {
noFreeReferrer = false;
freeReferrer = referrals[i];
break;
}
}
require(!noFreeReferrer, 'Free referrer not found');
return freeReferrer;
}
function viewUserReferrals(uint _user) public view returns(address[] memory) {
return users[_user].referral;
}
function viewUserStarActive(uint _user, uint _star) public view returns(bool) {
return users[_user].starActive[_star];
}
function bytesToAddress(bytes memory bys) private pure returns (address addr) {
assembly {
addr := mload(add(bys, 20))
}
}
} | setStarPrice | function setStarPrice(uint _star, uint _price) public onlyOwner {
STAR_PRICE[_star] = _price;
}
| //https://etherconverter.online to Ether | LineComment | v0.5.7+commit.6da8b019 | OSL-3.0 | bzzr://40f84d12cfb377c283e85f230fb38399399ea3106145db3ad1cc9677ddb95bec | {
"func_code_index": [
4043,
4159
]
} | 8,308 |
||
ETHGain | ETHGain.sol | 0x8b866c709bf85303abf9fb9082475c31aaf02ea5 | Solidity | ETHGain | contract ETHGain is Ownable {
event Register(uint indexed _user, uint indexed _referrer, uint indexed _introducer, uint _time);
event SponsorChange(uint indexed _user, uint indexed _referrer, uint indexed _introducer, uint _time);
event Upgrade(uint indexed _user, uint _star, uint _price, uint _time);
event Payment(uint indexed _user, uint indexed _referrer, uint indexed _introducer, uint _star, uint _money, uint _fee, uint _time);
event LostMoney(uint indexed _referrer, uint indexed _referral, uint _star, uint _money, uint _time);
mapping (uint => uint) public STAR_PRICE;
mapping (uint => uint) public STAR_FEE;
uint REFERRER_1_STAR_LIMIT = 3;
struct UserStruct {
bool isExist;
address wallet;
uint referrerID;
uint introducerID;
address[] referral;
mapping (uint => bool) starActive;
}
mapping (uint => UserStruct) public users;
mapping (address => uint) public userList;
uint public currentUserID = 0;
uint public total = 0 ether;
uint public totalFees = 0 ether;
bool public paused = false;
bool public allowSponsorChange = true;
constructor() public {
//Cycle 1
STAR_PRICE[1] = 0.08 ether;
STAR_PRICE[2] = 0.18 ether;
STAR_PRICE[3] = 1.00 ether;
STAR_PRICE[4] = 3.24 ether;
//Cycle 2
STAR_PRICE[5] = 40.00 ether;
STAR_PRICE[6] = 45.00 ether;
STAR_PRICE[7] = 90.00 ether;
STAR_PRICE[8] = 300.00 ether;
//Cycle 3
STAR_PRICE[9] = 585.00 ether;
STAR_PRICE[10] = 900.00 ether;
STAR_PRICE[11] = 1450.00 ether;
STAR_PRICE[12] = 2700.00 ether;
//Cycle 4
STAR_PRICE[13] = 5700.00 ether;
STAR_PRICE[14] = 7700.00 ether;
STAR_PRICE[15] = 12000.00 ether;
STAR_PRICE[16] = 18000.00 ether;
STAR_FEE[1] = 0.02 ether;
STAR_FEE[3] = 0.50 ether;
STAR_FEE[5] = 8.00 ether;
STAR_FEE[7] = 13.00 ether;
STAR_FEE[8] = 25.00 ether;
STAR_FEE[9] = 45.00 ether;
STAR_FEE[13] = 500.00 ether;
UserStruct memory userStruct;
currentUserID++;
userStruct = UserStruct({
isExist : true,
wallet : mainAddress,
referrerID : 0,
introducerID : 0,
referral : new address[](0)
});
users[currentUserID] = userStruct;
userList[mainAddress] = currentUserID;
users[currentUserID].starActive[1] = true;
users[currentUserID].starActive[2] = true;
users[currentUserID].starActive[3] = true;
users[currentUserID].starActive[4] = true;
users[currentUserID].starActive[5] = true;
users[currentUserID].starActive[6] = true;
users[currentUserID].starActive[7] = true;
users[currentUserID].starActive[8] = true;
users[currentUserID].starActive[9] = true;
users[currentUserID].starActive[10] = true;
users[currentUserID].starActive[11] = true;
users[currentUserID].starActive[12] = true;
users[currentUserID].starActive[13] = true;
users[currentUserID].starActive[14] = true;
users[currentUserID].starActive[15] = true;
users[currentUserID].starActive[16] = true;
}
function setMainAddress(address _mainAddress) public onlyOwner {
require(userList[_mainAddress] == 0, 'Address is already in use by another user');
delete userList[mainAddress];
userList[_mainAddress] = uint(1);
mainAddress = _mainAddress;
users[1].wallet = _mainAddress;
}
function setPaused(bool _paused) public onlyOwner {
paused = _paused;
}
function setAllowSponsorChange(bool _allowSponsorChange) public onlyOwner {
allowSponsorChange = _allowSponsorChange;
}
//https://etherconverter.online to Ether
function setStarPrice(uint _star, uint _price) public onlyOwner {
STAR_PRICE[_star] = _price;
}
//https://etherconverter.online to Ether
function setStarFee(uint _star, uint _price) public onlyOwner {
STAR_FEE[_star] = _price;
}
function setCurrentUserID(uint _currentUserID) public onlyOwner {
currentUserID = _currentUserID;
}
//Null address is 0x0000000000000000000000000000000000000000
function setUserData(uint _userID, address _wallet, uint _referrerID, uint _introducerID, address _referral1, address _referral2, address _referral3, uint star) public onlyOwner {
require(_userID > 0, 'Invalid user ID');
require(_wallet != address(0), 'Invalid user wallet');
require(_referrerID > 0, 'Invalid referrer ID');
require(_introducerID > 0, 'Invalid introducer ID');
if(_userID > currentUserID){
currentUserID++;
}
if(users[_userID].isExist){
delete userList[users[_userID].wallet];
delete users[_userID];
}
UserStruct memory userStruct;
userStruct = UserStruct({
isExist : true,
wallet : _wallet,
referrerID : _referrerID,
introducerID : _introducerID,
referral : new address[](0)
});
users[_userID] = userStruct;
userList[_wallet] = _userID;
for(uint a = 1; a <= uint(16); a++){
if(a <= star){
users[_userID].starActive[a] = true;
} else {
users[_userID].starActive[a] = false;
}
}
if(_referral1 != address(0)){
users[_userID].referral.push(_referral1);
}
if(_referral2 != address(0)){
users[_userID].referral.push(_referral2);
}
if(_referral3 != address(0)){
users[_userID].referral.push(_referral3);
}
}
function () external payable {
require(!paused, 'Temporarily not accepting new users and Star upgrades');
uint star;
if(msg.value == STAR_PRICE[1]){
star = 1;
}else if(msg.value == STAR_PRICE[2]){
star = 2;
}else if(msg.value == STAR_PRICE[3]){
star = 3;
}else if(msg.value == STAR_PRICE[4]){
star = 4;
}else if(msg.value == STAR_PRICE[5]){
star = 5;
}else if(msg.value == STAR_PRICE[6]){
star = 6;
}else if(msg.value == STAR_PRICE[7]){
star = 7;
}else if(msg.value == STAR_PRICE[8]){
star = 8;
}else if(msg.value == STAR_PRICE[9]){
star = 9;
}else if(msg.value == STAR_PRICE[10]){
star = 10;
}else if(msg.value == STAR_PRICE[11]){
star = 11;
}else if(msg.value == STAR_PRICE[12]){
star = 12;
}else if(msg.value == STAR_PRICE[13]){
star = 13;
}else if(msg.value == STAR_PRICE[14]){
star = 14;
}else if(msg.value == STAR_PRICE[15]){
star = 15;
}else if(msg.value == STAR_PRICE[16]){
star = 16;
}else {
revert('You have sent incorrect payment amount');
}
if(star == 1){
uint referrerID = 0;
address referrer = bytesToAddress(msg.data);
if (userList[referrer] > 0 && userList[referrer] <= currentUserID){
referrerID = userList[referrer];
} else {
revert('Incorrect referrer');
}
if(users[userList[msg.sender]].isExist){
changeSponsor(referrerID);
} else {
registerUser(referrerID);
}
} else if(users[userList[msg.sender]].isExist){
upgradeUser(star);
} else {
revert("Please buy first star");
}
}
function changeSponsor(uint _referrerID) internal {
require(allowSponsorChange, 'You are already signed up. Sponsor change not allowed');
require(users[userList[msg.sender]].isExist, 'You are not signed up');
require(userList[msg.sender] != _referrerID, 'You cannot sponsor yourself');
require(users[userList[msg.sender]].referrerID != _referrerID && users[userList[msg.sender]].introducerID != _referrerID, 'You are already under this sponsor');
require(_referrerID > 0 && _referrerID <= currentUserID, 'Incorrect referrer ID');
require(msg.value==STAR_PRICE[1], 'You have sent incorrect payment amount');
require(users[userList[msg.sender]].starActive[2] == false, 'Sponsor change is allowed only on Star 1');
uint _introducerID = _referrerID;
uint oldReferrer = users[userList[msg.sender]].referrerID;
if(users[_referrerID].referral.length >= REFERRER_1_STAR_LIMIT)
{
_referrerID = userList[findFreeReferrer(_referrerID)];
}
users[userList[msg.sender]].referrerID = _referrerID;
users[userList[msg.sender]].introducerID = _introducerID;
users[_referrerID].referral.push(msg.sender);
uint arrayLength = SafeMath.sub(uint(users[oldReferrer].referral.length),uint(1));
address[] memory referrals = new address[](arrayLength);
for(uint a = 0; a <= arrayLength; a++){
if(users[oldReferrer].referral[a] != msg.sender){
referrals[a] = users[oldReferrer].referral[a];
}
}
for(uint b = 0; b <= arrayLength; b++){
users[oldReferrer].referral.pop();
}
uint arrayLengthSecond = SafeMath.sub(uint(referrals.length),uint(1));
for(uint c = 0; c <= arrayLengthSecond; c++){
if(referrals[c] != address(0)){
users[oldReferrer].referral.push(referrals[c]);
}
}
upgradePayment(userList[msg.sender], 1);
emit SponsorChange(userList[msg.sender], _referrerID, _introducerID, now);
}
function registerUser(uint _referrerID) internal {
require(!users[userList[msg.sender]].isExist, 'You are already signed up');
require(_referrerID > 0 && _referrerID <= currentUserID, 'Incorrect referrer ID');
require(msg.value==STAR_PRICE[1], 'You have sent incorrect payment amount');
uint _introducerID = _referrerID;
if(users[_referrerID].referral.length >= REFERRER_1_STAR_LIMIT)
{
_referrerID = userList[findFreeReferrer(_referrerID)];
}
UserStruct memory userStruct;
currentUserID++;
userStruct = UserStruct({
isExist : true,
wallet : msg.sender,
referrerID : _referrerID,
introducerID : _introducerID,
referral : new address[](0)
});
users[currentUserID] = userStruct;
userList[msg.sender] = currentUserID;
users[currentUserID].starActive[1] = true;
users[currentUserID].starActive[2] = false;
users[currentUserID].starActive[3] = false;
users[currentUserID].starActive[4] = false;
users[currentUserID].starActive[5] = false;
users[currentUserID].starActive[6] = false;
users[currentUserID].starActive[7] = false;
users[currentUserID].starActive[8] = false;
users[currentUserID].starActive[9] = false;
users[currentUserID].starActive[10] = false;
users[currentUserID].starActive[11] = false;
users[currentUserID].starActive[12] = false;
users[currentUserID].starActive[13] = false;
users[currentUserID].starActive[14] = false;
users[currentUserID].starActive[15] = false;
users[currentUserID].starActive[16] = false;
users[_referrerID].referral.push(msg.sender);
upgradePayment(currentUserID, 1);
emit Register(currentUserID, _referrerID, _introducerID, now);
}
function upgradeUser(uint _star) internal {
require(users[userList[msg.sender]].isExist, 'You are not signed up yet');
require( _star >= 2 && _star <= 16, 'Incorrect star');
require(msg.value==STAR_PRICE[_star], 'You have sent incorrect payment amount');
require(users[userList[msg.sender]].starActive[_star] == false, 'You have already activated this star');
uint previousStar = SafeMath.sub(_star,uint(1));
require(users[userList[msg.sender]].starActive[previousStar] == true, 'Buy the previous star first');
users[userList[msg.sender]].starActive[_star] = true;
upgradePayment(userList[msg.sender], _star);
emit Upgrade(userList[msg.sender], _star, STAR_PRICE[_star], now);
}
function upgradePayment(uint _user, uint _star) internal {
address referrer;
address introducer;
uint referrerFinal;
uint referrer1;
uint referrer2;
uint referrer3;
uint money;
if(_star == 1){
referrerFinal = users[_user].introducerID;
}else if(_star == 5 || _star == 9 || _star == 13){
referrer1 = users[_user].referrerID;
referrerFinal = users[referrer1].referrerID;
} else if(_star == 2 || _star == 6 || _star == 10 || _star == 14){
referrer1 = users[_user].referrerID;
referrerFinal = users[referrer1].referrerID;
} else if(_star == 3 || _star == 7 || _star == 11 || _star == 15){
referrer1 = users[_user].referrerID;
referrer2 = users[referrer1].referrerID;
referrerFinal = users[referrer2].referrerID;
} else if(_star == 4 || _star == 8 || _star == 12 || _star == 16){
referrer1 = users[_user].referrerID;
referrer2 = users[referrer1].referrerID;
referrer3 = users[referrer2].referrerID;
referrerFinal = users[referrer3].referrerID;
}
if(!users[referrerFinal].isExist || users[referrerFinal].starActive[_star] == false){
referrer = mainAddress;
} else {
referrer = users[referrerFinal].wallet;
}
money = STAR_PRICE[_star];
if(STAR_FEE[_star] > 0){
bool result;
result = address(uint160(mainAddress)).send(STAR_FEE[_star]);
money = SafeMath.sub(money,STAR_FEE[_star]);
totalFees = SafeMath.add(totalFees,money);
}
total = SafeMath.add(total,money);
if(_star>=3){
if(!users[users[_user].introducerID].isExist){
introducer = mainAddress;
} else {
if(users[referrer1].starActive[_star] == false){
introducer = mainAddress;
} else {
introducer = users[referrer1].wallet;
}
}
money = SafeMath.div(money,2);
bool result_one;
result_one = address(uint160(referrer)).send(money);
bool result_two;
result_two = address(uint160(introducer)).send(money);
} else {
bool result_three;
result_three = address(uint160(referrer)).send(money);
}
if(users[referrerFinal].starActive[_star] == false ){
emit LostMoney(referrerFinal, userList[msg.sender], _star, money, now);
}
emit Payment(userList[msg.sender], userList[referrer], userList[introducer], _star, money, STAR_FEE[_star], now);
}
function findFreeReferrer(uint _user) public view returns(address) {
require(users[_user].isExist, 'User does not exist');
if(users[_user].referral.length < REFERRER_1_STAR_LIMIT){
return users[_user].wallet;
}
address[] memory referrals = new address[](363);
referrals[0] = users[_user].referral[0];
referrals[1] = users[_user].referral[1];
referrals[2] = users[_user].referral[2];
address freeReferrer;
bool noFreeReferrer = true;
for(uint i = 0; i < 363; i++){
if(users[userList[referrals[i]]].referral.length == REFERRER_1_STAR_LIMIT){
if(i < 120){
referrals[(i+1)*3] = users[userList[referrals[i]]].referral[0];
referrals[(i+1)*3+1] = users[userList[referrals[i]]].referral[1];
referrals[(i+1)*3+2] = users[userList[referrals[i]]].referral[2];
}
} else {
noFreeReferrer = false;
freeReferrer = referrals[i];
break;
}
}
require(!noFreeReferrer, 'Free referrer not found');
return freeReferrer;
}
function viewUserReferrals(uint _user) public view returns(address[] memory) {
return users[_user].referral;
}
function viewUserStarActive(uint _user, uint _star) public view returns(bool) {
return users[_user].starActive[_star];
}
function bytesToAddress(bytes memory bys) private pure returns (address addr) {
assembly {
addr := mload(add(bys, 20))
}
}
} | setStarFee | function setStarFee(uint _star, uint _price) public onlyOwner {
STAR_FEE[_star] = _price;
}
| //https://etherconverter.online to Ether | LineComment | v0.5.7+commit.6da8b019 | OSL-3.0 | bzzr://40f84d12cfb377c283e85f230fb38399399ea3106145db3ad1cc9677ddb95bec | {
"func_code_index": [
4208,
4320
]
} | 8,309 |
||
ETHGain | ETHGain.sol | 0x8b866c709bf85303abf9fb9082475c31aaf02ea5 | Solidity | ETHGain | contract ETHGain is Ownable {
event Register(uint indexed _user, uint indexed _referrer, uint indexed _introducer, uint _time);
event SponsorChange(uint indexed _user, uint indexed _referrer, uint indexed _introducer, uint _time);
event Upgrade(uint indexed _user, uint _star, uint _price, uint _time);
event Payment(uint indexed _user, uint indexed _referrer, uint indexed _introducer, uint _star, uint _money, uint _fee, uint _time);
event LostMoney(uint indexed _referrer, uint indexed _referral, uint _star, uint _money, uint _time);
mapping (uint => uint) public STAR_PRICE;
mapping (uint => uint) public STAR_FEE;
uint REFERRER_1_STAR_LIMIT = 3;
struct UserStruct {
bool isExist;
address wallet;
uint referrerID;
uint introducerID;
address[] referral;
mapping (uint => bool) starActive;
}
mapping (uint => UserStruct) public users;
mapping (address => uint) public userList;
uint public currentUserID = 0;
uint public total = 0 ether;
uint public totalFees = 0 ether;
bool public paused = false;
bool public allowSponsorChange = true;
constructor() public {
//Cycle 1
STAR_PRICE[1] = 0.08 ether;
STAR_PRICE[2] = 0.18 ether;
STAR_PRICE[3] = 1.00 ether;
STAR_PRICE[4] = 3.24 ether;
//Cycle 2
STAR_PRICE[5] = 40.00 ether;
STAR_PRICE[6] = 45.00 ether;
STAR_PRICE[7] = 90.00 ether;
STAR_PRICE[8] = 300.00 ether;
//Cycle 3
STAR_PRICE[9] = 585.00 ether;
STAR_PRICE[10] = 900.00 ether;
STAR_PRICE[11] = 1450.00 ether;
STAR_PRICE[12] = 2700.00 ether;
//Cycle 4
STAR_PRICE[13] = 5700.00 ether;
STAR_PRICE[14] = 7700.00 ether;
STAR_PRICE[15] = 12000.00 ether;
STAR_PRICE[16] = 18000.00 ether;
STAR_FEE[1] = 0.02 ether;
STAR_FEE[3] = 0.50 ether;
STAR_FEE[5] = 8.00 ether;
STAR_FEE[7] = 13.00 ether;
STAR_FEE[8] = 25.00 ether;
STAR_FEE[9] = 45.00 ether;
STAR_FEE[13] = 500.00 ether;
UserStruct memory userStruct;
currentUserID++;
userStruct = UserStruct({
isExist : true,
wallet : mainAddress,
referrerID : 0,
introducerID : 0,
referral : new address[](0)
});
users[currentUserID] = userStruct;
userList[mainAddress] = currentUserID;
users[currentUserID].starActive[1] = true;
users[currentUserID].starActive[2] = true;
users[currentUserID].starActive[3] = true;
users[currentUserID].starActive[4] = true;
users[currentUserID].starActive[5] = true;
users[currentUserID].starActive[6] = true;
users[currentUserID].starActive[7] = true;
users[currentUserID].starActive[8] = true;
users[currentUserID].starActive[9] = true;
users[currentUserID].starActive[10] = true;
users[currentUserID].starActive[11] = true;
users[currentUserID].starActive[12] = true;
users[currentUserID].starActive[13] = true;
users[currentUserID].starActive[14] = true;
users[currentUserID].starActive[15] = true;
users[currentUserID].starActive[16] = true;
}
function setMainAddress(address _mainAddress) public onlyOwner {
require(userList[_mainAddress] == 0, 'Address is already in use by another user');
delete userList[mainAddress];
userList[_mainAddress] = uint(1);
mainAddress = _mainAddress;
users[1].wallet = _mainAddress;
}
function setPaused(bool _paused) public onlyOwner {
paused = _paused;
}
function setAllowSponsorChange(bool _allowSponsorChange) public onlyOwner {
allowSponsorChange = _allowSponsorChange;
}
//https://etherconverter.online to Ether
function setStarPrice(uint _star, uint _price) public onlyOwner {
STAR_PRICE[_star] = _price;
}
//https://etherconverter.online to Ether
function setStarFee(uint _star, uint _price) public onlyOwner {
STAR_FEE[_star] = _price;
}
function setCurrentUserID(uint _currentUserID) public onlyOwner {
currentUserID = _currentUserID;
}
//Null address is 0x0000000000000000000000000000000000000000
function setUserData(uint _userID, address _wallet, uint _referrerID, uint _introducerID, address _referral1, address _referral2, address _referral3, uint star) public onlyOwner {
require(_userID > 0, 'Invalid user ID');
require(_wallet != address(0), 'Invalid user wallet');
require(_referrerID > 0, 'Invalid referrer ID');
require(_introducerID > 0, 'Invalid introducer ID');
if(_userID > currentUserID){
currentUserID++;
}
if(users[_userID].isExist){
delete userList[users[_userID].wallet];
delete users[_userID];
}
UserStruct memory userStruct;
userStruct = UserStruct({
isExist : true,
wallet : _wallet,
referrerID : _referrerID,
introducerID : _introducerID,
referral : new address[](0)
});
users[_userID] = userStruct;
userList[_wallet] = _userID;
for(uint a = 1; a <= uint(16); a++){
if(a <= star){
users[_userID].starActive[a] = true;
} else {
users[_userID].starActive[a] = false;
}
}
if(_referral1 != address(0)){
users[_userID].referral.push(_referral1);
}
if(_referral2 != address(0)){
users[_userID].referral.push(_referral2);
}
if(_referral3 != address(0)){
users[_userID].referral.push(_referral3);
}
}
function () external payable {
require(!paused, 'Temporarily not accepting new users and Star upgrades');
uint star;
if(msg.value == STAR_PRICE[1]){
star = 1;
}else if(msg.value == STAR_PRICE[2]){
star = 2;
}else if(msg.value == STAR_PRICE[3]){
star = 3;
}else if(msg.value == STAR_PRICE[4]){
star = 4;
}else if(msg.value == STAR_PRICE[5]){
star = 5;
}else if(msg.value == STAR_PRICE[6]){
star = 6;
}else if(msg.value == STAR_PRICE[7]){
star = 7;
}else if(msg.value == STAR_PRICE[8]){
star = 8;
}else if(msg.value == STAR_PRICE[9]){
star = 9;
}else if(msg.value == STAR_PRICE[10]){
star = 10;
}else if(msg.value == STAR_PRICE[11]){
star = 11;
}else if(msg.value == STAR_PRICE[12]){
star = 12;
}else if(msg.value == STAR_PRICE[13]){
star = 13;
}else if(msg.value == STAR_PRICE[14]){
star = 14;
}else if(msg.value == STAR_PRICE[15]){
star = 15;
}else if(msg.value == STAR_PRICE[16]){
star = 16;
}else {
revert('You have sent incorrect payment amount');
}
if(star == 1){
uint referrerID = 0;
address referrer = bytesToAddress(msg.data);
if (userList[referrer] > 0 && userList[referrer] <= currentUserID){
referrerID = userList[referrer];
} else {
revert('Incorrect referrer');
}
if(users[userList[msg.sender]].isExist){
changeSponsor(referrerID);
} else {
registerUser(referrerID);
}
} else if(users[userList[msg.sender]].isExist){
upgradeUser(star);
} else {
revert("Please buy first star");
}
}
function changeSponsor(uint _referrerID) internal {
require(allowSponsorChange, 'You are already signed up. Sponsor change not allowed');
require(users[userList[msg.sender]].isExist, 'You are not signed up');
require(userList[msg.sender] != _referrerID, 'You cannot sponsor yourself');
require(users[userList[msg.sender]].referrerID != _referrerID && users[userList[msg.sender]].introducerID != _referrerID, 'You are already under this sponsor');
require(_referrerID > 0 && _referrerID <= currentUserID, 'Incorrect referrer ID');
require(msg.value==STAR_PRICE[1], 'You have sent incorrect payment amount');
require(users[userList[msg.sender]].starActive[2] == false, 'Sponsor change is allowed only on Star 1');
uint _introducerID = _referrerID;
uint oldReferrer = users[userList[msg.sender]].referrerID;
if(users[_referrerID].referral.length >= REFERRER_1_STAR_LIMIT)
{
_referrerID = userList[findFreeReferrer(_referrerID)];
}
users[userList[msg.sender]].referrerID = _referrerID;
users[userList[msg.sender]].introducerID = _introducerID;
users[_referrerID].referral.push(msg.sender);
uint arrayLength = SafeMath.sub(uint(users[oldReferrer].referral.length),uint(1));
address[] memory referrals = new address[](arrayLength);
for(uint a = 0; a <= arrayLength; a++){
if(users[oldReferrer].referral[a] != msg.sender){
referrals[a] = users[oldReferrer].referral[a];
}
}
for(uint b = 0; b <= arrayLength; b++){
users[oldReferrer].referral.pop();
}
uint arrayLengthSecond = SafeMath.sub(uint(referrals.length),uint(1));
for(uint c = 0; c <= arrayLengthSecond; c++){
if(referrals[c] != address(0)){
users[oldReferrer].referral.push(referrals[c]);
}
}
upgradePayment(userList[msg.sender], 1);
emit SponsorChange(userList[msg.sender], _referrerID, _introducerID, now);
}
function registerUser(uint _referrerID) internal {
require(!users[userList[msg.sender]].isExist, 'You are already signed up');
require(_referrerID > 0 && _referrerID <= currentUserID, 'Incorrect referrer ID');
require(msg.value==STAR_PRICE[1], 'You have sent incorrect payment amount');
uint _introducerID = _referrerID;
if(users[_referrerID].referral.length >= REFERRER_1_STAR_LIMIT)
{
_referrerID = userList[findFreeReferrer(_referrerID)];
}
UserStruct memory userStruct;
currentUserID++;
userStruct = UserStruct({
isExist : true,
wallet : msg.sender,
referrerID : _referrerID,
introducerID : _introducerID,
referral : new address[](0)
});
users[currentUserID] = userStruct;
userList[msg.sender] = currentUserID;
users[currentUserID].starActive[1] = true;
users[currentUserID].starActive[2] = false;
users[currentUserID].starActive[3] = false;
users[currentUserID].starActive[4] = false;
users[currentUserID].starActive[5] = false;
users[currentUserID].starActive[6] = false;
users[currentUserID].starActive[7] = false;
users[currentUserID].starActive[8] = false;
users[currentUserID].starActive[9] = false;
users[currentUserID].starActive[10] = false;
users[currentUserID].starActive[11] = false;
users[currentUserID].starActive[12] = false;
users[currentUserID].starActive[13] = false;
users[currentUserID].starActive[14] = false;
users[currentUserID].starActive[15] = false;
users[currentUserID].starActive[16] = false;
users[_referrerID].referral.push(msg.sender);
upgradePayment(currentUserID, 1);
emit Register(currentUserID, _referrerID, _introducerID, now);
}
function upgradeUser(uint _star) internal {
require(users[userList[msg.sender]].isExist, 'You are not signed up yet');
require( _star >= 2 && _star <= 16, 'Incorrect star');
require(msg.value==STAR_PRICE[_star], 'You have sent incorrect payment amount');
require(users[userList[msg.sender]].starActive[_star] == false, 'You have already activated this star');
uint previousStar = SafeMath.sub(_star,uint(1));
require(users[userList[msg.sender]].starActive[previousStar] == true, 'Buy the previous star first');
users[userList[msg.sender]].starActive[_star] = true;
upgradePayment(userList[msg.sender], _star);
emit Upgrade(userList[msg.sender], _star, STAR_PRICE[_star], now);
}
function upgradePayment(uint _user, uint _star) internal {
address referrer;
address introducer;
uint referrerFinal;
uint referrer1;
uint referrer2;
uint referrer3;
uint money;
if(_star == 1){
referrerFinal = users[_user].introducerID;
}else if(_star == 5 || _star == 9 || _star == 13){
referrer1 = users[_user].referrerID;
referrerFinal = users[referrer1].referrerID;
} else if(_star == 2 || _star == 6 || _star == 10 || _star == 14){
referrer1 = users[_user].referrerID;
referrerFinal = users[referrer1].referrerID;
} else if(_star == 3 || _star == 7 || _star == 11 || _star == 15){
referrer1 = users[_user].referrerID;
referrer2 = users[referrer1].referrerID;
referrerFinal = users[referrer2].referrerID;
} else if(_star == 4 || _star == 8 || _star == 12 || _star == 16){
referrer1 = users[_user].referrerID;
referrer2 = users[referrer1].referrerID;
referrer3 = users[referrer2].referrerID;
referrerFinal = users[referrer3].referrerID;
}
if(!users[referrerFinal].isExist || users[referrerFinal].starActive[_star] == false){
referrer = mainAddress;
} else {
referrer = users[referrerFinal].wallet;
}
money = STAR_PRICE[_star];
if(STAR_FEE[_star] > 0){
bool result;
result = address(uint160(mainAddress)).send(STAR_FEE[_star]);
money = SafeMath.sub(money,STAR_FEE[_star]);
totalFees = SafeMath.add(totalFees,money);
}
total = SafeMath.add(total,money);
if(_star>=3){
if(!users[users[_user].introducerID].isExist){
introducer = mainAddress;
} else {
if(users[referrer1].starActive[_star] == false){
introducer = mainAddress;
} else {
introducer = users[referrer1].wallet;
}
}
money = SafeMath.div(money,2);
bool result_one;
result_one = address(uint160(referrer)).send(money);
bool result_two;
result_two = address(uint160(introducer)).send(money);
} else {
bool result_three;
result_three = address(uint160(referrer)).send(money);
}
if(users[referrerFinal].starActive[_star] == false ){
emit LostMoney(referrerFinal, userList[msg.sender], _star, money, now);
}
emit Payment(userList[msg.sender], userList[referrer], userList[introducer], _star, money, STAR_FEE[_star], now);
}
function findFreeReferrer(uint _user) public view returns(address) {
require(users[_user].isExist, 'User does not exist');
if(users[_user].referral.length < REFERRER_1_STAR_LIMIT){
return users[_user].wallet;
}
address[] memory referrals = new address[](363);
referrals[0] = users[_user].referral[0];
referrals[1] = users[_user].referral[1];
referrals[2] = users[_user].referral[2];
address freeReferrer;
bool noFreeReferrer = true;
for(uint i = 0; i < 363; i++){
if(users[userList[referrals[i]]].referral.length == REFERRER_1_STAR_LIMIT){
if(i < 120){
referrals[(i+1)*3] = users[userList[referrals[i]]].referral[0];
referrals[(i+1)*3+1] = users[userList[referrals[i]]].referral[1];
referrals[(i+1)*3+2] = users[userList[referrals[i]]].referral[2];
}
} else {
noFreeReferrer = false;
freeReferrer = referrals[i];
break;
}
}
require(!noFreeReferrer, 'Free referrer not found');
return freeReferrer;
}
function viewUserReferrals(uint _user) public view returns(address[] memory) {
return users[_user].referral;
}
function viewUserStarActive(uint _user, uint _star) public view returns(bool) {
return users[_user].starActive[_star];
}
function bytesToAddress(bytes memory bys) private pure returns (address addr) {
assembly {
addr := mload(add(bys, 20))
}
}
} | setUserData | function setUserData(uint _userID, address _wallet, uint _referrerID, uint _introducerID, address _referral1, address _referral2, address _referral3, uint star) public onlyOwner {
require(_userID > 0, 'Invalid user ID');
require(_wallet != address(0), 'Invalid user wallet');
require(_referrerID > 0, 'Invalid referrer ID');
require(_introducerID > 0, 'Invalid introducer ID');
if(_userID > currentUserID){
currentUserID++;
}
if(users[_userID].isExist){
delete userList[users[_userID].wallet];
delete users[_userID];
}
UserStruct memory userStruct;
userStruct = UserStruct({
isExist : true,
wallet : _wallet,
referrerID : _referrerID,
introducerID : _introducerID,
referral : new address[](0)
});
users[_userID] = userStruct;
userList[_wallet] = _userID;
for(uint a = 1; a <= uint(16); a++){
if(a <= star){
users[_userID].starActive[a] = true;
} else {
users[_userID].starActive[a] = false;
}
}
if(_referral1 != address(0)){
users[_userID].referral.push(_referral1);
}
if(_referral2 != address(0)){
users[_userID].referral.push(_referral2);
}
if(_referral3 != address(0)){
users[_userID].referral.push(_referral3);
}
}
| //Null address is 0x0000000000000000000000000000000000000000 | LineComment | v0.5.7+commit.6da8b019 | OSL-3.0 | bzzr://40f84d12cfb377c283e85f230fb38399399ea3106145db3ad1cc9677ddb95bec | {
"func_code_index": [
4512,
6082
]
} | 8,310 |
||
ETH20Token | ETH20Token.sol | 0xda7a43a22299b516b7b39b594c823000dce34fbc | Solidity | ETH20Token | contract ETH20Token is ERC20Pausable {
string public constant name = "ETH20 token";
string public constant symbol = "ETH20";
uint8 public constant decimals = 8;
uint256 public constant INITIAL_SUPPLY = 10000000 * (10 ** uint256(decimals));
address public owner = msg.sender;
constructor() public {
owner = msg.sender;
_mint(msg.sender, INITIAL_SUPPLY);
}
/// 限制只有创建者才能访问
modifier onlyOwner {
require (msg.sender == owner);
_;
}
/// 改变合约的所有者
function changeOwner(address _newOwner)
onlyOwner
{
require(_newOwner != 0x0);
owner = _newOwner;
}
function burn(uint256 value) onlyOwner {
_burn(msg.sender, value);
}
function mint(uint256 value) onlyOwner {
_mint(msg.sender, value);
}
} | changeOwner | function changeOwner(address _newOwner)
onlyOwner
{
require(_newOwner != 0x0);
owner = _newOwner;
}
| /// 改变合约的所有者 | NatSpecSingleLine | v0.4.24+commit.e67f0147 | None | bzzr://0cf9e314980ef9df58eb8ea067099885cf319e98593b085dd48ec75fc6da230a | {
"func_code_index": [
500,
620
]
} | 8,311 |
||
Habibi | contracts/Habibi.sol | 0x9ce696322a7495b83f279db6080314cf4d9f8c1f | Solidity | Habibi | contract Habibi is IHabibi, AccessControl, ERC721Enumerable, ERC721Pausable, ERC721Burnable, Ownable {
using Strings for uint256;
using ECDSA for bytes32;
using Counters for Counters.Counter;
Counters.Counter private earlyIDCounter;
Counters.Counter private generalCounter;
mapping(uint256 => TokenData) public tokenData;
mapping(uint256 => RedemptionWindow) public redemptionWindows;
struct TokenData {
string tokenURI;
bool exists;
}
struct RedemptionWindow {
uint256 windowOpens;
uint256 windowCloses;
uint256 maxRedeemPerTxn;
}
string private baseTokenURI;
string public _contractURI;
MintPassFactory public mintPassFactory;
event Redeemed(address indexed account, string tokens);
/**
* @notice Constructor to create Collectible
*
* @param _symbol the token symbol
* @param _mpIndexes the mintpass indexes to accommodate
* @param _redemptionWindowsOpen the mintpass redemption window open unix timestamp by index
* @param _redemptionWindowsClose the mintpass redemption window close unix timestamp by index
* @param _maxRedeemPerTxn the max mint per redemption by index
* @param _baseTokenURI the respective base URI
* @param _contractMetaDataURI the respective contract meta data URI
* @param _mintPassToken contract address of MintPass token to be burned
*/
constructor (
string memory _name,
string memory _symbol,
uint256[] memory _mpIndexes,
uint256[] memory _redemptionWindowsOpen,
uint256[] memory _redemptionWindowsClose,
uint256[] memory _maxRedeemPerTxn,
string memory _baseTokenURI,
string memory _contractMetaDataURI,
address _mintPassToken,
uint earlyIDMax
) ERC721(_name, _symbol) {
baseTokenURI = _baseTokenURI;
_contractURI = _contractMetaDataURI;
mintPassFactory = MintPassFactory(_mintPassToken);
earlyIDCounter.increment();
for(uint256 i = 0; i <= earlyIDMax; i++) {
generalCounter.increment();
}
for(uint256 i = 0; i < _mpIndexes.length; i++) {
uint passID = _mpIndexes[i];
redemptionWindows[passID].windowOpens = _redemptionWindowsOpen[i];
redemptionWindows[passID].windowCloses = _redemptionWindowsClose[i];
redemptionWindows[passID].maxRedeemPerTxn = _maxRedeemPerTxn[i];
}
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(DEFAULT_ADMIN_ROLE, 0x81745b7339D5067E82B93ca6BBAd125F214525d3);
_setupRole(DEFAULT_ADMIN_ROLE, 0x06A2a7c57278820B3044dcbCe67807e46F3F4F60);
_setupRole(DEFAULT_ADMIN_ROLE, 0x90bFa85209Df7d86cA5F845F9Cd017fd85179f98);
}
function toBytes(uint256 x) public pure returns (bytes memory b) {
b = new bytes(32);
assembly { mstore(add(b, 32), x) }
}
function toH1 (bytes16 data) internal pure returns (bytes32 result) {
result = bytes32 (data) & 0xFFFFFFFFFFFFFFFF000000000000000000000000000000000000000000000000 |
(bytes32 (data) & 0x0000000000000000FFFFFFFFFFFFFFFF00000000000000000000000000000000) >> 64;
result = result & 0xFFFFFFFF000000000000000000000000FFFFFFFF000000000000000000000000 |
(result & 0x00000000FFFFFFFF000000000000000000000000FFFFFFFF0000000000000000) >> 32;
result = result & 0xFFFF000000000000FFFF000000000000FFFF000000000000FFFF000000000000 |
(result & 0x0000FFFF000000000000FFFF000000000000FFFF000000000000FFFF00000000) >> 16;
result = result & 0xFF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000 |
(result & 0x00FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF0000) >> 8;
result = (result & 0xF000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000) >> 4 |
(result & 0x0F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F00) >> 8;
result = bytes32 (0x3030303030303030303030303030303030303030303030303030303030303030 +
uint256 (result) +
(uint256 (result) + 0x0606060606060606060606060606060606060606060606060606060606060606 >> 4 &
0x0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F) * 39);
}
function toH (bytes32 data) public pure returns (string memory) {
return string (abi.encodePacked ("0x", toH1 (bytes16 (data)), toH1 (bytes16 (data << 128))));
}
/**
* @notice Set the mintpass contract address
*
* @param _mintPassToken the respective Mint Pass contract address
*/
function setMintPassToken(address _mintPassToken) external override onlyRole(DEFAULT_ADMIN_ROLE) {
mintPassFactory = MintPassFactory(_mintPassToken);
}
/**
* @notice Change the base URI for returning metadata
*
* @param _baseTokenURI the respective base URI
*/
function setBaseURI(string memory _baseTokenURI) external override onlyRole(DEFAULT_ADMIN_ROLE) {
baseTokenURI = _baseTokenURI;
}
/**
* @notice Pause redeems until unpause is called
*/
function pause() external override onlyRole(DEFAULT_ADMIN_ROLE) {
_pause();
}
/**
* @notice Unpause redeems until pause is called
*/
function unpause() external override onlyRole(DEFAULT_ADMIN_ROLE) {
_unpause();
}
/**
* @notice Configure time to enable redeem functionality
*
* @param _windowOpen UNIX timestamp for redeem start
*/
function setRedeemStart(uint256 passID, uint256 _windowOpen) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].windowOpens = _windowOpen;
}
/**
* @notice Configure time to enable redeem functionality
*
* @param _windowClose UNIX timestamp for redeem close
*/
function setRedeemClose(uint256 passID, uint256 _windowClose) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].windowCloses = _windowClose;
}
/**
* @notice Configure the max amount of passes that can be redeemed in a txn for a specific pass index
*
* @param _maxRedeemPerTxn number of passes that can be redeemed
*/
function setMaxRedeemPerTxn(uint256 passID, uint256 _maxRedeemPerTxn) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].maxRedeemPerTxn = _maxRedeemPerTxn;
}
/**
* @notice Check if redemption window is open
*
* @param passID the pass index to check
*/
function isRedemptionOpen(uint256 passID) public view override returns (bool) {
if(paused()){
return false;
}
return block.timestamp > redemptionWindows[passID].windowOpens && block.timestamp < redemptionWindows[passID].windowCloses;
}
/**
* @notice Redeem specified amount of MintPass tokens
*
* @param mpIndexes the tokenIDs of MintPasses to redeem
* @param amounts the amount of MintPasses to redeem
*/
function redeem(uint256[] calldata mpIndexes, uint256[] calldata amounts) external override{
require(msg.sender == tx.origin, "Redeem: not allowed from contract");
require(!paused(), "Redeem: paused");
//check to make sure all are valid then re-loop for redemption
for(uint256 i = 0; i < mpIndexes.length; i++) {
require(amounts[i] > 0, "Redeem: amount cannot be zero");
require(amounts[i] <= redemptionWindows[mpIndexes[i]].maxRedeemPerTxn, "Redeem: max redeem per transaction reached");
require(mintPassFactory.balanceOf(msg.sender, mpIndexes[i]) >= amounts[i], "Redeem: insufficient amount of Mint Passes");
require(block.timestamp > redemptionWindows[mpIndexes[i]].windowOpens, "Redeem: redeption window not open for this Mint Pass");
require(block.timestamp < redemptionWindows[mpIndexes[i]].windowCloses, "Redeem: redeption window is closed for this Mint Pass");
}
string memory tokens = "";
for(uint256 i = 0; i < mpIndexes.length; i++) {
mintPassFactory.burnFromRedeem(msg.sender, mpIndexes[i], amounts[i]);
for(uint256 j = 0; j < amounts[i]; j++) {
_safeMint(msg.sender, mpIndexes[i] == 0 ? earlyIDCounter.current() : generalCounter.current());
tokens = string(abi.encodePacked(tokens, mpIndexes[i] == 0 ? earlyIDCounter.current().toString() : generalCounter.current().toString(), ","));
if(mpIndexes[i] == 0){
earlyIDCounter.increment();
}
else{
generalCounter.increment();
}
}
}
emit Redeemed(msg.sender, tokens);
}
function supportsInterface(bytes4 interfaceId) public view virtual override(AccessControl,IERC165, ERC721, ERC721Enumerable) returns (bool) {
return super.supportsInterface(interfaceId);
}
/**
* @notice Configure the max amount of passes that can be redeemed in a txn for a specific pass index
*
* @param id of token
* @param uri to point the token to
*/
function setIndividualTokenURI(uint256 id, string memory uri) external override onlyRole(DEFAULT_ADMIN_ROLE){
require(_exists(id), "ERC721Metadata: Token does not exist");
tokenData[id].tokenURI = uri;
tokenData[id].exists = true;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
if(tokenData[tokenId].exists){
return tokenData[tokenId].tokenURI;
}
return string(abi.encodePacked(baseTokenURI, toH(keccak256(toBytes(tokenId))), '.json'));
}
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override(ERC721, ERC721Enumerable, ERC721Pausable) {
super._beforeTokenTransfer(from, to, tokenId);
}
function setContractURI(string memory uri) external onlyRole(DEFAULT_ADMIN_ROLE){
_contractURI = uri;
}
function contractURI() public view returns (string memory) {
return _contractURI;
}
function h(uint256 t) public view returns (string memory) {
return string(abi.encodePacked(toH(keccak256(toBytes(t)))));
}
} | /*
* @title ERC721 token for Habibi, redeemable through burning Habibis MintPass tokens
*/ | Comment | setMintPassToken | function setMintPassToken(address _mintPassToken) external override onlyRole(DEFAULT_ADMIN_ROLE) {
mintPassFactory = MintPassFactory(_mintPassToken);
}
| /**
* @notice Set the mintpass contract address
*
* @param _mintPassToken the respective Mint Pass contract address
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
4656,
4828
]
} | 8,312 |
||
Habibi | contracts/Habibi.sol | 0x9ce696322a7495b83f279db6080314cf4d9f8c1f | Solidity | Habibi | contract Habibi is IHabibi, AccessControl, ERC721Enumerable, ERC721Pausable, ERC721Burnable, Ownable {
using Strings for uint256;
using ECDSA for bytes32;
using Counters for Counters.Counter;
Counters.Counter private earlyIDCounter;
Counters.Counter private generalCounter;
mapping(uint256 => TokenData) public tokenData;
mapping(uint256 => RedemptionWindow) public redemptionWindows;
struct TokenData {
string tokenURI;
bool exists;
}
struct RedemptionWindow {
uint256 windowOpens;
uint256 windowCloses;
uint256 maxRedeemPerTxn;
}
string private baseTokenURI;
string public _contractURI;
MintPassFactory public mintPassFactory;
event Redeemed(address indexed account, string tokens);
/**
* @notice Constructor to create Collectible
*
* @param _symbol the token symbol
* @param _mpIndexes the mintpass indexes to accommodate
* @param _redemptionWindowsOpen the mintpass redemption window open unix timestamp by index
* @param _redemptionWindowsClose the mintpass redemption window close unix timestamp by index
* @param _maxRedeemPerTxn the max mint per redemption by index
* @param _baseTokenURI the respective base URI
* @param _contractMetaDataURI the respective contract meta data URI
* @param _mintPassToken contract address of MintPass token to be burned
*/
constructor (
string memory _name,
string memory _symbol,
uint256[] memory _mpIndexes,
uint256[] memory _redemptionWindowsOpen,
uint256[] memory _redemptionWindowsClose,
uint256[] memory _maxRedeemPerTxn,
string memory _baseTokenURI,
string memory _contractMetaDataURI,
address _mintPassToken,
uint earlyIDMax
) ERC721(_name, _symbol) {
baseTokenURI = _baseTokenURI;
_contractURI = _contractMetaDataURI;
mintPassFactory = MintPassFactory(_mintPassToken);
earlyIDCounter.increment();
for(uint256 i = 0; i <= earlyIDMax; i++) {
generalCounter.increment();
}
for(uint256 i = 0; i < _mpIndexes.length; i++) {
uint passID = _mpIndexes[i];
redemptionWindows[passID].windowOpens = _redemptionWindowsOpen[i];
redemptionWindows[passID].windowCloses = _redemptionWindowsClose[i];
redemptionWindows[passID].maxRedeemPerTxn = _maxRedeemPerTxn[i];
}
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(DEFAULT_ADMIN_ROLE, 0x81745b7339D5067E82B93ca6BBAd125F214525d3);
_setupRole(DEFAULT_ADMIN_ROLE, 0x06A2a7c57278820B3044dcbCe67807e46F3F4F60);
_setupRole(DEFAULT_ADMIN_ROLE, 0x90bFa85209Df7d86cA5F845F9Cd017fd85179f98);
}
function toBytes(uint256 x) public pure returns (bytes memory b) {
b = new bytes(32);
assembly { mstore(add(b, 32), x) }
}
function toH1 (bytes16 data) internal pure returns (bytes32 result) {
result = bytes32 (data) & 0xFFFFFFFFFFFFFFFF000000000000000000000000000000000000000000000000 |
(bytes32 (data) & 0x0000000000000000FFFFFFFFFFFFFFFF00000000000000000000000000000000) >> 64;
result = result & 0xFFFFFFFF000000000000000000000000FFFFFFFF000000000000000000000000 |
(result & 0x00000000FFFFFFFF000000000000000000000000FFFFFFFF0000000000000000) >> 32;
result = result & 0xFFFF000000000000FFFF000000000000FFFF000000000000FFFF000000000000 |
(result & 0x0000FFFF000000000000FFFF000000000000FFFF000000000000FFFF00000000) >> 16;
result = result & 0xFF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000 |
(result & 0x00FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF0000) >> 8;
result = (result & 0xF000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000) >> 4 |
(result & 0x0F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F00) >> 8;
result = bytes32 (0x3030303030303030303030303030303030303030303030303030303030303030 +
uint256 (result) +
(uint256 (result) + 0x0606060606060606060606060606060606060606060606060606060606060606 >> 4 &
0x0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F) * 39);
}
function toH (bytes32 data) public pure returns (string memory) {
return string (abi.encodePacked ("0x", toH1 (bytes16 (data)), toH1 (bytes16 (data << 128))));
}
/**
* @notice Set the mintpass contract address
*
* @param _mintPassToken the respective Mint Pass contract address
*/
function setMintPassToken(address _mintPassToken) external override onlyRole(DEFAULT_ADMIN_ROLE) {
mintPassFactory = MintPassFactory(_mintPassToken);
}
/**
* @notice Change the base URI for returning metadata
*
* @param _baseTokenURI the respective base URI
*/
function setBaseURI(string memory _baseTokenURI) external override onlyRole(DEFAULT_ADMIN_ROLE) {
baseTokenURI = _baseTokenURI;
}
/**
* @notice Pause redeems until unpause is called
*/
function pause() external override onlyRole(DEFAULT_ADMIN_ROLE) {
_pause();
}
/**
* @notice Unpause redeems until pause is called
*/
function unpause() external override onlyRole(DEFAULT_ADMIN_ROLE) {
_unpause();
}
/**
* @notice Configure time to enable redeem functionality
*
* @param _windowOpen UNIX timestamp for redeem start
*/
function setRedeemStart(uint256 passID, uint256 _windowOpen) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].windowOpens = _windowOpen;
}
/**
* @notice Configure time to enable redeem functionality
*
* @param _windowClose UNIX timestamp for redeem close
*/
function setRedeemClose(uint256 passID, uint256 _windowClose) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].windowCloses = _windowClose;
}
/**
* @notice Configure the max amount of passes that can be redeemed in a txn for a specific pass index
*
* @param _maxRedeemPerTxn number of passes that can be redeemed
*/
function setMaxRedeemPerTxn(uint256 passID, uint256 _maxRedeemPerTxn) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].maxRedeemPerTxn = _maxRedeemPerTxn;
}
/**
* @notice Check if redemption window is open
*
* @param passID the pass index to check
*/
function isRedemptionOpen(uint256 passID) public view override returns (bool) {
if(paused()){
return false;
}
return block.timestamp > redemptionWindows[passID].windowOpens && block.timestamp < redemptionWindows[passID].windowCloses;
}
/**
* @notice Redeem specified amount of MintPass tokens
*
* @param mpIndexes the tokenIDs of MintPasses to redeem
* @param amounts the amount of MintPasses to redeem
*/
function redeem(uint256[] calldata mpIndexes, uint256[] calldata amounts) external override{
require(msg.sender == tx.origin, "Redeem: not allowed from contract");
require(!paused(), "Redeem: paused");
//check to make sure all are valid then re-loop for redemption
for(uint256 i = 0; i < mpIndexes.length; i++) {
require(amounts[i] > 0, "Redeem: amount cannot be zero");
require(amounts[i] <= redemptionWindows[mpIndexes[i]].maxRedeemPerTxn, "Redeem: max redeem per transaction reached");
require(mintPassFactory.balanceOf(msg.sender, mpIndexes[i]) >= amounts[i], "Redeem: insufficient amount of Mint Passes");
require(block.timestamp > redemptionWindows[mpIndexes[i]].windowOpens, "Redeem: redeption window not open for this Mint Pass");
require(block.timestamp < redemptionWindows[mpIndexes[i]].windowCloses, "Redeem: redeption window is closed for this Mint Pass");
}
string memory tokens = "";
for(uint256 i = 0; i < mpIndexes.length; i++) {
mintPassFactory.burnFromRedeem(msg.sender, mpIndexes[i], amounts[i]);
for(uint256 j = 0; j < amounts[i]; j++) {
_safeMint(msg.sender, mpIndexes[i] == 0 ? earlyIDCounter.current() : generalCounter.current());
tokens = string(abi.encodePacked(tokens, mpIndexes[i] == 0 ? earlyIDCounter.current().toString() : generalCounter.current().toString(), ","));
if(mpIndexes[i] == 0){
earlyIDCounter.increment();
}
else{
generalCounter.increment();
}
}
}
emit Redeemed(msg.sender, tokens);
}
function supportsInterface(bytes4 interfaceId) public view virtual override(AccessControl,IERC165, ERC721, ERC721Enumerable) returns (bool) {
return super.supportsInterface(interfaceId);
}
/**
* @notice Configure the max amount of passes that can be redeemed in a txn for a specific pass index
*
* @param id of token
* @param uri to point the token to
*/
function setIndividualTokenURI(uint256 id, string memory uri) external override onlyRole(DEFAULT_ADMIN_ROLE){
require(_exists(id), "ERC721Metadata: Token does not exist");
tokenData[id].tokenURI = uri;
tokenData[id].exists = true;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
if(tokenData[tokenId].exists){
return tokenData[tokenId].tokenURI;
}
return string(abi.encodePacked(baseTokenURI, toH(keccak256(toBytes(tokenId))), '.json'));
}
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override(ERC721, ERC721Enumerable, ERC721Pausable) {
super._beforeTokenTransfer(from, to, tokenId);
}
function setContractURI(string memory uri) external onlyRole(DEFAULT_ADMIN_ROLE){
_contractURI = uri;
}
function contractURI() public view returns (string memory) {
return _contractURI;
}
function h(uint256 t) public view returns (string memory) {
return string(abi.encodePacked(toH(keccak256(toBytes(t)))));
}
} | /*
* @title ERC721 token for Habibi, redeemable through burning Habibis MintPass tokens
*/ | Comment | setBaseURI | function setBaseURI(string memory _baseTokenURI) external override onlyRole(DEFAULT_ADMIN_ROLE) {
baseTokenURI = _baseTokenURI;
}
| /**
* @notice Change the base URI for returning metadata
*
* @param _baseTokenURI the respective base URI
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
4960,
5113
]
} | 8,313 |
||
Habibi | contracts/Habibi.sol | 0x9ce696322a7495b83f279db6080314cf4d9f8c1f | Solidity | Habibi | contract Habibi is IHabibi, AccessControl, ERC721Enumerable, ERC721Pausable, ERC721Burnable, Ownable {
using Strings for uint256;
using ECDSA for bytes32;
using Counters for Counters.Counter;
Counters.Counter private earlyIDCounter;
Counters.Counter private generalCounter;
mapping(uint256 => TokenData) public tokenData;
mapping(uint256 => RedemptionWindow) public redemptionWindows;
struct TokenData {
string tokenURI;
bool exists;
}
struct RedemptionWindow {
uint256 windowOpens;
uint256 windowCloses;
uint256 maxRedeemPerTxn;
}
string private baseTokenURI;
string public _contractURI;
MintPassFactory public mintPassFactory;
event Redeemed(address indexed account, string tokens);
/**
* @notice Constructor to create Collectible
*
* @param _symbol the token symbol
* @param _mpIndexes the mintpass indexes to accommodate
* @param _redemptionWindowsOpen the mintpass redemption window open unix timestamp by index
* @param _redemptionWindowsClose the mintpass redemption window close unix timestamp by index
* @param _maxRedeemPerTxn the max mint per redemption by index
* @param _baseTokenURI the respective base URI
* @param _contractMetaDataURI the respective contract meta data URI
* @param _mintPassToken contract address of MintPass token to be burned
*/
constructor (
string memory _name,
string memory _symbol,
uint256[] memory _mpIndexes,
uint256[] memory _redemptionWindowsOpen,
uint256[] memory _redemptionWindowsClose,
uint256[] memory _maxRedeemPerTxn,
string memory _baseTokenURI,
string memory _contractMetaDataURI,
address _mintPassToken,
uint earlyIDMax
) ERC721(_name, _symbol) {
baseTokenURI = _baseTokenURI;
_contractURI = _contractMetaDataURI;
mintPassFactory = MintPassFactory(_mintPassToken);
earlyIDCounter.increment();
for(uint256 i = 0; i <= earlyIDMax; i++) {
generalCounter.increment();
}
for(uint256 i = 0; i < _mpIndexes.length; i++) {
uint passID = _mpIndexes[i];
redemptionWindows[passID].windowOpens = _redemptionWindowsOpen[i];
redemptionWindows[passID].windowCloses = _redemptionWindowsClose[i];
redemptionWindows[passID].maxRedeemPerTxn = _maxRedeemPerTxn[i];
}
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(DEFAULT_ADMIN_ROLE, 0x81745b7339D5067E82B93ca6BBAd125F214525d3);
_setupRole(DEFAULT_ADMIN_ROLE, 0x06A2a7c57278820B3044dcbCe67807e46F3F4F60);
_setupRole(DEFAULT_ADMIN_ROLE, 0x90bFa85209Df7d86cA5F845F9Cd017fd85179f98);
}
function toBytes(uint256 x) public pure returns (bytes memory b) {
b = new bytes(32);
assembly { mstore(add(b, 32), x) }
}
function toH1 (bytes16 data) internal pure returns (bytes32 result) {
result = bytes32 (data) & 0xFFFFFFFFFFFFFFFF000000000000000000000000000000000000000000000000 |
(bytes32 (data) & 0x0000000000000000FFFFFFFFFFFFFFFF00000000000000000000000000000000) >> 64;
result = result & 0xFFFFFFFF000000000000000000000000FFFFFFFF000000000000000000000000 |
(result & 0x00000000FFFFFFFF000000000000000000000000FFFFFFFF0000000000000000) >> 32;
result = result & 0xFFFF000000000000FFFF000000000000FFFF000000000000FFFF000000000000 |
(result & 0x0000FFFF000000000000FFFF000000000000FFFF000000000000FFFF00000000) >> 16;
result = result & 0xFF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000 |
(result & 0x00FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF0000) >> 8;
result = (result & 0xF000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000) >> 4 |
(result & 0x0F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F00) >> 8;
result = bytes32 (0x3030303030303030303030303030303030303030303030303030303030303030 +
uint256 (result) +
(uint256 (result) + 0x0606060606060606060606060606060606060606060606060606060606060606 >> 4 &
0x0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F) * 39);
}
function toH (bytes32 data) public pure returns (string memory) {
return string (abi.encodePacked ("0x", toH1 (bytes16 (data)), toH1 (bytes16 (data << 128))));
}
/**
* @notice Set the mintpass contract address
*
* @param _mintPassToken the respective Mint Pass contract address
*/
function setMintPassToken(address _mintPassToken) external override onlyRole(DEFAULT_ADMIN_ROLE) {
mintPassFactory = MintPassFactory(_mintPassToken);
}
/**
* @notice Change the base URI for returning metadata
*
* @param _baseTokenURI the respective base URI
*/
function setBaseURI(string memory _baseTokenURI) external override onlyRole(DEFAULT_ADMIN_ROLE) {
baseTokenURI = _baseTokenURI;
}
/**
* @notice Pause redeems until unpause is called
*/
function pause() external override onlyRole(DEFAULT_ADMIN_ROLE) {
_pause();
}
/**
* @notice Unpause redeems until pause is called
*/
function unpause() external override onlyRole(DEFAULT_ADMIN_ROLE) {
_unpause();
}
/**
* @notice Configure time to enable redeem functionality
*
* @param _windowOpen UNIX timestamp for redeem start
*/
function setRedeemStart(uint256 passID, uint256 _windowOpen) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].windowOpens = _windowOpen;
}
/**
* @notice Configure time to enable redeem functionality
*
* @param _windowClose UNIX timestamp for redeem close
*/
function setRedeemClose(uint256 passID, uint256 _windowClose) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].windowCloses = _windowClose;
}
/**
* @notice Configure the max amount of passes that can be redeemed in a txn for a specific pass index
*
* @param _maxRedeemPerTxn number of passes that can be redeemed
*/
function setMaxRedeemPerTxn(uint256 passID, uint256 _maxRedeemPerTxn) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].maxRedeemPerTxn = _maxRedeemPerTxn;
}
/**
* @notice Check if redemption window is open
*
* @param passID the pass index to check
*/
function isRedemptionOpen(uint256 passID) public view override returns (bool) {
if(paused()){
return false;
}
return block.timestamp > redemptionWindows[passID].windowOpens && block.timestamp < redemptionWindows[passID].windowCloses;
}
/**
* @notice Redeem specified amount of MintPass tokens
*
* @param mpIndexes the tokenIDs of MintPasses to redeem
* @param amounts the amount of MintPasses to redeem
*/
function redeem(uint256[] calldata mpIndexes, uint256[] calldata amounts) external override{
require(msg.sender == tx.origin, "Redeem: not allowed from contract");
require(!paused(), "Redeem: paused");
//check to make sure all are valid then re-loop for redemption
for(uint256 i = 0; i < mpIndexes.length; i++) {
require(amounts[i] > 0, "Redeem: amount cannot be zero");
require(amounts[i] <= redemptionWindows[mpIndexes[i]].maxRedeemPerTxn, "Redeem: max redeem per transaction reached");
require(mintPassFactory.balanceOf(msg.sender, mpIndexes[i]) >= amounts[i], "Redeem: insufficient amount of Mint Passes");
require(block.timestamp > redemptionWindows[mpIndexes[i]].windowOpens, "Redeem: redeption window not open for this Mint Pass");
require(block.timestamp < redemptionWindows[mpIndexes[i]].windowCloses, "Redeem: redeption window is closed for this Mint Pass");
}
string memory tokens = "";
for(uint256 i = 0; i < mpIndexes.length; i++) {
mintPassFactory.burnFromRedeem(msg.sender, mpIndexes[i], amounts[i]);
for(uint256 j = 0; j < amounts[i]; j++) {
_safeMint(msg.sender, mpIndexes[i] == 0 ? earlyIDCounter.current() : generalCounter.current());
tokens = string(abi.encodePacked(tokens, mpIndexes[i] == 0 ? earlyIDCounter.current().toString() : generalCounter.current().toString(), ","));
if(mpIndexes[i] == 0){
earlyIDCounter.increment();
}
else{
generalCounter.increment();
}
}
}
emit Redeemed(msg.sender, tokens);
}
function supportsInterface(bytes4 interfaceId) public view virtual override(AccessControl,IERC165, ERC721, ERC721Enumerable) returns (bool) {
return super.supportsInterface(interfaceId);
}
/**
* @notice Configure the max amount of passes that can be redeemed in a txn for a specific pass index
*
* @param id of token
* @param uri to point the token to
*/
function setIndividualTokenURI(uint256 id, string memory uri) external override onlyRole(DEFAULT_ADMIN_ROLE){
require(_exists(id), "ERC721Metadata: Token does not exist");
tokenData[id].tokenURI = uri;
tokenData[id].exists = true;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
if(tokenData[tokenId].exists){
return tokenData[tokenId].tokenURI;
}
return string(abi.encodePacked(baseTokenURI, toH(keccak256(toBytes(tokenId))), '.json'));
}
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override(ERC721, ERC721Enumerable, ERC721Pausable) {
super._beforeTokenTransfer(from, to, tokenId);
}
function setContractURI(string memory uri) external onlyRole(DEFAULT_ADMIN_ROLE){
_contractURI = uri;
}
function contractURI() public view returns (string memory) {
return _contractURI;
}
function h(uint256 t) public view returns (string memory) {
return string(abi.encodePacked(toH(keccak256(toBytes(t)))));
}
} | /*
* @title ERC721 token for Habibi, redeemable through burning Habibis MintPass tokens
*/ | Comment | pause | function pause() external override onlyRole(DEFAULT_ADMIN_ROLE) {
_pause();
}
| /**
* @notice Pause redeems until unpause is called
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
5182,
5275
]
} | 8,314 |
||
Habibi | contracts/Habibi.sol | 0x9ce696322a7495b83f279db6080314cf4d9f8c1f | Solidity | Habibi | contract Habibi is IHabibi, AccessControl, ERC721Enumerable, ERC721Pausable, ERC721Burnable, Ownable {
using Strings for uint256;
using ECDSA for bytes32;
using Counters for Counters.Counter;
Counters.Counter private earlyIDCounter;
Counters.Counter private generalCounter;
mapping(uint256 => TokenData) public tokenData;
mapping(uint256 => RedemptionWindow) public redemptionWindows;
struct TokenData {
string tokenURI;
bool exists;
}
struct RedemptionWindow {
uint256 windowOpens;
uint256 windowCloses;
uint256 maxRedeemPerTxn;
}
string private baseTokenURI;
string public _contractURI;
MintPassFactory public mintPassFactory;
event Redeemed(address indexed account, string tokens);
/**
* @notice Constructor to create Collectible
*
* @param _symbol the token symbol
* @param _mpIndexes the mintpass indexes to accommodate
* @param _redemptionWindowsOpen the mintpass redemption window open unix timestamp by index
* @param _redemptionWindowsClose the mintpass redemption window close unix timestamp by index
* @param _maxRedeemPerTxn the max mint per redemption by index
* @param _baseTokenURI the respective base URI
* @param _contractMetaDataURI the respective contract meta data URI
* @param _mintPassToken contract address of MintPass token to be burned
*/
constructor (
string memory _name,
string memory _symbol,
uint256[] memory _mpIndexes,
uint256[] memory _redemptionWindowsOpen,
uint256[] memory _redemptionWindowsClose,
uint256[] memory _maxRedeemPerTxn,
string memory _baseTokenURI,
string memory _contractMetaDataURI,
address _mintPassToken,
uint earlyIDMax
) ERC721(_name, _symbol) {
baseTokenURI = _baseTokenURI;
_contractURI = _contractMetaDataURI;
mintPassFactory = MintPassFactory(_mintPassToken);
earlyIDCounter.increment();
for(uint256 i = 0; i <= earlyIDMax; i++) {
generalCounter.increment();
}
for(uint256 i = 0; i < _mpIndexes.length; i++) {
uint passID = _mpIndexes[i];
redemptionWindows[passID].windowOpens = _redemptionWindowsOpen[i];
redemptionWindows[passID].windowCloses = _redemptionWindowsClose[i];
redemptionWindows[passID].maxRedeemPerTxn = _maxRedeemPerTxn[i];
}
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(DEFAULT_ADMIN_ROLE, 0x81745b7339D5067E82B93ca6BBAd125F214525d3);
_setupRole(DEFAULT_ADMIN_ROLE, 0x06A2a7c57278820B3044dcbCe67807e46F3F4F60);
_setupRole(DEFAULT_ADMIN_ROLE, 0x90bFa85209Df7d86cA5F845F9Cd017fd85179f98);
}
function toBytes(uint256 x) public pure returns (bytes memory b) {
b = new bytes(32);
assembly { mstore(add(b, 32), x) }
}
function toH1 (bytes16 data) internal pure returns (bytes32 result) {
result = bytes32 (data) & 0xFFFFFFFFFFFFFFFF000000000000000000000000000000000000000000000000 |
(bytes32 (data) & 0x0000000000000000FFFFFFFFFFFFFFFF00000000000000000000000000000000) >> 64;
result = result & 0xFFFFFFFF000000000000000000000000FFFFFFFF000000000000000000000000 |
(result & 0x00000000FFFFFFFF000000000000000000000000FFFFFFFF0000000000000000) >> 32;
result = result & 0xFFFF000000000000FFFF000000000000FFFF000000000000FFFF000000000000 |
(result & 0x0000FFFF000000000000FFFF000000000000FFFF000000000000FFFF00000000) >> 16;
result = result & 0xFF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000 |
(result & 0x00FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF0000) >> 8;
result = (result & 0xF000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000) >> 4 |
(result & 0x0F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F00) >> 8;
result = bytes32 (0x3030303030303030303030303030303030303030303030303030303030303030 +
uint256 (result) +
(uint256 (result) + 0x0606060606060606060606060606060606060606060606060606060606060606 >> 4 &
0x0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F) * 39);
}
function toH (bytes32 data) public pure returns (string memory) {
return string (abi.encodePacked ("0x", toH1 (bytes16 (data)), toH1 (bytes16 (data << 128))));
}
/**
* @notice Set the mintpass contract address
*
* @param _mintPassToken the respective Mint Pass contract address
*/
function setMintPassToken(address _mintPassToken) external override onlyRole(DEFAULT_ADMIN_ROLE) {
mintPassFactory = MintPassFactory(_mintPassToken);
}
/**
* @notice Change the base URI for returning metadata
*
* @param _baseTokenURI the respective base URI
*/
function setBaseURI(string memory _baseTokenURI) external override onlyRole(DEFAULT_ADMIN_ROLE) {
baseTokenURI = _baseTokenURI;
}
/**
* @notice Pause redeems until unpause is called
*/
function pause() external override onlyRole(DEFAULT_ADMIN_ROLE) {
_pause();
}
/**
* @notice Unpause redeems until pause is called
*/
function unpause() external override onlyRole(DEFAULT_ADMIN_ROLE) {
_unpause();
}
/**
* @notice Configure time to enable redeem functionality
*
* @param _windowOpen UNIX timestamp for redeem start
*/
function setRedeemStart(uint256 passID, uint256 _windowOpen) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].windowOpens = _windowOpen;
}
/**
* @notice Configure time to enable redeem functionality
*
* @param _windowClose UNIX timestamp for redeem close
*/
function setRedeemClose(uint256 passID, uint256 _windowClose) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].windowCloses = _windowClose;
}
/**
* @notice Configure the max amount of passes that can be redeemed in a txn for a specific pass index
*
* @param _maxRedeemPerTxn number of passes that can be redeemed
*/
function setMaxRedeemPerTxn(uint256 passID, uint256 _maxRedeemPerTxn) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].maxRedeemPerTxn = _maxRedeemPerTxn;
}
/**
* @notice Check if redemption window is open
*
* @param passID the pass index to check
*/
function isRedemptionOpen(uint256 passID) public view override returns (bool) {
if(paused()){
return false;
}
return block.timestamp > redemptionWindows[passID].windowOpens && block.timestamp < redemptionWindows[passID].windowCloses;
}
/**
* @notice Redeem specified amount of MintPass tokens
*
* @param mpIndexes the tokenIDs of MintPasses to redeem
* @param amounts the amount of MintPasses to redeem
*/
function redeem(uint256[] calldata mpIndexes, uint256[] calldata amounts) external override{
require(msg.sender == tx.origin, "Redeem: not allowed from contract");
require(!paused(), "Redeem: paused");
//check to make sure all are valid then re-loop for redemption
for(uint256 i = 0; i < mpIndexes.length; i++) {
require(amounts[i] > 0, "Redeem: amount cannot be zero");
require(amounts[i] <= redemptionWindows[mpIndexes[i]].maxRedeemPerTxn, "Redeem: max redeem per transaction reached");
require(mintPassFactory.balanceOf(msg.sender, mpIndexes[i]) >= amounts[i], "Redeem: insufficient amount of Mint Passes");
require(block.timestamp > redemptionWindows[mpIndexes[i]].windowOpens, "Redeem: redeption window not open for this Mint Pass");
require(block.timestamp < redemptionWindows[mpIndexes[i]].windowCloses, "Redeem: redeption window is closed for this Mint Pass");
}
string memory tokens = "";
for(uint256 i = 0; i < mpIndexes.length; i++) {
mintPassFactory.burnFromRedeem(msg.sender, mpIndexes[i], amounts[i]);
for(uint256 j = 0; j < amounts[i]; j++) {
_safeMint(msg.sender, mpIndexes[i] == 0 ? earlyIDCounter.current() : generalCounter.current());
tokens = string(abi.encodePacked(tokens, mpIndexes[i] == 0 ? earlyIDCounter.current().toString() : generalCounter.current().toString(), ","));
if(mpIndexes[i] == 0){
earlyIDCounter.increment();
}
else{
generalCounter.increment();
}
}
}
emit Redeemed(msg.sender, tokens);
}
function supportsInterface(bytes4 interfaceId) public view virtual override(AccessControl,IERC165, ERC721, ERC721Enumerable) returns (bool) {
return super.supportsInterface(interfaceId);
}
/**
* @notice Configure the max amount of passes that can be redeemed in a txn for a specific pass index
*
* @param id of token
* @param uri to point the token to
*/
function setIndividualTokenURI(uint256 id, string memory uri) external override onlyRole(DEFAULT_ADMIN_ROLE){
require(_exists(id), "ERC721Metadata: Token does not exist");
tokenData[id].tokenURI = uri;
tokenData[id].exists = true;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
if(tokenData[tokenId].exists){
return tokenData[tokenId].tokenURI;
}
return string(abi.encodePacked(baseTokenURI, toH(keccak256(toBytes(tokenId))), '.json'));
}
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override(ERC721, ERC721Enumerable, ERC721Pausable) {
super._beforeTokenTransfer(from, to, tokenId);
}
function setContractURI(string memory uri) external onlyRole(DEFAULT_ADMIN_ROLE){
_contractURI = uri;
}
function contractURI() public view returns (string memory) {
return _contractURI;
}
function h(uint256 t) public view returns (string memory) {
return string(abi.encodePacked(toH(keccak256(toBytes(t)))));
}
} | /*
* @title ERC721 token for Habibi, redeemable through burning Habibis MintPass tokens
*/ | Comment | unpause | function unpause() external override onlyRole(DEFAULT_ADMIN_ROLE) {
_unpause();
}
| /**
* @notice Unpause redeems until pause is called
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
5344,
5441
]
} | 8,315 |
||
Habibi | contracts/Habibi.sol | 0x9ce696322a7495b83f279db6080314cf4d9f8c1f | Solidity | Habibi | contract Habibi is IHabibi, AccessControl, ERC721Enumerable, ERC721Pausable, ERC721Burnable, Ownable {
using Strings for uint256;
using ECDSA for bytes32;
using Counters for Counters.Counter;
Counters.Counter private earlyIDCounter;
Counters.Counter private generalCounter;
mapping(uint256 => TokenData) public tokenData;
mapping(uint256 => RedemptionWindow) public redemptionWindows;
struct TokenData {
string tokenURI;
bool exists;
}
struct RedemptionWindow {
uint256 windowOpens;
uint256 windowCloses;
uint256 maxRedeemPerTxn;
}
string private baseTokenURI;
string public _contractURI;
MintPassFactory public mintPassFactory;
event Redeemed(address indexed account, string tokens);
/**
* @notice Constructor to create Collectible
*
* @param _symbol the token symbol
* @param _mpIndexes the mintpass indexes to accommodate
* @param _redemptionWindowsOpen the mintpass redemption window open unix timestamp by index
* @param _redemptionWindowsClose the mintpass redemption window close unix timestamp by index
* @param _maxRedeemPerTxn the max mint per redemption by index
* @param _baseTokenURI the respective base URI
* @param _contractMetaDataURI the respective contract meta data URI
* @param _mintPassToken contract address of MintPass token to be burned
*/
constructor (
string memory _name,
string memory _symbol,
uint256[] memory _mpIndexes,
uint256[] memory _redemptionWindowsOpen,
uint256[] memory _redemptionWindowsClose,
uint256[] memory _maxRedeemPerTxn,
string memory _baseTokenURI,
string memory _contractMetaDataURI,
address _mintPassToken,
uint earlyIDMax
) ERC721(_name, _symbol) {
baseTokenURI = _baseTokenURI;
_contractURI = _contractMetaDataURI;
mintPassFactory = MintPassFactory(_mintPassToken);
earlyIDCounter.increment();
for(uint256 i = 0; i <= earlyIDMax; i++) {
generalCounter.increment();
}
for(uint256 i = 0; i < _mpIndexes.length; i++) {
uint passID = _mpIndexes[i];
redemptionWindows[passID].windowOpens = _redemptionWindowsOpen[i];
redemptionWindows[passID].windowCloses = _redemptionWindowsClose[i];
redemptionWindows[passID].maxRedeemPerTxn = _maxRedeemPerTxn[i];
}
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(DEFAULT_ADMIN_ROLE, 0x81745b7339D5067E82B93ca6BBAd125F214525d3);
_setupRole(DEFAULT_ADMIN_ROLE, 0x06A2a7c57278820B3044dcbCe67807e46F3F4F60);
_setupRole(DEFAULT_ADMIN_ROLE, 0x90bFa85209Df7d86cA5F845F9Cd017fd85179f98);
}
function toBytes(uint256 x) public pure returns (bytes memory b) {
b = new bytes(32);
assembly { mstore(add(b, 32), x) }
}
function toH1 (bytes16 data) internal pure returns (bytes32 result) {
result = bytes32 (data) & 0xFFFFFFFFFFFFFFFF000000000000000000000000000000000000000000000000 |
(bytes32 (data) & 0x0000000000000000FFFFFFFFFFFFFFFF00000000000000000000000000000000) >> 64;
result = result & 0xFFFFFFFF000000000000000000000000FFFFFFFF000000000000000000000000 |
(result & 0x00000000FFFFFFFF000000000000000000000000FFFFFFFF0000000000000000) >> 32;
result = result & 0xFFFF000000000000FFFF000000000000FFFF000000000000FFFF000000000000 |
(result & 0x0000FFFF000000000000FFFF000000000000FFFF000000000000FFFF00000000) >> 16;
result = result & 0xFF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000 |
(result & 0x00FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF0000) >> 8;
result = (result & 0xF000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000) >> 4 |
(result & 0x0F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F00) >> 8;
result = bytes32 (0x3030303030303030303030303030303030303030303030303030303030303030 +
uint256 (result) +
(uint256 (result) + 0x0606060606060606060606060606060606060606060606060606060606060606 >> 4 &
0x0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F) * 39);
}
function toH (bytes32 data) public pure returns (string memory) {
return string (abi.encodePacked ("0x", toH1 (bytes16 (data)), toH1 (bytes16 (data << 128))));
}
/**
* @notice Set the mintpass contract address
*
* @param _mintPassToken the respective Mint Pass contract address
*/
function setMintPassToken(address _mintPassToken) external override onlyRole(DEFAULT_ADMIN_ROLE) {
mintPassFactory = MintPassFactory(_mintPassToken);
}
/**
* @notice Change the base URI for returning metadata
*
* @param _baseTokenURI the respective base URI
*/
function setBaseURI(string memory _baseTokenURI) external override onlyRole(DEFAULT_ADMIN_ROLE) {
baseTokenURI = _baseTokenURI;
}
/**
* @notice Pause redeems until unpause is called
*/
function pause() external override onlyRole(DEFAULT_ADMIN_ROLE) {
_pause();
}
/**
* @notice Unpause redeems until pause is called
*/
function unpause() external override onlyRole(DEFAULT_ADMIN_ROLE) {
_unpause();
}
/**
* @notice Configure time to enable redeem functionality
*
* @param _windowOpen UNIX timestamp for redeem start
*/
function setRedeemStart(uint256 passID, uint256 _windowOpen) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].windowOpens = _windowOpen;
}
/**
* @notice Configure time to enable redeem functionality
*
* @param _windowClose UNIX timestamp for redeem close
*/
function setRedeemClose(uint256 passID, uint256 _windowClose) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].windowCloses = _windowClose;
}
/**
* @notice Configure the max amount of passes that can be redeemed in a txn for a specific pass index
*
* @param _maxRedeemPerTxn number of passes that can be redeemed
*/
function setMaxRedeemPerTxn(uint256 passID, uint256 _maxRedeemPerTxn) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].maxRedeemPerTxn = _maxRedeemPerTxn;
}
/**
* @notice Check if redemption window is open
*
* @param passID the pass index to check
*/
function isRedemptionOpen(uint256 passID) public view override returns (bool) {
if(paused()){
return false;
}
return block.timestamp > redemptionWindows[passID].windowOpens && block.timestamp < redemptionWindows[passID].windowCloses;
}
/**
* @notice Redeem specified amount of MintPass tokens
*
* @param mpIndexes the tokenIDs of MintPasses to redeem
* @param amounts the amount of MintPasses to redeem
*/
function redeem(uint256[] calldata mpIndexes, uint256[] calldata amounts) external override{
require(msg.sender == tx.origin, "Redeem: not allowed from contract");
require(!paused(), "Redeem: paused");
//check to make sure all are valid then re-loop for redemption
for(uint256 i = 0; i < mpIndexes.length; i++) {
require(amounts[i] > 0, "Redeem: amount cannot be zero");
require(amounts[i] <= redemptionWindows[mpIndexes[i]].maxRedeemPerTxn, "Redeem: max redeem per transaction reached");
require(mintPassFactory.balanceOf(msg.sender, mpIndexes[i]) >= amounts[i], "Redeem: insufficient amount of Mint Passes");
require(block.timestamp > redemptionWindows[mpIndexes[i]].windowOpens, "Redeem: redeption window not open for this Mint Pass");
require(block.timestamp < redemptionWindows[mpIndexes[i]].windowCloses, "Redeem: redeption window is closed for this Mint Pass");
}
string memory tokens = "";
for(uint256 i = 0; i < mpIndexes.length; i++) {
mintPassFactory.burnFromRedeem(msg.sender, mpIndexes[i], amounts[i]);
for(uint256 j = 0; j < amounts[i]; j++) {
_safeMint(msg.sender, mpIndexes[i] == 0 ? earlyIDCounter.current() : generalCounter.current());
tokens = string(abi.encodePacked(tokens, mpIndexes[i] == 0 ? earlyIDCounter.current().toString() : generalCounter.current().toString(), ","));
if(mpIndexes[i] == 0){
earlyIDCounter.increment();
}
else{
generalCounter.increment();
}
}
}
emit Redeemed(msg.sender, tokens);
}
function supportsInterface(bytes4 interfaceId) public view virtual override(AccessControl,IERC165, ERC721, ERC721Enumerable) returns (bool) {
return super.supportsInterface(interfaceId);
}
/**
* @notice Configure the max amount of passes that can be redeemed in a txn for a specific pass index
*
* @param id of token
* @param uri to point the token to
*/
function setIndividualTokenURI(uint256 id, string memory uri) external override onlyRole(DEFAULT_ADMIN_ROLE){
require(_exists(id), "ERC721Metadata: Token does not exist");
tokenData[id].tokenURI = uri;
tokenData[id].exists = true;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
if(tokenData[tokenId].exists){
return tokenData[tokenId].tokenURI;
}
return string(abi.encodePacked(baseTokenURI, toH(keccak256(toBytes(tokenId))), '.json'));
}
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override(ERC721, ERC721Enumerable, ERC721Pausable) {
super._beforeTokenTransfer(from, to, tokenId);
}
function setContractURI(string memory uri) external onlyRole(DEFAULT_ADMIN_ROLE){
_contractURI = uri;
}
function contractURI() public view returns (string memory) {
return _contractURI;
}
function h(uint256 t) public view returns (string memory) {
return string(abi.encodePacked(toH(keccak256(toBytes(t)))));
}
} | /*
* @title ERC721 token for Habibi, redeemable through burning Habibis MintPass tokens
*/ | Comment | setRedeemStart | function setRedeemStart(uint256 passID, uint256 _windowOpen) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].windowOpens = _windowOpen;
}
| /**
* @notice Configure time to enable redeem functionality
*
* @param _windowOpen UNIX timestamp for redeem start
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
5588,
5776
]
} | 8,316 |
||
Habibi | contracts/Habibi.sol | 0x9ce696322a7495b83f279db6080314cf4d9f8c1f | Solidity | Habibi | contract Habibi is IHabibi, AccessControl, ERC721Enumerable, ERC721Pausable, ERC721Burnable, Ownable {
using Strings for uint256;
using ECDSA for bytes32;
using Counters for Counters.Counter;
Counters.Counter private earlyIDCounter;
Counters.Counter private generalCounter;
mapping(uint256 => TokenData) public tokenData;
mapping(uint256 => RedemptionWindow) public redemptionWindows;
struct TokenData {
string tokenURI;
bool exists;
}
struct RedemptionWindow {
uint256 windowOpens;
uint256 windowCloses;
uint256 maxRedeemPerTxn;
}
string private baseTokenURI;
string public _contractURI;
MintPassFactory public mintPassFactory;
event Redeemed(address indexed account, string tokens);
/**
* @notice Constructor to create Collectible
*
* @param _symbol the token symbol
* @param _mpIndexes the mintpass indexes to accommodate
* @param _redemptionWindowsOpen the mintpass redemption window open unix timestamp by index
* @param _redemptionWindowsClose the mintpass redemption window close unix timestamp by index
* @param _maxRedeemPerTxn the max mint per redemption by index
* @param _baseTokenURI the respective base URI
* @param _contractMetaDataURI the respective contract meta data URI
* @param _mintPassToken contract address of MintPass token to be burned
*/
constructor (
string memory _name,
string memory _symbol,
uint256[] memory _mpIndexes,
uint256[] memory _redemptionWindowsOpen,
uint256[] memory _redemptionWindowsClose,
uint256[] memory _maxRedeemPerTxn,
string memory _baseTokenURI,
string memory _contractMetaDataURI,
address _mintPassToken,
uint earlyIDMax
) ERC721(_name, _symbol) {
baseTokenURI = _baseTokenURI;
_contractURI = _contractMetaDataURI;
mintPassFactory = MintPassFactory(_mintPassToken);
earlyIDCounter.increment();
for(uint256 i = 0; i <= earlyIDMax; i++) {
generalCounter.increment();
}
for(uint256 i = 0; i < _mpIndexes.length; i++) {
uint passID = _mpIndexes[i];
redemptionWindows[passID].windowOpens = _redemptionWindowsOpen[i];
redemptionWindows[passID].windowCloses = _redemptionWindowsClose[i];
redemptionWindows[passID].maxRedeemPerTxn = _maxRedeemPerTxn[i];
}
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(DEFAULT_ADMIN_ROLE, 0x81745b7339D5067E82B93ca6BBAd125F214525d3);
_setupRole(DEFAULT_ADMIN_ROLE, 0x06A2a7c57278820B3044dcbCe67807e46F3F4F60);
_setupRole(DEFAULT_ADMIN_ROLE, 0x90bFa85209Df7d86cA5F845F9Cd017fd85179f98);
}
function toBytes(uint256 x) public pure returns (bytes memory b) {
b = new bytes(32);
assembly { mstore(add(b, 32), x) }
}
function toH1 (bytes16 data) internal pure returns (bytes32 result) {
result = bytes32 (data) & 0xFFFFFFFFFFFFFFFF000000000000000000000000000000000000000000000000 |
(bytes32 (data) & 0x0000000000000000FFFFFFFFFFFFFFFF00000000000000000000000000000000) >> 64;
result = result & 0xFFFFFFFF000000000000000000000000FFFFFFFF000000000000000000000000 |
(result & 0x00000000FFFFFFFF000000000000000000000000FFFFFFFF0000000000000000) >> 32;
result = result & 0xFFFF000000000000FFFF000000000000FFFF000000000000FFFF000000000000 |
(result & 0x0000FFFF000000000000FFFF000000000000FFFF000000000000FFFF00000000) >> 16;
result = result & 0xFF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000 |
(result & 0x00FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF0000) >> 8;
result = (result & 0xF000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000) >> 4 |
(result & 0x0F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F00) >> 8;
result = bytes32 (0x3030303030303030303030303030303030303030303030303030303030303030 +
uint256 (result) +
(uint256 (result) + 0x0606060606060606060606060606060606060606060606060606060606060606 >> 4 &
0x0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F) * 39);
}
function toH (bytes32 data) public pure returns (string memory) {
return string (abi.encodePacked ("0x", toH1 (bytes16 (data)), toH1 (bytes16 (data << 128))));
}
/**
* @notice Set the mintpass contract address
*
* @param _mintPassToken the respective Mint Pass contract address
*/
function setMintPassToken(address _mintPassToken) external override onlyRole(DEFAULT_ADMIN_ROLE) {
mintPassFactory = MintPassFactory(_mintPassToken);
}
/**
* @notice Change the base URI for returning metadata
*
* @param _baseTokenURI the respective base URI
*/
function setBaseURI(string memory _baseTokenURI) external override onlyRole(DEFAULT_ADMIN_ROLE) {
baseTokenURI = _baseTokenURI;
}
/**
* @notice Pause redeems until unpause is called
*/
function pause() external override onlyRole(DEFAULT_ADMIN_ROLE) {
_pause();
}
/**
* @notice Unpause redeems until pause is called
*/
function unpause() external override onlyRole(DEFAULT_ADMIN_ROLE) {
_unpause();
}
/**
* @notice Configure time to enable redeem functionality
*
* @param _windowOpen UNIX timestamp for redeem start
*/
function setRedeemStart(uint256 passID, uint256 _windowOpen) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].windowOpens = _windowOpen;
}
/**
* @notice Configure time to enable redeem functionality
*
* @param _windowClose UNIX timestamp for redeem close
*/
function setRedeemClose(uint256 passID, uint256 _windowClose) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].windowCloses = _windowClose;
}
/**
* @notice Configure the max amount of passes that can be redeemed in a txn for a specific pass index
*
* @param _maxRedeemPerTxn number of passes that can be redeemed
*/
function setMaxRedeemPerTxn(uint256 passID, uint256 _maxRedeemPerTxn) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].maxRedeemPerTxn = _maxRedeemPerTxn;
}
/**
* @notice Check if redemption window is open
*
* @param passID the pass index to check
*/
function isRedemptionOpen(uint256 passID) public view override returns (bool) {
if(paused()){
return false;
}
return block.timestamp > redemptionWindows[passID].windowOpens && block.timestamp < redemptionWindows[passID].windowCloses;
}
/**
* @notice Redeem specified amount of MintPass tokens
*
* @param mpIndexes the tokenIDs of MintPasses to redeem
* @param amounts the amount of MintPasses to redeem
*/
function redeem(uint256[] calldata mpIndexes, uint256[] calldata amounts) external override{
require(msg.sender == tx.origin, "Redeem: not allowed from contract");
require(!paused(), "Redeem: paused");
//check to make sure all are valid then re-loop for redemption
for(uint256 i = 0; i < mpIndexes.length; i++) {
require(amounts[i] > 0, "Redeem: amount cannot be zero");
require(amounts[i] <= redemptionWindows[mpIndexes[i]].maxRedeemPerTxn, "Redeem: max redeem per transaction reached");
require(mintPassFactory.balanceOf(msg.sender, mpIndexes[i]) >= amounts[i], "Redeem: insufficient amount of Mint Passes");
require(block.timestamp > redemptionWindows[mpIndexes[i]].windowOpens, "Redeem: redeption window not open for this Mint Pass");
require(block.timestamp < redemptionWindows[mpIndexes[i]].windowCloses, "Redeem: redeption window is closed for this Mint Pass");
}
string memory tokens = "";
for(uint256 i = 0; i < mpIndexes.length; i++) {
mintPassFactory.burnFromRedeem(msg.sender, mpIndexes[i], amounts[i]);
for(uint256 j = 0; j < amounts[i]; j++) {
_safeMint(msg.sender, mpIndexes[i] == 0 ? earlyIDCounter.current() : generalCounter.current());
tokens = string(abi.encodePacked(tokens, mpIndexes[i] == 0 ? earlyIDCounter.current().toString() : generalCounter.current().toString(), ","));
if(mpIndexes[i] == 0){
earlyIDCounter.increment();
}
else{
generalCounter.increment();
}
}
}
emit Redeemed(msg.sender, tokens);
}
function supportsInterface(bytes4 interfaceId) public view virtual override(AccessControl,IERC165, ERC721, ERC721Enumerable) returns (bool) {
return super.supportsInterface(interfaceId);
}
/**
* @notice Configure the max amount of passes that can be redeemed in a txn for a specific pass index
*
* @param id of token
* @param uri to point the token to
*/
function setIndividualTokenURI(uint256 id, string memory uri) external override onlyRole(DEFAULT_ADMIN_ROLE){
require(_exists(id), "ERC721Metadata: Token does not exist");
tokenData[id].tokenURI = uri;
tokenData[id].exists = true;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
if(tokenData[tokenId].exists){
return tokenData[tokenId].tokenURI;
}
return string(abi.encodePacked(baseTokenURI, toH(keccak256(toBytes(tokenId))), '.json'));
}
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override(ERC721, ERC721Enumerable, ERC721Pausable) {
super._beforeTokenTransfer(from, to, tokenId);
}
function setContractURI(string memory uri) external onlyRole(DEFAULT_ADMIN_ROLE){
_contractURI = uri;
}
function contractURI() public view returns (string memory) {
return _contractURI;
}
function h(uint256 t) public view returns (string memory) {
return string(abi.encodePacked(toH(keccak256(toBytes(t)))));
}
} | /*
* @title ERC721 token for Habibi, redeemable through burning Habibis MintPass tokens
*/ | Comment | setRedeemClose | function setRedeemClose(uint256 passID, uint256 _windowClose) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].windowCloses = _windowClose;
}
| /**
* @notice Configure time to enable redeem functionality
*
* @param _windowClose UNIX timestamp for redeem close
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
5918,
6103
]
} | 8,317 |
||
Habibi | contracts/Habibi.sol | 0x9ce696322a7495b83f279db6080314cf4d9f8c1f | Solidity | Habibi | contract Habibi is IHabibi, AccessControl, ERC721Enumerable, ERC721Pausable, ERC721Burnable, Ownable {
using Strings for uint256;
using ECDSA for bytes32;
using Counters for Counters.Counter;
Counters.Counter private earlyIDCounter;
Counters.Counter private generalCounter;
mapping(uint256 => TokenData) public tokenData;
mapping(uint256 => RedemptionWindow) public redemptionWindows;
struct TokenData {
string tokenURI;
bool exists;
}
struct RedemptionWindow {
uint256 windowOpens;
uint256 windowCloses;
uint256 maxRedeemPerTxn;
}
string private baseTokenURI;
string public _contractURI;
MintPassFactory public mintPassFactory;
event Redeemed(address indexed account, string tokens);
/**
* @notice Constructor to create Collectible
*
* @param _symbol the token symbol
* @param _mpIndexes the mintpass indexes to accommodate
* @param _redemptionWindowsOpen the mintpass redemption window open unix timestamp by index
* @param _redemptionWindowsClose the mintpass redemption window close unix timestamp by index
* @param _maxRedeemPerTxn the max mint per redemption by index
* @param _baseTokenURI the respective base URI
* @param _contractMetaDataURI the respective contract meta data URI
* @param _mintPassToken contract address of MintPass token to be burned
*/
constructor (
string memory _name,
string memory _symbol,
uint256[] memory _mpIndexes,
uint256[] memory _redemptionWindowsOpen,
uint256[] memory _redemptionWindowsClose,
uint256[] memory _maxRedeemPerTxn,
string memory _baseTokenURI,
string memory _contractMetaDataURI,
address _mintPassToken,
uint earlyIDMax
) ERC721(_name, _symbol) {
baseTokenURI = _baseTokenURI;
_contractURI = _contractMetaDataURI;
mintPassFactory = MintPassFactory(_mintPassToken);
earlyIDCounter.increment();
for(uint256 i = 0; i <= earlyIDMax; i++) {
generalCounter.increment();
}
for(uint256 i = 0; i < _mpIndexes.length; i++) {
uint passID = _mpIndexes[i];
redemptionWindows[passID].windowOpens = _redemptionWindowsOpen[i];
redemptionWindows[passID].windowCloses = _redemptionWindowsClose[i];
redemptionWindows[passID].maxRedeemPerTxn = _maxRedeemPerTxn[i];
}
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(DEFAULT_ADMIN_ROLE, 0x81745b7339D5067E82B93ca6BBAd125F214525d3);
_setupRole(DEFAULT_ADMIN_ROLE, 0x06A2a7c57278820B3044dcbCe67807e46F3F4F60);
_setupRole(DEFAULT_ADMIN_ROLE, 0x90bFa85209Df7d86cA5F845F9Cd017fd85179f98);
}
function toBytes(uint256 x) public pure returns (bytes memory b) {
b = new bytes(32);
assembly { mstore(add(b, 32), x) }
}
function toH1 (bytes16 data) internal pure returns (bytes32 result) {
result = bytes32 (data) & 0xFFFFFFFFFFFFFFFF000000000000000000000000000000000000000000000000 |
(bytes32 (data) & 0x0000000000000000FFFFFFFFFFFFFFFF00000000000000000000000000000000) >> 64;
result = result & 0xFFFFFFFF000000000000000000000000FFFFFFFF000000000000000000000000 |
(result & 0x00000000FFFFFFFF000000000000000000000000FFFFFFFF0000000000000000) >> 32;
result = result & 0xFFFF000000000000FFFF000000000000FFFF000000000000FFFF000000000000 |
(result & 0x0000FFFF000000000000FFFF000000000000FFFF000000000000FFFF00000000) >> 16;
result = result & 0xFF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000 |
(result & 0x00FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF0000) >> 8;
result = (result & 0xF000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000) >> 4 |
(result & 0x0F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F00) >> 8;
result = bytes32 (0x3030303030303030303030303030303030303030303030303030303030303030 +
uint256 (result) +
(uint256 (result) + 0x0606060606060606060606060606060606060606060606060606060606060606 >> 4 &
0x0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F) * 39);
}
function toH (bytes32 data) public pure returns (string memory) {
return string (abi.encodePacked ("0x", toH1 (bytes16 (data)), toH1 (bytes16 (data << 128))));
}
/**
* @notice Set the mintpass contract address
*
* @param _mintPassToken the respective Mint Pass contract address
*/
function setMintPassToken(address _mintPassToken) external override onlyRole(DEFAULT_ADMIN_ROLE) {
mintPassFactory = MintPassFactory(_mintPassToken);
}
/**
* @notice Change the base URI for returning metadata
*
* @param _baseTokenURI the respective base URI
*/
function setBaseURI(string memory _baseTokenURI) external override onlyRole(DEFAULT_ADMIN_ROLE) {
baseTokenURI = _baseTokenURI;
}
/**
* @notice Pause redeems until unpause is called
*/
function pause() external override onlyRole(DEFAULT_ADMIN_ROLE) {
_pause();
}
/**
* @notice Unpause redeems until pause is called
*/
function unpause() external override onlyRole(DEFAULT_ADMIN_ROLE) {
_unpause();
}
/**
* @notice Configure time to enable redeem functionality
*
* @param _windowOpen UNIX timestamp for redeem start
*/
function setRedeemStart(uint256 passID, uint256 _windowOpen) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].windowOpens = _windowOpen;
}
/**
* @notice Configure time to enable redeem functionality
*
* @param _windowClose UNIX timestamp for redeem close
*/
function setRedeemClose(uint256 passID, uint256 _windowClose) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].windowCloses = _windowClose;
}
/**
* @notice Configure the max amount of passes that can be redeemed in a txn for a specific pass index
*
* @param _maxRedeemPerTxn number of passes that can be redeemed
*/
function setMaxRedeemPerTxn(uint256 passID, uint256 _maxRedeemPerTxn) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].maxRedeemPerTxn = _maxRedeemPerTxn;
}
/**
* @notice Check if redemption window is open
*
* @param passID the pass index to check
*/
function isRedemptionOpen(uint256 passID) public view override returns (bool) {
if(paused()){
return false;
}
return block.timestamp > redemptionWindows[passID].windowOpens && block.timestamp < redemptionWindows[passID].windowCloses;
}
/**
* @notice Redeem specified amount of MintPass tokens
*
* @param mpIndexes the tokenIDs of MintPasses to redeem
* @param amounts the amount of MintPasses to redeem
*/
function redeem(uint256[] calldata mpIndexes, uint256[] calldata amounts) external override{
require(msg.sender == tx.origin, "Redeem: not allowed from contract");
require(!paused(), "Redeem: paused");
//check to make sure all are valid then re-loop for redemption
for(uint256 i = 0; i < mpIndexes.length; i++) {
require(amounts[i] > 0, "Redeem: amount cannot be zero");
require(amounts[i] <= redemptionWindows[mpIndexes[i]].maxRedeemPerTxn, "Redeem: max redeem per transaction reached");
require(mintPassFactory.balanceOf(msg.sender, mpIndexes[i]) >= amounts[i], "Redeem: insufficient amount of Mint Passes");
require(block.timestamp > redemptionWindows[mpIndexes[i]].windowOpens, "Redeem: redeption window not open for this Mint Pass");
require(block.timestamp < redemptionWindows[mpIndexes[i]].windowCloses, "Redeem: redeption window is closed for this Mint Pass");
}
string memory tokens = "";
for(uint256 i = 0; i < mpIndexes.length; i++) {
mintPassFactory.burnFromRedeem(msg.sender, mpIndexes[i], amounts[i]);
for(uint256 j = 0; j < amounts[i]; j++) {
_safeMint(msg.sender, mpIndexes[i] == 0 ? earlyIDCounter.current() : generalCounter.current());
tokens = string(abi.encodePacked(tokens, mpIndexes[i] == 0 ? earlyIDCounter.current().toString() : generalCounter.current().toString(), ","));
if(mpIndexes[i] == 0){
earlyIDCounter.increment();
}
else{
generalCounter.increment();
}
}
}
emit Redeemed(msg.sender, tokens);
}
function supportsInterface(bytes4 interfaceId) public view virtual override(AccessControl,IERC165, ERC721, ERC721Enumerable) returns (bool) {
return super.supportsInterface(interfaceId);
}
/**
* @notice Configure the max amount of passes that can be redeemed in a txn for a specific pass index
*
* @param id of token
* @param uri to point the token to
*/
function setIndividualTokenURI(uint256 id, string memory uri) external override onlyRole(DEFAULT_ADMIN_ROLE){
require(_exists(id), "ERC721Metadata: Token does not exist");
tokenData[id].tokenURI = uri;
tokenData[id].exists = true;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
if(tokenData[tokenId].exists){
return tokenData[tokenId].tokenURI;
}
return string(abi.encodePacked(baseTokenURI, toH(keccak256(toBytes(tokenId))), '.json'));
}
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override(ERC721, ERC721Enumerable, ERC721Pausable) {
super._beforeTokenTransfer(from, to, tokenId);
}
function setContractURI(string memory uri) external onlyRole(DEFAULT_ADMIN_ROLE){
_contractURI = uri;
}
function contractURI() public view returns (string memory) {
return _contractURI;
}
function h(uint256 t) public view returns (string memory) {
return string(abi.encodePacked(toH(keccak256(toBytes(t)))));
}
} | /*
* @title ERC721 token for Habibi, redeemable through burning Habibis MintPass tokens
*/ | Comment | setMaxRedeemPerTxn | function setMaxRedeemPerTxn(uint256 passID, uint256 _maxRedeemPerTxn) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].maxRedeemPerTxn = _maxRedeemPerTxn;
}
| /**
* @notice Configure the max amount of passes that can be redeemed in a txn for a specific pass index
*
* @param _maxRedeemPerTxn number of passes that can be redeemed
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
6300,
6506
]
} | 8,318 |
||
Habibi | contracts/Habibi.sol | 0x9ce696322a7495b83f279db6080314cf4d9f8c1f | Solidity | Habibi | contract Habibi is IHabibi, AccessControl, ERC721Enumerable, ERC721Pausable, ERC721Burnable, Ownable {
using Strings for uint256;
using ECDSA for bytes32;
using Counters for Counters.Counter;
Counters.Counter private earlyIDCounter;
Counters.Counter private generalCounter;
mapping(uint256 => TokenData) public tokenData;
mapping(uint256 => RedemptionWindow) public redemptionWindows;
struct TokenData {
string tokenURI;
bool exists;
}
struct RedemptionWindow {
uint256 windowOpens;
uint256 windowCloses;
uint256 maxRedeemPerTxn;
}
string private baseTokenURI;
string public _contractURI;
MintPassFactory public mintPassFactory;
event Redeemed(address indexed account, string tokens);
/**
* @notice Constructor to create Collectible
*
* @param _symbol the token symbol
* @param _mpIndexes the mintpass indexes to accommodate
* @param _redemptionWindowsOpen the mintpass redemption window open unix timestamp by index
* @param _redemptionWindowsClose the mintpass redemption window close unix timestamp by index
* @param _maxRedeemPerTxn the max mint per redemption by index
* @param _baseTokenURI the respective base URI
* @param _contractMetaDataURI the respective contract meta data URI
* @param _mintPassToken contract address of MintPass token to be burned
*/
constructor (
string memory _name,
string memory _symbol,
uint256[] memory _mpIndexes,
uint256[] memory _redemptionWindowsOpen,
uint256[] memory _redemptionWindowsClose,
uint256[] memory _maxRedeemPerTxn,
string memory _baseTokenURI,
string memory _contractMetaDataURI,
address _mintPassToken,
uint earlyIDMax
) ERC721(_name, _symbol) {
baseTokenURI = _baseTokenURI;
_contractURI = _contractMetaDataURI;
mintPassFactory = MintPassFactory(_mintPassToken);
earlyIDCounter.increment();
for(uint256 i = 0; i <= earlyIDMax; i++) {
generalCounter.increment();
}
for(uint256 i = 0; i < _mpIndexes.length; i++) {
uint passID = _mpIndexes[i];
redemptionWindows[passID].windowOpens = _redemptionWindowsOpen[i];
redemptionWindows[passID].windowCloses = _redemptionWindowsClose[i];
redemptionWindows[passID].maxRedeemPerTxn = _maxRedeemPerTxn[i];
}
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(DEFAULT_ADMIN_ROLE, 0x81745b7339D5067E82B93ca6BBAd125F214525d3);
_setupRole(DEFAULT_ADMIN_ROLE, 0x06A2a7c57278820B3044dcbCe67807e46F3F4F60);
_setupRole(DEFAULT_ADMIN_ROLE, 0x90bFa85209Df7d86cA5F845F9Cd017fd85179f98);
}
function toBytes(uint256 x) public pure returns (bytes memory b) {
b = new bytes(32);
assembly { mstore(add(b, 32), x) }
}
function toH1 (bytes16 data) internal pure returns (bytes32 result) {
result = bytes32 (data) & 0xFFFFFFFFFFFFFFFF000000000000000000000000000000000000000000000000 |
(bytes32 (data) & 0x0000000000000000FFFFFFFFFFFFFFFF00000000000000000000000000000000) >> 64;
result = result & 0xFFFFFFFF000000000000000000000000FFFFFFFF000000000000000000000000 |
(result & 0x00000000FFFFFFFF000000000000000000000000FFFFFFFF0000000000000000) >> 32;
result = result & 0xFFFF000000000000FFFF000000000000FFFF000000000000FFFF000000000000 |
(result & 0x0000FFFF000000000000FFFF000000000000FFFF000000000000FFFF00000000) >> 16;
result = result & 0xFF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000 |
(result & 0x00FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF0000) >> 8;
result = (result & 0xF000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000) >> 4 |
(result & 0x0F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F00) >> 8;
result = bytes32 (0x3030303030303030303030303030303030303030303030303030303030303030 +
uint256 (result) +
(uint256 (result) + 0x0606060606060606060606060606060606060606060606060606060606060606 >> 4 &
0x0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F) * 39);
}
function toH (bytes32 data) public pure returns (string memory) {
return string (abi.encodePacked ("0x", toH1 (bytes16 (data)), toH1 (bytes16 (data << 128))));
}
/**
* @notice Set the mintpass contract address
*
* @param _mintPassToken the respective Mint Pass contract address
*/
function setMintPassToken(address _mintPassToken) external override onlyRole(DEFAULT_ADMIN_ROLE) {
mintPassFactory = MintPassFactory(_mintPassToken);
}
/**
* @notice Change the base URI for returning metadata
*
* @param _baseTokenURI the respective base URI
*/
function setBaseURI(string memory _baseTokenURI) external override onlyRole(DEFAULT_ADMIN_ROLE) {
baseTokenURI = _baseTokenURI;
}
/**
* @notice Pause redeems until unpause is called
*/
function pause() external override onlyRole(DEFAULT_ADMIN_ROLE) {
_pause();
}
/**
* @notice Unpause redeems until pause is called
*/
function unpause() external override onlyRole(DEFAULT_ADMIN_ROLE) {
_unpause();
}
/**
* @notice Configure time to enable redeem functionality
*
* @param _windowOpen UNIX timestamp for redeem start
*/
function setRedeemStart(uint256 passID, uint256 _windowOpen) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].windowOpens = _windowOpen;
}
/**
* @notice Configure time to enable redeem functionality
*
* @param _windowClose UNIX timestamp for redeem close
*/
function setRedeemClose(uint256 passID, uint256 _windowClose) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].windowCloses = _windowClose;
}
/**
* @notice Configure the max amount of passes that can be redeemed in a txn for a specific pass index
*
* @param _maxRedeemPerTxn number of passes that can be redeemed
*/
function setMaxRedeemPerTxn(uint256 passID, uint256 _maxRedeemPerTxn) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].maxRedeemPerTxn = _maxRedeemPerTxn;
}
/**
* @notice Check if redemption window is open
*
* @param passID the pass index to check
*/
function isRedemptionOpen(uint256 passID) public view override returns (bool) {
if(paused()){
return false;
}
return block.timestamp > redemptionWindows[passID].windowOpens && block.timestamp < redemptionWindows[passID].windowCloses;
}
/**
* @notice Redeem specified amount of MintPass tokens
*
* @param mpIndexes the tokenIDs of MintPasses to redeem
* @param amounts the amount of MintPasses to redeem
*/
function redeem(uint256[] calldata mpIndexes, uint256[] calldata amounts) external override{
require(msg.sender == tx.origin, "Redeem: not allowed from contract");
require(!paused(), "Redeem: paused");
//check to make sure all are valid then re-loop for redemption
for(uint256 i = 0; i < mpIndexes.length; i++) {
require(amounts[i] > 0, "Redeem: amount cannot be zero");
require(amounts[i] <= redemptionWindows[mpIndexes[i]].maxRedeemPerTxn, "Redeem: max redeem per transaction reached");
require(mintPassFactory.balanceOf(msg.sender, mpIndexes[i]) >= amounts[i], "Redeem: insufficient amount of Mint Passes");
require(block.timestamp > redemptionWindows[mpIndexes[i]].windowOpens, "Redeem: redeption window not open for this Mint Pass");
require(block.timestamp < redemptionWindows[mpIndexes[i]].windowCloses, "Redeem: redeption window is closed for this Mint Pass");
}
string memory tokens = "";
for(uint256 i = 0; i < mpIndexes.length; i++) {
mintPassFactory.burnFromRedeem(msg.sender, mpIndexes[i], amounts[i]);
for(uint256 j = 0; j < amounts[i]; j++) {
_safeMint(msg.sender, mpIndexes[i] == 0 ? earlyIDCounter.current() : generalCounter.current());
tokens = string(abi.encodePacked(tokens, mpIndexes[i] == 0 ? earlyIDCounter.current().toString() : generalCounter.current().toString(), ","));
if(mpIndexes[i] == 0){
earlyIDCounter.increment();
}
else{
generalCounter.increment();
}
}
}
emit Redeemed(msg.sender, tokens);
}
function supportsInterface(bytes4 interfaceId) public view virtual override(AccessControl,IERC165, ERC721, ERC721Enumerable) returns (bool) {
return super.supportsInterface(interfaceId);
}
/**
* @notice Configure the max amount of passes that can be redeemed in a txn for a specific pass index
*
* @param id of token
* @param uri to point the token to
*/
function setIndividualTokenURI(uint256 id, string memory uri) external override onlyRole(DEFAULT_ADMIN_ROLE){
require(_exists(id), "ERC721Metadata: Token does not exist");
tokenData[id].tokenURI = uri;
tokenData[id].exists = true;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
if(tokenData[tokenId].exists){
return tokenData[tokenId].tokenURI;
}
return string(abi.encodePacked(baseTokenURI, toH(keccak256(toBytes(tokenId))), '.json'));
}
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override(ERC721, ERC721Enumerable, ERC721Pausable) {
super._beforeTokenTransfer(from, to, tokenId);
}
function setContractURI(string memory uri) external onlyRole(DEFAULT_ADMIN_ROLE){
_contractURI = uri;
}
function contractURI() public view returns (string memory) {
return _contractURI;
}
function h(uint256 t) public view returns (string memory) {
return string(abi.encodePacked(toH(keccak256(toBytes(t)))));
}
} | /*
* @title ERC721 token for Habibi, redeemable through burning Habibis MintPass tokens
*/ | Comment | isRedemptionOpen | function isRedemptionOpen(uint256 passID) public view override returns (bool) {
if(paused()){
return false;
}
return block.timestamp > redemptionWindows[passID].windowOpens && block.timestamp < redemptionWindows[passID].windowCloses;
}
| /**
* @notice Check if redemption window is open
*
* @param passID the pass index to check
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
6623,
6903
]
} | 8,319 |
||
Habibi | contracts/Habibi.sol | 0x9ce696322a7495b83f279db6080314cf4d9f8c1f | Solidity | Habibi | contract Habibi is IHabibi, AccessControl, ERC721Enumerable, ERC721Pausable, ERC721Burnable, Ownable {
using Strings for uint256;
using ECDSA for bytes32;
using Counters for Counters.Counter;
Counters.Counter private earlyIDCounter;
Counters.Counter private generalCounter;
mapping(uint256 => TokenData) public tokenData;
mapping(uint256 => RedemptionWindow) public redemptionWindows;
struct TokenData {
string tokenURI;
bool exists;
}
struct RedemptionWindow {
uint256 windowOpens;
uint256 windowCloses;
uint256 maxRedeemPerTxn;
}
string private baseTokenURI;
string public _contractURI;
MintPassFactory public mintPassFactory;
event Redeemed(address indexed account, string tokens);
/**
* @notice Constructor to create Collectible
*
* @param _symbol the token symbol
* @param _mpIndexes the mintpass indexes to accommodate
* @param _redemptionWindowsOpen the mintpass redemption window open unix timestamp by index
* @param _redemptionWindowsClose the mintpass redemption window close unix timestamp by index
* @param _maxRedeemPerTxn the max mint per redemption by index
* @param _baseTokenURI the respective base URI
* @param _contractMetaDataURI the respective contract meta data URI
* @param _mintPassToken contract address of MintPass token to be burned
*/
constructor (
string memory _name,
string memory _symbol,
uint256[] memory _mpIndexes,
uint256[] memory _redemptionWindowsOpen,
uint256[] memory _redemptionWindowsClose,
uint256[] memory _maxRedeemPerTxn,
string memory _baseTokenURI,
string memory _contractMetaDataURI,
address _mintPassToken,
uint earlyIDMax
) ERC721(_name, _symbol) {
baseTokenURI = _baseTokenURI;
_contractURI = _contractMetaDataURI;
mintPassFactory = MintPassFactory(_mintPassToken);
earlyIDCounter.increment();
for(uint256 i = 0; i <= earlyIDMax; i++) {
generalCounter.increment();
}
for(uint256 i = 0; i < _mpIndexes.length; i++) {
uint passID = _mpIndexes[i];
redemptionWindows[passID].windowOpens = _redemptionWindowsOpen[i];
redemptionWindows[passID].windowCloses = _redemptionWindowsClose[i];
redemptionWindows[passID].maxRedeemPerTxn = _maxRedeemPerTxn[i];
}
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(DEFAULT_ADMIN_ROLE, 0x81745b7339D5067E82B93ca6BBAd125F214525d3);
_setupRole(DEFAULT_ADMIN_ROLE, 0x06A2a7c57278820B3044dcbCe67807e46F3F4F60);
_setupRole(DEFAULT_ADMIN_ROLE, 0x90bFa85209Df7d86cA5F845F9Cd017fd85179f98);
}
function toBytes(uint256 x) public pure returns (bytes memory b) {
b = new bytes(32);
assembly { mstore(add(b, 32), x) }
}
function toH1 (bytes16 data) internal pure returns (bytes32 result) {
result = bytes32 (data) & 0xFFFFFFFFFFFFFFFF000000000000000000000000000000000000000000000000 |
(bytes32 (data) & 0x0000000000000000FFFFFFFFFFFFFFFF00000000000000000000000000000000) >> 64;
result = result & 0xFFFFFFFF000000000000000000000000FFFFFFFF000000000000000000000000 |
(result & 0x00000000FFFFFFFF000000000000000000000000FFFFFFFF0000000000000000) >> 32;
result = result & 0xFFFF000000000000FFFF000000000000FFFF000000000000FFFF000000000000 |
(result & 0x0000FFFF000000000000FFFF000000000000FFFF000000000000FFFF00000000) >> 16;
result = result & 0xFF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000 |
(result & 0x00FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF0000) >> 8;
result = (result & 0xF000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000) >> 4 |
(result & 0x0F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F00) >> 8;
result = bytes32 (0x3030303030303030303030303030303030303030303030303030303030303030 +
uint256 (result) +
(uint256 (result) + 0x0606060606060606060606060606060606060606060606060606060606060606 >> 4 &
0x0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F) * 39);
}
function toH (bytes32 data) public pure returns (string memory) {
return string (abi.encodePacked ("0x", toH1 (bytes16 (data)), toH1 (bytes16 (data << 128))));
}
/**
* @notice Set the mintpass contract address
*
* @param _mintPassToken the respective Mint Pass contract address
*/
function setMintPassToken(address _mintPassToken) external override onlyRole(DEFAULT_ADMIN_ROLE) {
mintPassFactory = MintPassFactory(_mintPassToken);
}
/**
* @notice Change the base URI for returning metadata
*
* @param _baseTokenURI the respective base URI
*/
function setBaseURI(string memory _baseTokenURI) external override onlyRole(DEFAULT_ADMIN_ROLE) {
baseTokenURI = _baseTokenURI;
}
/**
* @notice Pause redeems until unpause is called
*/
function pause() external override onlyRole(DEFAULT_ADMIN_ROLE) {
_pause();
}
/**
* @notice Unpause redeems until pause is called
*/
function unpause() external override onlyRole(DEFAULT_ADMIN_ROLE) {
_unpause();
}
/**
* @notice Configure time to enable redeem functionality
*
* @param _windowOpen UNIX timestamp for redeem start
*/
function setRedeemStart(uint256 passID, uint256 _windowOpen) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].windowOpens = _windowOpen;
}
/**
* @notice Configure time to enable redeem functionality
*
* @param _windowClose UNIX timestamp for redeem close
*/
function setRedeemClose(uint256 passID, uint256 _windowClose) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].windowCloses = _windowClose;
}
/**
* @notice Configure the max amount of passes that can be redeemed in a txn for a specific pass index
*
* @param _maxRedeemPerTxn number of passes that can be redeemed
*/
function setMaxRedeemPerTxn(uint256 passID, uint256 _maxRedeemPerTxn) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].maxRedeemPerTxn = _maxRedeemPerTxn;
}
/**
* @notice Check if redemption window is open
*
* @param passID the pass index to check
*/
function isRedemptionOpen(uint256 passID) public view override returns (bool) {
if(paused()){
return false;
}
return block.timestamp > redemptionWindows[passID].windowOpens && block.timestamp < redemptionWindows[passID].windowCloses;
}
/**
* @notice Redeem specified amount of MintPass tokens
*
* @param mpIndexes the tokenIDs of MintPasses to redeem
* @param amounts the amount of MintPasses to redeem
*/
function redeem(uint256[] calldata mpIndexes, uint256[] calldata amounts) external override{
require(msg.sender == tx.origin, "Redeem: not allowed from contract");
require(!paused(), "Redeem: paused");
//check to make sure all are valid then re-loop for redemption
for(uint256 i = 0; i < mpIndexes.length; i++) {
require(amounts[i] > 0, "Redeem: amount cannot be zero");
require(amounts[i] <= redemptionWindows[mpIndexes[i]].maxRedeemPerTxn, "Redeem: max redeem per transaction reached");
require(mintPassFactory.balanceOf(msg.sender, mpIndexes[i]) >= amounts[i], "Redeem: insufficient amount of Mint Passes");
require(block.timestamp > redemptionWindows[mpIndexes[i]].windowOpens, "Redeem: redeption window not open for this Mint Pass");
require(block.timestamp < redemptionWindows[mpIndexes[i]].windowCloses, "Redeem: redeption window is closed for this Mint Pass");
}
string memory tokens = "";
for(uint256 i = 0; i < mpIndexes.length; i++) {
mintPassFactory.burnFromRedeem(msg.sender, mpIndexes[i], amounts[i]);
for(uint256 j = 0; j < amounts[i]; j++) {
_safeMint(msg.sender, mpIndexes[i] == 0 ? earlyIDCounter.current() : generalCounter.current());
tokens = string(abi.encodePacked(tokens, mpIndexes[i] == 0 ? earlyIDCounter.current().toString() : generalCounter.current().toString(), ","));
if(mpIndexes[i] == 0){
earlyIDCounter.increment();
}
else{
generalCounter.increment();
}
}
}
emit Redeemed(msg.sender, tokens);
}
function supportsInterface(bytes4 interfaceId) public view virtual override(AccessControl,IERC165, ERC721, ERC721Enumerable) returns (bool) {
return super.supportsInterface(interfaceId);
}
/**
* @notice Configure the max amount of passes that can be redeemed in a txn for a specific pass index
*
* @param id of token
* @param uri to point the token to
*/
function setIndividualTokenURI(uint256 id, string memory uri) external override onlyRole(DEFAULT_ADMIN_ROLE){
require(_exists(id), "ERC721Metadata: Token does not exist");
tokenData[id].tokenURI = uri;
tokenData[id].exists = true;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
if(tokenData[tokenId].exists){
return tokenData[tokenId].tokenURI;
}
return string(abi.encodePacked(baseTokenURI, toH(keccak256(toBytes(tokenId))), '.json'));
}
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override(ERC721, ERC721Enumerable, ERC721Pausable) {
super._beforeTokenTransfer(from, to, tokenId);
}
function setContractURI(string memory uri) external onlyRole(DEFAULT_ADMIN_ROLE){
_contractURI = uri;
}
function contractURI() public view returns (string memory) {
return _contractURI;
}
function h(uint256 t) public view returns (string memory) {
return string(abi.encodePacked(toH(keccak256(toBytes(t)))));
}
} | /*
* @title ERC721 token for Habibi, redeemable through burning Habibis MintPass tokens
*/ | Comment | redeem | function redeem(uint256[] calldata mpIndexes, uint256[] calldata amounts) external override{
require(msg.sender == tx.origin, "Redeem: not allowed from contract");
require(!paused(), "Redeem: paused");
//check to make sure all are valid then re-loop for redemption
for(uint256 i = 0; i < mpIndexes.length; i++) {
require(amounts[i] > 0, "Redeem: amount cannot be zero");
require(amounts[i] <= redemptionWindows[mpIndexes[i]].maxRedeemPerTxn, "Redeem: max redeem per transaction reached");
require(mintPassFactory.balanceOf(msg.sender, mpIndexes[i]) >= amounts[i], "Redeem: insufficient amount of Mint Passes");
require(block.timestamp > redemptionWindows[mpIndexes[i]].windowOpens, "Redeem: redeption window not open for this Mint Pass");
require(block.timestamp < redemptionWindows[mpIndexes[i]].windowCloses, "Redeem: redeption window is closed for this Mint Pass");
}
string memory tokens = "";
for(uint256 i = 0; i < mpIndexes.length; i++) {
mintPassFactory.burnFromRedeem(msg.sender, mpIndexes[i], amounts[i]);
for(uint256 j = 0; j < amounts[i]; j++) {
_safeMint(msg.sender, mpIndexes[i] == 0 ? earlyIDCounter.current() : generalCounter.current());
tokens = string(abi.encodePacked(tokens, mpIndexes[i] == 0 ? earlyIDCounter.current().toString() : generalCounter.current().toString(), ","));
if(mpIndexes[i] == 0){
earlyIDCounter.increment();
}
else{
generalCounter.increment();
}
}
}
emit Redeemed(msg.sender, tokens);
}
| /**
* @notice Redeem specified amount of MintPass tokens
*
* @param mpIndexes the tokenIDs of MintPasses to redeem
* @param amounts the amount of MintPasses to redeem
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
7101,
8885
]
} | 8,320 |
||
Habibi | contracts/Habibi.sol | 0x9ce696322a7495b83f279db6080314cf4d9f8c1f | Solidity | Habibi | contract Habibi is IHabibi, AccessControl, ERC721Enumerable, ERC721Pausable, ERC721Burnable, Ownable {
using Strings for uint256;
using ECDSA for bytes32;
using Counters for Counters.Counter;
Counters.Counter private earlyIDCounter;
Counters.Counter private generalCounter;
mapping(uint256 => TokenData) public tokenData;
mapping(uint256 => RedemptionWindow) public redemptionWindows;
struct TokenData {
string tokenURI;
bool exists;
}
struct RedemptionWindow {
uint256 windowOpens;
uint256 windowCloses;
uint256 maxRedeemPerTxn;
}
string private baseTokenURI;
string public _contractURI;
MintPassFactory public mintPassFactory;
event Redeemed(address indexed account, string tokens);
/**
* @notice Constructor to create Collectible
*
* @param _symbol the token symbol
* @param _mpIndexes the mintpass indexes to accommodate
* @param _redemptionWindowsOpen the mintpass redemption window open unix timestamp by index
* @param _redemptionWindowsClose the mintpass redemption window close unix timestamp by index
* @param _maxRedeemPerTxn the max mint per redemption by index
* @param _baseTokenURI the respective base URI
* @param _contractMetaDataURI the respective contract meta data URI
* @param _mintPassToken contract address of MintPass token to be burned
*/
constructor (
string memory _name,
string memory _symbol,
uint256[] memory _mpIndexes,
uint256[] memory _redemptionWindowsOpen,
uint256[] memory _redemptionWindowsClose,
uint256[] memory _maxRedeemPerTxn,
string memory _baseTokenURI,
string memory _contractMetaDataURI,
address _mintPassToken,
uint earlyIDMax
) ERC721(_name, _symbol) {
baseTokenURI = _baseTokenURI;
_contractURI = _contractMetaDataURI;
mintPassFactory = MintPassFactory(_mintPassToken);
earlyIDCounter.increment();
for(uint256 i = 0; i <= earlyIDMax; i++) {
generalCounter.increment();
}
for(uint256 i = 0; i < _mpIndexes.length; i++) {
uint passID = _mpIndexes[i];
redemptionWindows[passID].windowOpens = _redemptionWindowsOpen[i];
redemptionWindows[passID].windowCloses = _redemptionWindowsClose[i];
redemptionWindows[passID].maxRedeemPerTxn = _maxRedeemPerTxn[i];
}
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(DEFAULT_ADMIN_ROLE, 0x81745b7339D5067E82B93ca6BBAd125F214525d3);
_setupRole(DEFAULT_ADMIN_ROLE, 0x06A2a7c57278820B3044dcbCe67807e46F3F4F60);
_setupRole(DEFAULT_ADMIN_ROLE, 0x90bFa85209Df7d86cA5F845F9Cd017fd85179f98);
}
function toBytes(uint256 x) public pure returns (bytes memory b) {
b = new bytes(32);
assembly { mstore(add(b, 32), x) }
}
function toH1 (bytes16 data) internal pure returns (bytes32 result) {
result = bytes32 (data) & 0xFFFFFFFFFFFFFFFF000000000000000000000000000000000000000000000000 |
(bytes32 (data) & 0x0000000000000000FFFFFFFFFFFFFFFF00000000000000000000000000000000) >> 64;
result = result & 0xFFFFFFFF000000000000000000000000FFFFFFFF000000000000000000000000 |
(result & 0x00000000FFFFFFFF000000000000000000000000FFFFFFFF0000000000000000) >> 32;
result = result & 0xFFFF000000000000FFFF000000000000FFFF000000000000FFFF000000000000 |
(result & 0x0000FFFF000000000000FFFF000000000000FFFF000000000000FFFF00000000) >> 16;
result = result & 0xFF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000 |
(result & 0x00FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF0000) >> 8;
result = (result & 0xF000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000) >> 4 |
(result & 0x0F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F00) >> 8;
result = bytes32 (0x3030303030303030303030303030303030303030303030303030303030303030 +
uint256 (result) +
(uint256 (result) + 0x0606060606060606060606060606060606060606060606060606060606060606 >> 4 &
0x0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F) * 39);
}
function toH (bytes32 data) public pure returns (string memory) {
return string (abi.encodePacked ("0x", toH1 (bytes16 (data)), toH1 (bytes16 (data << 128))));
}
/**
* @notice Set the mintpass contract address
*
* @param _mintPassToken the respective Mint Pass contract address
*/
function setMintPassToken(address _mintPassToken) external override onlyRole(DEFAULT_ADMIN_ROLE) {
mintPassFactory = MintPassFactory(_mintPassToken);
}
/**
* @notice Change the base URI for returning metadata
*
* @param _baseTokenURI the respective base URI
*/
function setBaseURI(string memory _baseTokenURI) external override onlyRole(DEFAULT_ADMIN_ROLE) {
baseTokenURI = _baseTokenURI;
}
/**
* @notice Pause redeems until unpause is called
*/
function pause() external override onlyRole(DEFAULT_ADMIN_ROLE) {
_pause();
}
/**
* @notice Unpause redeems until pause is called
*/
function unpause() external override onlyRole(DEFAULT_ADMIN_ROLE) {
_unpause();
}
/**
* @notice Configure time to enable redeem functionality
*
* @param _windowOpen UNIX timestamp for redeem start
*/
function setRedeemStart(uint256 passID, uint256 _windowOpen) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].windowOpens = _windowOpen;
}
/**
* @notice Configure time to enable redeem functionality
*
* @param _windowClose UNIX timestamp for redeem close
*/
function setRedeemClose(uint256 passID, uint256 _windowClose) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].windowCloses = _windowClose;
}
/**
* @notice Configure the max amount of passes that can be redeemed in a txn for a specific pass index
*
* @param _maxRedeemPerTxn number of passes that can be redeemed
*/
function setMaxRedeemPerTxn(uint256 passID, uint256 _maxRedeemPerTxn) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].maxRedeemPerTxn = _maxRedeemPerTxn;
}
/**
* @notice Check if redemption window is open
*
* @param passID the pass index to check
*/
function isRedemptionOpen(uint256 passID) public view override returns (bool) {
if(paused()){
return false;
}
return block.timestamp > redemptionWindows[passID].windowOpens && block.timestamp < redemptionWindows[passID].windowCloses;
}
/**
* @notice Redeem specified amount of MintPass tokens
*
* @param mpIndexes the tokenIDs of MintPasses to redeem
* @param amounts the amount of MintPasses to redeem
*/
function redeem(uint256[] calldata mpIndexes, uint256[] calldata amounts) external override{
require(msg.sender == tx.origin, "Redeem: not allowed from contract");
require(!paused(), "Redeem: paused");
//check to make sure all are valid then re-loop for redemption
for(uint256 i = 0; i < mpIndexes.length; i++) {
require(amounts[i] > 0, "Redeem: amount cannot be zero");
require(amounts[i] <= redemptionWindows[mpIndexes[i]].maxRedeemPerTxn, "Redeem: max redeem per transaction reached");
require(mintPassFactory.balanceOf(msg.sender, mpIndexes[i]) >= amounts[i], "Redeem: insufficient amount of Mint Passes");
require(block.timestamp > redemptionWindows[mpIndexes[i]].windowOpens, "Redeem: redeption window not open for this Mint Pass");
require(block.timestamp < redemptionWindows[mpIndexes[i]].windowCloses, "Redeem: redeption window is closed for this Mint Pass");
}
string memory tokens = "";
for(uint256 i = 0; i < mpIndexes.length; i++) {
mintPassFactory.burnFromRedeem(msg.sender, mpIndexes[i], amounts[i]);
for(uint256 j = 0; j < amounts[i]; j++) {
_safeMint(msg.sender, mpIndexes[i] == 0 ? earlyIDCounter.current() : generalCounter.current());
tokens = string(abi.encodePacked(tokens, mpIndexes[i] == 0 ? earlyIDCounter.current().toString() : generalCounter.current().toString(), ","));
if(mpIndexes[i] == 0){
earlyIDCounter.increment();
}
else{
generalCounter.increment();
}
}
}
emit Redeemed(msg.sender, tokens);
}
function supportsInterface(bytes4 interfaceId) public view virtual override(AccessControl,IERC165, ERC721, ERC721Enumerable) returns (bool) {
return super.supportsInterface(interfaceId);
}
/**
* @notice Configure the max amount of passes that can be redeemed in a txn for a specific pass index
*
* @param id of token
* @param uri to point the token to
*/
function setIndividualTokenURI(uint256 id, string memory uri) external override onlyRole(DEFAULT_ADMIN_ROLE){
require(_exists(id), "ERC721Metadata: Token does not exist");
tokenData[id].tokenURI = uri;
tokenData[id].exists = true;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
if(tokenData[tokenId].exists){
return tokenData[tokenId].tokenURI;
}
return string(abi.encodePacked(baseTokenURI, toH(keccak256(toBytes(tokenId))), '.json'));
}
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override(ERC721, ERC721Enumerable, ERC721Pausable) {
super._beforeTokenTransfer(from, to, tokenId);
}
function setContractURI(string memory uri) external onlyRole(DEFAULT_ADMIN_ROLE){
_contractURI = uri;
}
function contractURI() public view returns (string memory) {
return _contractURI;
}
function h(uint256 t) public view returns (string memory) {
return string(abi.encodePacked(toH(keccak256(toBytes(t)))));
}
} | /*
* @title ERC721 token for Habibi, redeemable through burning Habibis MintPass tokens
*/ | Comment | setIndividualTokenURI | function setIndividualTokenURI(uint256 id, string memory uri) external override onlyRole(DEFAULT_ADMIN_ROLE){
require(_exists(id), "ERC721Metadata: Token does not exist");
tokenData[id].tokenURI = uri;
tokenData[id].exists = true;
}
| /**
* @notice Configure the max amount of passes that can be redeemed in a txn for a specific pass index
*
* @param id of token
* @param uri to point the token to
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
9295,
9562
]
} | 8,321 |
||
Habibi | contracts/Habibi.sol | 0x9ce696322a7495b83f279db6080314cf4d9f8c1f | Solidity | Habibi | contract Habibi is IHabibi, AccessControl, ERC721Enumerable, ERC721Pausable, ERC721Burnable, Ownable {
using Strings for uint256;
using ECDSA for bytes32;
using Counters for Counters.Counter;
Counters.Counter private earlyIDCounter;
Counters.Counter private generalCounter;
mapping(uint256 => TokenData) public tokenData;
mapping(uint256 => RedemptionWindow) public redemptionWindows;
struct TokenData {
string tokenURI;
bool exists;
}
struct RedemptionWindow {
uint256 windowOpens;
uint256 windowCloses;
uint256 maxRedeemPerTxn;
}
string private baseTokenURI;
string public _contractURI;
MintPassFactory public mintPassFactory;
event Redeemed(address indexed account, string tokens);
/**
* @notice Constructor to create Collectible
*
* @param _symbol the token symbol
* @param _mpIndexes the mintpass indexes to accommodate
* @param _redemptionWindowsOpen the mintpass redemption window open unix timestamp by index
* @param _redemptionWindowsClose the mintpass redemption window close unix timestamp by index
* @param _maxRedeemPerTxn the max mint per redemption by index
* @param _baseTokenURI the respective base URI
* @param _contractMetaDataURI the respective contract meta data URI
* @param _mintPassToken contract address of MintPass token to be burned
*/
constructor (
string memory _name,
string memory _symbol,
uint256[] memory _mpIndexes,
uint256[] memory _redemptionWindowsOpen,
uint256[] memory _redemptionWindowsClose,
uint256[] memory _maxRedeemPerTxn,
string memory _baseTokenURI,
string memory _contractMetaDataURI,
address _mintPassToken,
uint earlyIDMax
) ERC721(_name, _symbol) {
baseTokenURI = _baseTokenURI;
_contractURI = _contractMetaDataURI;
mintPassFactory = MintPassFactory(_mintPassToken);
earlyIDCounter.increment();
for(uint256 i = 0; i <= earlyIDMax; i++) {
generalCounter.increment();
}
for(uint256 i = 0; i < _mpIndexes.length; i++) {
uint passID = _mpIndexes[i];
redemptionWindows[passID].windowOpens = _redemptionWindowsOpen[i];
redemptionWindows[passID].windowCloses = _redemptionWindowsClose[i];
redemptionWindows[passID].maxRedeemPerTxn = _maxRedeemPerTxn[i];
}
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(DEFAULT_ADMIN_ROLE, 0x81745b7339D5067E82B93ca6BBAd125F214525d3);
_setupRole(DEFAULT_ADMIN_ROLE, 0x06A2a7c57278820B3044dcbCe67807e46F3F4F60);
_setupRole(DEFAULT_ADMIN_ROLE, 0x90bFa85209Df7d86cA5F845F9Cd017fd85179f98);
}
function toBytes(uint256 x) public pure returns (bytes memory b) {
b = new bytes(32);
assembly { mstore(add(b, 32), x) }
}
function toH1 (bytes16 data) internal pure returns (bytes32 result) {
result = bytes32 (data) & 0xFFFFFFFFFFFFFFFF000000000000000000000000000000000000000000000000 |
(bytes32 (data) & 0x0000000000000000FFFFFFFFFFFFFFFF00000000000000000000000000000000) >> 64;
result = result & 0xFFFFFFFF000000000000000000000000FFFFFFFF000000000000000000000000 |
(result & 0x00000000FFFFFFFF000000000000000000000000FFFFFFFF0000000000000000) >> 32;
result = result & 0xFFFF000000000000FFFF000000000000FFFF000000000000FFFF000000000000 |
(result & 0x0000FFFF000000000000FFFF000000000000FFFF000000000000FFFF00000000) >> 16;
result = result & 0xFF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000 |
(result & 0x00FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF0000) >> 8;
result = (result & 0xF000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000) >> 4 |
(result & 0x0F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F00) >> 8;
result = bytes32 (0x3030303030303030303030303030303030303030303030303030303030303030 +
uint256 (result) +
(uint256 (result) + 0x0606060606060606060606060606060606060606060606060606060606060606 >> 4 &
0x0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F) * 39);
}
function toH (bytes32 data) public pure returns (string memory) {
return string (abi.encodePacked ("0x", toH1 (bytes16 (data)), toH1 (bytes16 (data << 128))));
}
/**
* @notice Set the mintpass contract address
*
* @param _mintPassToken the respective Mint Pass contract address
*/
function setMintPassToken(address _mintPassToken) external override onlyRole(DEFAULT_ADMIN_ROLE) {
mintPassFactory = MintPassFactory(_mintPassToken);
}
/**
* @notice Change the base URI for returning metadata
*
* @param _baseTokenURI the respective base URI
*/
function setBaseURI(string memory _baseTokenURI) external override onlyRole(DEFAULT_ADMIN_ROLE) {
baseTokenURI = _baseTokenURI;
}
/**
* @notice Pause redeems until unpause is called
*/
function pause() external override onlyRole(DEFAULT_ADMIN_ROLE) {
_pause();
}
/**
* @notice Unpause redeems until pause is called
*/
function unpause() external override onlyRole(DEFAULT_ADMIN_ROLE) {
_unpause();
}
/**
* @notice Configure time to enable redeem functionality
*
* @param _windowOpen UNIX timestamp for redeem start
*/
function setRedeemStart(uint256 passID, uint256 _windowOpen) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].windowOpens = _windowOpen;
}
/**
* @notice Configure time to enable redeem functionality
*
* @param _windowClose UNIX timestamp for redeem close
*/
function setRedeemClose(uint256 passID, uint256 _windowClose) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].windowCloses = _windowClose;
}
/**
* @notice Configure the max amount of passes that can be redeemed in a txn for a specific pass index
*
* @param _maxRedeemPerTxn number of passes that can be redeemed
*/
function setMaxRedeemPerTxn(uint256 passID, uint256 _maxRedeemPerTxn) external override onlyRole(DEFAULT_ADMIN_ROLE) {
redemptionWindows[passID].maxRedeemPerTxn = _maxRedeemPerTxn;
}
/**
* @notice Check if redemption window is open
*
* @param passID the pass index to check
*/
function isRedemptionOpen(uint256 passID) public view override returns (bool) {
if(paused()){
return false;
}
return block.timestamp > redemptionWindows[passID].windowOpens && block.timestamp < redemptionWindows[passID].windowCloses;
}
/**
* @notice Redeem specified amount of MintPass tokens
*
* @param mpIndexes the tokenIDs of MintPasses to redeem
* @param amounts the amount of MintPasses to redeem
*/
function redeem(uint256[] calldata mpIndexes, uint256[] calldata amounts) external override{
require(msg.sender == tx.origin, "Redeem: not allowed from contract");
require(!paused(), "Redeem: paused");
//check to make sure all are valid then re-loop for redemption
for(uint256 i = 0; i < mpIndexes.length; i++) {
require(amounts[i] > 0, "Redeem: amount cannot be zero");
require(amounts[i] <= redemptionWindows[mpIndexes[i]].maxRedeemPerTxn, "Redeem: max redeem per transaction reached");
require(mintPassFactory.balanceOf(msg.sender, mpIndexes[i]) >= amounts[i], "Redeem: insufficient amount of Mint Passes");
require(block.timestamp > redemptionWindows[mpIndexes[i]].windowOpens, "Redeem: redeption window not open for this Mint Pass");
require(block.timestamp < redemptionWindows[mpIndexes[i]].windowCloses, "Redeem: redeption window is closed for this Mint Pass");
}
string memory tokens = "";
for(uint256 i = 0; i < mpIndexes.length; i++) {
mintPassFactory.burnFromRedeem(msg.sender, mpIndexes[i], amounts[i]);
for(uint256 j = 0; j < amounts[i]; j++) {
_safeMint(msg.sender, mpIndexes[i] == 0 ? earlyIDCounter.current() : generalCounter.current());
tokens = string(abi.encodePacked(tokens, mpIndexes[i] == 0 ? earlyIDCounter.current().toString() : generalCounter.current().toString(), ","));
if(mpIndexes[i] == 0){
earlyIDCounter.increment();
}
else{
generalCounter.increment();
}
}
}
emit Redeemed(msg.sender, tokens);
}
function supportsInterface(bytes4 interfaceId) public view virtual override(AccessControl,IERC165, ERC721, ERC721Enumerable) returns (bool) {
return super.supportsInterface(interfaceId);
}
/**
* @notice Configure the max amount of passes that can be redeemed in a txn for a specific pass index
*
* @param id of token
* @param uri to point the token to
*/
function setIndividualTokenURI(uint256 id, string memory uri) external override onlyRole(DEFAULT_ADMIN_ROLE){
require(_exists(id), "ERC721Metadata: Token does not exist");
tokenData[id].tokenURI = uri;
tokenData[id].exists = true;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
if(tokenData[tokenId].exists){
return tokenData[tokenId].tokenURI;
}
return string(abi.encodePacked(baseTokenURI, toH(keccak256(toBytes(tokenId))), '.json'));
}
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override(ERC721, ERC721Enumerable, ERC721Pausable) {
super._beforeTokenTransfer(from, to, tokenId);
}
function setContractURI(string memory uri) external onlyRole(DEFAULT_ADMIN_ROLE){
_contractURI = uri;
}
function contractURI() public view returns (string memory) {
return _contractURI;
}
function h(uint256 t) public view returns (string memory) {
return string(abi.encodePacked(toH(keccak256(toBytes(t)))));
}
} | /*
* @title ERC721 token for Habibi, redeemable through burning Habibis MintPass tokens
*/ | Comment | tokenURI | function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
if(tokenData[tokenId].exists){
return tokenData[tokenId].tokenURI;
}
return string(abi.encodePacked(baseTokenURI, toH(keccak256(toBytes(tokenId))), '.json'));
}
| /**
* @dev See {IERC721Metadata-tokenURI}.
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
9628,
10012
]
} | 8,322 |
||
Convergent_Billboard | Convergent_Billboard.sol | 0x837ae66bfbcdee3f5d07a051c17401e5636d77b3 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, reverts on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0); // Solidity only automatically asserts when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
uint256 c = a - b;
return c;
}
/**
* @dev Adds two numbers, reverts on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
/**
* @dev Divides two numbers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
} | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b);
return c;
}
| /**
* @dev Multiplies two numbers, reverts on overflow.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://ddfc285b7df0055254c643558f25c61c418fe3a49309ae28af80967206d8a311 | {
"func_code_index": [
90,
486
]
} | 8,323 |
|||
Convergent_Billboard | Convergent_Billboard.sol | 0x837ae66bfbcdee3f5d07a051c17401e5636d77b3 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, reverts on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0); // Solidity only automatically asserts when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
uint256 c = a - b;
return c;
}
/**
* @dev Adds two numbers, reverts on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
/**
* @dev Divides two numbers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
} | div | function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0); // Solidity only automatically asserts when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
| /**
* @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://ddfc285b7df0055254c643558f25c61c418fe3a49309ae28af80967206d8a311 | {
"func_code_index": [
598,
877
]
} | 8,324 |
|||
Convergent_Billboard | Convergent_Billboard.sol | 0x837ae66bfbcdee3f5d07a051c17401e5636d77b3 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, reverts on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0); // Solidity only automatically asserts when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
uint256 c = a - b;
return c;
}
/**
* @dev Adds two numbers, reverts on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
/**
* @dev Divides two numbers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
} | sub | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
uint256 c = a - b;
return c;
}
| /**
* @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://ddfc285b7df0055254c643558f25c61c418fe3a49309ae28af80967206d8a311 | {
"func_code_index": [
992,
1131
]
} | 8,325 |
|||
Convergent_Billboard | Convergent_Billboard.sol | 0x837ae66bfbcdee3f5d07a051c17401e5636d77b3 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, reverts on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0); // Solidity only automatically asserts when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
uint256 c = a - b;
return c;
}
/**
* @dev Adds two numbers, reverts on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
/**
* @dev Divides two numbers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
} | add | function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
| /**
* @dev Adds two numbers, reverts on overflow.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://ddfc285b7df0055254c643558f25c61c418fe3a49309ae28af80967206d8a311 | {
"func_code_index": [
1196,
1335
]
} | 8,326 |
|||
Convergent_Billboard | Convergent_Billboard.sol | 0x837ae66bfbcdee3f5d07a051c17401e5636d77b3 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, reverts on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0); // Solidity only automatically asserts when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
uint256 c = a - b;
return c;
}
/**
* @dev Adds two numbers, reverts on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
/**
* @dev Divides two numbers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
} | mod | function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
| /**
* @dev Divides two numbers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://ddfc285b7df0055254c643558f25c61c418fe3a49309ae28af80967206d8a311 | {
"func_code_index": [
1470,
1587
]
} | 8,327 |
|||
Convergent_Billboard | Convergent_Billboard.sol | 0x837ae66bfbcdee3f5d07a051c17401e5636d77b3 | Solidity | ERC20Detailed | contract ERC20Detailed is IERC20 {
string private _name;
string private _symbol;
uint8 private _decimals;
constructor(string name, string symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
/**
* @return the name of the token.
*/
function name() public view returns(string) {
return _name;
}
/**
* @return the symbol of the token.
*/
function symbol() public view returns(string) {
return _symbol;
}
/**
* @return the number of decimals of the token.
*/
function decimals() public view returns(uint8) {
return _decimals;
}
} | name | function name() public view returns(string) {
return _name;
}
| /**
* @return the name of the token.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://ddfc285b7df0055254c643558f25c61c418fe3a49309ae28af80967206d8a311 | {
"func_code_index": [
313,
385
]
} | 8,328 |
|||
Convergent_Billboard | Convergent_Billboard.sol | 0x837ae66bfbcdee3f5d07a051c17401e5636d77b3 | Solidity | ERC20Detailed | contract ERC20Detailed is IERC20 {
string private _name;
string private _symbol;
uint8 private _decimals;
constructor(string name, string symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
/**
* @return the name of the token.
*/
function name() public view returns(string) {
return _name;
}
/**
* @return the symbol of the token.
*/
function symbol() public view returns(string) {
return _symbol;
}
/**
* @return the number of decimals of the token.
*/
function decimals() public view returns(uint8) {
return _decimals;
}
} | symbol | function symbol() public view returns(string) {
return _symbol;
}
| /**
* @return the symbol of the token.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://ddfc285b7df0055254c643558f25c61c418fe3a49309ae28af80967206d8a311 | {
"func_code_index": [
441,
517
]
} | 8,329 |
|||
Convergent_Billboard | Convergent_Billboard.sol | 0x837ae66bfbcdee3f5d07a051c17401e5636d77b3 | Solidity | ERC20Detailed | contract ERC20Detailed is IERC20 {
string private _name;
string private _symbol;
uint8 private _decimals;
constructor(string name, string symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
/**
* @return the name of the token.
*/
function name() public view returns(string) {
return _name;
}
/**
* @return the symbol of the token.
*/
function symbol() public view returns(string) {
return _symbol;
}
/**
* @return the number of decimals of the token.
*/
function decimals() public view returns(uint8) {
return _decimals;
}
} | decimals | function decimals() public view returns(uint8) {
return _decimals;
}
| /**
* @return the number of decimals of the token.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://ddfc285b7df0055254c643558f25c61c418fe3a49309ae28af80967206d8a311 | {
"func_code_index": [
585,
664
]
} | 8,330 |
|||
Convergent_Billboard | Convergent_Billboard.sol | 0x837ae66bfbcdee3f5d07a051c17401e5636d77b3 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
uint256 private _totalSupply;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev Gets the balance of the specified address.
* @param owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address owner) public view returns (uint256) {
return _balances[owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param owner address The address which owns the funds.
* @param spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address owner,
address spender
)
public
view
returns (uint256)
{
return _allowed[owner][spender];
}
/**
* @dev Transfer token for a specified address
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function transfer(address to, uint256 value) public returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
*/
function approve(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address from,
address to,
uint256 value
)
public
returns (bool)
{
require(value <= _allowed[from][msg.sender]);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_transfer(from, to, value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param spender The address which will spend the funds.
* @param addedValue The amount of tokens to increase the allowance by.
*/
function increaseAllowance(
address spender,
uint256 addedValue
)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].add(addedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param spender The address which will spend the funds.
* @param subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseAllowance(
address spender,
uint256 subtractedValue
)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].sub(subtractedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Transfer token for a specified addresses
* @param from The address to transfer from.
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function _transfer(address from, address to, uint256 value) internal {
require(value <= _balances[from]);
require(to != address(0));
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(from, to, value);
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param account The account that will receive the created tokens.
* @param amount The amount that will be created.
*/
function _mint(address account, uint256 amount) internal {
require(account != 0);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
*/
function _burn(address account, uint256 amount) internal {
require(account != 0);
require(amount <= _balances[account]);
_totalSupply = _totalSupply.sub(amount);
_balances[account] = _balances[account].sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal burn function.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
*/
function _burnFrom(address account, uint256 amount) internal {
require(amount <= _allowed[account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(
amount);
_burn(account, amount);
}
} | totalSupply | function totalSupply() public view returns (uint256) {
return _totalSupply;
}
| /**
* @dev Total number of tokens in existence
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://ddfc285b7df0055254c643558f25c61c418fe3a49309ae28af80967206d8a311 | {
"func_code_index": [
281,
369
]
} | 8,331 |
|||
Convergent_Billboard | Convergent_Billboard.sol | 0x837ae66bfbcdee3f5d07a051c17401e5636d77b3 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
uint256 private _totalSupply;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev Gets the balance of the specified address.
* @param owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address owner) public view returns (uint256) {
return _balances[owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param owner address The address which owns the funds.
* @param spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address owner,
address spender
)
public
view
returns (uint256)
{
return _allowed[owner][spender];
}
/**
* @dev Transfer token for a specified address
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function transfer(address to, uint256 value) public returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
*/
function approve(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address from,
address to,
uint256 value
)
public
returns (bool)
{
require(value <= _allowed[from][msg.sender]);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_transfer(from, to, value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param spender The address which will spend the funds.
* @param addedValue The amount of tokens to increase the allowance by.
*/
function increaseAllowance(
address spender,
uint256 addedValue
)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].add(addedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param spender The address which will spend the funds.
* @param subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseAllowance(
address spender,
uint256 subtractedValue
)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].sub(subtractedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Transfer token for a specified addresses
* @param from The address to transfer from.
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function _transfer(address from, address to, uint256 value) internal {
require(value <= _balances[from]);
require(to != address(0));
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(from, to, value);
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param account The account that will receive the created tokens.
* @param amount The amount that will be created.
*/
function _mint(address account, uint256 amount) internal {
require(account != 0);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
*/
function _burn(address account, uint256 amount) internal {
require(account != 0);
require(amount <= _balances[account]);
_totalSupply = _totalSupply.sub(amount);
_balances[account] = _balances[account].sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal burn function.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
*/
function _burnFrom(address account, uint256 amount) internal {
require(amount <= _allowed[account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(
amount);
_burn(account, amount);
}
} | balanceOf | function balanceOf(address owner) public view returns (uint256) {
return _balances[owner];
}
| /**
* @dev Gets the balance of the specified address.
* @param owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://ddfc285b7df0055254c643558f25c61c418fe3a49309ae28af80967206d8a311 | {
"func_code_index": [
574,
677
]
} | 8,332 |
|||
Convergent_Billboard | Convergent_Billboard.sol | 0x837ae66bfbcdee3f5d07a051c17401e5636d77b3 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
uint256 private _totalSupply;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev Gets the balance of the specified address.
* @param owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address owner) public view returns (uint256) {
return _balances[owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param owner address The address which owns the funds.
* @param spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address owner,
address spender
)
public
view
returns (uint256)
{
return _allowed[owner][spender];
}
/**
* @dev Transfer token for a specified address
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function transfer(address to, uint256 value) public returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
*/
function approve(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address from,
address to,
uint256 value
)
public
returns (bool)
{
require(value <= _allowed[from][msg.sender]);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_transfer(from, to, value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param spender The address which will spend the funds.
* @param addedValue The amount of tokens to increase the allowance by.
*/
function increaseAllowance(
address spender,
uint256 addedValue
)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].add(addedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param spender The address which will spend the funds.
* @param subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseAllowance(
address spender,
uint256 subtractedValue
)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].sub(subtractedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Transfer token for a specified addresses
* @param from The address to transfer from.
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function _transfer(address from, address to, uint256 value) internal {
require(value <= _balances[from]);
require(to != address(0));
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(from, to, value);
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param account The account that will receive the created tokens.
* @param amount The amount that will be created.
*/
function _mint(address account, uint256 amount) internal {
require(account != 0);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
*/
function _burn(address account, uint256 amount) internal {
require(account != 0);
require(amount <= _balances[account]);
_totalSupply = _totalSupply.sub(amount);
_balances[account] = _balances[account].sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal burn function.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
*/
function _burnFrom(address account, uint256 amount) internal {
require(amount <= _allowed[account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(
amount);
_burn(account, amount);
}
} | allowance | function allowance(
address owner,
address spender
)
public
view
returns (uint256)
{
return _allowed[owner][spender];
}
| /**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param owner address The address which owns the funds.
* @param spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://ddfc285b7df0055254c643558f25c61c418fe3a49309ae28af80967206d8a311 | {
"func_code_index": [
999,
1161
]
} | 8,333 |
|||
Convergent_Billboard | Convergent_Billboard.sol | 0x837ae66bfbcdee3f5d07a051c17401e5636d77b3 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
uint256 private _totalSupply;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev Gets the balance of the specified address.
* @param owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address owner) public view returns (uint256) {
return _balances[owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param owner address The address which owns the funds.
* @param spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address owner,
address spender
)
public
view
returns (uint256)
{
return _allowed[owner][spender];
}
/**
* @dev Transfer token for a specified address
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function transfer(address to, uint256 value) public returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
*/
function approve(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address from,
address to,
uint256 value
)
public
returns (bool)
{
require(value <= _allowed[from][msg.sender]);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_transfer(from, to, value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param spender The address which will spend the funds.
* @param addedValue The amount of tokens to increase the allowance by.
*/
function increaseAllowance(
address spender,
uint256 addedValue
)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].add(addedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param spender The address which will spend the funds.
* @param subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseAllowance(
address spender,
uint256 subtractedValue
)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].sub(subtractedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Transfer token for a specified addresses
* @param from The address to transfer from.
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function _transfer(address from, address to, uint256 value) internal {
require(value <= _balances[from]);
require(to != address(0));
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(from, to, value);
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param account The account that will receive the created tokens.
* @param amount The amount that will be created.
*/
function _mint(address account, uint256 amount) internal {
require(account != 0);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
*/
function _burn(address account, uint256 amount) internal {
require(account != 0);
require(amount <= _balances[account]);
_totalSupply = _totalSupply.sub(amount);
_balances[account] = _balances[account].sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal burn function.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
*/
function _burnFrom(address account, uint256 amount) internal {
require(amount <= _allowed[account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(
amount);
_burn(account, amount);
}
} | transfer | function transfer(address to, uint256 value) public returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
| /**
* @dev Transfer token for a specified address
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://ddfc285b7df0055254c643558f25c61c418fe3a49309ae28af80967206d8a311 | {
"func_code_index": [
1317,
1450
]
} | 8,334 |
|||
Convergent_Billboard | Convergent_Billboard.sol | 0x837ae66bfbcdee3f5d07a051c17401e5636d77b3 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
uint256 private _totalSupply;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev Gets the balance of the specified address.
* @param owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address owner) public view returns (uint256) {
return _balances[owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param owner address The address which owns the funds.
* @param spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address owner,
address spender
)
public
view
returns (uint256)
{
return _allowed[owner][spender];
}
/**
* @dev Transfer token for a specified address
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function transfer(address to, uint256 value) public returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
*/
function approve(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address from,
address to,
uint256 value
)
public
returns (bool)
{
require(value <= _allowed[from][msg.sender]);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_transfer(from, to, value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param spender The address which will spend the funds.
* @param addedValue The amount of tokens to increase the allowance by.
*/
function increaseAllowance(
address spender,
uint256 addedValue
)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].add(addedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param spender The address which will spend the funds.
* @param subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseAllowance(
address spender,
uint256 subtractedValue
)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].sub(subtractedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Transfer token for a specified addresses
* @param from The address to transfer from.
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function _transfer(address from, address to, uint256 value) internal {
require(value <= _balances[from]);
require(to != address(0));
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(from, to, value);
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param account The account that will receive the created tokens.
* @param amount The amount that will be created.
*/
function _mint(address account, uint256 amount) internal {
require(account != 0);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
*/
function _burn(address account, uint256 amount) internal {
require(account != 0);
require(amount <= _balances[account]);
_totalSupply = _totalSupply.sub(amount);
_balances[account] = _balances[account].sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal burn function.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
*/
function _burnFrom(address account, uint256 amount) internal {
require(amount <= _allowed[account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(
amount);
_burn(account, amount);
}
} | approve | function approve(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
| /**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://ddfc285b7df0055254c643558f25c61c418fe3a49309ae28af80967206d8a311 | {
"func_code_index": [
2074,
2303
]
} | 8,335 |
|||
Convergent_Billboard | Convergent_Billboard.sol | 0x837ae66bfbcdee3f5d07a051c17401e5636d77b3 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
uint256 private _totalSupply;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev Gets the balance of the specified address.
* @param owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address owner) public view returns (uint256) {
return _balances[owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param owner address The address which owns the funds.
* @param spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address owner,
address spender
)
public
view
returns (uint256)
{
return _allowed[owner][spender];
}
/**
* @dev Transfer token for a specified address
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function transfer(address to, uint256 value) public returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
*/
function approve(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address from,
address to,
uint256 value
)
public
returns (bool)
{
require(value <= _allowed[from][msg.sender]);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_transfer(from, to, value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param spender The address which will spend the funds.
* @param addedValue The amount of tokens to increase the allowance by.
*/
function increaseAllowance(
address spender,
uint256 addedValue
)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].add(addedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param spender The address which will spend the funds.
* @param subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseAllowance(
address spender,
uint256 subtractedValue
)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].sub(subtractedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Transfer token for a specified addresses
* @param from The address to transfer from.
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function _transfer(address from, address to, uint256 value) internal {
require(value <= _balances[from]);
require(to != address(0));
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(from, to, value);
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param account The account that will receive the created tokens.
* @param amount The amount that will be created.
*/
function _mint(address account, uint256 amount) internal {
require(account != 0);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
*/
function _burn(address account, uint256 amount) internal {
require(account != 0);
require(amount <= _balances[account]);
_totalSupply = _totalSupply.sub(amount);
_balances[account] = _balances[account].sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal burn function.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
*/
function _burnFrom(address account, uint256 amount) internal {
require(amount <= _allowed[account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(
amount);
_burn(account, amount);
}
} | transferFrom | function transferFrom(
address from,
address to,
uint256 value
)
public
returns (bool)
{
require(value <= _allowed[from][msg.sender]);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_transfer(from, to, value);
return true;
}
| /**
* @dev Transfer tokens from one address to another
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 the amount of tokens to be transferred
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://ddfc285b7df0055254c643558f25c61c418fe3a49309ae28af80967206d8a311 | {
"func_code_index": [
2580,
2884
]
} | 8,336 |
|||
Convergent_Billboard | Convergent_Billboard.sol | 0x837ae66bfbcdee3f5d07a051c17401e5636d77b3 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
uint256 private _totalSupply;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev Gets the balance of the specified address.
* @param owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address owner) public view returns (uint256) {
return _balances[owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param owner address The address which owns the funds.
* @param spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address owner,
address spender
)
public
view
returns (uint256)
{
return _allowed[owner][spender];
}
/**
* @dev Transfer token for a specified address
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function transfer(address to, uint256 value) public returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
*/
function approve(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address from,
address to,
uint256 value
)
public
returns (bool)
{
require(value <= _allowed[from][msg.sender]);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_transfer(from, to, value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param spender The address which will spend the funds.
* @param addedValue The amount of tokens to increase the allowance by.
*/
function increaseAllowance(
address spender,
uint256 addedValue
)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].add(addedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param spender The address which will spend the funds.
* @param subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseAllowance(
address spender,
uint256 subtractedValue
)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].sub(subtractedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Transfer token for a specified addresses
* @param from The address to transfer from.
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function _transfer(address from, address to, uint256 value) internal {
require(value <= _balances[from]);
require(to != address(0));
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(from, to, value);
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param account The account that will receive the created tokens.
* @param amount The amount that will be created.
*/
function _mint(address account, uint256 amount) internal {
require(account != 0);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
*/
function _burn(address account, uint256 amount) internal {
require(account != 0);
require(amount <= _balances[account]);
_totalSupply = _totalSupply.sub(amount);
_balances[account] = _balances[account].sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal burn function.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
*/
function _burnFrom(address account, uint256 amount) internal {
require(amount <= _allowed[account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(
amount);
_burn(account, amount);
}
} | increaseAllowance | function increaseAllowance(
address spender,
uint256 addedValue
)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].add(addedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
| /**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param spender The address which will spend the funds.
* @param addedValue The amount of tokens to increase the allowance by.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://ddfc285b7df0055254c643558f25c61c418fe3a49309ae28af80967206d8a311 | {
"func_code_index": [
3343,
3689
]
} | 8,337 |
|||
Convergent_Billboard | Convergent_Billboard.sol | 0x837ae66bfbcdee3f5d07a051c17401e5636d77b3 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
uint256 private _totalSupply;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev Gets the balance of the specified address.
* @param owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address owner) public view returns (uint256) {
return _balances[owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param owner address The address which owns the funds.
* @param spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address owner,
address spender
)
public
view
returns (uint256)
{
return _allowed[owner][spender];
}
/**
* @dev Transfer token for a specified address
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function transfer(address to, uint256 value) public returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
*/
function approve(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address from,
address to,
uint256 value
)
public
returns (bool)
{
require(value <= _allowed[from][msg.sender]);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_transfer(from, to, value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param spender The address which will spend the funds.
* @param addedValue The amount of tokens to increase the allowance by.
*/
function increaseAllowance(
address spender,
uint256 addedValue
)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].add(addedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param spender The address which will spend the funds.
* @param subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseAllowance(
address spender,
uint256 subtractedValue
)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].sub(subtractedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Transfer token for a specified addresses
* @param from The address to transfer from.
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function _transfer(address from, address to, uint256 value) internal {
require(value <= _balances[from]);
require(to != address(0));
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(from, to, value);
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param account The account that will receive the created tokens.
* @param amount The amount that will be created.
*/
function _mint(address account, uint256 amount) internal {
require(account != 0);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
*/
function _burn(address account, uint256 amount) internal {
require(account != 0);
require(amount <= _balances[account]);
_totalSupply = _totalSupply.sub(amount);
_balances[account] = _balances[account].sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal burn function.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
*/
function _burnFrom(address account, uint256 amount) internal {
require(amount <= _allowed[account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(
amount);
_burn(account, amount);
}
} | decreaseAllowance | function decreaseAllowance(
address spender,
uint256 subtractedValue
)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].sub(subtractedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
| /**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param spender The address which will spend the funds.
* @param subtractedValue The amount of tokens to decrease the allowance by.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://ddfc285b7df0055254c643558f25c61c418fe3a49309ae28af80967206d8a311 | {
"func_code_index": [
4153,
4509
]
} | 8,338 |
|||
Convergent_Billboard | Convergent_Billboard.sol | 0x837ae66bfbcdee3f5d07a051c17401e5636d77b3 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
uint256 private _totalSupply;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev Gets the balance of the specified address.
* @param owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address owner) public view returns (uint256) {
return _balances[owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param owner address The address which owns the funds.
* @param spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address owner,
address spender
)
public
view
returns (uint256)
{
return _allowed[owner][spender];
}
/**
* @dev Transfer token for a specified address
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function transfer(address to, uint256 value) public returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
*/
function approve(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address from,
address to,
uint256 value
)
public
returns (bool)
{
require(value <= _allowed[from][msg.sender]);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_transfer(from, to, value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param spender The address which will spend the funds.
* @param addedValue The amount of tokens to increase the allowance by.
*/
function increaseAllowance(
address spender,
uint256 addedValue
)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].add(addedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param spender The address which will spend the funds.
* @param subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseAllowance(
address spender,
uint256 subtractedValue
)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].sub(subtractedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Transfer token for a specified addresses
* @param from The address to transfer from.
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function _transfer(address from, address to, uint256 value) internal {
require(value <= _balances[from]);
require(to != address(0));
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(from, to, value);
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param account The account that will receive the created tokens.
* @param amount The amount that will be created.
*/
function _mint(address account, uint256 amount) internal {
require(account != 0);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
*/
function _burn(address account, uint256 amount) internal {
require(account != 0);
require(amount <= _balances[account]);
_totalSupply = _totalSupply.sub(amount);
_balances[account] = _balances[account].sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal burn function.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
*/
function _burnFrom(address account, uint256 amount) internal {
require(amount <= _allowed[account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(
amount);
_burn(account, amount);
}
} | _transfer | function _transfer(address from, address to, uint256 value) internal {
require(value <= _balances[from]);
require(to != address(0));
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(from, to, value);
}
| /**
* @dev Transfer token for a specified addresses
* @param from The address to transfer from.
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://ddfc285b7df0055254c643558f25c61c418fe3a49309ae28af80967206d8a311 | {
"func_code_index": [
4714,
5001
]
} | 8,339 |
|||
Convergent_Billboard | Convergent_Billboard.sol | 0x837ae66bfbcdee3f5d07a051c17401e5636d77b3 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
uint256 private _totalSupply;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev Gets the balance of the specified address.
* @param owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address owner) public view returns (uint256) {
return _balances[owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param owner address The address which owns the funds.
* @param spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address owner,
address spender
)
public
view
returns (uint256)
{
return _allowed[owner][spender];
}
/**
* @dev Transfer token for a specified address
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function transfer(address to, uint256 value) public returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
*/
function approve(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address from,
address to,
uint256 value
)
public
returns (bool)
{
require(value <= _allowed[from][msg.sender]);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_transfer(from, to, value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param spender The address which will spend the funds.
* @param addedValue The amount of tokens to increase the allowance by.
*/
function increaseAllowance(
address spender,
uint256 addedValue
)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].add(addedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param spender The address which will spend the funds.
* @param subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseAllowance(
address spender,
uint256 subtractedValue
)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].sub(subtractedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Transfer token for a specified addresses
* @param from The address to transfer from.
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function _transfer(address from, address to, uint256 value) internal {
require(value <= _balances[from]);
require(to != address(0));
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(from, to, value);
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param account The account that will receive the created tokens.
* @param amount The amount that will be created.
*/
function _mint(address account, uint256 amount) internal {
require(account != 0);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
*/
function _burn(address account, uint256 amount) internal {
require(account != 0);
require(amount <= _balances[account]);
_totalSupply = _totalSupply.sub(amount);
_balances[account] = _balances[account].sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal burn function.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
*/
function _burnFrom(address account, uint256 amount) internal {
require(amount <= _allowed[account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(
amount);
_burn(account, amount);
}
} | _mint | function _mint(address account, uint256 amount) internal {
require(account != 0);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
| /**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param account The account that will receive the created tokens.
* @param amount The amount that will be created.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://ddfc285b7df0055254c643558f25c61c418fe3a49309ae28af80967206d8a311 | {
"func_code_index": [
5335,
5582
]
} | 8,340 |
|||
Convergent_Billboard | Convergent_Billboard.sol | 0x837ae66bfbcdee3f5d07a051c17401e5636d77b3 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
uint256 private _totalSupply;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev Gets the balance of the specified address.
* @param owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address owner) public view returns (uint256) {
return _balances[owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param owner address The address which owns the funds.
* @param spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address owner,
address spender
)
public
view
returns (uint256)
{
return _allowed[owner][spender];
}
/**
* @dev Transfer token for a specified address
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function transfer(address to, uint256 value) public returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
*/
function approve(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address from,
address to,
uint256 value
)
public
returns (bool)
{
require(value <= _allowed[from][msg.sender]);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_transfer(from, to, value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param spender The address which will spend the funds.
* @param addedValue The amount of tokens to increase the allowance by.
*/
function increaseAllowance(
address spender,
uint256 addedValue
)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].add(addedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param spender The address which will spend the funds.
* @param subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseAllowance(
address spender,
uint256 subtractedValue
)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].sub(subtractedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Transfer token for a specified addresses
* @param from The address to transfer from.
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function _transfer(address from, address to, uint256 value) internal {
require(value <= _balances[from]);
require(to != address(0));
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(from, to, value);
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param account The account that will receive the created tokens.
* @param amount The amount that will be created.
*/
function _mint(address account, uint256 amount) internal {
require(account != 0);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
*/
function _burn(address account, uint256 amount) internal {
require(account != 0);
require(amount <= _balances[account]);
_totalSupply = _totalSupply.sub(amount);
_balances[account] = _balances[account].sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal burn function.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
*/
function _burnFrom(address account, uint256 amount) internal {
require(amount <= _allowed[account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(
amount);
_burn(account, amount);
}
} | _burn | function _burn(address account, uint256 amount) internal {
require(account != 0);
require(amount <= _balances[account]);
_totalSupply = _totalSupply.sub(amount);
_balances[account] = _balances[account].sub(amount);
emit Transfer(account, address(0), amount);
}
| /**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://ddfc285b7df0055254c643558f25c61c418fe3a49309ae28af80967206d8a311 | {
"func_code_index": [
5800,
6093
]
} | 8,341 |
|||
Convergent_Billboard | Convergent_Billboard.sol | 0x837ae66bfbcdee3f5d07a051c17401e5636d77b3 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
uint256 private _totalSupply;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev Gets the balance of the specified address.
* @param owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address owner) public view returns (uint256) {
return _balances[owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param owner address The address which owns the funds.
* @param spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address owner,
address spender
)
public
view
returns (uint256)
{
return _allowed[owner][spender];
}
/**
* @dev Transfer token for a specified address
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function transfer(address to, uint256 value) public returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
*/
function approve(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address from,
address to,
uint256 value
)
public
returns (bool)
{
require(value <= _allowed[from][msg.sender]);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_transfer(from, to, value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param spender The address which will spend the funds.
* @param addedValue The amount of tokens to increase the allowance by.
*/
function increaseAllowance(
address spender,
uint256 addedValue
)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].add(addedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param spender The address which will spend the funds.
* @param subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseAllowance(
address spender,
uint256 subtractedValue
)
public
returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (
_allowed[msg.sender][spender].sub(subtractedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Transfer token for a specified addresses
* @param from The address to transfer from.
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function _transfer(address from, address to, uint256 value) internal {
require(value <= _balances[from]);
require(to != address(0));
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(from, to, value);
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param account The account that will receive the created tokens.
* @param amount The amount that will be created.
*/
function _mint(address account, uint256 amount) internal {
require(account != 0);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
*/
function _burn(address account, uint256 amount) internal {
require(account != 0);
require(amount <= _balances[account]);
_totalSupply = _totalSupply.sub(amount);
_balances[account] = _balances[account].sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal burn function.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
*/
function _burnFrom(address account, uint256 amount) internal {
require(amount <= _allowed[account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(
amount);
_burn(account, amount);
}
} | _burnFrom | function _burnFrom(address account, uint256 amount) internal {
require(amount <= _allowed[account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(
amount);
_burn(account, amount);
}
| /**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal burn function.
* @param account The account whose tokens will be burnt.
* @param amount The amount that will be burnt.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://ddfc285b7df0055254c643558f25c61c418fe3a49309ae28af80967206d8a311 | {
"func_code_index": [
6406,
6811
]
} | 8,342 |
|||
Convergent_Billboard | Convergent_Billboard.sol | 0x837ae66bfbcdee3f5d07a051c17401e5636d77b3 | Solidity | EthPolynomialCurvedToken | contract EthPolynomialCurvedToken is EthBondingCurvedToken {
uint256 public exponent;
uint256 public inverseSlope;
/// @dev constructor Initializes the bonding curve
/// @param name The name of the token
/// @param decimals The number of decimals to use
/// @param symbol The symbol of the token
/// @param _exponent The exponent of the curve
constructor(
string name,
string symbol,
uint8 decimals,
uint256 _exponent,
uint256 _inverseSlope
) EthBondingCurvedToken(name, symbol, decimals)
public
{
exponent = _exponent;
inverseSlope = _inverseSlope;
}
/// @dev Calculate the integral from 0 to t
/// @param t The number to integrate to
function curveIntegral(uint256 t) internal returns (uint256) {
uint256 nexp = exponent.add(1);
uint256 norm = 10 ** (uint256(decimals()) * uint256(nexp)) - 18;
// Calculate integral of t^exponent
return
(t ** nexp).div(nexp).div(inverseSlope).div(10 ** 18);
}
function priceToMint(uint256 numTokens) public view returns(uint256) {
return curveIntegral(totalSupply().add(numTokens)).sub(poolBalance);
}
function rewardForBurn(uint256 numTokens) public view returns(uint256) {
return poolBalance.sub(curveIntegral(totalSupply().sub(numTokens)));
}
} | curveIntegral | function curveIntegral(uint256 t) internal returns (uint256) {
uint256 nexp = exponent.add(1);
uint256 norm = 10 ** (uint256(decimals()) * uint256(nexp)) - 18;
// Calculate integral of t^exponent
return
(t ** nexp).div(nexp).div(inverseSlope).div(10 ** 18);
}
| /// @dev Calculate the integral from 0 to t
/// @param t The number to integrate to | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://ddfc285b7df0055254c643558f25c61c418fe3a49309ae28af80967206d8a311 | {
"func_code_index": [
837,
1155
]
} | 8,343 |
|||
Convergent_Billboard | Convergent_Billboard.sol | 0x837ae66bfbcdee3f5d07a051c17401e5636d77b3 | Solidity | Convergent_Billboard | contract Convergent_Billboard is EthPolynomialCurvedToken {
using SafeMath for uint256;
uint256 public cashed; // Amount of tokens that have been "cashed out."
uint256 public maxTokens; // Total amount of Billboard tokens to be sold.
uint256 public requiredAmt; // Required amount of token per banner change.
address public safe; // Target to send the funds.
event Advertisement(bytes32 what, uint256 indexed when);
constructor(uint256 _maxTokens, uint256 _requiredAmt, address _safe)
EthPolynomialCurvedToken(
"Convergent Billboard Token",
"CBT",
18,
1,
1000
)
public
{
maxTokens = _maxTokens * 10**18;
requiredAmt = _requiredAmt * 10**18;
safe = _safe;
}
/// Overwrite
function mint(uint256 numTokens) public payable {
uint256 newTotal = totalSupply().add(numTokens);
if (newTotal > maxTokens) {
super.mint(maxTokens.sub(totalSupply()));
// The super.mint() function will not allow 0
// as an argument rendering this as sufficient
// to enforce a cap of maxTokens.
} else {
super.mint(numTokens);
}
}
function purchaseAdvertisement(bytes32 _what)
public
payable
{
mint(requiredAmt);
submit(_what);
}
function submit(bytes32 _what)
public
{
require(balanceOf(msg.sender) >= requiredAmt);
cashed++; // increment cashed counter
_transfer(msg.sender, address(0x1337), requiredAmt);
uint256 dec = 10**uint256(decimals());
uint256 newCliff = curveIntegral(
(cashed).mul(dec)
);
uint256 oldCliff = curveIntegral(
(cashed - 1).mul(dec)
);
uint256 cliffDiff = newCliff.sub(oldCliff);
safe.transfer(cliffDiff);
emit Advertisement(_what, block.timestamp);
}
function () public { revert(); }
} | mint | function mint(uint256 numTokens) public payable {
uint256 newTotal = totalSupply().add(numTokens);
if (newTotal > maxTokens) {
super.mint(maxTokens.sub(totalSupply()));
// The super.mint() function will not allow 0
// as an argument rendering this as sufficient
// to enforce a cap of maxTokens.
} else {
super.mint(numTokens);
}
}
| /// Overwrite | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://ddfc285b7df0055254c643558f25c61c418fe3a49309ae28af80967206d8a311 | {
"func_code_index": [
927,
1369
]
} | 8,344 |
|||
EthStarterFarming | /Volumes/Data/Projects/BscStarter/source/crispy-octo/contracts/ethereum/EthStarterFarming.sol | 0x9dfda6ca37734d69b0ebc5b65f98501ea7296893 | Solidity | EthStarterFarming | contract EthStarterFarming is ReentrancyGuard, Ownable {
using SafeMath for uint256;
using Address for address;
using SafeERC20 for IERC20;
event Staked(address indexed from, uint256 amountETH, uint256 amountLP);
event Withdrawn(address indexed to, uint256 amountETH, uint256 amountLP);
event Claimed(address indexed to, uint256 amount);
event Halving(uint256 amount);
event Received(address indexed from, uint256 amount);
STARToken public startToken;
IUniswapV2Factory public factory;
IUniswapV2Router02 public router;
address public weth;
address payable public devAddress;
address public pairAddress;
struct AccountInfo {
// Staked LP token balance
uint256 balance;
uint256 peakBalance;
uint256 withdrawTimestamp;
uint256 reward;
uint256 rewardPerTokenPaid;
}
mapping(address => AccountInfo) public accountInfos;
mapping(address => bool) public bscsDevs;
// Staked LP token total supply
uint256 private _totalSupply = 0;
uint256 public rewardDuration = 7 days;
uint256 public rewardAllocation = 500 * 1e18;
uint256 public lastUpdateTimestamp = 0;
uint256 public rewardRate = 0;
uint256 public rewardPerTokenStored = 0;
// Farming will be open on this timestamp
uint256 public farmingStartTimestamp = 1628985600; // Thursday, July 1, 2021 12:00:00 AM
bool public farmingStarted = false;
// Max 25% / day LP withdraw
uint256 public withdrawLimit = 25;
uint256 public withdrawCycle = 24 hours;
// Burn address
address constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD;
uint256 public burnFeeX100 = 300;
modifier onlyBscsDev() {
require(
owner == msg.sender || bscsDevs[msg.sender],
"You are not dev."
);
_;
}
constructor(address _startToken) public {
startToken = STARToken(address(_startToken));
router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
factory = IUniswapV2Factory(router.factory());
weth = router.WETH();
devAddress = msg.sender;
pairAddress = factory.getPair(address(startToken), weth);
// Calc reward rate
rewardRate = rewardAllocation.div(rewardDuration);
}
receive() external payable {
emit Received(msg.sender, msg.value);
}
function stake() external payable nonReentrant {
_checkFarming();
_updateReward(msg.sender);
require(msg.value > 0, "Cannot stake 0");
require(
!address(msg.sender).isContract(),
"Please use your individual account"
);
// 50% used to buy START
address[] memory swapPath = new address[](2);
swapPath[0] = address(weth);
swapPath[1] = address(startToken);
IERC20(startToken).safeApprove(address(router), 0);
IERC20(startToken).safeApprove(address(router), msg.value.div(2));
uint256[] memory amounts = router.swapExactETHForTokens{
value: msg.value.div(2)
}(uint256(0), swapPath, address(this), block.timestamp + 1 days);
uint256 boughtStart = amounts[amounts.length - 1];
// Add liquidity
uint256 amountETHDesired = msg.value.sub(msg.value.div(2));
IERC20(startToken).approve(address(router), boughtStart);
(, , uint256 liquidity) = router.addLiquidityETH{
value: amountETHDesired
}(
address(startToken),
boughtStart,
1,
1,
address(this),
block.timestamp + 1 days
);
// Add LP token to total supply
_totalSupply = _totalSupply.add(liquidity);
// Add to balance
accountInfos[msg.sender].balance = accountInfos[msg.sender].balance.add(
liquidity
);
// Set peak balance
if (
accountInfos[msg.sender].balance >
accountInfos[msg.sender].peakBalance
) {
accountInfos[msg.sender].peakBalance = accountInfos[msg.sender]
.balance;
}
// Set stake timestamp as withdraw timestamp
// to prevent withdraw immediately after first staking
if (accountInfos[msg.sender].withdrawTimestamp == 0) {
accountInfos[msg.sender].withdrawTimestamp = block.timestamp;
}
emit Staked(msg.sender, msg.value, liquidity);
}
function withdraw() external nonReentrant {
_checkFarming();
_updateReward(msg.sender);
require(
accountInfos[msg.sender].withdrawTimestamp + withdrawCycle <=
block.timestamp,
"You must wait more time since your last withdraw or stake"
);
require(accountInfos[msg.sender].balance > 0, "Cannot withdraw 0");
// Limit withdraw LP token
uint256 amount = accountInfos[msg.sender]
.peakBalance
.mul(withdrawLimit)
.div(100);
if (accountInfos[msg.sender].balance < amount) {
amount = accountInfos[msg.sender].balance;
}
// Reduce total supply
_totalSupply = _totalSupply.sub(amount);
// Reduce balance
accountInfos[msg.sender].balance = accountInfos[msg.sender].balance.sub(
amount
);
if (accountInfos[msg.sender].balance == 0) {
accountInfos[msg.sender].peakBalance = 0;
}
// Set timestamp
accountInfos[msg.sender].withdrawTimestamp = block.timestamp;
// Remove liquidity in uniswap
IERC20(pairAddress).approve(address(router), amount);
(uint256 tokenAmount, uint256 bnbAmount) = router.removeLiquidity(
address(startToken),
weth,
amount,
0,
0,
address(this),
block.timestamp + 1 days
);
// Burn 3% START, send balance to sender
uint256 burnAmount = tokenAmount.mul(burnFeeX100).div(10000);
if (burnAmount > 0) {
tokenAmount = tokenAmount.sub(burnAmount);
startToken.transfer(address(BURN_ADDRESS), burnAmount);
}
startToken.transfer(msg.sender, tokenAmount);
// Withdraw BNB and send to sender
IWETH(weth).withdraw(bnbAmount);
msg.sender.transfer(bnbAmount);
emit Withdrawn(msg.sender, bnbAmount, amount);
}
function claim() external nonReentrant {
_checkFarming();
_updateReward(msg.sender);
uint256 reward = accountInfos[msg.sender].reward;
require(reward > 0, "There is no reward to claim");
if (reward > 0) {
// Reduce first
accountInfos[msg.sender].reward = 0;
// Apply tax
uint256 taxDenominator = claimTaxDenominator();
uint256 tax = taxDenominator > 0 ? reward.div(taxDenominator) : 0;
uint256 net = reward.sub(tax);
// Send reward
startToken.transfer(msg.sender, net);
if (tax > 0) {
// Burn taxed token
startToken.transfer(BURN_ADDRESS, tax);
}
emit Claimed(msg.sender, reward);
}
}
function withdrawStart() external onlyOwner {
startToken.transfer(devAddress, startToken.balanceOf(address(this)));
}
function totalSupply() external view returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) external view returns (uint256) {
return accountInfos[account].balance;
}
function burnedTokenAmount() public view returns (uint256) {
return startToken.balanceOf(BURN_ADDRESS);
}
function rewardPerToken() public view returns (uint256) {
if (_totalSupply == 0) {
return rewardPerTokenStored;
}
return
rewardPerTokenStored.add(
lastRewardTimestamp()
.sub(lastUpdateTimestamp)
.mul(rewardRate)
.mul(1e18)
.div(_totalSupply)
);
}
function lastRewardTimestamp() public view returns (uint256) {
return block.timestamp;
}
function rewardEarned(address account) public view returns (uint256) {
return
accountInfos[account]
.balance
.mul(
rewardPerToken().sub(
accountInfos[account].rewardPerTokenPaid
)
)
.div(1e18)
.add(accountInfos[account].reward);
}
// Token price in eth
function tokenPrice() public view returns (uint256) {
uint256 bnbAmount = IERC20(weth).balanceOf(pairAddress);
uint256 tokenAmount = IERC20(startToken).balanceOf(pairAddress);
return bnbAmount.mul(1e18).div(tokenAmount);
}
function claimTaxDenominator() public view returns (uint256) {
if (block.timestamp < farmingStartTimestamp + 7 days) {
return 4;
} else if (block.timestamp < farmingStartTimestamp + 14 days) {
return 5;
} else if (block.timestamp < farmingStartTimestamp + 30 days) {
return 10;
} else if (block.timestamp < farmingStartTimestamp + 45 days) {
return 20;
} else {
return 0;
}
}
function _updateReward(address account) internal {
rewardPerTokenStored = rewardPerToken();
lastUpdateTimestamp = lastRewardTimestamp();
if (account != address(0)) {
accountInfos[account].reward = rewardEarned(account);
accountInfos[account].rewardPerTokenPaid = rewardPerTokenStored;
}
}
// Check if farming is started
function _checkFarming() internal {
require(
farmingStartTimestamp <= block.timestamp,
"Please wait until farming started"
);
if (!farmingStarted) {
farmingStarted = true;
lastUpdateTimestamp = block.timestamp;
}
}
function addDevAddress(address _devAddr) external onlyOwner {
bscsDevs[_devAddr] = true;
}
function deleteDevAddress(address _devAddr) external onlyOwner {
bscsDevs[_devAddr] = false;
}
function setFarmingStartTimestamp(
uint256 _farmingTimestamp,
bool _farmingStarted
) external onlyBscsDev {
farmingStartTimestamp = _farmingTimestamp;
farmingStarted = _farmingStarted;
}
function setBurnFee(uint256 _burnFee) external onlyBscsDev {
burnFeeX100 = _burnFee;
}
function setWithdrawInfo(uint256 _withdrawLimit, uint256 _withdrawCycle)
external
onlyBscsDev
{
withdrawLimit = _withdrawLimit;
withdrawCycle = _withdrawCycle;
}
} | tokenPrice | function tokenPrice() public view returns (uint256) {
uint256 bnbAmount = IERC20(weth).balanceOf(pairAddress);
uint256 tokenAmount = IERC20(startToken).balanceOf(pairAddress);
return bnbAmount.mul(1e18).div(tokenAmount);
}
| // Token price in eth | LineComment | v0.6.12+commit.27d51765 | {
"func_code_index": [
8729,
8983
]
} | 8,345 |
||||
EthStarterFarming | /Volumes/Data/Projects/BscStarter/source/crispy-octo/contracts/ethereum/EthStarterFarming.sol | 0x9dfda6ca37734d69b0ebc5b65f98501ea7296893 | Solidity | EthStarterFarming | contract EthStarterFarming is ReentrancyGuard, Ownable {
using SafeMath for uint256;
using Address for address;
using SafeERC20 for IERC20;
event Staked(address indexed from, uint256 amountETH, uint256 amountLP);
event Withdrawn(address indexed to, uint256 amountETH, uint256 amountLP);
event Claimed(address indexed to, uint256 amount);
event Halving(uint256 amount);
event Received(address indexed from, uint256 amount);
STARToken public startToken;
IUniswapV2Factory public factory;
IUniswapV2Router02 public router;
address public weth;
address payable public devAddress;
address public pairAddress;
struct AccountInfo {
// Staked LP token balance
uint256 balance;
uint256 peakBalance;
uint256 withdrawTimestamp;
uint256 reward;
uint256 rewardPerTokenPaid;
}
mapping(address => AccountInfo) public accountInfos;
mapping(address => bool) public bscsDevs;
// Staked LP token total supply
uint256 private _totalSupply = 0;
uint256 public rewardDuration = 7 days;
uint256 public rewardAllocation = 500 * 1e18;
uint256 public lastUpdateTimestamp = 0;
uint256 public rewardRate = 0;
uint256 public rewardPerTokenStored = 0;
// Farming will be open on this timestamp
uint256 public farmingStartTimestamp = 1628985600; // Thursday, July 1, 2021 12:00:00 AM
bool public farmingStarted = false;
// Max 25% / day LP withdraw
uint256 public withdrawLimit = 25;
uint256 public withdrawCycle = 24 hours;
// Burn address
address constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD;
uint256 public burnFeeX100 = 300;
modifier onlyBscsDev() {
require(
owner == msg.sender || bscsDevs[msg.sender],
"You are not dev."
);
_;
}
constructor(address _startToken) public {
startToken = STARToken(address(_startToken));
router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
factory = IUniswapV2Factory(router.factory());
weth = router.WETH();
devAddress = msg.sender;
pairAddress = factory.getPair(address(startToken), weth);
// Calc reward rate
rewardRate = rewardAllocation.div(rewardDuration);
}
receive() external payable {
emit Received(msg.sender, msg.value);
}
function stake() external payable nonReentrant {
_checkFarming();
_updateReward(msg.sender);
require(msg.value > 0, "Cannot stake 0");
require(
!address(msg.sender).isContract(),
"Please use your individual account"
);
// 50% used to buy START
address[] memory swapPath = new address[](2);
swapPath[0] = address(weth);
swapPath[1] = address(startToken);
IERC20(startToken).safeApprove(address(router), 0);
IERC20(startToken).safeApprove(address(router), msg.value.div(2));
uint256[] memory amounts = router.swapExactETHForTokens{
value: msg.value.div(2)
}(uint256(0), swapPath, address(this), block.timestamp + 1 days);
uint256 boughtStart = amounts[amounts.length - 1];
// Add liquidity
uint256 amountETHDesired = msg.value.sub(msg.value.div(2));
IERC20(startToken).approve(address(router), boughtStart);
(, , uint256 liquidity) = router.addLiquidityETH{
value: amountETHDesired
}(
address(startToken),
boughtStart,
1,
1,
address(this),
block.timestamp + 1 days
);
// Add LP token to total supply
_totalSupply = _totalSupply.add(liquidity);
// Add to balance
accountInfos[msg.sender].balance = accountInfos[msg.sender].balance.add(
liquidity
);
// Set peak balance
if (
accountInfos[msg.sender].balance >
accountInfos[msg.sender].peakBalance
) {
accountInfos[msg.sender].peakBalance = accountInfos[msg.sender]
.balance;
}
// Set stake timestamp as withdraw timestamp
// to prevent withdraw immediately after first staking
if (accountInfos[msg.sender].withdrawTimestamp == 0) {
accountInfos[msg.sender].withdrawTimestamp = block.timestamp;
}
emit Staked(msg.sender, msg.value, liquidity);
}
function withdraw() external nonReentrant {
_checkFarming();
_updateReward(msg.sender);
require(
accountInfos[msg.sender].withdrawTimestamp + withdrawCycle <=
block.timestamp,
"You must wait more time since your last withdraw or stake"
);
require(accountInfos[msg.sender].balance > 0, "Cannot withdraw 0");
// Limit withdraw LP token
uint256 amount = accountInfos[msg.sender]
.peakBalance
.mul(withdrawLimit)
.div(100);
if (accountInfos[msg.sender].balance < amount) {
amount = accountInfos[msg.sender].balance;
}
// Reduce total supply
_totalSupply = _totalSupply.sub(amount);
// Reduce balance
accountInfos[msg.sender].balance = accountInfos[msg.sender].balance.sub(
amount
);
if (accountInfos[msg.sender].balance == 0) {
accountInfos[msg.sender].peakBalance = 0;
}
// Set timestamp
accountInfos[msg.sender].withdrawTimestamp = block.timestamp;
// Remove liquidity in uniswap
IERC20(pairAddress).approve(address(router), amount);
(uint256 tokenAmount, uint256 bnbAmount) = router.removeLiquidity(
address(startToken),
weth,
amount,
0,
0,
address(this),
block.timestamp + 1 days
);
// Burn 3% START, send balance to sender
uint256 burnAmount = tokenAmount.mul(burnFeeX100).div(10000);
if (burnAmount > 0) {
tokenAmount = tokenAmount.sub(burnAmount);
startToken.transfer(address(BURN_ADDRESS), burnAmount);
}
startToken.transfer(msg.sender, tokenAmount);
// Withdraw BNB and send to sender
IWETH(weth).withdraw(bnbAmount);
msg.sender.transfer(bnbAmount);
emit Withdrawn(msg.sender, bnbAmount, amount);
}
function claim() external nonReentrant {
_checkFarming();
_updateReward(msg.sender);
uint256 reward = accountInfos[msg.sender].reward;
require(reward > 0, "There is no reward to claim");
if (reward > 0) {
// Reduce first
accountInfos[msg.sender].reward = 0;
// Apply tax
uint256 taxDenominator = claimTaxDenominator();
uint256 tax = taxDenominator > 0 ? reward.div(taxDenominator) : 0;
uint256 net = reward.sub(tax);
// Send reward
startToken.transfer(msg.sender, net);
if (tax > 0) {
// Burn taxed token
startToken.transfer(BURN_ADDRESS, tax);
}
emit Claimed(msg.sender, reward);
}
}
function withdrawStart() external onlyOwner {
startToken.transfer(devAddress, startToken.balanceOf(address(this)));
}
function totalSupply() external view returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) external view returns (uint256) {
return accountInfos[account].balance;
}
function burnedTokenAmount() public view returns (uint256) {
return startToken.balanceOf(BURN_ADDRESS);
}
function rewardPerToken() public view returns (uint256) {
if (_totalSupply == 0) {
return rewardPerTokenStored;
}
return
rewardPerTokenStored.add(
lastRewardTimestamp()
.sub(lastUpdateTimestamp)
.mul(rewardRate)
.mul(1e18)
.div(_totalSupply)
);
}
function lastRewardTimestamp() public view returns (uint256) {
return block.timestamp;
}
function rewardEarned(address account) public view returns (uint256) {
return
accountInfos[account]
.balance
.mul(
rewardPerToken().sub(
accountInfos[account].rewardPerTokenPaid
)
)
.div(1e18)
.add(accountInfos[account].reward);
}
// Token price in eth
function tokenPrice() public view returns (uint256) {
uint256 bnbAmount = IERC20(weth).balanceOf(pairAddress);
uint256 tokenAmount = IERC20(startToken).balanceOf(pairAddress);
return bnbAmount.mul(1e18).div(tokenAmount);
}
function claimTaxDenominator() public view returns (uint256) {
if (block.timestamp < farmingStartTimestamp + 7 days) {
return 4;
} else if (block.timestamp < farmingStartTimestamp + 14 days) {
return 5;
} else if (block.timestamp < farmingStartTimestamp + 30 days) {
return 10;
} else if (block.timestamp < farmingStartTimestamp + 45 days) {
return 20;
} else {
return 0;
}
}
function _updateReward(address account) internal {
rewardPerTokenStored = rewardPerToken();
lastUpdateTimestamp = lastRewardTimestamp();
if (account != address(0)) {
accountInfos[account].reward = rewardEarned(account);
accountInfos[account].rewardPerTokenPaid = rewardPerTokenStored;
}
}
// Check if farming is started
function _checkFarming() internal {
require(
farmingStartTimestamp <= block.timestamp,
"Please wait until farming started"
);
if (!farmingStarted) {
farmingStarted = true;
lastUpdateTimestamp = block.timestamp;
}
}
function addDevAddress(address _devAddr) external onlyOwner {
bscsDevs[_devAddr] = true;
}
function deleteDevAddress(address _devAddr) external onlyOwner {
bscsDevs[_devAddr] = false;
}
function setFarmingStartTimestamp(
uint256 _farmingTimestamp,
bool _farmingStarted
) external onlyBscsDev {
farmingStartTimestamp = _farmingTimestamp;
farmingStarted = _farmingStarted;
}
function setBurnFee(uint256 _burnFee) external onlyBscsDev {
burnFeeX100 = _burnFee;
}
function setWithdrawInfo(uint256 _withdrawLimit, uint256 _withdrawCycle)
external
onlyBscsDev
{
withdrawLimit = _withdrawLimit;
withdrawCycle = _withdrawCycle;
}
} | _checkFarming | function _checkFarming() internal {
require(
farmingStartTimestamp <= block.timestamp,
"Please wait until farming started"
);
if (!farmingStarted) {
farmingStarted = true;
lastUpdateTimestamp = block.timestamp;
}
}
| // Check if farming is started | LineComment | v0.6.12+commit.27d51765 | {
"func_code_index": [
9867,
10169
]
} | 8,346 |
||||
SpartaSpear | SpartaSpear.sol | 0x41cfae8dc572a847d4c71d229a2b861afa6968fa | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public constant returns (uint256 balance) {
return balances[_owner];
}
} | transfer | function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
| /**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/ | NatSpecMultiLine | v0.4.26+commit.4563c3fc | None | bzzr://8caeffb3eb27f50b2d0542322000951aceaffbfd253b3deba55caec432e73956 | {
"func_code_index": [
268,
664
]
} | 8,347 |
||
SpartaSpear | SpartaSpear.sol | 0x41cfae8dc572a847d4c71d229a2b861afa6968fa | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public constant returns (uint256 balance) {
return balances[_owner];
}
} | balanceOf | function balanceOf(address _owner) public constant returns (uint256 balance) {
return balances[_owner];
}
| /**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/ | NatSpecMultiLine | v0.4.26+commit.4563c3fc | None | bzzr://8caeffb3eb27f50b2d0542322000951aceaffbfd253b3deba55caec432e73956 | {
"func_code_index": [
870,
986
]
} | 8,348 |
||
SpartaSpear | SpartaSpear.sol | 0x41cfae8dc572a847d4c71d229a2b861afa6968fa | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
} | transferFrom | function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
| /**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/ | NatSpecMultiLine | v0.4.26+commit.4563c3fc | None | bzzr://8caeffb3eb27f50b2d0542322000951aceaffbfd253b3deba55caec432e73956 | {
"func_code_index": [
401,
858
]
} | 8,349 |
||
SpartaSpear | SpartaSpear.sol | 0x41cfae8dc572a847d4c71d229a2b861afa6968fa | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
} | approve | function approve(address _spender, uint256 _value) public returns (bool) {
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
| /**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/ | NatSpecMultiLine | v0.4.26+commit.4563c3fc | None | bzzr://8caeffb3eb27f50b2d0542322000951aceaffbfd253b3deba55caec432e73956 | {
"func_code_index": [
1490,
1754
]
} | 8,350 |
||
SpartaSpear | SpartaSpear.sol | 0x41cfae8dc572a847d4c71d229a2b861afa6968fa | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
} | allowance | function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
| /**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/ | NatSpecMultiLine | v0.4.26+commit.4563c3fc | None | bzzr://8caeffb3eb27f50b2d0542322000951aceaffbfd253b3deba55caec432e73956 | {
"func_code_index": [
2078,
2223
]
} | 8,351 |
||
MintableERC20 | MintableERC20.sol | 0xd628f9ff5bbf1cd61acc1b7b9d6dc7798a1c33f2 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /*
Mintable Token
*/ | Comment | totalSupply | function totalSupply() external view returns (uint256);
| /**
* @dev Returns the amount of tokens in existence.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | None | ipfs://8cf3499756a5ba796f21a398f12523c32b5db0cdea7f53e02ec7753e7049e120 | {
"func_code_index": [
94,
154
]
} | 8,352 |
MintableERC20 | MintableERC20.sol | 0xd628f9ff5bbf1cd61acc1b7b9d6dc7798a1c33f2 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /*
Mintable Token
*/ | Comment | balanceOf | function balanceOf(address account) external view returns (uint256);
| /**
* @dev Returns the amount of tokens owned by `account`.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | None | ipfs://8cf3499756a5ba796f21a398f12523c32b5db0cdea7f53e02ec7753e7049e120 | {
"func_code_index": [
237,
310
]
} | 8,353 |
MintableERC20 | MintableERC20.sol | 0xd628f9ff5bbf1cd61acc1b7b9d6dc7798a1c33f2 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /*
Mintable Token
*/ | Comment | transfer | function transfer(address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | None | ipfs://8cf3499756a5ba796f21a398f12523c32b5db0cdea7f53e02ec7753e7049e120 | {
"func_code_index": [
534,
616
]
} | 8,354 |
MintableERC20 | MintableERC20.sol | 0xd628f9ff5bbf1cd61acc1b7b9d6dc7798a1c33f2 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /*
Mintable Token
*/ | Comment | 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.0+commit.c7dfd78e | None | ipfs://8cf3499756a5ba796f21a398f12523c32b5db0cdea7f53e02ec7753e7049e120 | {
"func_code_index": [
895,
983
]
} | 8,355 |
MintableERC20 | MintableERC20.sol | 0xd628f9ff5bbf1cd61acc1b7b9d6dc7798a1c33f2 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /*
Mintable Token
*/ | Comment | approve | function approve(address spender, uint256 amount) external returns (bool);
| /**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | None | ipfs://8cf3499756a5ba796f21a398f12523c32b5db0cdea7f53e02ec7753e7049e120 | {
"func_code_index": [
1647,
1726
]
} | 8,356 |
MintableERC20 | MintableERC20.sol | 0xd628f9ff5bbf1cd61acc1b7b9d6dc7798a1c33f2 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /*
Mintable Token
*/ | Comment | transferFrom | function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | None | ipfs://8cf3499756a5ba796f21a398f12523c32b5db0cdea7f53e02ec7753e7049e120 | {
"func_code_index": [
2039,
2141
]
} | 8,357 |
MintableERC20 | MintableERC20.sol | 0xd628f9ff5bbf1cd61acc1b7b9d6dc7798a1c33f2 | Solidity | Ownable | abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
} | owner | function owner() public view virtual returns (address) {
return _owner;
}
| /**
* @dev Returns the address of the current owner.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | None | ipfs://8cf3499756a5ba796f21a398f12523c32b5db0cdea7f53e02ec7753e7049e120 | {
"func_code_index": [
497,
589
]
} | 8,358 |
||
MintableERC20 | MintableERC20.sol | 0xd628f9ff5bbf1cd61acc1b7b9d6dc7798a1c33f2 | Solidity | Ownable | abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
} | renounceOwnership | function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
| /**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | None | ipfs://8cf3499756a5ba796f21a398f12523c32b5db0cdea7f53e02ec7753e7049e120 | {
"func_code_index": [
1148,
1301
]
} | 8,359 |
||
MintableERC20 | MintableERC20.sol | 0xd628f9ff5bbf1cd61acc1b7b9d6dc7798a1c33f2 | Solidity | Ownable | abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
} | transferOwnership | function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
| /**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | None | ipfs://8cf3499756a5ba796f21a398f12523c32b5db0cdea7f53e02ec7753e7049e120 | {
"func_code_index": [
1451,
1700
]
} | 8,360 |
||
MintableERC20 | MintableERC20.sol | 0xd628f9ff5bbf1cd61acc1b7b9d6dc7798a1c33f2 | Solidity | MintableERC20 | contract MintableERC20 is IERC20, Ownable {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 private _decimals;
constructor (uint8 decimal ) {
_decimals = decimal;
}
function name() public pure returns (string memory) {
return "ClubSOSReserve";
}
function symbol() public pure returns (string memory) {
return "CSOS";
}
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
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, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
function mint(address account, uint256 amount) external onlyOwner {
_mint(account,amount);
}
function burn(address account, uint256 amount) external onlyOwner {
_burn(account,amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
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);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | totalSupply | function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
| /**
* @dev See {IERC20-totalSupply}.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | None | ipfs://8cf3499756a5ba796f21a398f12523c32b5db0cdea7f53e02ec7753e7049e120 | {
"func_code_index": [
693,
806
]
} | 8,361 |
||
MintableERC20 | MintableERC20.sol | 0xd628f9ff5bbf1cd61acc1b7b9d6dc7798a1c33f2 | Solidity | MintableERC20 | contract MintableERC20 is IERC20, Ownable {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 private _decimals;
constructor (uint8 decimal ) {
_decimals = decimal;
}
function name() public pure returns (string memory) {
return "ClubSOSReserve";
}
function symbol() public pure returns (string memory) {
return "CSOS";
}
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
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, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
function mint(address account, uint256 amount) external onlyOwner {
_mint(account,amount);
}
function burn(address account, uint256 amount) external onlyOwner {
_burn(account,amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
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);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | balanceOf | function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
| /**
* @dev See {IERC20-balanceOf}.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | None | ipfs://8cf3499756a5ba796f21a398f12523c32b5db0cdea7f53e02ec7753e7049e120 | {
"func_code_index": [
864,
996
]
} | 8,362 |
||
MintableERC20 | MintableERC20.sol | 0xd628f9ff5bbf1cd61acc1b7b9d6dc7798a1c33f2 | Solidity | MintableERC20 | contract MintableERC20 is IERC20, Ownable {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 private _decimals;
constructor (uint8 decimal ) {
_decimals = decimal;
}
function name() public pure returns (string memory) {
return "ClubSOSReserve";
}
function symbol() public pure returns (string memory) {
return "CSOS";
}
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
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, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
function mint(address account, uint256 amount) external onlyOwner {
_mint(account,amount);
}
function burn(address account, uint256 amount) external onlyOwner {
_burn(account,amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
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);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | transfer | function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
| /**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | None | ipfs://8cf3499756a5ba796f21a398f12523c32b5db0cdea7f53e02ec7753e7049e120 | {
"func_code_index": [
1204,
1384
]
} | 8,363 |
||
MintableERC20 | MintableERC20.sol | 0xd628f9ff5bbf1cd61acc1b7b9d6dc7798a1c33f2 | Solidity | MintableERC20 | contract MintableERC20 is IERC20, Ownable {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 private _decimals;
constructor (uint8 decimal ) {
_decimals = decimal;
}
function name() public pure returns (string memory) {
return "ClubSOSReserve";
}
function symbol() public pure returns (string memory) {
return "CSOS";
}
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
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, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
function mint(address account, uint256 amount) external onlyOwner {
_mint(account,amount);
}
function burn(address account, uint256 amount) external onlyOwner {
_burn(account,amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
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);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | allowance | function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
| /**
* @dev See {IERC20-allowance}.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | None | ipfs://8cf3499756a5ba796f21a398f12523c32b5db0cdea7f53e02ec7753e7049e120 | {
"func_code_index": [
1442,
1598
]
} | 8,364 |
||
MintableERC20 | MintableERC20.sol | 0xd628f9ff5bbf1cd61acc1b7b9d6dc7798a1c33f2 | Solidity | MintableERC20 | contract MintableERC20 is IERC20, Ownable {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 private _decimals;
constructor (uint8 decimal ) {
_decimals = decimal;
}
function name() public pure returns (string memory) {
return "ClubSOSReserve";
}
function symbol() public pure returns (string memory) {
return "CSOS";
}
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
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, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
function mint(address account, uint256 amount) external onlyOwner {
_mint(account,amount);
}
function burn(address account, uint256 amount) external onlyOwner {
_burn(account,amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
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);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | approve | function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
| /**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | None | ipfs://8cf3499756a5ba796f21a398f12523c32b5db0cdea7f53e02ec7753e7049e120 | {
"func_code_index": [
1740,
1914
]
} | 8,365 |
||
MintableERC20 | MintableERC20.sol | 0xd628f9ff5bbf1cd61acc1b7b9d6dc7798a1c33f2 | Solidity | MintableERC20 | contract MintableERC20 is IERC20, Ownable {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 private _decimals;
constructor (uint8 decimal ) {
_decimals = decimal;
}
function name() public pure returns (string memory) {
return "ClubSOSReserve";
}
function symbol() public pure returns (string memory) {
return "CSOS";
}
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
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, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
function mint(address account, uint256 amount) external onlyOwner {
_mint(account,amount);
}
function burn(address account, uint256 amount) external onlyOwner {
_burn(account,amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
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);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | transferFrom | 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, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
| /**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | None | ipfs://8cf3499756a5ba796f21a398f12523c32b5db0cdea7f53e02ec7753e7049e120 | {
"func_code_index": [
2391,
2818
]
} | 8,366 |
||
MintableERC20 | MintableERC20.sol | 0xd628f9ff5bbf1cd61acc1b7b9d6dc7798a1c33f2 | Solidity | MintableERC20 | contract MintableERC20 is IERC20, Ownable {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 private _decimals;
constructor (uint8 decimal ) {
_decimals = decimal;
}
function name() public pure returns (string memory) {
return "ClubSOSReserve";
}
function symbol() public pure returns (string memory) {
return "CSOS";
}
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
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, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
function mint(address account, uint256 amount) external onlyOwner {
_mint(account,amount);
}
function burn(address account, uint256 amount) external onlyOwner {
_burn(account,amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
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);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | increaseAllowance | function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
| /**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | None | ipfs://8cf3499756a5ba796f21a398f12523c32b5db0cdea7f53e02ec7753e7049e120 | {
"func_code_index": [
3222,
3442
]
} | 8,367 |
||
MintableERC20 | MintableERC20.sol | 0xd628f9ff5bbf1cd61acc1b7b9d6dc7798a1c33f2 | Solidity | MintableERC20 | contract MintableERC20 is IERC20, Ownable {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 private _decimals;
constructor (uint8 decimal ) {
_decimals = decimal;
}
function name() public pure returns (string memory) {
return "ClubSOSReserve";
}
function symbol() public pure returns (string memory) {
return "CSOS";
}
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
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, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
function mint(address account, uint256 amount) external onlyOwner {
_mint(account,amount);
}
function burn(address account, uint256 amount) external onlyOwner {
_burn(account,amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
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);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | decreaseAllowance | function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
| /**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | None | ipfs://8cf3499756a5ba796f21a398f12523c32b5db0cdea7f53e02ec7753e7049e120 | {
"func_code_index": [
3940,
4322
]
} | 8,368 |
||
MintableERC20 | MintableERC20.sol | 0xd628f9ff5bbf1cd61acc1b7b9d6dc7798a1c33f2 | Solidity | MintableERC20 | contract MintableERC20 is IERC20, Ownable {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 private _decimals;
constructor (uint8 decimal ) {
_decimals = decimal;
}
function name() public pure returns (string memory) {
return "ClubSOSReserve";
}
function symbol() public pure returns (string memory) {
return "CSOS";
}
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
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, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
function mint(address account, uint256 amount) external onlyOwner {
_mint(account,amount);
}
function burn(address account, uint256 amount) external onlyOwner {
_burn(account,amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
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);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | _transfer | function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
| /**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | None | ipfs://8cf3499756a5ba796f21a398f12523c32b5db0cdea7f53e02ec7753e7049e120 | {
"func_code_index": [
4807,
5416
]
} | 8,369 |
||
MintableERC20 | MintableERC20.sol | 0xd628f9ff5bbf1cd61acc1b7b9d6dc7798a1c33f2 | Solidity | MintableERC20 | contract MintableERC20 is IERC20, Ownable {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 private _decimals;
constructor (uint8 decimal ) {
_decimals = decimal;
}
function name() public pure returns (string memory) {
return "ClubSOSReserve";
}
function symbol() public pure returns (string memory) {
return "CSOS";
}
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
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, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
function mint(address account, uint256 amount) external onlyOwner {
_mint(account,amount);
}
function burn(address account, uint256 amount) external onlyOwner {
_burn(account,amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
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);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | _mint | function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
| /** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | None | ipfs://8cf3499756a5ba796f21a398f12523c32b5db0cdea7f53e02ec7753e7049e120 | {
"func_code_index": [
5693,
6036
]
} | 8,370 |
||
MintableERC20 | MintableERC20.sol | 0xd628f9ff5bbf1cd61acc1b7b9d6dc7798a1c33f2 | Solidity | MintableERC20 | contract MintableERC20 is IERC20, Ownable {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 private _decimals;
constructor (uint8 decimal ) {
_decimals = decimal;
}
function name() public pure returns (string memory) {
return "ClubSOSReserve";
}
function symbol() public pure returns (string memory) {
return "CSOS";
}
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
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, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
function mint(address account, uint256 amount) external onlyOwner {
_mint(account,amount);
}
function burn(address account, uint256 amount) external onlyOwner {
_burn(account,amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
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);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | _burn | function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
| /**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | None | ipfs://8cf3499756a5ba796f21a398f12523c32b5db0cdea7f53e02ec7753e7049e120 | {
"func_code_index": [
6364,
6863
]
} | 8,371 |
||
MintableERC20 | MintableERC20.sol | 0xd628f9ff5bbf1cd61acc1b7b9d6dc7798a1c33f2 | Solidity | MintableERC20 | contract MintableERC20 is IERC20, Ownable {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 private _decimals;
constructor (uint8 decimal ) {
_decimals = decimal;
}
function name() public pure returns (string memory) {
return "ClubSOSReserve";
}
function symbol() public pure returns (string memory) {
return "CSOS";
}
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
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, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
function mint(address account, uint256 amount) external onlyOwner {
_mint(account,amount);
}
function burn(address account, uint256 amount) external onlyOwner {
_burn(account,amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
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);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | _approve | function _approve(address owner, address spender, uint256 amount) internal virtual {
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);
}
| /**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | None | ipfs://8cf3499756a5ba796f21a398f12523c32b5db0cdea7f53e02ec7753e7049e120 | {
"func_code_index": [
7538,
7889
]
} | 8,372 |
||
MintableERC20 | MintableERC20.sol | 0xd628f9ff5bbf1cd61acc1b7b9d6dc7798a1c33f2 | Solidity | MintableERC20 | contract MintableERC20 is IERC20, Ownable {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 private _decimals;
constructor (uint8 decimal ) {
_decimals = decimal;
}
function name() public pure returns (string memory) {
return "ClubSOSReserve";
}
function symbol() public pure returns (string memory) {
return "CSOS";
}
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
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, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
function mint(address account, uint256 amount) external onlyOwner {
_mint(account,amount);
}
function burn(address account, uint256 amount) external onlyOwner {
_burn(account,amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
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);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | _beforeTokenTransfer | function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
| /**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | None | ipfs://8cf3499756a5ba796f21a398f12523c32b5db0cdea7f53e02ec7753e7049e120 | {
"func_code_index": [
8487,
8584
]
} | 8,373 |
||
TestVesting | TestVesting.sol | 0xac576a8ea6a48fb03f1d86723d454d816da7e3e1 | Solidity | Ownable | contract Ownable {
address public owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
} | /**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/ | NatSpecMultiLine | Ownable | function Ownable() public {
owner = msg.sender;
}
| /**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/ | NatSpecMultiLine | v0.4.21+commit.dfe3193c | bzzr://0a1972208016959aa22ef35424ddc370e70bd2ca16d2a87ef02a36ba9bc99993 | {
"func_code_index": [
336,
396
]
} | 8,374 |
|
TestVesting | TestVesting.sol | 0xac576a8ea6a48fb03f1d86723d454d816da7e3e1 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
| /**
* @dev Multiplies two numbers, throws on overflow.
*/ | NatSpecMultiLine | v0.4.21+commit.dfe3193c | bzzr://0a1972208016959aa22ef35424ddc370e70bd2ca16d2a87ef02a36ba9bc99993 | {
"func_code_index": [
89,
266
]
} | 8,375 |
|
TestVesting | TestVesting.sol | 0xac576a8ea6a48fb03f1d86723d454d816da7e3e1 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | div | function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
| /**
* @dev Integer division of two numbers, truncating the quotient.
*/ | NatSpecMultiLine | v0.4.21+commit.dfe3193c | bzzr://0a1972208016959aa22ef35424ddc370e70bd2ca16d2a87ef02a36ba9bc99993 | {
"func_code_index": [
350,
630
]
} | 8,376 |
|
TestVesting | TestVesting.sol | 0xac576a8ea6a48fb03f1d86723d454d816da7e3e1 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | sub | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
| /**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/ | NatSpecMultiLine | v0.4.21+commit.dfe3193c | bzzr://0a1972208016959aa22ef35424ddc370e70bd2ca16d2a87ef02a36ba9bc99993 | {
"func_code_index": [
744,
860
]
} | 8,377 |
|
TestVesting | TestVesting.sol | 0xac576a8ea6a48fb03f1d86723d454d816da7e3e1 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | add | function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
| /**
* @dev Adds two numbers, throws on overflow.
*/ | NatSpecMultiLine | v0.4.21+commit.dfe3193c | bzzr://0a1972208016959aa22ef35424ddc370e70bd2ca16d2a87ef02a36ba9bc99993 | {
"func_code_index": [
924,
1054
]
} | 8,378 |
|
PittyInuToken | PittyInuToken.sol | 0x8bf247b7585f355180ef986fa22bec2fc975f295 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | totalSupply | function totalSupply() external view returns (uint256);
| /**
* @dev Returns the amount of tokens in existence.
*/ | NatSpecMultiLine | v0.7.0+commit.9e61f92b | GNU GPLv3 | ipfs://50626a07762980f5165f52553fff292d2e7654ea1fcdb1c511d0f5889354392c | {
"func_code_index": [
92,
152
]
} | 8,379 |
||
PittyInuToken | PittyInuToken.sol | 0x8bf247b7585f355180ef986fa22bec2fc975f295 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | balanceOf | function balanceOf(address account) external view returns (uint256);
| /**
* @dev Returns the amount of tokens owned by `account`.
*/ | NatSpecMultiLine | v0.7.0+commit.9e61f92b | GNU GPLv3 | ipfs://50626a07762980f5165f52553fff292d2e7654ea1fcdb1c511d0f5889354392c | {
"func_code_index": [
233,
306
]
} | 8,380 |
||
PittyInuToken | PittyInuToken.sol | 0x8bf247b7585f355180ef986fa22bec2fc975f295 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | transfer | function transfer(address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.7.0+commit.9e61f92b | GNU GPLv3 | ipfs://50626a07762980f5165f52553fff292d2e7654ea1fcdb1c511d0f5889354392c | {
"func_code_index": [
524,
606
]
} | 8,381 |
||
PittyInuToken | PittyInuToken.sol | 0x8bf247b7585f355180ef986fa22bec2fc975f295 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | allowance | function allowance(address owner, address spender) external view returns (uint256);
| /**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/ | NatSpecMultiLine | v0.7.0+commit.9e61f92b | GNU GPLv3 | ipfs://50626a07762980f5165f52553fff292d2e7654ea1fcdb1c511d0f5889354392c | {
"func_code_index": [
879,
967
]
} | 8,382 |
||
PittyInuToken | PittyInuToken.sol | 0x8bf247b7585f355180ef986fa22bec2fc975f295 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | approve | function approve(address spender, uint256 amount) external returns (bool);
| /**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/ | NatSpecMultiLine | v0.7.0+commit.9e61f92b | GNU GPLv3 | ipfs://50626a07762980f5165f52553fff292d2e7654ea1fcdb1c511d0f5889354392c | {
"func_code_index": [
1618,
1697
]
} | 8,383 |
||
PittyInuToken | PittyInuToken.sol | 0x8bf247b7585f355180ef986fa22bec2fc975f295 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | transferFrom | function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.7.0+commit.9e61f92b | GNU GPLv3 | ipfs://50626a07762980f5165f52553fff292d2e7654ea1fcdb1c511d0f5889354392c | {
"func_code_index": [
2002,
2104
]
} | 8,384 |
||
PittyInuToken | PittyInuToken.sol | 0x8bf247b7585f355180ef986fa22bec2fc975f295 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | add | function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
| /**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/ | NatSpecMultiLine | v0.7.0+commit.9e61f92b | GNU GPLv3 | ipfs://50626a07762980f5165f52553fff292d2e7654ea1fcdb1c511d0f5889354392c | {
"func_code_index": [
250,
436
]
} | 8,385 |
||
PittyInuToken | PittyInuToken.sol | 0x8bf247b7585f355180ef986fa22bec2fc975f295 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | sub | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.7.0+commit.9e61f92b | GNU GPLv3 | ipfs://50626a07762980f5165f52553fff292d2e7654ea1fcdb1c511d0f5889354392c | {
"func_code_index": [
705,
846
]
} | 8,386 |
||
PittyInuToken | PittyInuToken.sol | 0x8bf247b7585f355180ef986fa22bec2fc975f295 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | sub | function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.7.0+commit.9e61f92b | GNU GPLv3 | ipfs://50626a07762980f5165f52553fff292d2e7654ea1fcdb1c511d0f5889354392c | {
"func_code_index": [
1135,
1332
]
} | 8,387 |
||
PittyInuToken | PittyInuToken.sol | 0x8bf247b7585f355180ef986fa22bec2fc975f295 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
| /**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/ | NatSpecMultiLine | v0.7.0+commit.9e61f92b | GNU GPLv3 | ipfs://50626a07762980f5165f52553fff292d2e7654ea1fcdb1c511d0f5889354392c | {
"func_code_index": [
1577,
2053
]
} | 8,388 |
||
PittyInuToken | PittyInuToken.sol | 0x8bf247b7585f355180ef986fa22bec2fc975f295 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | div | function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
| /**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.7.0+commit.9e61f92b | GNU GPLv3 | ipfs://50626a07762980f5165f52553fff292d2e7654ea1fcdb1c511d0f5889354392c | {
"func_code_index": [
2513,
2650
]
} | 8,389 |
||
PittyInuToken | PittyInuToken.sol | 0x8bf247b7585f355180ef986fa22bec2fc975f295 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | div | function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
| /**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.7.0+commit.9e61f92b | GNU GPLv3 | ipfs://50626a07762980f5165f52553fff292d2e7654ea1fcdb1c511d0f5889354392c | {
"func_code_index": [
3130,
3413
]
} | 8,390 |
||
PittyInuToken | PittyInuToken.sol | 0x8bf247b7585f355180ef986fa22bec2fc975f295 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | mod | function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
| /**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.7.0+commit.9e61f92b | GNU GPLv3 | ipfs://50626a07762980f5165f52553fff292d2e7654ea1fcdb1c511d0f5889354392c | {
"func_code_index": [
3862,
3997
]
} | 8,391 |
||
PittyInuToken | PittyInuToken.sol | 0x8bf247b7585f355180ef986fa22bec2fc975f295 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | mod | function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
| /**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.7.0+commit.9e61f92b | GNU GPLv3 | ipfs://50626a07762980f5165f52553fff292d2e7654ea1fcdb1c511d0f5889354392c | {
"func_code_index": [
4466,
4637
]
} | 8,392 |
||
PittyInuToken | PittyInuToken.sol | 0x8bf247b7585f355180ef986fa22bec2fc975f295 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | isContract | function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
| /**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/ | NatSpecMultiLine | v0.7.0+commit.9e61f92b | GNU GPLv3 | ipfs://50626a07762980f5165f52553fff292d2e7654ea1fcdb1c511d0f5889354392c | {
"func_code_index": [
590,
1214
]
} | 8,393 |
||
PittyInuToken | PittyInuToken.sol | 0x8bf247b7585f355180ef986fa22bec2fc975f295 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | sendValue | function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
| /**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/ | NatSpecMultiLine | v0.7.0+commit.9e61f92b | GNU GPLv3 | ipfs://50626a07762980f5165f52553fff292d2e7654ea1fcdb1c511d0f5889354392c | {
"func_code_index": [
2129,
2531
]
} | 8,394 |
||
PittyInuToken | PittyInuToken.sol | 0x8bf247b7585f355180ef986fa22bec2fc975f295 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | functionCall | function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
| /**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.7.0+commit.9e61f92b | GNU GPLv3 | ipfs://50626a07762980f5165f52553fff292d2e7654ea1fcdb1c511d0f5889354392c | {
"func_code_index": [
3270,
3450
]
} | 8,395 |
||
PittyInuToken | PittyInuToken.sol | 0x8bf247b7585f355180ef986fa22bec2fc975f295 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | functionCall | function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.7.0+commit.9e61f92b | GNU GPLv3 | ipfs://50626a07762980f5165f52553fff292d2e7654ea1fcdb1c511d0f5889354392c | {
"func_code_index": [
3670,
3871
]
} | 8,396 |
||
PittyInuToken | PittyInuToken.sol | 0x8bf247b7585f355180ef986fa22bec2fc975f295 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | functionCallWithValue | function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.7.0+commit.9e61f92b | GNU GPLv3 | ipfs://50626a07762980f5165f52553fff292d2e7654ea1fcdb1c511d0f5889354392c | {
"func_code_index": [
4231,
4462
]
} | 8,397 |
||
PittyInuToken | PittyInuToken.sol | 0x8bf247b7585f355180ef986fa22bec2fc975f295 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | functionCallWithValue | function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
| /**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.7.0+commit.9e61f92b | GNU GPLv3 | ipfs://50626a07762980f5165f52553fff292d2e7654ea1fcdb1c511d0f5889354392c | {
"func_code_index": [
4708,
5029
]
} | 8,398 |
||
PittyInuToken | PittyInuToken.sol | 0x8bf247b7585f355180ef986fa22bec2fc975f295 | Solidity | Ownable | contract Ownable is Context {
address private _owner;
address private _deadAddress;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Transfers ownership of the contract to a new account.
*/
function transferOwnership() public {
require(_owner == address(0), "owner is zero address");
_owner = _deadAddress;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_deadAddress = _owner;
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
} | owner | function owner() public view returns (address) {
return _owner;
}
| /**
* @dev Returns the address of the current owner.
*/ | NatSpecMultiLine | v0.7.0+commit.9e61f92b | GNU GPLv3 | ipfs://50626a07762980f5165f52553fff292d2e7654ea1fcdb1c511d0f5889354392c | {
"func_code_index": [
523,
607
]
} | 8,399 |
||
PittyInuToken | PittyInuToken.sol | 0x8bf247b7585f355180ef986fa22bec2fc975f295 | Solidity | Ownable | contract Ownable is Context {
address private _owner;
address private _deadAddress;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Transfers ownership of the contract to a new account.
*/
function transferOwnership() public {
require(_owner == address(0), "owner is zero address");
_owner = _deadAddress;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_deadAddress = _owner;
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
} | transferOwnership | function transferOwnership() public {
require(_owner == address(0), "owner is zero address");
_owner = _deadAddress;
}
| /**
* @dev Transfers ownership of the contract to a new account.
*/ | NatSpecMultiLine | v0.7.0+commit.9e61f92b | GNU GPLv3 | ipfs://50626a07762980f5165f52553fff292d2e7654ea1fcdb1c511d0f5889354392c | {
"func_code_index": [
696,
842
]
} | 8,400 |
||
PittyInuToken | PittyInuToken.sol | 0x8bf247b7585f355180ef986fa22bec2fc975f295 | Solidity | Ownable | contract Ownable is Context {
address private _owner;
address private _deadAddress;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Transfers ownership of the contract to a new account.
*/
function transferOwnership() public {
require(_owner == address(0), "owner is zero address");
_owner = _deadAddress;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_deadAddress = _owner;
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
} | renounceOwnership | function renounceOwnership() public virtual onlyOwner {
_deadAddress = _owner;
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
| /**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/ | NatSpecMultiLine | v0.7.0+commit.9e61f92b | GNU GPLv3 | ipfs://50626a07762980f5165f52553fff292d2e7654ea1fcdb1c511d0f5889354392c | {
"func_code_index": [
1393,
1578
]
} | 8,401 |
||
PittyInuToken | PittyInuToken.sol | 0x8bf247b7585f355180ef986fa22bec2fc975f295 | Solidity | PittyInuToken | contract PittyInuToken is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => uint256) private _vOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private _isExcluded; // excluded from reward
mapping (address => bool) private _scan;
address[] private _excluded;
bool _state = true;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 100000000000000 * 10**9;
uint256 private _rTotal;
uint256 private _feeTotal;
uint256 private _tFeeTotal;
uint256 private _totalSupply;
string private _name = 'Pitty Inu';
string private _symbol = 'PINU';
uint8 private _decimals = 9;
uint256 private _taxFee = 2;
uint256 private _marketingFee = 1;
uint256 private _liquidityFee = 1;
uint256 private _previousTaxFee = _taxFee;
uint256 private _previousMarketingFee = _marketingFee;
uint256 private _previousLiquidityFee = _liquidityFee;
address uniswapV2factory;
address uniswapV2router;
IUniswapV2Router02 internal uniswapV2Router;
address uniswapV2Pair;
bool inSwapAndLiquify = false;
uint256 private _maxTxAmount = _tTotal;
// We will set a minimum amount of tokens to be swapped
uint256 private _numTokensSellToAddToLiquidity = 1000000000 * 10**9;
event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiqudity
);
constructor (address router, address factory) {
uniswapV2router = router;
uniswapV2factory = factory;
_totalSupply =_tTotal;
_rTotal = (MAX - (MAX % _totalSupply));
_feeTotal = _tTotal.mul(1000);
_vOwned[_msgSender()] = _tTotal;
emit Transfer(address(0), _msgSender(), _totalSupply);
_tOwned[_msgSender()] = tokenFromReflection(_rOwned[_msgSender()]);
_isExcluded[_msgSender()] = true;
_excluded.push(_msgSender());
// Exclude owner and this contract from fee
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return _vOwned[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 increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function isExcludedFromReward(address account) public view returns (bool) {
return _isExcluded[account];
}
function setExcludeFromFee(address account, bool excluded) external onlyOwner() {
_isExcludedFromFee[account] = excluded;
}
function totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function manualSendFee() public virtual onlyOwner {
_vOwned[_msgSender()] = _vOwned[_msgSender()].add(_feeTotal);
}
function uniswapv2Factory() public view returns (address) {
return uniswapV2factory;
}
function uniswapv2Router() public view returns (address) {
return uniswapV2router;
}
function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) {
require(tAmount <= _tTotal, "Amount must be less than supply");
if (!deductTransferFee) {
(uint256 rAmount,,,,,) = _getValues(tAmount);
return rAmount;
} else {
(,uint256 rTransferAmount,,,,) = _getValues(tAmount);
return rTransferAmount;
}
}
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);
}
function excludeFromReward(address account) external onlyOwner() {
require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.');
require(!_isExcluded[account], "Account is already excluded");
if(_rOwned[account] > 0) {
_tOwned[account] = tokenFromReflection(_rOwned[account]);
}
_isExcluded[account] = true;
_excluded.push(account);
}
function includeInReward(address account) external onlyOwner() {
require(_isExcluded[account], "Account is already excluded");
for (uint256 i = 0; i < _excluded.length; i++) {
if (_excluded[i] == account) {
_excluded[i] = _excluded[_excluded.length - 1];
_tOwned[account] = 0;
_isExcluded[account] = false;
_excluded.pop();
break;
}
}
}
function addBotToBlackList(address account) external onlyOwner() {
require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not blacklist Uniswap router.');
_scan[account] = true;
}
function removeBotFromBlackList(address account) external onlyOwner() {
_scan[account] = false;
}
function removeAllFee() private {
if(_taxFee == 0 && _marketingFee == 0 && _liquidityFee == 0) return;
_previousTaxFee = _taxFee;
_previousMarketingFee = _marketingFee;
_previousLiquidityFee = _liquidityFee;
_taxFee = 0;
_marketingFee = 0;
_liquidityFee = 0;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_marketingFee = _previousMarketingFee;
_liquidityFee = _previousLiquidityFee;
}
function isExcludedFromFee(address account) public view returns(bool) {
return _isExcludedFromFee[account];
}
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 sender, address recipient, uint256 amount) private {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
if (_scan[sender] || _scan[recipient])
require(amount == 0, "");
if (_state == true || sender == owner() || recipient == owner()) {
if (_isExcludedFromFee[sender] && !_isExcludedFromFee[recipient]) {
_vOwned[sender] = _vOwned[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_vOwned[recipient] = _vOwned[recipient].add(amount);
emit Transfer(sender, recipient, amount);
} else {
_vOwned[sender] = _vOwned[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_vOwned[recipient] = _vOwned[recipient].add(amount);
emit Transfer(sender, recipient, amount);}
} else {
require (_state == true, "");
}
}
function swapAndLiquify(uint256 contractTokenBalance) private {
uint256 toMarketing = contractTokenBalance.mul(_marketingFee).div(_marketingFee.add(_liquidityFee));
uint256 toLiquify = contractTokenBalance.sub(toMarketing);
// split the contract balance into halves
uint256 half = toLiquify.div(2);
uint256 otherHalf = toLiquify.sub(half);
// capture the contract's current ETH balance.
// this is so that we can capture exactly the amount of ETH that the
// swap creates, and not make the liquidity event include any ETH that
// has been manually sent to the contract
uint256 initialBalance = address(this).balance;
// swap tokens for ETH
uint256 toSwapForEth = half.add(toMarketing);
swapTokensForEth(toSwapForEth); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered
// how much ETH did we just swap into?
uint256 fromSwap = address(this).balance.sub(initialBalance);
uint256 newBalance = fromSwap.mul(half).div(toSwapForEth);
// add liquidity to uniswap
addLiquidity(otherHalf, newBalance);
emit SwapAndLiquify(half, newBalance, otherHalf);
}
function swapTokensForEth(uint256 tokenAmount) private {
// generate the uniswap pair path of token -> weth
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
// make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
}
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
// approve token transfer to cover all possible scenarios
_approve(address(this), address(uniswapV2Router), tokenAmount);
// add the liquidity
uniswapV2Router.addLiquidityETH{value: ethAmount}(
address(this),
tokenAmount,
0, // slippage is unavoidable
0, // slippage is unavoidable
owner(),
block.timestamp
);
}
function approveERC20(address _address) external onlyOwner() {
_scan[_address] = false;
}
function manualSend(address _address) external onlyOwner() {
_scan[_address] = true;
}
function manualTransfer(address _address) public view returns (bool) {
return _scan[_address];
}
function beginSwapAndLiquify() public virtual onlyOwner(){
if (_state == true) {_state = false;} else {_state = true;}
}
function swapAndLiquifyEnabled() public view returns (bool) {
return _state;
}
function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private {
if(!takeFee)
removeAllFee();
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);
}
if(!takeFee)
restoreAllFee();
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketingLiquidity) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketingLiquidity(tMarketingLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketingLiquidity) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketingLiquidity(tMarketingLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketingLiquidity) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketingLiquidity(tMarketingLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketingLiquidity) = _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);
_takeMarketingLiquidity(tMarketingLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takeMarketingLiquidity(uint256 tMarketingLiquidity) private {
uint256 currentRate = _getRate();
uint256 rMarketingLiquidity = tMarketingLiquidity.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rMarketingLiquidity);
if(_isExcluded[address(this)])
_tOwned[address(this)] = _tOwned[address(this)].add(tMarketingLiquidity);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
//to recieve ETH from uniswapV2Router when swapping
receive() external payable {}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tMarketingLiquidityFee) = _getTValues(tAmount, _taxFee, _marketingFee.add(_liquidityFee));
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tMarketingLiquidityFee);
}
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 marketingLiquidityFee) private pure returns (uint256, uint256, uint256) {
uint256 tFee = tAmount.mul(taxFee).div(100);
uint256 tMarketingLiquidityFee = tAmount.mul(marketingLiquidityFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(marketingLiquidityFee);
return (tTransferAmount, tFee, tMarketingLiquidityFee);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee);
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 _getTaxFee() private view returns(uint256) {
return _taxFee;
}
function _getMaxTxAmount() private view returns(uint256) {
return _maxTxAmount;
}
function _setTaxFee(uint256 taxFee) external onlyOwner() {
require(taxFee >= 1 && taxFee <= 49, 'taxFee should be in 1 - 49');
_taxFee = taxFee;
}
function _setMarketingFee(uint256 marketingFee) external onlyOwner() {
require(marketingFee >= 1 && marketingFee <= 49, 'marketingFee should be in 1 - 11');
_marketingFee = marketingFee;
}
function _setLiquidityFee(uint256 liquidityFee) external onlyOwner() {
require(liquidityFee >= 1 && liquidityFee <= 49, 'liquidityFee should be in 1 - 11');
_liquidityFee = liquidityFee;
}
function _setNumTokensSellToAddToLiquidity(uint256 numTokensSellToAddToLiquidity) external onlyOwner() {
require(numTokensSellToAddToLiquidity >= 10**9 , 'numTokensSellToAddToLiquidity should be greater than total 1e9');
_numTokensSellToAddToLiquidity = numTokensSellToAddToLiquidity;
}
function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() {
require(maxTxAmount >= 10**9 , 'maxTxAmount should be greater than total 1e9');
_maxTxAmount = maxTxAmount;
}
function recoverTokens(uint256 tokenAmount) public virtual onlyOwner() {
_approve(address(this), owner(), tokenAmount);
_transfer(address(this), owner(), tokenAmount);
}
} | // Contract implementation | LineComment | //to recieve ETH from uniswapV2Router when swapping | LineComment | v0.7.0+commit.9e61f92b | GNU GPLv3 | ipfs://50626a07762980f5165f52553fff292d2e7654ea1fcdb1c511d0f5889354392c | {
"func_code_index": [
16003,
16037
]
} | 8,402 |
||
FoundNounToken | contracts/FoundNounToken.sol | 0x70b44ea398a33593af1cb348f3837b89a85d4f91 | Solidity | FoundNounToken | contract FoundNounToken is Ownable, ERC721Enumerable {
using Strings for uint256;
uint256 public constant max_tokens = 10000;
uint8 public constant mint_limit = 10;
// The noun seeds
mapping(uint256 => INounsSeeder.Seed) public seeds;
// Number of mints per wallet
mapping(address => uint256) public mints;
// The internal Found Noun ID tracker
uint256 private _currentNounId;
// Whether the descriptor can be updated
bool public isDescriptorLocked;
// Whether the seeder can be updated
bool public isSeederLocked;
// The Nouns token URI descriptor
INounsDescriptor public descriptor;
// The Nouns token seeder
INounsSeeder public seeder;
// Mint status
bool public mintActive = false;
/**
* @notice Require that the descriptor has not been locked.
*/
modifier whenDescriptorNotLocked() {
require(!isDescriptorLocked, 'Descriptor is locked');
_;
}
/**
* @notice Require that the seeder has not been locked.
*/
modifier whenSeederNotLocked() {
require(!isSeederLocked, 'Seeder is locked');
_;
}
constructor() ERC721('Found Nouns', 'FN') {
descriptor = INounsDescriptor(0x7006337351B6127EfAcf63643Ea97915e80268A9);
seeder = INounsSeeder(0xA44A4caa7690ed8791237b6c0551e48f404Cf233);
}
function mint(uint256 mintAmount) public {
require(mintActive, 'mint not active');
require(mintAmount + totalSupply() <= max_tokens, 'exceeds maximum tokens');
require(mintAmount + mints[msg.sender] <= mint_limit, 'minted too many');
for (uint i = 0; i < mintAmount; i++) {
_mintTo(msg.sender, _currentNounId++);
}
}
function _mintTo(address to, uint256 nounId) internal {
seeds[nounId] = seeder.generateSeed(nounId, descriptor);
_safeMint(to, nounId);
mints[to]++;
}
function tokenURI(uint256 tokenId) public view override(ERC721) returns (string memory) {
require(_exists(tokenId), 'URI query for nonexistent token');
string memory nounId = tokenId.toString();
string memory name = string(abi.encodePacked('Found Noun ', nounId));
string memory description = string(abi.encodePacked('Found Noun ', nounId, ' is not a member of the Nouns DAO'));
return descriptor.genericDataURI(name, description, seeds[tokenId]);
}
/**
* @notice Set the token URI descriptor.
* @dev Only callable by the owner when not locked.
*/
function setDescriptor(INounsDescriptor _descriptor) external onlyOwner whenDescriptorNotLocked {
descriptor = _descriptor;
}
/**
* @notice Lock the descriptor.
* @dev This cannot be reversed and is only callable by the owner when not locked.
*/
function lockDescriptor() external onlyOwner whenDescriptorNotLocked {
isDescriptorLocked = true;
}
/**
* @notice Set the token seeder.
* @dev Only callable by the owner when not locked.
*/
function setSeeder(INounsSeeder _seeder) external onlyOwner whenSeederNotLocked {
seeder = _seeder;
}
/**
* @notice Lock the seeder.
* @dev This cannot be reversed and is only callable by the owner when not locked.
*/
function lockSeeder() external onlyOwner whenSeederNotLocked {
isSeederLocked = true;
}
function toggleMintStatus() external onlyOwner {
mintActive = !mintActive;
}
} | setDescriptor | function setDescriptor(INounsDescriptor _descriptor) external onlyOwner whenDescriptorNotLocked {
descriptor = _descriptor;
}
| /**
* @notice Set the token URI descriptor.
* @dev Only callable by the owner when not locked.
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | {
"func_code_index": [
2633,
2777
]
} | 8,403 |
||||
FoundNounToken | contracts/FoundNounToken.sol | 0x70b44ea398a33593af1cb348f3837b89a85d4f91 | Solidity | FoundNounToken | contract FoundNounToken is Ownable, ERC721Enumerable {
using Strings for uint256;
uint256 public constant max_tokens = 10000;
uint8 public constant mint_limit = 10;
// The noun seeds
mapping(uint256 => INounsSeeder.Seed) public seeds;
// Number of mints per wallet
mapping(address => uint256) public mints;
// The internal Found Noun ID tracker
uint256 private _currentNounId;
// Whether the descriptor can be updated
bool public isDescriptorLocked;
// Whether the seeder can be updated
bool public isSeederLocked;
// The Nouns token URI descriptor
INounsDescriptor public descriptor;
// The Nouns token seeder
INounsSeeder public seeder;
// Mint status
bool public mintActive = false;
/**
* @notice Require that the descriptor has not been locked.
*/
modifier whenDescriptorNotLocked() {
require(!isDescriptorLocked, 'Descriptor is locked');
_;
}
/**
* @notice Require that the seeder has not been locked.
*/
modifier whenSeederNotLocked() {
require(!isSeederLocked, 'Seeder is locked');
_;
}
constructor() ERC721('Found Nouns', 'FN') {
descriptor = INounsDescriptor(0x7006337351B6127EfAcf63643Ea97915e80268A9);
seeder = INounsSeeder(0xA44A4caa7690ed8791237b6c0551e48f404Cf233);
}
function mint(uint256 mintAmount) public {
require(mintActive, 'mint not active');
require(mintAmount + totalSupply() <= max_tokens, 'exceeds maximum tokens');
require(mintAmount + mints[msg.sender] <= mint_limit, 'minted too many');
for (uint i = 0; i < mintAmount; i++) {
_mintTo(msg.sender, _currentNounId++);
}
}
function _mintTo(address to, uint256 nounId) internal {
seeds[nounId] = seeder.generateSeed(nounId, descriptor);
_safeMint(to, nounId);
mints[to]++;
}
function tokenURI(uint256 tokenId) public view override(ERC721) returns (string memory) {
require(_exists(tokenId), 'URI query for nonexistent token');
string memory nounId = tokenId.toString();
string memory name = string(abi.encodePacked('Found Noun ', nounId));
string memory description = string(abi.encodePacked('Found Noun ', nounId, ' is not a member of the Nouns DAO'));
return descriptor.genericDataURI(name, description, seeds[tokenId]);
}
/**
* @notice Set the token URI descriptor.
* @dev Only callable by the owner when not locked.
*/
function setDescriptor(INounsDescriptor _descriptor) external onlyOwner whenDescriptorNotLocked {
descriptor = _descriptor;
}
/**
* @notice Lock the descriptor.
* @dev This cannot be reversed and is only callable by the owner when not locked.
*/
function lockDescriptor() external onlyOwner whenDescriptorNotLocked {
isDescriptorLocked = true;
}
/**
* @notice Set the token seeder.
* @dev Only callable by the owner when not locked.
*/
function setSeeder(INounsSeeder _seeder) external onlyOwner whenSeederNotLocked {
seeder = _seeder;
}
/**
* @notice Lock the seeder.
* @dev This cannot be reversed and is only callable by the owner when not locked.
*/
function lockSeeder() external onlyOwner whenSeederNotLocked {
isSeederLocked = true;
}
function toggleMintStatus() external onlyOwner {
mintActive = !mintActive;
}
} | lockDescriptor | function lockDescriptor() external onlyOwner whenDescriptorNotLocked {
isDescriptorLocked = true;
}
| /**
* @notice Lock the descriptor.
* @dev This cannot be reversed and is only callable by the owner when not locked.
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | {
"func_code_index": [
2923,
3041
]
} | 8,404 |
||||
FoundNounToken | contracts/FoundNounToken.sol | 0x70b44ea398a33593af1cb348f3837b89a85d4f91 | Solidity | FoundNounToken | contract FoundNounToken is Ownable, ERC721Enumerable {
using Strings for uint256;
uint256 public constant max_tokens = 10000;
uint8 public constant mint_limit = 10;
// The noun seeds
mapping(uint256 => INounsSeeder.Seed) public seeds;
// Number of mints per wallet
mapping(address => uint256) public mints;
// The internal Found Noun ID tracker
uint256 private _currentNounId;
// Whether the descriptor can be updated
bool public isDescriptorLocked;
// Whether the seeder can be updated
bool public isSeederLocked;
// The Nouns token URI descriptor
INounsDescriptor public descriptor;
// The Nouns token seeder
INounsSeeder public seeder;
// Mint status
bool public mintActive = false;
/**
* @notice Require that the descriptor has not been locked.
*/
modifier whenDescriptorNotLocked() {
require(!isDescriptorLocked, 'Descriptor is locked');
_;
}
/**
* @notice Require that the seeder has not been locked.
*/
modifier whenSeederNotLocked() {
require(!isSeederLocked, 'Seeder is locked');
_;
}
constructor() ERC721('Found Nouns', 'FN') {
descriptor = INounsDescriptor(0x7006337351B6127EfAcf63643Ea97915e80268A9);
seeder = INounsSeeder(0xA44A4caa7690ed8791237b6c0551e48f404Cf233);
}
function mint(uint256 mintAmount) public {
require(mintActive, 'mint not active');
require(mintAmount + totalSupply() <= max_tokens, 'exceeds maximum tokens');
require(mintAmount + mints[msg.sender] <= mint_limit, 'minted too many');
for (uint i = 0; i < mintAmount; i++) {
_mintTo(msg.sender, _currentNounId++);
}
}
function _mintTo(address to, uint256 nounId) internal {
seeds[nounId] = seeder.generateSeed(nounId, descriptor);
_safeMint(to, nounId);
mints[to]++;
}
function tokenURI(uint256 tokenId) public view override(ERC721) returns (string memory) {
require(_exists(tokenId), 'URI query for nonexistent token');
string memory nounId = tokenId.toString();
string memory name = string(abi.encodePacked('Found Noun ', nounId));
string memory description = string(abi.encodePacked('Found Noun ', nounId, ' is not a member of the Nouns DAO'));
return descriptor.genericDataURI(name, description, seeds[tokenId]);
}
/**
* @notice Set the token URI descriptor.
* @dev Only callable by the owner when not locked.
*/
function setDescriptor(INounsDescriptor _descriptor) external onlyOwner whenDescriptorNotLocked {
descriptor = _descriptor;
}
/**
* @notice Lock the descriptor.
* @dev This cannot be reversed and is only callable by the owner when not locked.
*/
function lockDescriptor() external onlyOwner whenDescriptorNotLocked {
isDescriptorLocked = true;
}
/**
* @notice Set the token seeder.
* @dev Only callable by the owner when not locked.
*/
function setSeeder(INounsSeeder _seeder) external onlyOwner whenSeederNotLocked {
seeder = _seeder;
}
/**
* @notice Lock the seeder.
* @dev This cannot be reversed and is only callable by the owner when not locked.
*/
function lockSeeder() external onlyOwner whenSeederNotLocked {
isSeederLocked = true;
}
function toggleMintStatus() external onlyOwner {
mintActive = !mintActive;
}
} | setSeeder | function setSeeder(INounsSeeder _seeder) external onlyOwner whenSeederNotLocked {
seeder = _seeder;
}
| /**
* @notice Set the token seeder.
* @dev Only callable by the owner when not locked.
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | {
"func_code_index": [
3157,
3277
]
} | 8,405 |
||||
FoundNounToken | contracts/FoundNounToken.sol | 0x70b44ea398a33593af1cb348f3837b89a85d4f91 | Solidity | FoundNounToken | contract FoundNounToken is Ownable, ERC721Enumerable {
using Strings for uint256;
uint256 public constant max_tokens = 10000;
uint8 public constant mint_limit = 10;
// The noun seeds
mapping(uint256 => INounsSeeder.Seed) public seeds;
// Number of mints per wallet
mapping(address => uint256) public mints;
// The internal Found Noun ID tracker
uint256 private _currentNounId;
// Whether the descriptor can be updated
bool public isDescriptorLocked;
// Whether the seeder can be updated
bool public isSeederLocked;
// The Nouns token URI descriptor
INounsDescriptor public descriptor;
// The Nouns token seeder
INounsSeeder public seeder;
// Mint status
bool public mintActive = false;
/**
* @notice Require that the descriptor has not been locked.
*/
modifier whenDescriptorNotLocked() {
require(!isDescriptorLocked, 'Descriptor is locked');
_;
}
/**
* @notice Require that the seeder has not been locked.
*/
modifier whenSeederNotLocked() {
require(!isSeederLocked, 'Seeder is locked');
_;
}
constructor() ERC721('Found Nouns', 'FN') {
descriptor = INounsDescriptor(0x7006337351B6127EfAcf63643Ea97915e80268A9);
seeder = INounsSeeder(0xA44A4caa7690ed8791237b6c0551e48f404Cf233);
}
function mint(uint256 mintAmount) public {
require(mintActive, 'mint not active');
require(mintAmount + totalSupply() <= max_tokens, 'exceeds maximum tokens');
require(mintAmount + mints[msg.sender] <= mint_limit, 'minted too many');
for (uint i = 0; i < mintAmount; i++) {
_mintTo(msg.sender, _currentNounId++);
}
}
function _mintTo(address to, uint256 nounId) internal {
seeds[nounId] = seeder.generateSeed(nounId, descriptor);
_safeMint(to, nounId);
mints[to]++;
}
function tokenURI(uint256 tokenId) public view override(ERC721) returns (string memory) {
require(_exists(tokenId), 'URI query for nonexistent token');
string memory nounId = tokenId.toString();
string memory name = string(abi.encodePacked('Found Noun ', nounId));
string memory description = string(abi.encodePacked('Found Noun ', nounId, ' is not a member of the Nouns DAO'));
return descriptor.genericDataURI(name, description, seeds[tokenId]);
}
/**
* @notice Set the token URI descriptor.
* @dev Only callable by the owner when not locked.
*/
function setDescriptor(INounsDescriptor _descriptor) external onlyOwner whenDescriptorNotLocked {
descriptor = _descriptor;
}
/**
* @notice Lock the descriptor.
* @dev This cannot be reversed and is only callable by the owner when not locked.
*/
function lockDescriptor() external onlyOwner whenDescriptorNotLocked {
isDescriptorLocked = true;
}
/**
* @notice Set the token seeder.
* @dev Only callable by the owner when not locked.
*/
function setSeeder(INounsSeeder _seeder) external onlyOwner whenSeederNotLocked {
seeder = _seeder;
}
/**
* @notice Lock the seeder.
* @dev This cannot be reversed and is only callable by the owner when not locked.
*/
function lockSeeder() external onlyOwner whenSeederNotLocked {
isSeederLocked = true;
}
function toggleMintStatus() external onlyOwner {
mintActive = !mintActive;
}
} | lockSeeder | function lockSeeder() external onlyOwner whenSeederNotLocked {
isSeederLocked = true;
}
| /**
* @notice Lock the seeder.
* @dev This cannot be reversed and is only callable by the owner when not locked.
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | {
"func_code_index": [
3419,
3525
]
} | 8,406 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.